Commit 764f1dec authored by Ilias Tsitsimpis's avatar Ilias Tsitsimpis
Browse files

snf-burnin: Better log output

Testsuite ServerTestSuite will not fail if one of the generated
tests fails.
parent 1fbe4d09
......@@ -54,7 +54,8 @@ from synnefo_tools.burnin.logger import Log
# --------------------------------------------------------------------
# Global variables
logger = None # Invalid constant name. pylint: disable-msg=C0103
logger = None # Invalid constant name. pylint: disable-msg=C0103
success = None # Invalid constant name. pylint: disable-msg=C0103
SNF_TEST_PREFIX = "snf-test-"
CONNECTION_RETRY_LIMIT = 2
SYSTEM_USERS = ["images@okeanos.grnet.gr", "images@demo.synnefo.org"]
......@@ -233,6 +234,16 @@ class BurninTests(unittest.TestCase):
self.info(" Network usage is %s",
self.quotas['system']['cyclades.network.private']['usage'])
def _run_tests(self, tcases):
"""Run some generated testcases"""
global success # Using global. pylint: disable-msg=C0103,W0603,W0602
for tcase in tcases:
self.info("Running testsuite %s", tcase.__name__)
success = run_test(tcase) and success
if self.failfast and not success:
break
# ----------------------------------
# Loggers helper functions
def log(self, msg, *args):
......@@ -593,14 +604,11 @@ def initialize(opts, testsuites, stale_testsuites):
# Run Burnin
def run_burnin(testsuites, failfast=False):
"""Run burnin testsuites"""
global logger # Using global. pylint: disable-msg=C0103,W0603,W0602
# Using global. pylint: disable-msg=C0103,W0603,W0602
global logger, success
success = True
for tcase in testsuites:
was_success = run_test(tcase)
success = success and was_success
if failfast and not success:
break
run_tests(testsuites, failfast=failfast)
# Clean up our logger
del(logger)
......@@ -609,6 +617,17 @@ def run_burnin(testsuites, failfast=False):
return 0 if success else 1
def run_tests(tcases, failfast=False):
"""Run some testcases"""
global success # Using global. pylint: disable-msg=C0103,W0603,W0602
for tcase in tcases:
was_success = run_test(tcase)
success = success and was_success
if failfast and not success:
break
def run_test(tcase):
"""Run a testcase"""
tsuite = unittest.TestLoader().loadTestsFromTestCase(tcase)
......@@ -619,9 +638,9 @@ def run_test(tcase):
# --------------------------------------------------------------------
# Helper functions
def was_successful(tsuite, success):
def was_successful(tsuite, successful):
"""Handle whether a testsuite was succesful or not"""
if success:
if successful:
logger.testsuite_success(tsuite)
return True
else:
......
......@@ -364,7 +364,7 @@ class CycladesTests(BurninTests):
try:
ssh.connect(hostip, username=username, password=password)
except paramiko.SSHException as excpt:
if excpt.code == 104: # Error reading SSH protocol banner
if excpt.errno == 104: # Error reading SSH protocol banner
raise Retry()
else:
raise
......
......@@ -44,7 +44,7 @@ import socket
from vncauthproxy.d3des import generate_response as d3des_generate_response
from synnefo_tools.burnin.common import BurninTests, Proper, run_test
from synnefo_tools.burnin.common import BurninTests, Proper
from synnefo_tools.burnin.cyclades_common import CycladesTests
......@@ -341,10 +341,4 @@ class ServerTestSuite(BurninTests):
def test_004_run_testsuites(self):
"""Run the generated tests"""
success = True
for gen_cls in self.gen_classes:
self.info("Running testsuite %s", gen_cls.__name__)
success = run_test(gen_cls) and success # With this order
if self.failfast and not success:
break
self.assertTrue(success, "Some of the generated tests failed")
self._run_tests(self.gen_classes)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment