diff options
author | 2016-12-13 18:11:08 +0000 | |
---|---|---|
committer | 2016-12-13 18:11:08 +0000 | |
commit | 76d39e29232020e2fc7b4252185e301484ebca1d (patch) | |
tree | 7070900b0cc94c77a67bfd5a6e8cd91fd17dc7fd /test/functest/results.py | |
parent | 7c552712e38ac896ff08366f6862590d29659e33 (diff) | |
parent | 2417d16aa6767a4c1bb6f28104076bb4b11d5e10 (diff) |
Merge "Encapsulate some functionality in Results class"
Diffstat (limited to 'test/functest/results.py')
-rw-r--r-- | test/functest/results.py | 27 |
1 files changed, 19 insertions, 8 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): |