Commit 5d09ea96 authored by Łukasz Nowak's avatar Łukasz Nowak

[erp5testnode] Use only taskdistribution.TaskDistributor

This results with calling correct methods on the server.
parent fa9c4e83
......@@ -13,7 +13,6 @@ from erp5.util.testnode.ScalabilityTestRunner import ScalabilityTestRunner
from erp5.util.testnode.SlapOSControler import createFolder
from erp5.util.taskdistribution import TaskDistributor
from erp5.util.taskdistribution import TaskDistributionTool
from erp5.util.taskdistribution import TestResultProxy
import argparse
import os
......@@ -674,11 +673,11 @@ shared = true
original_startTestSuite = TaskDistributor.startTestSuite
original_subscribeNode = TaskDistributor.subscribeNode
original_getTestType = TaskDistributor.getTestType
original_createTestResult = TaskDistributionTool.createTestResult
original_createTestResult = TaskDistributor.createTestResult
TaskDistributor.startTestSuite = patch_startTestSuite
TaskDistributor.subscribeNode = doNothing
TaskDistributor.getTestType = patch_getTestType
TaskDistributionTool.createTestResult = patch_createTestResult
TaskDistributor.createTestResult = patch_createTestResult
# TestNode
test_node = self.getTestNode()
......@@ -703,9 +702,9 @@ shared = true
SlapOSMasterCommunicator.__init__ = original_SlapOSMasterCommunicator__init__
TaskDistributor.generateConfiguration = original_generateConfiguration
TaskDistributor.startTestSuite = original_startTestSuite
TaskDistributionTool.createTestResult = original_createTestResult
TaskDistributionTool.subscribeNode = original_subscribeNode
TaskDistributionTool.getTestType = original_getTestType
TaskDistributor.createTestResult = original_createTestResult
TaskDistributor.subscribeNode = original_subscribeNode
TaskDistributor.getTestType = original_getTestType
RunnerClass._prepareSlapOS = original_prepareSlapOS
RunnerClass.runTestSuite = original_runTestSuite
......@@ -841,8 +840,8 @@ shared = true
TaskDistributor.startTestSuite = patch_startTestSuite
TaskDistributor.subscribeNode = doNothing
TaskDistributor.getTestType = patch_getTestType
original_createTestResult = TaskDistributionTool.createTestResult
TaskDistributionTool.createTestResult = patch_createTestResult
original_createTestResult = TaskDistributor.createTestResult
TaskDistributor.createTestResult = patch_createTestResult
test_node = self.getTestNode()
# Change UnitTestRunner class methods
original_prepareSlapOS = RunnerClass._prepareSlapOS
......@@ -873,9 +872,9 @@ shared = true
SlapOSMasterCommunicator.__init__ = original_SlapOSMasterCommunicator__init__
TaskDistributor.generateConfiguration = original_generateConfiguration
TaskDistributor.startTestSuite = original_startTestSuite
TaskDistributionTool.createTestResult = original_createTestResult
TaskDistributionTool.subscribeNode = original_subscribeNode
TaskDistributionTool.getTestType = original_getTestType
TaskDistributor.createTestResult = original_createTestResult
TaskDistributor.subscribeNode = original_subscribeNode
TaskDistributor.getTestType = original_getTestType
RunnerClass._prepareSlapOS = original_prepareSlapOS
RunnerClass.runTestSuite = original_runTestSuite
......@@ -1049,7 +1048,7 @@ shared = true
original_startTestSuite = TaskDistributor.startTestSuite
original_subscribeNode = TaskDistributor.subscribeNode
original_getTestType = TaskDistributor.getTestType
original_createTestResult = TaskDistributionTool.createTestResult
original_createTestResult = TaskDistributor.createTestResult
original_prepareSlapOS = RunnerClass._prepareSlapOS
original_runTestSuite = RunnerClass.runTestSuite
original_supply = SlapOSControler.supply
......@@ -1067,7 +1066,7 @@ shared = true
TaskDistributor.startTestSuite = patch_startTestSuite
TaskDistributor.subscribeNode = doNothing
TaskDistributor.getTestType = patch_getTestType
TaskDistributionTool.createTestResult = patch_createTestResult
TaskDistributor.createTestResult = patch_createTestResult
RunnerClass._prepareSlapOS = doNothing
RunnerClass.runTestSuite = patch_runTestSuite
SlapOSControler.supply = doNothing
......@@ -1085,9 +1084,9 @@ shared = true
TaskDistributor.generateConfiguration = original_generateConfiguration
TaskDistributor.isMasterTestnode = original_isMasterTestnode
TaskDistributor.startTestSuite = original_startTestSuite
TaskDistributionTool.createTestResult = original_createTestResult
TaskDistributionTool.subscribeNode = original_subscribeNode
TaskDistributionTool.getTestType = original_getTestType
TaskDistributor.createTestResult = original_createTestResult
TaskDistributor.subscribeNode = original_subscribeNode
TaskDistributor.getTestType = original_getTestType
RunnerClass._prepareSlapOS = original_prepareSlapOS
RunnerClass.runTestSuite = original_runTestSuite
SlapOSControler.supply = original_supply
......
......@@ -29,7 +29,7 @@ Client implementation for portal_task_distribution.
Example use:
import erp5.util.taskdistribution
tool = erp5.util.taskdistribution.TaskDistributionTool(...)
distributor = erp5.util.taskdistribution.TaskDistributor(...)
test_result = tool.createTestResult(...)
test_result.addWatch('foo', open('foo'))
while True:
......@@ -138,7 +138,7 @@ class TestResultLineProxy(RPCRetry):
Properties:
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,
test_name):
......@@ -468,9 +468,13 @@ class TaskDistributor(RPCRetry):
if logger is None:
logger = null_logger
if portal_url is None:
proxy = DummyTaskDistributionTool()
proxy = DummyTaskDistributor()
else:
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
Please register or sign in to reply
super(TaskDistributor, self).__init__(proxy, retry_time,logger)
protocol_revision = self._retryRPC('getProtocolRevision')
if protocol_revision != 1:
......@@ -538,8 +542,40 @@ class TaskDistributor(RPCRetry):
"""
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.
......
......@@ -316,13 +316,10 @@ shared = true
remote_test_result_needs_cleanup = False
begin = time.time()
portal_url = config['test_suite_master_url']
portal = taskdistribution.TaskDistributionTool(portal_url,
logger=DummyLogger(log))
self.portal = portal
self.test_suite_portal = taskdistribution.TaskDistributor(
self.taskdistribution = taskdistribution.TaskDistributor(
portal_url,
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'])
if type(node_configuration) == str:
# Backward compatiblity
......@@ -334,7 +331,7 @@ shared = true
log('Received and using process timeout from master: %i' % (
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'],
computer_guid=config['computer_id'])
if type(test_suite_data) == str:
......@@ -344,7 +341,7 @@ shared = true
log("Got following test suite data from master : %r",
test_suite_data)
try:
my_test_type = self.test_suite_portal.getTestType()
my_test_type = self.taskdistribution.getTestType()
except Exception:
log("testnode, error during requesting getTestType() method"
" from the distributor.")
......@@ -392,7 +389,8 @@ shared = true
self.constructProfile(node_test_suite, my_test_type,
runner.getRelativePathUsage())
# 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,
node_test_suite.test_suite_title,
node_test_suite.project_title)
......@@ -405,7 +403,7 @@ shared = true
# get cluster configuration for this test suite, this is needed to
# know slapos parameters to user for creating instances
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)
cluster_configuration = Utils.deunicodeData(json_data['configuration_list'][0])
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