Merge lp:~roadmr/checkbox/1342304-network-bad-strings into lp:checkbox

Proposed by Daniel Manrique
Status: Merged
Approved by: Zygmunt Krynicki
Approved revision: 3129
Merged at revision: 3131
Proposed branch: lp:~roadmr/checkbox/1342304-network-bad-strings
Merge into: lp:checkbox
Diff against target: 154 lines (+42/-49)
1 file modified
providers/plainbox-provider-checkbox/bin/network (+42/-49)
To merge this branch: bzr merge lp:~roadmr/checkbox/1342304-network-bad-strings
Reviewer Review Type Date Requested Status
Zygmunt Krynicki (community) Approve
Review via email: mp+226922@code.launchpad.net

Commit message

    providers:checkbox: Revamp of argument handling for network script.

    - Provide clearer message of where to configure settings.
    - Handle "partial" settings (i.e. test won't mysteriously exit if not
      all 4 values are provided, even if for the current test they're not
      all needed)
    - Remove support for the legacy /etc/checkbox.d files.

    https://bugs.launchpad.net/plainbox-provider-checkbox/+bug/1342304
    https://bugs.launchpad.net/plainbox-provider-checkbox/+bug/1309640

Description of the change

    providers:checkbox: Revamp of argument handling for network script.

    - Provide clearer message of where to configure settings.
    - Handle "partial" settings (i.e. test won't mysteriously exit if not
      all 4 values are provided, even if for the current test they're not
      all needed)
    - Remove support for the legacy /etc/checkbox.d files.

    https://bugs.launchpad.net/plainbox-provider-checkbox/+bug/1342304
    https://bugs.launchpad.net/plainbox-provider-checkbox/+bug/1309640

To post a comment you must log in.
3122. By Daniel Manrique

"This implements the "unity disable hack" to properly test 3/4-finger tap gestures using Qt/QML.

bad7a00 providers:checkbox: updated multitouch test definitions to use the management script to disable/reenable Unity.
492741d providers:checkbox: Add manage_compiz_plugin script
 [r=zkrynicki][bug=][author=roadmr]"

3123. By Po-Hsu Lin

"automatic merge by tarmac [r=roadmr][bug=][author=cypressyew]"

3124. By Daniel Manrique

"f2c4dc2 checkbox-support: include and install cputable file
4b788a9 checkbox-support: use io.open in setup.py for compatibility with python 2.7

These allow the tar.gz produced with setup.py sdist for checkbox-support to be used in hexr, in place of checkbox-legacy/old.

 [r=zkrynicki][bug=][author=roadmr]"

3125. By Rod Smith

"automatic merge by tarmac [r=zkrynicki][bug=][author=rodsmith]"

3126. By Taihsiang Ho

"implement a smarter parser to get pci slot names from DEVPATH (LP: #1334991) [r=zkrynicki][bug=1334991][author=taihsiangho]"

3127. By Sylvain Pineau

"Release_2014_Week29 [r=sylvain-pineau][bug=1331302,1341769][author=checkbox-dev]"

3128. By Po-Hsu Lin

"automatic merge by tarmac [r=zkrynicki][bug=1346132][author=cypressyew]"

Revision history for this message
Zygmunt Krynicki (zyga) wrote :

Some comments and questions. See below for details.

I haven't tested this but it looks okay-ish except for one question

Revision history for this message
Daniel Manrique (roadmr) wrote :

I'll resubmit with the changes.

3129. By Daniel Manrique

providers:checkbox: Revamp of argument handling for network script.

- Provide clearer message of where to configure settings.
- Handle "partial" settings (i.e. test won't mysteriously exit if not
  all 4 values are provided, even if for the current test they're not
  all needed)
- Remove support for the legacy /etc/checkbox.d files.

https://bugs.launchpad.net/plainbox-provider-checkbox/+bug/1342304
https://bugs.launchpad.net/plainbox-provider-checkbox/+bug/1309640

Revision history for this message
Zygmunt Krynicki (zyga) wrote :

+1, thanks

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'providers/plainbox-provider-checkbox/bin/network'
--- providers/plainbox-provider-checkbox/bin/network 2014-07-03 21:15:05 +0000
+++ providers/plainbox-provider-checkbox/bin/network 2014-07-21 14:45:58 +0000
@@ -379,7 +379,7 @@
379 def max_speed(self):379 def max_speed(self):
380 # Parse ethtool data for max speed since /sys/class/net/DEV/speed only380 # Parse ethtool data for max speed since /sys/class/net/DEV/speed only
381 # reports link speed.381 # reports link speed.
382 382
383 # Search for things that look like 100baseSX, 383 # Search for things that look like 100baseSX,
384 #40000baseNX, 10000baseT384 #40000baseNX, 10000baseT
385 try:385 try:
@@ -421,46 +421,31 @@
421 return self._read_data("device/label")421 return self._read_data("device/label")
422422
423423
424def get_test_parameters(args, environ, config_filename):424def get_test_parameters(args, environ):
425 # Decide the actual values for test parameters, which can come425 # Decide the actual values for test parameters, which can come
426 # from one of three possible sources: a config file, command-line426 # from one of two possible sources: command-line
427 # arguments, or environment variables.427 # arguments, or environment variables.
428 # - If command-line args were given, they take precedence428 # - If command-line args were given, they take precedence
429 # - Next come environment variables, if set.429 # - Next come environment variables, if set.
430 # - Last, values in the config file are used if present.
431430
432 params = {"test_target_ftp": None,431 params = {"test_target_ftp": None,
433 "test_user": None,432 "test_user": None,
434 "test_pass": None,433 "test_pass": None,
435 "test_target_iperf": None}434 "test_target_iperf": None}
436435
437 #First (try to) load values from config file436 # See if we have environment variables
438 config = configparser.SafeConfigParser()437 for key in params.keys():
439438 params[key] = os.environ.get(key.upper(), "")
440 try:
441 with open(config_filename) as config_file:
442 config.readfp(config_file)
443 params["test_target_ftp"] = config.get("FTP", "Target")
444 params["test_user"] = config.get("FTP", "User")
445 params["test_pass"] = config.get("FTP", "Pass")
446 params["test_target_iperf"] = config.get("IPERF", "Target")
447 except FileNotFoundError as err:
448 pass # No biggie, we can still get configs from elsewhere
449
450 # Next see if we have environment variables to override the config file
451 # "partial" overrides are not allowed; if an env variable is missing,
452 # we won't use this at all.
453 if all([param.upper() in os.environ for param in params.keys()]):
454 for key in params.keys():
455 params[key] = os.environ[key.upper()]
456439
457 # Finally, see if we have the command-line arguments that are the ultimate440 # Finally, see if we have the command-line arguments that are the ultimate
458 # override. Again, we will only override if we have all of them.441 # override.
459 if args.target and args.username and args.password:442 if args.target:
460 params["test_target_ftp"] = args.target443 params["test_target_ftp"] = args.target
444 params["test_target_iperf"] = args.target
445 if args.username:
461 params["test_user"] = args.username446 params["test_user"] = args.username
447 if args.password:
462 params["test_pass"] = args.password448 params["test_pass"] = args.password
463 params["test_target_iperf"] = args.target
464449
465 return params450 return params
466451
@@ -469,16 +454,8 @@
469 if not "test_type" in vars(args):454 if not "test_type" in vars(args):
470 return455 return
471456
472 # Determine whether to use the default or user-supplied config457 # Get the actual test data from one of two possible sources
473 # file name.458 test_parameters = get_test_parameters(args, os.environ)
474 DEFAULT_CFG = "/etc/checkbox.d/network.cfg"
475 if not "config" in vars(args):
476 config_filename = DEFAULT_CFG
477 else:
478 config_filename = args.config
479
480 # Get the actual test data from one of three possible sources
481 test_parameters = get_test_parameters(args, os.environ, config_filename)
482459
483 test_user = test_parameters["test_user"]460 test_user = test_parameters["test_user"]
484 test_pass = test_parameters["test_pass"]461 test_pass = test_parameters["test_pass"]
@@ -491,7 +468,23 @@
491 # Validate that we got reasonable values468 # Validate that we got reasonable values
492 if not test_target or "example.com" in test_target:469 if not test_target or "example.com" in test_target:
493 # Default values found in config file470 # Default values found in config file
494 logging.error("Please supply target via: %s", config_filename)471 logging.error("Target server has not been supplied.")
472 logging.info("Configuration settings can be configured 3 different ways:")
473 logging.info("1- If calling the script directly, pass the --target option")
474 logging.info("2- Define the TEST_TARGET_IPERF environment variable")
475 logging.info("3- (If running the test via checkbox/plainbox, define the ")
476 logging.info("target in /etc/xdg/canonical-certification.conf)")
477 logging.info("Please run this script with -h to see more details on how to configure")
478 sys.exit(1)
479
480 if args.test_type.lower() == 'ftp' and not (test_user and test_pass):
481 logging.error("Target user/password have not been supplied.")
482 logging.info("Target user/password can be configured 3 different ways:")
483 logging.info("1- If calling the script directly, give --user or --pass option")
484 logging.info("2- Define the TEST_USER or TEST_PASS environment variables")
485 logging.info("3- (If running the test via checkbox/plainbox, define the ")
486 logging.info("settings in /etc/xdg/canonical-certification.conf)")
487 logging.info("Please run this script with -h to see more details on how to configure")
495 sys.exit(1)488 sys.exit(1)
496489
497 # Testing begins here!490 # Testing begins here!
@@ -595,13 +588,14 @@
595588
5961- Command-line parameters (see above).5891- Command-line parameters (see above).
5972- Environment variables (example will follow).5902- Environment variables (example will follow).
5983- Configuration file (example will follow).5913- If run via checkbox/plainbox, /etc/xdg/checkbox-certification.conf
599 Default config location is /etc/checkbox.d/network.cfg592 can have the below-mentioned environment variables defined in the
593 [environment] section. An example file is provided and can be simply
594 modified with the correct values.
600595
601Environment variables596Environment variables
602=====================597=====================
603ALL environment variables must be defined, even if empty, for them to be598The variables are:
604picked up. The variables are:
605TEST_TARGET_FTP599TEST_TARGET_FTP
606TEST_USER600TEST_USER
607TEST_PASS601TEST_PASS
@@ -609,14 +603,13 @@
609603
610example config file604example config file
611===================605===================
612[FTP]606[environment]
613607TEST_TARGET_FTP = ftp-server.example.com
614Target: 192.168.1.23608TEST_USER = my-name
615User: FTPUser609TEST_PASS = a-password
616Pass:PassW0Rd610TEST_TARGET_IPERF = iperf-server.example.com
617611
618[IPERF]612
619Target: 192.168.1.45
620**NOTE**613**NOTE**
621614
622"""615"""

Subscribers

People subscribed via source and target branches