Commit 0efe3ee9 authored by Benjamin Blanc's avatar Benjamin Blanc

util: testnode test

parent 8717c124
...@@ -7,22 +7,26 @@ import time ...@@ -7,22 +7,26 @@ import time
import sys import sys
import multiprocessing import multiprocessing
import errno import errno
import json
import logging import logging
import logging.handlers import logging.handlers
from .argument import ArgumentType from .argument import ArgumentType
from .performance_tester import PerformanceTester from .performance_tester import PerformanceTester
from erp5.util import taskdistribution from erp5.util import taskdistribution
from erp5.util.testnode import testnodeUtils
class ScalabilityTest(object): class ScalabilityTest(object):
def __init__(self, title, count): def __init__(self, data, test_result):
self.title = title self.__dict__ = {}
self.count = count self.__dict__.update(data)
self.test_result = test_result
def stop(self):
self.test_result.stopTestCase(self.relative_path)
def cancel(self):
self.test_result.cancelTestCase(self.relative_path)
def dump(self):
print '<ScalabilityTest>'
print 'self.title: %s' %(str(self.title))
print 'self.count: %s' %(str(self.count))
class ScalabilityLauncher(object): class ScalabilityLauncher(object):
def __init__(self): def __init__(self):
...@@ -44,10 +48,13 @@ class ScalabilityLauncher(object): ...@@ -44,10 +48,13 @@ class ScalabilityLauncher(object):
self.log = logger.info self.log = logger.info
# Proxy to with erp5 master test_result # Proxy to with erp5 master test_result
self.test_result = taskdistribution.TestResultProxyProxy(self.__argumentNamespace.portal_url, self.test_result = taskdistribution.TestResultProxyProxy(
1.0, logger, self.__argumentNamespace.test_result_url, self.__argumentNamespace.test_suite_master_url,
self.__argumentNamespace.node_title, self.__argumentNamespace.revision) 1.0, self.log,
self.__argumentNamespace.test_result_path,
self.__argumentNamespace.node_title,
self.__argumentNamespace.revision
)
@staticmethod @staticmethod
def _addParserArguments(parser): def _addParserArguments(parser):
# Mandatory arguments # Mandatory arguments
...@@ -93,45 +100,36 @@ class ScalabilityLauncher(object): ...@@ -93,45 +100,36 @@ class ScalabilityLauncher(object):
""" """
pass pass
def updateTestResultLineStatus(self, state): def getNextTest(self):
""" """
Update state of a test_result_line Return a ScalabilityTest with current running test case informations,
or None if no test_case ready
""" """
# TODO : set a line per count value and use setState (?) data = self.test_result.getNextTestCase()
# if data == None :
pass return None
decoded_data = testnodeUtils.deunicodeData(json.loads(
def _getNextTest(self): data
""" ))
Get testsuite parameters next_test = ScalabilityTest(decoded_data, self.test_result)
"""
title = "My Sweet Title"
count = 1
next_test = ScalabilityTest(title, count)
return next_test return next_test
def run(self): def run(self):
self.log("Scalability Launcher started") self.log("Scalability Launcher started")
max_time = 10 max_time = 36000
start_time = time.time() start_time = time.time()
error_message_set, exit_status = set(), 0 error_message_set, exit_status = set(), 0
test_result = taskdistribution.TestResultProxyProxy(
self.__argumentNamespace.test_suite_master_url,
1.0, self.log,
self.__argumentNamespace.test_result_path,
self.__argumentNamespace.node_title,
self.__argumentNamespace.revision
)
#self.log("%s", self.test_result.isAlive())
while time.time()-start_time < max_time: while time.time()-start_time < max_time:
current_test = self._getNextTest() current_test = self.getNextTest()
current_test.dump() if current_test == None:
time.sleep(2) self.log("No Test Case Ready")
time.sleep(5)
else:
# Here call a runScalabilityTest ( placed on product/ERP5Type/tests ) ? # Here call a runScalabilityTest ( placed on product/ERP5Type/tests ) ?
self.log("Test Case %s is running..." %(current_test.title))
current_test.stop()
self.log("Test Case Stopped")
return error_message_set, exit_status return error_message_set, exit_status
......
...@@ -386,7 +386,7 @@ class TestResultProxyProxy(TestResultProxy): ...@@ -386,7 +386,7 @@ class TestResultProxyProxy(TestResultProxy):
node_title, revision): node_title, revision):
try: try:
proxy = ServerProxy( proxy = ServerProxy(
portal_url, test_suite_master_url,
allow_none=True, allow_none=True,
).portal_task_distribution ).portal_task_distribution
except: except:
...@@ -394,12 +394,24 @@ class TestResultProxyProxy(TestResultProxy): ...@@ -394,12 +394,24 @@ class TestResultProxyProxy(TestResultProxy):
TestResultProxy.__init__(self, proxy, retry_time, logger, test_result_path, TestResultProxy.__init__(self, proxy, retry_time, logger, test_result_path,
node_title, revision) node_title, revision)
def getNextTestResultLinePath(self): def getNextTestCase(self):
""" """
A proxy to getNextTestResultLinePath A proxy to getNextTestCase
Return the relative path of the test with the running state Return the relative path of the test with the running state
""" """
return bool(self._retryRPC('getNextTestResultLinePath', [self._test_result_path])) return self._retryRPC('getNextTestCase', [self._test_result_path])
def cancelTestCase(self, test_result_line_path):
"""
"""
return self._retryRPC('cancelTestCase', [test_result_line_path])
def stopTestCase(self, test_result_line_path):
"""
"""
return self._retryRPC('stopTestCase', [test_result_line_path])
......
...@@ -109,7 +109,7 @@ class ScalabilityTestRunner(): ...@@ -109,7 +109,7 @@ class ScalabilityTestRunner():
config.update({'scalability-launcher-title':'MyTestNodeTitle'}) config.update({'scalability-launcher-title':'MyTestNodeTitle'})
config.update({'test-result-path':test_result.test_result_path}) config.update({'test-result-path':test_result.test_result_path})
config.update({'test-suite-revision':test_result.revision}) config.update({'test-suite-revision':test_result.revision})
config.update({'test-suite-master-url':self.config['test_suite_master_url']}) config.update({'test-suite-master-url':self.testnode.config['test_suite_master_url']})
return config return config
def _createInstance(self, software_path, software_configuration, instance_title, def _createInstance(self, software_path, software_configuration, instance_title,
...@@ -301,6 +301,13 @@ late a SlapOS (positive) answer." %(str(os.getpid()),str(os.getpid()),)) ...@@ -301,6 +301,13 @@ 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)
# No more test to run
if test_result_line_proxy == None :
# Hum normal ?
self.log("Already tested.")
# Clean up
return {'status_code' : 0}
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(): while test_result_line_proxy.isRunning() and test_result_proxy.isAlive():
time.sleep(15) time.sleep(15)
...@@ -328,6 +335,7 @@ late a SlapOS (positive) answer." %(str(os.getpid()),str(os.getpid()),)) ...@@ -328,6 +335,7 @@ late a SlapOS (positive) answer." %(str(os.getpid()),str(os.getpid()),))
self.log("Test in a undeterminated state.") self.log("Test in a undeterminated state.")
raise ValueError("Test case is in an undeterminated state") raise ValueError("Test case is in an undeterminated state")
# todo : something like test_result_line_proxy.stop()
return {'status_code' : 0} return {'status_code' : 0}
def _cleanUpNodesInformation(self): def _cleanUpNodesInformation(self):
......
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