summaryrefslogtreecommitdiff
path: root/validation/test
diff options
context:
space:
mode:
authorJean-Philippe NOEL2012-09-25 09:33:19 +0200
committerJean-Philippe NOEL2012-10-05 09:46:05 +0200
commite0bb75bfe3290e6e95bd0f41212293eafe2049a8 (patch)
tree02e1f28a8926eda03b15b1935cfd2c2502ae4607 /validation/test
parent956fbe463be129d3c98e6196eb85685ca1055408 (diff)
validation: implement a token mechanism, refs #3363
Diffstat (limited to 'validation/test')
-rw-r--r--validation/test/P2P_throughput_report/P2P_throughput_report.py24
-rw-r--r--validation/test/P2P_throughput_report/P2P_throughput_report_caller.py124
-rw-r--r--validation/test/P2P_throughput_report/config.py38
3 files changed, 119 insertions, 67 deletions
diff --git a/validation/test/P2P_throughput_report/P2P_throughput_report.py b/validation/test/P2P_throughput_report/P2P_throughput_report.py
index 6106279b79..9e4874e7fc 100644
--- a/validation/test/P2P_throughput_report/P2P_throughput_report.py
+++ b/validation/test/P2P_throughput_report/P2P_throughput_report.py
@@ -43,13 +43,6 @@ def update_config(new_config):
global config
config = new_config
-def report(new_config):
- """Generates the PDF report as specified in the configuration.
- It requires to set up first the test bench as detailed in the test bench
- description."""
-
- update_config(new_config)
-
# Configure the 'attenuator' module
attenuator.update_config(config["attenuator"])
@@ -70,11 +63,26 @@ def report(new_config):
check_config()
+def set_tokens(new_config):
+ update_config(new_config)
+ iperf.set_tokens()
+
+def clear_tokens(new_config):
+ update_config(new_config)
+ iperf.clear_tokens()
+
+def report(new_config):
+ """Generates the PDF report as specified in the configuration.
+ It requires to set up first the test bench as detailed in the test bench
+ description."""
+ update_config(new_config)
+
# Build the picture of the test bench
fig_name = build_test_bench_picture()
# Make all the measurements
if config["make_measurements"] == True:
+ iperf.clean_traces()
t0 = time.time()
estimated_min = measurements_estimated_time_min()
print "\nEstimated measurements time in minutes:", estimated_min, "\n"
@@ -387,7 +395,7 @@ def make_measurements(test_protocol, test_type, test_params):
if change_channel(test_type, test_params, test_value) == True:
iperf.update_tone_maps(time_s)
make_measurement(test_protocol, test_type, test_params, test_value)
- iperf.kill()
+ iperf.kill_iperfs()
initialize_testing_devices()
print "End of the measurements of the maximum", test_protocol, \
"throughput vs the", test_type
diff --git a/validation/test/P2P_throughput_report/P2P_throughput_report_caller.py b/validation/test/P2P_throughput_report/P2P_throughput_report_caller.py
index d65dc227bd..5b132d0e0a 100644
--- a/validation/test/P2P_throughput_report/P2P_throughput_report_caller.py
+++ b/validation/test/P2P_throughput_report/P2P_throughput_report_caller.py
@@ -8,6 +8,86 @@ import P2P_throughput_report
import sys
import os
+class P2P_throughput_report_caller:
+
+ """P2P throughput report caller"""
+
+ def __init__(self):
+ from optparse import OptionParser
+ dirname = os.path.dirname(__file__)
+ self.example_file_name = os.path.join(dirname, "config.py")
+ usage = r"""
+ %prog report conf_file
+ Generate the P2P throughput report based on conf_file
+
+ %prog clear_tokens conf_file
+ Clear the tokens on the two iperf hosts specified in conf_file
+
+ %prog set_tokens conf_file
+ Set the tokens on the two iperf hosts specified in conf_file
+
+ conf_file must be the path of a file containing exactly the same
+ parameters as the template (""" + \
+ self.example_file_name + """).\n""" + \
+ """
+ The tokens must be set before generating the report and cleared when the
+ test bench is released."""
+
+ self._commands = dict((n[4:], getattr(self, n))
+ for n in dir(self) if n.startswith('run_'))
+ self._parser = OptionParser(usage = usage)
+
+ def run(self, args):
+ if len(args) != 2:
+ self._parser.error("Bad number of arguments")
+ options, args = self._parser.parse_args(args)
+ cmd = args[0]
+ if cmd not in self._commands:
+ self._parser.error("Unknown command \"{0}\".".format(cmd))
+
+ example_config = evaluate(self.example_file_name)
+ file_name = args[1]
+
+ try:
+ config = evaluate(file_name)
+ expected = sorted(example_config.keys())
+ actual = sorted(config.keys())
+ assert actual == expected, (actual, expected)
+ except IOError:
+ self._parser.error(file_name + " cannot be read.")
+ except SyntaxError:
+ self._parser.error(file_name + " cannot be evaluated.")
+ except AttributeError:
+ self._parser.error(file_name + " does not contain a dictionnary.")
+ except AssertionError as error:
+ (actual, expected) = error.args
+ message = file_name + " does not contain exactly the same " \
+ "parameters as the template (" + \
+ self.example_file_name + ").\n" + \
+ file_name + \
+ " contains the following parameters:\n" + \
+ str(actual) + \
+ "\n" + \
+ self.example_file_name + \
+ " contains the following parameters:\n" + \
+ str(expected)
+ self._parser.error(message)
+ except Exception as error:
+ self._parser.error("Unknown error.\n" + \
+ str(type(error)) + "\n" + \
+ str(error))
+
+ self._commands[cmd](config)
+
+ def run_report(self, config):
+ P2P_throughput_report.report(config)
+
+ def run_set_tokens(self, config):
+ P2P_throughput_report.set_tokens(config)
+
+ def run_clear_tokens(self, config):
+ P2P_throughput_report.clear_tokens(config)
+
def evaluate(file_name):
config_file = open(file_name, "r")
config_string = config_file.read()
@@ -15,46 +95,10 @@ def evaluate(file_name):
config = eval(config_string)
return config
-def report():
-
- args = sys.argv
- example_file_name = os.path.join(os.path.dirname(__file__), "config.py")
- example_config = evaluate(example_file_name)
- config_is_ok = False
-
+if __name__ == "__main__":
try:
- file_name = args[1]
- config = evaluate(file_name)
- expected = sorted(example_config)
- actual = sorted(config)
- assert actual == expected, (actual, expected)
- config_is_ok = True
- except IndexError:
- print >> sys.stderr, "Error: no argument is passed."
- except IOError:
- print >> sys.stderr, "Error: the configuration file cannot be read."
- except SyntaxError:
- print >> sys.stderr, "Error: the configuration cannot be evaluated."
- except AttributeError:
- print >> sys.stderr, "Error: the configuration is not a dictionnary."
- except AssertionError as error:
- (actual, expected) = error.args
- print >> sys.stderr, "Error: the parameters of the configuration " \
- "are not the same as the parameters of the " \
- "configuration file template (" + example_file_name + ")."
- print >> sys.stderr, "The actual parameters are the following:"
- print >> sys.stderr, actual
- print >> sys.stderr, "The expected parameters are the following:"
- print >> sys.stderr, expected
- except Exception as error:
- print >> sys.stderr, "Unknown error.", type(error)
-
- if config_is_ok is False:
- print >> sys.stderr, "The first argument passed to the function " \
- "must be the path of a file containing the same parameters as " \
- "the configuration file template (" + example_file_name + ")."
+ P2P_throughput_report_caller().run(sys.argv[1:])
+ except RuntimeError, e:
+ print >> sys.stderr, "Error:", e
sys.exit(1)
- P2P_throughput_report.report(config)
-
-report()
diff --git a/validation/test/P2P_throughput_report/config.py b/validation/test/P2P_throughput_report/config.py
index 4cf5fecfca..990ab5ece5 100644
--- a/validation/test/P2P_throughput_report/config.py
+++ b/validation/test/P2P_throughput_report/config.py
@@ -21,7 +21,7 @@
#True|False
#If True, the measurements are reset, made and then the report is generated
#If False, the report is generated from the previous measurements
- "make_measurements":False,
+ "make_measurements":True,
"attenuation":{
"values":numpy.arange(30, 100, 5).tolist(),
"duration_s":20,
@@ -80,24 +80,24 @@
# sweep time (seconds)) for "dynamic_jammer"
# and None otherwise)]
"fixtures":[
- ("UDP", "attenuation", None),
- ("TCP", "attenuation", None),
- ("UDP", "SNR", None),
- ("TCP", "SNR", None),
- ("UDP", "SJR", (13.5, None))
- ("UDP", "SJR", (18.5, None)),
- ("UDP", "SJR", (23.5, None)),
- ("UDP", "SJR", (4, ("SINusoid", 1, 80))),
- ("UDP", "SJR", (15, ("SINusoid", 1, 80))),
- ("UDP", "SJR", (26, ("SINusoid", 1, 80))),
- ("UDP", "SJR", (27.345, ("SINusoid", 1, 80))),
- ("UDP", "frame_size", None),
- ("UDP", "dynamic_jammer", (10, 2, 30, 60)),
- ("UDP", "dynamic_jammer", (0, 2, 30, 60)),
- ("UDP", "dynamic_jammer", (-10, 2, 30, 60)),
- ("UDP", "dynamic_jammer", (-20, 2, 30, 60)),
- ("UDP", "dynamic_jammer", (-30, 2, 30, 60))
- ],
+ ("UDP", "attenuation", None),
+ ("TCP", "attenuation", None),
+ ("UDP", "SNR", None),
+ ("TCP", "SNR", None),
+ ("UDP", "SJR", (13.5, None)),
+ ("UDP", "SJR", (18.5, None)),
+ ("UDP", "SJR", (23.5, None)),
+ ("UDP", "SJR", (4, ("SINusoid", 1, 80))),
+ ("UDP", "SJR", (15, ("SINusoid", 1, 80))),
+ ("UDP", "SJR", (26, ("SINusoid", 1, 80))),
+ ("UDP", "SJR", (27.345, ("SINusoid", 1, 80))),
+ ("UDP", "frame_size", None),
+ ("UDP", "dynamic_jammer", (10, 2, 30, 60)),
+ ("UDP", "dynamic_jammer", (0, 2, 30, 60)),
+ ("UDP", "dynamic_jammer", (-10, 2, 30, 60)),
+ ("UDP", "dynamic_jammer", (-20, 2, 30, 60)),
+ ("UDP", "dynamic_jammer", (-30, 2, 30, 60))
+ ],
#Duration after the channel modification during which we generate traffic
#to let the CE converge
"ce_sync_time_s":2,