Commit 923dc677 authored by Sebastien Robin's avatar Sebastien Robin

allow to test a particular branch

parent 56686a2b
from setuptools import setup, find_packages from setuptools import setup, find_packages
name = "erp5.recipe.testnode" name = "erp5.recipe.testnode"
version = '1.0' version = '1.0.5'
def read(name): def read(name):
return open(name).read() return open(name).read()
......
...@@ -47,11 +47,12 @@ class SlapOSControler(object): ...@@ -47,11 +47,12 @@ class SlapOSControler(object):
'reference': config['computer_id'], 'reference': config['computer_id'],
'software_root': config['software_root']})) 'software_root': config['software_root']}))
def runSoftwareRelease(self, config, process_group_pid_list=None): def runSoftwareRelease(self, config, environment, process_group_pid_list=None):
print "SlapOSControler.runSoftwareRelease" print "SlapOSControler.runSoftwareRelease"
while True: while True:
cpu_count = os.sysconf("SC_NPROCESSORS_ONLN") cpu_count = os.sysconf("SC_NPROCESSORS_ONLN")
os.putenv('MAKEFLAGS', '-j%s' % cpu_count) os.putenv('MAKEFLAGS', '-j%s' % cpu_count)
os.environ['PATH'] = environment['PATH']
slapgrid = subprocess.Popen([config['slapgrid_software_binary'], '-v', '-c', slapgrid = subprocess.Popen([config['slapgrid_software_binary'], '-v', '-c',
#'--buildout-parameter',"'-U -N' -o", #'--buildout-parameter',"'-U -N' -o",
config['slapos_config']], config['slapos_config']],
......
...@@ -85,6 +85,7 @@ class Recipe(BaseSlapRecipe): ...@@ -85,6 +85,7 @@ class Recipe(BaseSlapRecipe):
working_directory=CONFIG['working_directory'], working_directory=CONFIG['working_directory'],
vcs_repository=self.parameter_dict.get('vcs_repository'), vcs_repository=self.parameter_dict.get('vcs_repository'),
node_quantity=self.parameter_dict.get('node_quantity', '1'), node_quantity=self.parameter_dict.get('node_quantity', '1'),
branch=self.parameter_dict.get('branch', None),
test_suite_master_url=self.parameter_dict.get( test_suite_master_url=self.parameter_dict.get(
'test_suite_master_url', None), 'test_suite_master_url', None),
test_suite_name=self.parameter_dict.get('test_suite_name'), test_suite_name=self.parameter_dict.get('test_suite_name'),
...@@ -96,6 +97,7 @@ class Recipe(BaseSlapRecipe): ...@@ -96,6 +97,7 @@ class Recipe(BaseSlapRecipe):
# environment of running bot # environment of running bot
bot_environment=self.parameter_dict.get('bot_environment', ''), bot_environment=self.parameter_dict.get('bot_environment', ''),
partition_reference=CONFIG['partition_reference'], partition_reference=CONFIG['partition_reference'],
environment=dict(PATH=os.environ['PATH']),
) )
])) ]))
......
...@@ -59,6 +59,7 @@ slapos_controler = None ...@@ -59,6 +59,7 @@ slapos_controler = None
def run(args): def run(args):
config = args[0] config = args[0]
slapgrid = None slapgrid = None
branch = config.get('branch', None)
supervisord_pid_file = os.path.join(config['instance_root'], 'var', 'run', supervisord_pid_file = os.path.join(config['instance_root'], 'var', 'run',
'supervisord.pid') 'supervisord.pid')
subprocess.check_call([config['git_binary'], subprocess.check_call([config['git_binary'],
...@@ -74,27 +75,33 @@ def run(args): ...@@ -74,27 +75,33 @@ def run(args):
# Write our own software.cfg to use the local repository # Write our own software.cfg to use the local repository
custom_profile_path = os.path.join(config['working_directory'], 'software.cfg') custom_profile_path = os.path.join(config['working_directory'], 'software.cfg')
config['custom_profile_path'] = custom_profile_path config['custom_profile_path'] = custom_profile_path
if not os.path.exists(custom_profile_path):
# create a profile in order to use the repository we already have # create a profile in order to use the repository we already have
custom_profile = open(custom_profile_path, 'w') custom_profile = open(custom_profile_path, 'w')
profile_content = """ profile_content = """
[buildout] [buildout]
extends = %(software_config_path)s extends = %(software_config_path)s
[%(repository_name)s_repository] [%(repository_name)s]
repository = %(repository_path)s repository = %(repository_path)s
""" % {'software_config_path': os.path.join(repository_path, """ % {'software_config_path': os.path.join(repository_path,
config['profile_url']), config['profile_url']),
'repository_name': repository_name, 'repository_name': repository_name,
'repository_path' : repository_path} 'repository_path' : repository_path}
if branch is not None:
profile_content += "\nbranch = %s" % branch
custom_profile.write(profile_content) custom_profile.write(profile_content)
custom_profile.close() custom_profile.close()
try: try:
while True: while True:
# Make sure we have local repository # Make sure we have local repository
if not os.path.exists(repository_path): if not os.path.exists(repository_path):
subprocess.check_call([config['git_binary'], parameter_list = [config['git_binary'], 'clone',
'clone', config['vcs_repository'], repository_path]) config['vcs_repository']]
if branch is not None:
parameter_list.extend(['-b',branch])
parameter_list.append(repository_path)
subprocess.check_call(parameter_list)
# XXX this looks like to not wait the end of the command # XXX this looks like to not wait the end of the command
# Make sure we have local repository # Make sure we have local repository
updater = Updater(repository_path, git_binary=config['git_binary']) updater = Updater(repository_path, git_binary=config['git_binary'])
...@@ -105,7 +112,6 @@ repository = %(repository_path)s ...@@ -105,7 +112,6 @@ repository = %(repository_path)s
continue continue
previous_revision = revision previous_revision = revision
print config print config
portal_url = config['test_suite_master_url'] portal_url = config['test_suite_master_url']
test_result_path = None test_result_path = None
...@@ -137,6 +143,7 @@ repository = %(repository_path)s ...@@ -137,6 +143,7 @@ repository = %(repository_path)s
if run_software: if run_software:
# this should be always true later, but it is too slow for now # this should be always true later, but it is too slow for now
slapos_controler.runSoftwareRelease(config, slapos_controler.runSoftwareRelease(config,
environment=config['environment'],
process_group_pid_list=process_group_pid_list, process_group_pid_list=process_group_pid_list,
) )
run_software = False run_software = 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