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

util: testnode test

parent 8717c124
......@@ -7,22 +7,26 @@ import time
import sys
import multiprocessing
import errno
import json
import logging
import logging.handlers
from .argument import ArgumentType
from .performance_tester import PerformanceTester
from erp5.util import taskdistribution
from erp5.util.testnode import testnodeUtils
class ScalabilityTest(object):
def __init__(self, title, count):
self.title = title
self.count = count
def __init__(self, data, test_result):
self.__dict__ = {}
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):
def __init__(self):
......@@ -44,10 +48,13 @@ class ScalabilityLauncher(object):
self.log = logger.info
# Proxy to with erp5 master test_result
self.test_result = taskdistribution.TestResultProxyProxy(self.__argumentNamespace.portal_url,
1.0, logger, self.__argumentNamespace.test_result_url,
self.__argumentNamespace.node_title, self.__argumentNamespace.revision)
self.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
)
@staticmethod
def _addParserArguments(parser):
# Mandatory arguments
......@@ -93,45 +100,36 @@ class ScalabilityLauncher(object):
"""
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 (?)
#
pass
def _getNextTest(self):
"""
Get testsuite parameters
"""
title = "My Sweet Title"
count = 1
next_test = ScalabilityTest(title, count)
data = self.test_result.getNextTestCase()
if data == None :
return None
decoded_data = testnodeUtils.deunicodeData(json.loads(
data
))
next_test = ScalabilityTest(decoded_data, self.test_result)
return next_test
def run(self):
self.log("Scalability Launcher started")
max_time = 10
max_time = 36000
start_time = time.time()
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:
current_test = self._getNextTest()
current_test.dump()
time.sleep(2)
current_test = self.getNextTest()
if current_test == None:
self.log("No Test Case Ready")
time.sleep(5)
else:
# 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
......
......@@ -386,7 +386,7 @@ class TestResultProxyProxy(TestResultProxy):
node_title, revision):
try:
proxy = ServerProxy(
portal_url,
test_suite_master_url,
allow_none=True,
).portal_task_distribution
except:
......@@ -394,12 +394,24 @@ class TestResultProxyProxy(TestResultProxy):
TestResultProxy.__init__(self, proxy, retry_time, logger, test_result_path,
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 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():
config.update({'scalability-launcher-title':'MyTestNodeTitle'})
config.update({'test-result-path':test_result.test_result_path})
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
def _createInstance(self, software_path, software_configuration, instance_title,
......@@ -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]]
count += 1
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)
while test_result_line_proxy.isRunning() and test_result_proxy.isAlive():
time.sleep(15)
......@@ -328,6 +335,7 @@ late a SlapOS (positive) answer." %(str(os.getpid()),str(os.getpid()),))
self.log("Test in a undeterminated state.")
raise ValueError("Test case is in an undeterminated state")
# todo : something like test_result_line_proxy.stop()
return {'status_code' : 0}
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