summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorRomanos Skiadas <rski@intracom-telecom.com>2016-12-13 10:55:35 +0200
committerRomanos Skiadas <rski@intracom-telecom.com>2016-12-13 15:16:57 +0200
commit2417d16aa6767a4c1bb6f28104076bb4b11d5e10 (patch)
tree551a546a11e6ecf83b48f3de96184aad1110b0fa /test
parent2445ba0a0325611e0b927ecc7ed4d361426e5fc4 (diff)
Encapsulate some functionality in Results class
- Move adding actions taken during tests to summary in a method in Results - Provide add_success/failure methods that hide the column size manipulation Change-Id: If7416f3f9399125fe21632328a49af285a4b6cc6 Signed-off-by: Romanos Skiadas <rski@intracom-telecom.com>
Diffstat (limited to 'test')
-rw-r--r--test/functest/results.py27
-rw-r--r--test/functest/testcase_1.py12
-rw-r--r--test/functest/testcase_2.py12
-rw-r--r--test/functest/testcase_4.py12
4 files changed, 31 insertions, 32 deletions
diff --git a/test/functest/results.py b/test/functest/results.py
index 7c73556..343c962 100644
--- a/test/functest/results.py
+++ b/test/functest/results.py
@@ -59,11 +59,11 @@ class Results(object):
% (vm_source.name, vm_target.name))
if expected == "PASS":
logger.debug("[PASS] %s" % msg)
- self.add_to_summary(2, "PASS", test_case_name)
+ self.add_success(test_case_name)
else:
logger.debug("[FAIL] %s" % msg)
self.test_result = "FAIL"
- self.add_to_summary(2, "FAIL", test_case_name)
+ self.add_failure(test_case_name)
logger.debug("\n%s" % last_n_lines)
break
elif ("ping %s KO" % ip_target) in last_n_lines:
@@ -71,11 +71,11 @@ class Results(object):
(vm_source.name, vm_target.name))
if expected == "FAIL":
logger.debug("[PASS] %s" % msg)
- self.add_to_summary(2, "PASS", test_case_name)
+ self.add_success(test_case_name)
else:
logger.debug("[FAIL] %s" % msg)
self.test_result = "FAIL"
- self.add_to_summary(2, "FAIL", test_case_name)
+ self.add_failure(test_case_name)
break
time.sleep(1)
timeout -= 1
@@ -84,7 +84,7 @@ class Results(object):
logger.debug("[FAIL] Timeout reached for '%s'. "
"No ping output captured in the console log"
% vm_source.name)
- self.add_to_summary(2, "FAIL", test_case_name)
+ self.add_failure(test_case_name)
break
def add_to_summary(self, num_cols, col1, col2=""):
@@ -101,6 +101,17 @@ class Results(object):
if col1 == "FAIL":
self.num_tests_failed += 1
+ def record_action(self, msg):
+ """Record and log an action and display it in the summary."""
+ logger.info(msg)
+ self.add_to_summary(1, msg)
+
+ def add_failure(self, test):
+ self.add_to_summary(2, "FAIL", test)
+
+ def add_success(self, test):
+ self.add_to_summary(2, "PASS", test)
+
def check_ssh_output(self, vm_source, ip_source,
vm_target, ip_target,
expected, timeout=30):
@@ -129,11 +140,11 @@ class Results(object):
last_n_lines = lines[-5:]
if ("%s %s" % (ip_target, expected)) in last_n_lines:
logger.debug("[PASS] %s" % test_case_name)
- self.add_to_summary(2, "PASS", test_case_name)
+ self.add_success(test_case_name)
break
elif ("%s not reachable" % ip_target) in last_n_lines:
logger.debug("[FAIL] %s" % test_case_name)
- self.add_to_summary(2, "FAIL", test_case_name)
+ self.add_failure(test_case_name)
self.test_result = "FAIL"
break
time.sleep(1)
@@ -143,7 +154,7 @@ class Results(object):
logger.debug("[FAIL] Timeout reached for '%s'."
" No ping output captured in the console log"
% vm_source.name)
- self.add_to_summary(2, "FAIL", test_case_name)
+ self.add_failure(test_case_name)
break
def compile_summary(self, SUCCESS_CRITERIA):
diff --git a/test/functest/testcase_1.py b/test/functest/testcase_1.py
index eba39bb..a84478f 100644
--- a/test/functest/testcase_1.py
+++ b/test/functest/testcase_1.py
@@ -135,8 +135,7 @@ def main():
vm_1_ip = vm_1.networks.itervalues().next()[0]
msg = ("Create VPN with eRT<>iRT")
- logger.info(msg)
- results.add_to_summary(1, msg)
+ results.record_action(msg)
vpn_name = "sdnvpn-" + str(randint(100000, 999999))
kwargs = {
"import_targets": TESTCASE_CONFIG.targets1,
@@ -149,8 +148,7 @@ def main():
logger.debug("VPN created details: %s" % bgpvpn)
msg = ("Associate network '%s' to the VPN." % TESTCASE_CONFIG.net_1_name)
- logger.info(msg)
- results.add_to_summary(1, msg)
+ results.record_action(msg)
results.add_to_summary(0, "-")
os_utils.create_network_association(
@@ -176,9 +174,8 @@ def main():
expected="FAIL", timeout=30)
msg = ("Associate network '%s' to the VPN." % TESTCASE_CONFIG.net_2_name)
- logger.info(msg)
results.add_to_summary(0, "-")
- results.add_to_summary(1, msg)
+ results.record_action(msg)
results.add_to_summary(0, "-")
os_utils.create_network_association(
neutron_client, bgpvpn_id, network_2_id)
@@ -203,9 +200,8 @@ def main():
expected="FAIL", timeout=30)
msg = ("Update VPN with eRT=iRT ...")
- logger.info(msg)
results.add_to_summary(0, "-")
- results.add_to_summary(1, msg)
+ results.record_action(msg)
results.add_to_summary(0, "-")
kwargs = {"import_targets": TESTCASE_CONFIG.targets1,
"export_targets": TESTCASE_CONFIG.targets1,
diff --git a/test/functest/testcase_2.py b/test/functest/testcase_2.py
index e8b8048..d2c3d57 100644
--- a/test/functest/testcase_2.py
+++ b/test/functest/testcase_2.py
@@ -171,8 +171,7 @@ def main():
vm_1_ip = vm_1.networks.itervalues().next()[0]
msg = ("Create VPN1 with eRT=iRT")
- logger.info(msg)
- results.add_to_summary(1, msg)
+ results.record_action(msg)
vpn1_name = "sdnvpn-1-" + str(randint(100000, 999999))
kwargs = {"import_targets": TESTCASE_CONFIG.targets2,
"export_targets": TESTCASE_CONFIG.targets2,
@@ -184,8 +183,7 @@ def main():
logger.debug("VPN1 created details: %s" % bgpvpn1)
msg = ("Associate network '%s' to the VPN." % TESTCASE_CONFIG.net_1_name)
- logger.info(msg)
- results.add_to_summary(1, msg)
+ results.record_action(msg)
results.add_to_summary(0, "-")
os_utils.create_network_association(
@@ -219,8 +217,7 @@ def main():
results.add_to_summary(0, "-")
msg = ("Create VPN2 with eRT=iRT")
- logger.info(msg)
- results.add_to_summary(1, msg)
+ results.record_action(msg)
vpn2_name = "sdnvpn-2-" + str(randint(100000, 999999))
kwargs = {"import_targets": TESTCASE_CONFIG.targets1,
"export_targets": TESTCASE_CONFIG.targets1,
@@ -232,8 +229,7 @@ def main():
logger.debug("VPN created details: %s" % bgpvpn2)
msg = ("Associate network '%s' to the VPN2." % TESTCASE_CONFIG.net_2_name)
- logger.info(msg)
- results.add_to_summary(1, msg)
+ results.record_action(msg)
results.add_to_summary(0, "-")
os_utils.create_network_association(
diff --git a/test/functest/testcase_4.py b/test/functest/testcase_4.py
index bb25cce..7485e84 100644
--- a/test/functest/testcase_4.py
+++ b/test/functest/testcase_4.py
@@ -135,8 +135,7 @@ def main():
vm_1_ip = vm_1.networks.itervalues().next()[0]
msg = ("Create VPN with eRT<>iRT")
- logger.info(msg)
- results.add_to_summary(1, msg)
+ results.record_action(msg)
vpn_name = "sdnvpn-" + str(randint(100000, 999999))
kwargs = {"import_targets": TESTCASE_CONFIG.targets1,
"export_targets": TESTCASE_CONFIG.targets2,
@@ -147,8 +146,7 @@ def main():
logger.debug("VPN created details: %s" % bgpvpn)
msg = ("Associate router '%s' to the VPN." % TESTCASE_CONFIG.router_1_name)
- logger.info(msg)
- results.add_to_summary(1, msg)
+ results.record_action(msg)
results.add_to_summary(0, "-")
os_utils.create_router_association(
@@ -174,9 +172,8 @@ def main():
expected="FAIL", timeout=30)
msg = ("Associate network '%s' to the VPN." % TESTCASE_CONFIG.net_2_name)
- logger.info(msg)
results.add_to_summary(0, "-")
- results.add_to_summary(1, msg)
+ results.record_action(msg)
results.add_to_summary(0, "-")
os_utils.create_network_association(
neutron_client, bgpvpn_id, network_2_id)
@@ -201,9 +198,8 @@ def main():
expected="FAIL", timeout=30)
msg = ("Update VPN with eRT=iRT ...")
- logger.info(msg)
results.add_to_summary(0, "-")
- results.add_to_summary(1, msg)
+ results.record_action(msg)
results.add_to_summary(0, "-")
kwargs = {"import_targets": TESTCASE_CONFIG.targets1,
"export_targets": TESTCASE_CONFIG.targets1,