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
1=== modified file 'providers/plainbox-provider-checkbox/bin/network'
2--- providers/plainbox-provider-checkbox/bin/network 2014-07-03 21:15:05 +0000
3+++ providers/plainbox-provider-checkbox/bin/network 2014-07-21 14:45:58 +0000
4@@ -379,7 +379,7 @@
5 def max_speed(self):
6 # Parse ethtool data for max speed since /sys/class/net/DEV/speed only
7 # reports link speed.
8-
9+
10 # Search for things that look like 100baseSX,
11 #40000baseNX, 10000baseT
12 try:
13@@ -421,46 +421,31 @@
14 return self._read_data("device/label")
15
16
17-def get_test_parameters(args, environ, config_filename):
18+def get_test_parameters(args, environ):
19 # Decide the actual values for test parameters, which can come
20- # from one of three possible sources: a config file, command-line
21+ # from one of two possible sources: command-line
22 # arguments, or environment variables.
23 # - If command-line args were given, they take precedence
24 # - Next come environment variables, if set.
25- # - Last, values in the config file are used if present.
26
27 params = {"test_target_ftp": None,
28 "test_user": None,
29 "test_pass": None,
30 "test_target_iperf": None}
31
32- #First (try to) load values from config file
33- config = configparser.SafeConfigParser()
34-
35- try:
36- with open(config_filename) as config_file:
37- config.readfp(config_file)
38- params["test_target_ftp"] = config.get("FTP", "Target")
39- params["test_user"] = config.get("FTP", "User")
40- params["test_pass"] = config.get("FTP", "Pass")
41- params["test_target_iperf"] = config.get("IPERF", "Target")
42- except FileNotFoundError as err:
43- pass # No biggie, we can still get configs from elsewhere
44-
45- # Next see if we have environment variables to override the config file
46- # "partial" overrides are not allowed; if an env variable is missing,
47- # we won't use this at all.
48- if all([param.upper() in os.environ for param in params.keys()]):
49- for key in params.keys():
50- params[key] = os.environ[key.upper()]
51+ # See if we have environment variables
52+ for key in params.keys():
53+ params[key] = os.environ.get(key.upper(), "")
54
55 # Finally, see if we have the command-line arguments that are the ultimate
56- # override. Again, we will only override if we have all of them.
57- if args.target and args.username and args.password:
58+ # override.
59+ if args.target:
60 params["test_target_ftp"] = args.target
61+ params["test_target_iperf"] = args.target
62+ if args.username:
63 params["test_user"] = args.username
64+ if args.password:
65 params["test_pass"] = args.password
66- params["test_target_iperf"] = args.target
67
68 return params
69
70@@ -469,16 +454,8 @@
71 if not "test_type" in vars(args):
72 return
73
74- # Determine whether to use the default or user-supplied config
75- # file name.
76- DEFAULT_CFG = "/etc/checkbox.d/network.cfg"
77- if not "config" in vars(args):
78- config_filename = DEFAULT_CFG
79- else:
80- config_filename = args.config
81-
82- # Get the actual test data from one of three possible sources
83- test_parameters = get_test_parameters(args, os.environ, config_filename)
84+ # Get the actual test data from one of two possible sources
85+ test_parameters = get_test_parameters(args, os.environ)
86
87 test_user = test_parameters["test_user"]
88 test_pass = test_parameters["test_pass"]
89@@ -491,7 +468,23 @@
90 # Validate that we got reasonable values
91 if not test_target or "example.com" in test_target:
92 # Default values found in config file
93- logging.error("Please supply target via: %s", config_filename)
94+ logging.error("Target server has not been supplied.")
95+ logging.info("Configuration settings can be configured 3 different ways:")
96+ logging.info("1- If calling the script directly, pass the --target option")
97+ logging.info("2- Define the TEST_TARGET_IPERF environment variable")
98+ logging.info("3- (If running the test via checkbox/plainbox, define the ")
99+ logging.info("target in /etc/xdg/canonical-certification.conf)")
100+ logging.info("Please run this script with -h to see more details on how to configure")
101+ sys.exit(1)
102+
103+ if args.test_type.lower() == 'ftp' and not (test_user and test_pass):
104+ logging.error("Target user/password have not been supplied.")
105+ logging.info("Target user/password can be configured 3 different ways:")
106+ logging.info("1- If calling the script directly, give --user or --pass option")
107+ logging.info("2- Define the TEST_USER or TEST_PASS environment variables")
108+ logging.info("3- (If running the test via checkbox/plainbox, define the ")
109+ logging.info("settings in /etc/xdg/canonical-certification.conf)")
110+ logging.info("Please run this script with -h to see more details on how to configure")
111 sys.exit(1)
112
113 # Testing begins here!
114@@ -595,13 +588,14 @@
115
116 1- Command-line parameters (see above).
117 2- Environment variables (example will follow).
118-3- Configuration file (example will follow).
119- Default config location is /etc/checkbox.d/network.cfg
120+3- If run via checkbox/plainbox, /etc/xdg/checkbox-certification.conf
121+ can have the below-mentioned environment variables defined in the
122+ [environment] section. An example file is provided and can be simply
123+ modified with the correct values.
124
125 Environment variables
126 =====================
127-ALL environment variables must be defined, even if empty, for them to be
128-picked up. The variables are:
129+The variables are:
130 TEST_TARGET_FTP
131 TEST_USER
132 TEST_PASS
133@@ -609,14 +603,13 @@
134
135 example config file
136 ===================
137-[FTP]
138-
139-Target: 192.168.1.23
140-User: FTPUser
141-Pass:PassW0Rd
142-
143-[IPERF]
144-Target: 192.168.1.45
145+[environment]
146+TEST_TARGET_FTP = ftp-server.example.com
147+TEST_USER = my-name
148+TEST_PASS = a-password
149+TEST_TARGET_IPERF = iperf-server.example.com
150+
151+
152 **NOTE**
153
154 """

Subscribers

People subscribed via source and target branches