Commit 645fb1e4 authored by Benjamin Blanc's avatar Benjamin Blanc

testnode: Use revision for scalability case

parent b663f40b
......@@ -209,15 +209,19 @@ class ERP5TestNode(TestCase):
def test_04_constructProfile(self, my_test_type='UnitTest'):
"""
Check if the software profile is correctly generated
"""
"""
test_node = self.getTestNode()
test_node.test_suite_portal = TaskDistributor
test_node.test_suite_portal.getTestNode = TaskDistributor.getTestType
node_test_suite = test_node.getNodeTestSuite('foo')
self.updateNodeTestSuiteData(node_test_suite, add_third_repository=True)
test_node.constructProfile(node_test_suite)
node_test_suite.revision = 'rep1=1234-azerty,rep2=3456-qwerty'
test_node.constructProfile(node_test_suite,my_test_type)
self.assertEquals("%s/software.cfg" % (node_test_suite.working_directory,),
node_test_suite.custom_profile_path)
profile = open(node_test_suite.custom_profile_path, 'r')
expected_profile = """
if my_test_type=='UnitTest':
expected_profile = """
[buildout]
extends = %(temp_dir)s/testnode/foo/rep0/software.cfg
......@@ -229,6 +233,21 @@ branch = master
repository = %(temp_dir)s/testnode/foo/rep2
branch = foo
""" % {'temp_dir': self._temp_dir}
else:
revision1 = "azerty"
revision2 = "qwerty"
expected_profile = """
[buildout]
extends = %(temp_dir)s/testnode/foo/rep0/software.cfg
[rep1]
revision = %(revision1)s
branch =
[rep2]
revision = %(revision2)s
branch =
""" % {'temp_dir': self._temp_dir, 'revision1': revision1, 'revision2': revision2}
self.assertEquals(expected_profile, profile.read())
profile.close()
......@@ -726,7 +745,7 @@ branch = foo
TaskDistributor.isMasterTestnode = original_isMasterTestnode
SlapOSControler.supply =original_supply
SlapOSControler.request = original_request
SlapOSControler._updateInstanceXML = original_updateInstanceXML
SlapOSControler.updateInstanceXML = original_updateInstanceXML
TaskDistributor.startTestSuite = original_startTestSuite
TaskDistributionTool.createTestResult = original_createTestResult
TaskDistributionTool.subscribeNode = original_subscribeNode
......@@ -921,7 +940,7 @@ branch = foo
original_runTestSuite = RunnerClass.runTestSuite
original_supply = SlapOSControler.supply
original_request = SlapOSControler.request
original_updateInstanceXML = SlapOSControler._updateInstanceXML
original_updateInstanceXML = SlapOSControler.updateInstanceXML
#
time.sleep = doNothing
......@@ -937,7 +956,7 @@ branch = foo
RunnerClass.runTestSuite = doNothing
SlapOSControler.supply = doNothing
SlapOSControler.request = doNothing
SlapOSControler._updateInstanceXML = doNothing
SlapOSControler.updateInstanceXML = doNothing
# Run
test_node = self.getTestNode()
test_node.run()
......@@ -954,5 +973,5 @@ branch = foo
RunnerClass.runTestSuite = original_runTestSuite
SlapOSControler.supply = original_supply
SlapOSControler.request = original_request
SlapOSControler._updateInstanceXML = original_updateInstanceXML
SlapOSControler.updateInstanceXML = original_updateInstanceXML
time.sleep =original_sleep
......@@ -113,7 +113,7 @@ class TestNode(object):
invocation_list = line[2:].split()
return invocation_list
def constructProfile(self, node_test_suite, use_relative_path=False):
def constructProfile(self, node_test_suite, test_type, use_relative_path=False):
config = self.config
profile_content = ''
assert len(node_test_suite.vcs_repository_list), "we must have at least one repository"
......@@ -153,7 +153,24 @@ extends = %(software_config_path)s
node_test_suite.reference)
repository_path = os.path.relpath(repository_path, from_path)
profile_content_list.append("""
if test_type=="ScalabilityTest":
# updater = Updater(repository_path, git_binary=self.config['git_binary'],
# branch = vcs_repository.get('branch','master'), log=self.log, process_manager=self.process_manager)
# updater.checkout()
# revision = updater.getRevision()[1]
all_revision = node_test_suite.revision
# from 'sec1=xx-azer,sec2=yy-qwer,..' to [[sec1,azer],[sec2,qwer],..]
revision_list = [ [x.split('=')[0],x.split('=')[1].split('-')[1]] for x in all_revision.split(',') ]
# from [[sec1,azer],[sec2,qwer],..] to {sec1:azer,sec2:qwer,..}
revision_dict = {branch:revision for branch,revision in revision_list}
profile_content_list.append("""
[%(buildout_section_id)s]
revision = %(revision)s
branch =
""" % {'buildout_section_id': buildout_section_id,
'revision' : revision_dict[buildout_section_id]})
else:
profile_content_list.append("""
[%(buildout_section_id)s]
repository = %(repository_path)s
branch = %(branch)s
......@@ -345,11 +362,11 @@ from the distributor.")
log_directory=self.config['log_directory'])
node_test_suite.edit(**test_suite)
run_software = True
# Write our own software.cfg to use the local repository
self.constructProfile(node_test_suite, runner.getRelativePathUsage())
# kill processes from previous loop if any
self.process_manager.killPreviousRun()
self.getAndUpdateFullRevisionList(node_test_suite)
# Write our own software.cfg to use the local repository
self.constructProfile(node_test_suite, my_test_type, runner.getRelativePathUsage())
# Make sure we have local repository
test_result = portal.createTestResult(node_test_suite.revision, [],
config['test_node_title'], False,
......
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