Commit c7989a40 authored by Kazuhiko Shiozaki's avatar Kazuhiko Shiozaki

Merge remote-tracking branch 'origin/master'

parents 56358d3f f35be15d
......@@ -105,13 +105,20 @@ class ERP5TestNode(TestCase):
for i, repository_path in enumerate(repository_list):
call = self.getCaller(cwd=repository_path)
call("git init".split())
git_config = open(os.path.join(repository_path, '.git', 'config'), 'a')
git_config.write("""
[user]
name = a b
email = a@b.c
""")
git_config.close()
call("touch first_file".split())
call("git add first_file".split())
call("git commit -v -m first_commit".split() + ['--author="a b <a@b.c>"'])
call("git commit -v -m first_commit".split())
my_file = open(os.path.join(repository_path, 'first_file'), 'w')
my_file.write("initial_content%i" % i)
my_file.close()
call("git commit -av -m next_commit".split() + ['--author="a b <a@b.c>"'])
call("git commit -av -m next_commit".split())
output = call(['git', 'log', '--format=%H %s'])
output_line_list = output.split("\n")
self.assertEquals(3, len(output_line_list))
......@@ -211,7 +218,7 @@ branch = foo
my_file.write("next_content")
my_file.close()
call = self.getCaller(cwd=self.remote_repository1)
call("git commit -av -m new_commit".split() + ['--author="a b <a@b.c>"'])
call("git commit -av -m new_commit".split())
rev_list = test_node.getAndUpdateFullRevisionList(node_test_suite)
self.assertTrue(rev_list[0].startswith('rep0=2-'))
self.assertTrue(rev_list[1].startswith('rep1=3-'))
......@@ -310,7 +317,7 @@ branch = foo
return []
test_node = self.getTestNode()
test_node.slapos_controler = SlapOSControler(self.working_directory,
test_node.config)
test_node.config, self.log)
node_test_suite = test_node.getNodeTestSuite('foo')
self.updateNodeTestSuiteData(node_test_suite)
node_test_suite.revision = 'dummy'
......@@ -457,3 +464,16 @@ branch = foo
process_manager = ProcessManager(log=self.log, max_timeout=1)
_checkCorrectStatus(0, *['sleep','0'])
_checkCorrectStatus(-15, *['sleep','2'])
def test_13_SlaposControlerResetSoftware(self):
test_node = self.getTestNode()
controler = SlapOSControler(self.working_directory,
test_node.config, self.log)
os.mkdir(controler.software_root)
file_name = 'AC_Ra\xc3\xadzertic\xc3\xa1ma'
non_ascii_file = open(os.path.join(controler.software_root, file_name), 'w')
non_ascii_file.close()
self.assertEquals([file_name], os.listdir(controler.software_root))
controler.software_root = unicode(controler.software_root)
controler._resetSoftware()
self.assertEquals([], os.listdir(controler.software_root))
......@@ -42,14 +42,24 @@ def createFolder(folder):
class SlapOSControler(object):
def __init__(self, working_directory, config):
def __init__(self, working_directory, config, log):
self.config = config
self.software_root = os.path.join(working_directory, 'soft')
self.instance_root = os.path.join(working_directory, 'inst')
self.slapos_config = os.path.join(working_directory, 'slapos.cfg')
self.proxy_database = os.path.join(working_directory, 'proxy.db')
self.log = log
def _resetSoftware(self):
self.log('SlapOSControler : GOING TO RESET ALL SOFTWARE : %r' %
(self.software_root,))
if os.path.exists(self.software_root):
shutil.rmtree(self.software_root)
os.mkdir(self.software_root)
os.chmod(self.software_root, 0750)
def initializeSlapOSControler(self, log, slapproxy_log=None, process_manager=None,
def initializeSlapOSControler(self, slapproxy_log=None, process_manager=None,
reset_software=False, software_path_list=None):
self.log = log
self.process_manager = process_manager
......@@ -91,11 +101,7 @@ class SlapOSControler(object):
computer = slap.registerComputer(config['computer_id'])
# Reset all previously generated software if needed
if reset_software:
log('SlapOSControler : GOING TO RESET ALL SOFTWARE : %r' % (self.software_root,))
if os.path.exists(self.software_root):
shutil.rmtree(self.software_root)
os.mkdir(self.software_root)
os.chmod(self.software_root, 0750)
self._resetSoftware()
instance_root = self.instance_root
if os.path.exists(instance_root):
# delete old paritions which may exists in order to not get its data
......
......@@ -81,6 +81,9 @@ def main(*args):
for key in ('slapos_directory', 'working_directory', 'test_suite_directory',
'log_directory', 'run_directory'):
d = CONFIG[key]
if isinstance(d, unicode):
d = d.encode('utf8')
CONFIG[key] = d
if not os.path.isdir(d):
raise ValueError('Directory %r does not exists.' % d)
CONFIG['master_url'] = 'http://%s:%s' % (CONFIG['proxy_host'],
......
......@@ -230,8 +230,8 @@ branch = %(branch)s
self.log('testnode, retry_software_count : %r' % \
slapos_instance.retry_software_count)
self.slapos_controler = SlapOSControler.SlapOSControler(
working_directory, self.config)
self.slapos_controler.initializeSlapOSControler(log=self.log, slapproxy_log=slapproxy_log,
working_directory, self.config, self.log)
self.slapos_controler.initializeSlapOSControler(slapproxy_log=slapproxy_log,
process_manager=self.process_manager, reset_software=reset_software,
software_path_list=software_path_list)
self.process_manager.supervisord_pid_file = os.path.join(\
......
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