Commit 423cca27 authored by Benjamin Blanc's avatar Benjamin Blanc

testnode: update runTestSuite code according to recent chanements in taskdistribution

parent cc7c8b13
...@@ -138,33 +138,14 @@ class TestResultLineProxy(RPCRetry): ...@@ -138,33 +138,14 @@ class TestResultLineProxy(RPCRetry):
def name(self): def name(self):
return self._name return self._name
def isRunning(self): def isTestCaseAlive(self):
""" """
Return : boolean Tell if test result line is still alive on site.
""" """
try: try:
return bool(self._retryRPC('isTestCaseRunning', [self._test_result_line_path])) return bool(self._retryRPC('isTestCaseAlive', [self._test_result_line_path]))
except: except:
raise ValueError('isTestCaseRunning Failed.') raise ValueError('isTestCaseAlive Failed.')
def isFailed(self):
"""
Return : boolean
"""
return bool(self._retryRPC('isTestCaseFailed', [self._test_result_line_path]))
def isCompleted(self):
"""
Return : boolean
"""
return bool(self._retryRPC('isTestCaseCompleted', [self._test_result_line_path]))
def isCancelled(self):
"""
Return : boolean
"""
return bool(self._retryRPC('isTestCaseCancelled', [self._test_result_line_path]))
def stop(self, test_count=None, error_count=None, failure_count=None, def stop(self, test_count=None, error_count=None, failure_count=None,
skip_count=None, duration=None, date=None, command=None, skip_count=None, duration=None, date=None, command=None,
......
...@@ -50,6 +50,8 @@ import signal ...@@ -50,6 +50,8 @@ import signal
MAX_INSTANCE_TIME = 60*60*2 MAX_INSTANCE_TIME = 60*60*2
# max time to register instance to slapOSMaster: 5 minutes # max time to register instance to slapOSMaster: 5 minutes
MAX_CREATION_INSTANCE_TIME = 60*10 MAX_CREATION_INSTANCE_TIME = 60*10
# max time for a test: 1 hour
MAX_TEST_CASE_TIME = 60*60
class ScalabilityTestRunner(): class ScalabilityTestRunner():
def __init__(self, testnode): def __init__(self, testnode):
...@@ -371,7 +373,12 @@ late a SlapOS (positive) answer." %(str(os.getpid()),str(os.getpid()),)) ...@@ -371,7 +373,12 @@ late a SlapOS (positive) answer." %(str(os.getpid()),str(os.getpid()),))
node_test_suite.project_title) node_test_suite.project_title)
count = 0 count = 0
error = None
# Each cluster configuration are tested
for configuration in configuration_list: for configuration in configuration_list:
# First configuration doesn't need XML configuration update.
if count > 0: if count > 0:
# Stop instance # Stop instance
self.slapos_controler.stopInstance(self.instance_title) self.slapos_controler.stopInstance(self.instance_title)
...@@ -397,69 +404,59 @@ late a SlapOS (positive) answer." %(str(os.getpid()),str(os.getpid()),)) ...@@ -397,69 +404,59 @@ late a SlapOS (positive) answer." %(str(os.getpid()),str(os.getpid()),))
exclude_list=[x for x in test_list if x!=test_list[count]] exclude_list=[x for x in test_list if x!=test_list[count]]
count += 1 count += 1
test_result_line_proxy = test_result_proxy.start(exclude_list) test_result_line_proxy = test_result_proxy.start(exclude_list)
#
if test_result_line_proxy == None : if test_result_line_proxy == None :
#self.log("Already tested.") error_message = "Test case already tested."
#error = ValueError("Test already tested.") error = ValueError(error_message)
self.log("Warning::Test already tested.") break
break;
# TODO: use only isAlive() and change test_result workflow on ERP5 Master side for the scalability case
self.log("Test for count : %d is in a running state." %count) self.log("Test for count : %d is in a running state." %count)
while test_result_line_proxy.isRunning() and test_result_proxy.isAlive():
# Wait for test case ending
test_case_start_time = time.time()
while test_result_line_proxy.isTestCaseAlive() and \
test_result_proxy.isAlive() and \
time.time() - test_case_start_time < MAX_TEST_CASE_TIME:
time.sleep(15) time.sleep(15)
pass
# Check test case state # Max time limit reach for current test case: failure.
if test_result_line_proxy.isCompleted(): if test_result_line_proxy.isTestCaseAlive():
self.log("Test case completed.") error_message = "Test case during for %s seconds, too long. (max: %s seconds). Test failure." \
error = None %(str(time.time() - test_case_start_time), MAX_TEST_CASE_TIME)
elif not test_result_proxy.isAlive(): error = ValueError(error_message)
self.log("Test cancelled.") test_result_proxy.reportFailure(stdout=error_message)
# Here do somethig with instances break
error = ValueError("Test cancelled")
break; # Test cancelled or in an undeterminate state.
elif test_result_line_proxy.isFailed(): if not test_result_proxy.isAlive():
self.log("Test failed.") error_message = "Test cancelled or undeterminate state."
# Here do somethig with instances error = ValueError(error_message)
error = ValueError("Test failed") break
break;
elif test_result_line_proxy.isCancelled():
self.log("Test cancelled.")
# Here do somethig with instances
error = ValueError("Test has been cancelled")
break;
elif test_result_line_proxy.isRunning():
self.log("Test always running after max time elapsed.")
# Here do somethig with instances
error = ValueError("Max time for this test case is elapsed.")
break;
else:
self.log("Test in a undeterminated state.")
error = ValueError("Test case is in an undeterminated state")
break;
# Stop instance # Stop current instance
self.slapos_controler.stopInstance(self.instance_title) self.slapos_controler.stopInstance(self.instance_title)
self._waitInstance(self.instance_title, 'stopped') self._waitInstance(self.instance_title, 'stopped')
#self.slapos_controler.destroyInstance(self.instance_title)
# Delete old instances # Delete old instances
self._cleanUpOldInstance() self._cleanUpOldInstance()
# If error appears then that's a test failure.
if error: if error:
test_result_proxy.fail() test_result_proxy.fail()
raise error raise error
#else: #else:
#test_result_proxy.stop() #test_result_proxy.stop()
return {'status_code' : 0} return {'status_code' : 0}
def _cleanUpOldInstance(self): def _cleanUpOldInstance(self):
self.log("_cleanUpOldInstance") self.log("_cleanUpOldInstance")
# Get title and link list of all instances # Get title and link list of all instances
instance_dict = self.slapos_communicator.getHostingSubscriptionDict() instance_dict = self.slapos_communicator.getHostingSubscriptionDict()
instance_to_delete_list = [] instance_to_delete_list = []
outdated_date = datetime.datetime.fromtimestamp(time.time()) - datetime.timedelta(days=2) outdated_date = datetime.datetime.fromtimestamp(time.time()) - datetime.timedelta(days=2)
# Select instances to delete # Select instances to delete
for title,link in instance_dict.items(): for title,link in instance_dict.items():
# Instances created by testnode contains "Scalability-" and # Instances created by testnode contains "Scalability-" and
......
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