Commit 8356b2cb authored by Łukasz Nowak's avatar Łukasz Nowak Committed by Klaus Wölfel

[erp5testnode] Use only taskdistribution.TaskDistributor

This results with calling correct methods on the server.
parent 23245a8f
...@@ -13,7 +13,6 @@ from erp5.util.testnode.ScalabilityTestRunner import ScalabilityTestRunner ...@@ -13,7 +13,6 @@ from erp5.util.testnode.ScalabilityTestRunner import ScalabilityTestRunner
from erp5.util.testnode.SlapOSControler import createFolder from erp5.util.testnode.SlapOSControler import createFolder
from erp5.util.taskdistribution import TaskDistributor from erp5.util.taskdistribution import TaskDistributor
from erp5.util.taskdistribution import TaskDistributionTool
from erp5.util.taskdistribution import TestResultProxy from erp5.util.taskdistribution import TestResultProxy
import os import os
import shutil import shutil
...@@ -690,11 +689,11 @@ develop = false ...@@ -690,11 +689,11 @@ develop = false
original_startTestSuite = TaskDistributor.startTestSuite original_startTestSuite = TaskDistributor.startTestSuite
original_subscribeNode = TaskDistributor.subscribeNode original_subscribeNode = TaskDistributor.subscribeNode
original_getTestType = TaskDistributor.getTestType original_getTestType = TaskDistributor.getTestType
original_createTestResult = TaskDistributionTool.createTestResult original_createTestResult = TaskDistributor.createTestResult
TaskDistributor.startTestSuite = patch_startTestSuite TaskDistributor.startTestSuite = patch_startTestSuite
TaskDistributor.subscribeNode = doNothing TaskDistributor.subscribeNode = doNothing
TaskDistributor.getTestType = patch_getTestType TaskDistributor.getTestType = patch_getTestType
TaskDistributionTool.createTestResult = patch_createTestResult TaskDistributor.createTestResult = patch_createTestResult
# TestNode # TestNode
test_node = self.getTestNode() test_node = self.getTestNode()
...@@ -719,9 +718,9 @@ develop = false ...@@ -719,9 +718,9 @@ develop = false
SlapOSMasterCommunicator.__init__ = original_SlapOSMasterCommunicator__init__ SlapOSMasterCommunicator.__init__ = original_SlapOSMasterCommunicator__init__
TaskDistributor.generateConfiguration = original_generateConfiguration TaskDistributor.generateConfiguration = original_generateConfiguration
TaskDistributor.startTestSuite = original_startTestSuite TaskDistributor.startTestSuite = original_startTestSuite
TaskDistributionTool.createTestResult = original_createTestResult TaskDistributor.createTestResult = original_createTestResult
TaskDistributionTool.subscribeNode = original_subscribeNode TaskDistributor.subscribeNode = original_subscribeNode
TaskDistributionTool.getTestType = original_getTestType TaskDistributor.getTestType = original_getTestType
RunnerClass._prepareSlapOS = original_prepareSlapOS RunnerClass._prepareSlapOS = original_prepareSlapOS
RunnerClass.runTestSuite = original_runTestSuite RunnerClass.runTestSuite = original_runTestSuite
...@@ -857,8 +856,8 @@ develop = false ...@@ -857,8 +856,8 @@ develop = false
TaskDistributor.startTestSuite = patch_startTestSuite TaskDistributor.startTestSuite = patch_startTestSuite
TaskDistributor.subscribeNode = doNothing TaskDistributor.subscribeNode = doNothing
TaskDistributor.getTestType = patch_getTestType TaskDistributor.getTestType = patch_getTestType
original_createTestResult = TaskDistributionTool.createTestResult original_createTestResult = TaskDistributor.createTestResult
TaskDistributionTool.createTestResult = patch_createTestResult TaskDistributor.createTestResult = patch_createTestResult
test_node = self.getTestNode() test_node = self.getTestNode()
# Change UnitTestRunner class methods # Change UnitTestRunner class methods
original_prepareSlapOS = RunnerClass._prepareSlapOS original_prepareSlapOS = RunnerClass._prepareSlapOS
...@@ -889,9 +888,9 @@ develop = false ...@@ -889,9 +888,9 @@ develop = false
SlapOSMasterCommunicator.__init__ = original_SlapOSMasterCommunicator__init__ SlapOSMasterCommunicator.__init__ = original_SlapOSMasterCommunicator__init__
TaskDistributor.generateConfiguration = original_generateConfiguration TaskDistributor.generateConfiguration = original_generateConfiguration
TaskDistributor.startTestSuite = original_startTestSuite TaskDistributor.startTestSuite = original_startTestSuite
TaskDistributionTool.createTestResult = original_createTestResult TaskDistributor.createTestResult = original_createTestResult
TaskDistributionTool.subscribeNode = original_subscribeNode TaskDistributor.subscribeNode = original_subscribeNode
TaskDistributionTool.getTestType = original_getTestType TaskDistributor.getTestType = original_getTestType
RunnerClass._prepareSlapOS = original_prepareSlapOS RunnerClass._prepareSlapOS = original_prepareSlapOS
RunnerClass.runTestSuite = original_runTestSuite RunnerClass.runTestSuite = original_runTestSuite
...@@ -1065,7 +1064,7 @@ develop = false ...@@ -1065,7 +1064,7 @@ develop = false
original_startTestSuite = TaskDistributor.startTestSuite original_startTestSuite = TaskDistributor.startTestSuite
original_subscribeNode = TaskDistributor.subscribeNode original_subscribeNode = TaskDistributor.subscribeNode
original_getTestType = TaskDistributor.getTestType original_getTestType = TaskDistributor.getTestType
original_createTestResult = TaskDistributionTool.createTestResult original_createTestResult = TaskDistributor.createTestResult
original_prepareSlapOS = RunnerClass._prepareSlapOS original_prepareSlapOS = RunnerClass._prepareSlapOS
original_runTestSuite = RunnerClass.runTestSuite original_runTestSuite = RunnerClass.runTestSuite
original_supply = SlapOSControler.supply original_supply = SlapOSControler.supply
...@@ -1083,7 +1082,7 @@ develop = false ...@@ -1083,7 +1082,7 @@ develop = false
TaskDistributor.startTestSuite = patch_startTestSuite TaskDistributor.startTestSuite = patch_startTestSuite
TaskDistributor.subscribeNode = doNothing TaskDistributor.subscribeNode = doNothing
TaskDistributor.getTestType = patch_getTestType TaskDistributor.getTestType = patch_getTestType
TaskDistributionTool.createTestResult = patch_createTestResult TaskDistributor.createTestResult = patch_createTestResult
RunnerClass._prepareSlapOS = doNothing RunnerClass._prepareSlapOS = doNothing
RunnerClass.runTestSuite = patch_runTestSuite RunnerClass.runTestSuite = patch_runTestSuite
SlapOSControler.supply = doNothing SlapOSControler.supply = doNothing
...@@ -1101,9 +1100,9 @@ develop = false ...@@ -1101,9 +1100,9 @@ develop = false
TaskDistributor.generateConfiguration = original_generateConfiguration TaskDistributor.generateConfiguration = original_generateConfiguration
TaskDistributor.isMasterTestnode = original_isMasterTestnode TaskDistributor.isMasterTestnode = original_isMasterTestnode
TaskDistributor.startTestSuite = original_startTestSuite TaskDistributor.startTestSuite = original_startTestSuite
TaskDistributionTool.createTestResult = original_createTestResult TaskDistributor.createTestResult = original_createTestResult
TaskDistributionTool.subscribeNode = original_subscribeNode TaskDistributor.subscribeNode = original_subscribeNode
TaskDistributionTool.getTestType = original_getTestType TaskDistributor.getTestType = original_getTestType
RunnerClass._prepareSlapOS = original_prepareSlapOS RunnerClass._prepareSlapOS = original_prepareSlapOS
RunnerClass.runTestSuite = original_runTestSuite RunnerClass.runTestSuite = original_runTestSuite
SlapOSControler.supply = original_supply SlapOSControler.supply = original_supply
......
...@@ -29,7 +29,7 @@ Client implementation for portal_task_distribution. ...@@ -29,7 +29,7 @@ Client implementation for portal_task_distribution.
Example use: Example use:
import erp5.util.taskdistribution import erp5.util.taskdistribution
tool = erp5.util.taskdistribution.TaskDistributionTool(...) distributor = erp5.util.taskdistribution.TaskDistributor(...)
test_result = tool.createTestResult(...) test_result = tool.createTestResult(...)
test_result.addWatch('foo', open('foo')) test_result.addWatch('foo', open('foo'))
while True: while True:
...@@ -138,7 +138,7 @@ class TestResultLineProxy(RPCRetry): ...@@ -138,7 +138,7 @@ class TestResultLineProxy(RPCRetry):
Properties: Properties:
name (str) (ro) name (str) (ro)
Test name, as provided to TaskDistributionTool.createTestResult . Test name, as provided to TaskDistributor.createTestResult .
""" """
def __init__(self, proxy, retry_time, logger, test_result_line_path, def __init__(self, proxy, retry_time, logger, test_result_line_path,
test_name): test_name):
...@@ -468,9 +468,13 @@ class TaskDistributor(RPCRetry): ...@@ -468,9 +468,13 @@ class TaskDistributor(RPCRetry):
if logger is None: if logger is None:
logger = null_logger logger = null_logger
if portal_url is None: if portal_url is None:
proxy = DummyTaskDistributionTool() proxy = DummyTaskDistributor()
else: else:
proxy = ServerProxy(portal_url, allow_none=True) proxy = ServerProxy(portal_url, allow_none=True)
# create internal proxy to the tool in order to fall-back in case
# of old server
self._tool_proxy = ServerProxy(portal_url, allow_none=True
).portal_task_distribution
super(TaskDistributor, self).__init__(proxy, retry_time,logger) super(TaskDistributor, self).__init__(proxy, retry_time,logger)
protocol_revision = self._retryRPC('getProtocolRevision') protocol_revision = self._retryRPC('getProtocolRevision')
if protocol_revision != 1: if protocol_revision != 1:
...@@ -538,8 +542,40 @@ class TaskDistributor(RPCRetry): ...@@ -538,8 +542,40 @@ class TaskDistributor(RPCRetry):
""" """
return self._retryRPC('getSlaposHateoasUrl') return self._retryRPC('getSlaposHateoasUrl')
def createTestResult(self, revision, test_name_list, node_title,
allow_restart=False, test_title=None, project_title=None):
"""
(maybe) create a new test run.
revision (str)
An opaque string describing code being tested.
test_name_list (list of str)
List of tests being part of this test run. May be empty.
node_title (str)
Human-readable test node identifier, so an adnmin can know which
node does what.
allow_restart (bool)
When true, a tet result is always created, even if a former finished
one is found for same name and revision pair.
test_title (str)
Human-readable title for test. Must be identical for successive runs.
Allows browsing its result history.
project_title (str)
Existing project title, so test result gets associated to it.
Returns None if no test run is needed (a test run for given name and
revision has already been completed).
Otherwise, returns a TestResultProxy instance.
"""
result = self._retryRPC('createTestResult', ('', revision,
test_name_list, allow_restart, test_title, node_title,
project_title))
if result:
test_result_path, revision = result
result = TestResultProxy(self._proxy, self._retry_time,
self._logger, test_result_path, node_title, revision)
return result
class DummyTaskDistributionTool(object): class DummyTaskDistributor(object):
""" """
Fake remote server. Fake remote server.
......
...@@ -323,13 +323,10 @@ develop = false ...@@ -323,13 +323,10 @@ develop = false
remote_test_result_needs_cleanup = False remote_test_result_needs_cleanup = False
begin = time.time() begin = time.time()
portal_url = config['test_suite_master_url'] portal_url = config['test_suite_master_url']
portal = taskdistribution.TaskDistributionTool(portal_url, self.taskdistribution = taskdistribution.TaskDistributor(
logger=DummyLogger(log))
self.portal = portal
self.test_suite_portal = taskdistribution.TaskDistributor(
portal_url, portal_url,
logger=DummyLogger(log)) logger=DummyLogger(log))
node_configuration = self.test_suite_portal.subscribeNode(node_title=config['test_node_title'], node_configuration = self.taskdistribution.subscribeNode(node_title=config['test_node_title'],
computer_guid=config['computer_id']) computer_guid=config['computer_id'])
if type(node_configuration) == str: if type(node_configuration) == str:
# Backward compatiblity # Backward compatiblity
...@@ -341,7 +338,7 @@ develop = false ...@@ -341,7 +338,7 @@ develop = false
log('Received and using process timeout from master: %i' % ( log('Received and using process timeout from master: %i' % (
process_timeout)) process_timeout))
self.process_manager.max_timeout = process_timeout self.process_manager.max_timeout = process_timeout
test_suite_data = self.test_suite_portal.startTestSuite( test_suite_data = self.taskdistribution.startTestSuite(
node_title=config['test_node_title'], node_title=config['test_node_title'],
computer_guid=config['computer_id']) computer_guid=config['computer_id'])
if type(test_suite_data) == str: if type(test_suite_data) == str:
...@@ -351,10 +348,10 @@ develop = false ...@@ -351,10 +348,10 @@ develop = false
log("Got following test suite data from master : %r" % \ log("Got following test suite data from master : %r" % \
(test_suite_data,)) (test_suite_data,))
try: try:
my_test_type = self.test_suite_portal.getTestType() my_test_type = self.taskdistribution.getTestType()
except: except Exception:
log("testnode, error during requesting getTestType() method \ log("testnode, error during requesting getTestType() method"
from the distributor.") " from the distributor.")
raise raise
# Select runner according to the test type # Select runner according to the test type
if my_test_type == 'UnitTest': if my_test_type == 'UnitTest':
...@@ -400,7 +397,8 @@ from the distributor.") ...@@ -400,7 +397,8 @@ from the distributor.")
self.constructProfile(node_test_suite, my_test_type, self.constructProfile(node_test_suite, my_test_type,
runner.getRelativePathUsage()) runner.getRelativePathUsage())
# Make sure we have local repository # Make sure we have local repository
test_result = portal.createTestResult(node_test_suite.revision, [], test_result = self.taskdistribution.createTestResult(
node_test_suite.revision, [],
config['test_node_title'], False, config['test_node_title'], False,
node_test_suite.test_suite_title, node_test_suite.test_suite_title,
node_test_suite.project_title) node_test_suite.project_title)
...@@ -413,7 +411,7 @@ from the distributor.") ...@@ -413,7 +411,7 @@ from the distributor.")
# get cluster configuration for this test suite, this is needed to # get cluster configuration for this test suite, this is needed to
# know slapos parameters to user for creating instances # know slapos parameters to user for creating instances
log("Getting configuration from test suite " + str(node_test_suite.test_suite_title)) log("Getting configuration from test suite " + str(node_test_suite.test_suite_title))
generated_config = self.test_suite_portal.generateConfiguration(node_test_suite.test_suite_title) generated_config = self.taskdistribution.generateConfiguration(node_test_suite.test_suite_title)
json_data = json.loads(generated_config) json_data = json.loads(generated_config)
cluster_configuration = Utils.deunicodeData(json_data['configuration_list'][0]) cluster_configuration = Utils.deunicodeData(json_data['configuration_list'][0])
node_test_suite.edit(cluster_configuration=cluster_configuration) node_test_suite.edit(cluster_configuration=cluster_configuration)
......
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