Commit 887aa655 authored by Łukasz Nowak's avatar Łukasz Nowak

Apply changes from slapos/erp5testnode branch.

Changes are done manually, as files were moved.

Original log:

02666ca3 Enclose runTestSuite in its workspace.
d029684f Use safeRpcCall always during calling master.
70d2e4bc Setup process group for test suite.
e94ff72d Always kill supervisord.
677895a5 Remove not filled kill lists.
b228b137 Make import list diff/patch friendly.
8ef8b9b6 Missing import.
37da9000 Always set partition's permission.
346ff3bb Cleanup test result when SubprocessError is raised.
5515a973 Reuse SubprocessError exception in more error cases.
e72a7c86 Remove no-op.
048d47d3 Remove debugging log.
dc8276c9 Increase verbosity.
2d47034b Get rid of empty lines between each commands.
bdd79ceb Use timestamped logger in Updater & SlapOSControler.
e0ec5401 Fix typo in log message.
d46f496c Output formated timestamp in front of each message.
2dfa0a97 Don't write to some dynamically-named, pwd-relative file.
de91c1ff Catch all RPC exceptions.
d413f619 Move log files to testrunner's log_directory.
4d357a41 Provide and use run_directory instead of computing it.
0cd300b9 Define profile_path on individual repository list entry.
1f5e7a3f save memory by stopping supervisor

Original commits are available in http://git.erp5.org/repos/slapos.git
repository.
parent b80072bc
...@@ -29,7 +29,12 @@ from xml_marshaller import xml_marshaller ...@@ -29,7 +29,12 @@ from xml_marshaller import xml_marshaller
class SlapOSControler(object): class SlapOSControler(object):
def __init__(self, config, process_group_pid_set=None): def log(self, message):
print message
def __init__(self, config, process_group_pid_set=None, log=None):
if log is not None:
self.log = log
self.config = config self.config = config
# By erasing everything, we make sure that we are able to "update" # By erasing everything, we make sure that we are able to "update"
# existing profiles. This is quite dirty way to do updates... # existing profiles. This is quite dirty way to do updates...
...@@ -74,13 +79,14 @@ class SlapOSControler(object): ...@@ -74,13 +79,14 @@ class SlapOSControler(object):
def runSoftwareRelease(self, config, environment, process_group_pid_set=None, def runSoftwareRelease(self, config, environment, process_group_pid_set=None,
stdout=None, stderr=None): stdout=None, stderr=None):
print "SlapOSControler.runSoftwareRelease" self.log("SlapOSControler.runSoftwareRelease")
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'] os.environ['PATH'] = environment['PATH']
slapgrid = subprocess.Popen([config['slapgrid_software_binary'], '-v', '-c', command = [config['slapgrid_software_binary'], '-v', '-c',
#'--buildout-parameter',"'-U -N' -o", #'--buildout-parameter',"'-U -N' -o",
config['slapos_config']], config['slapos_config']]
slapgrid = subprocess.Popen(command,
stdout=stdout, stderr=stderr, stdout=stdout, stderr=stderr,
close_fds=True, preexec_fn=os.setsid) close_fds=True, preexec_fn=os.setsid)
process_group_pid_set.add(slapgrid.pid) process_group_pid_set.add(slapgrid.pid)
...@@ -89,6 +95,7 @@ class SlapOSControler(object): ...@@ -89,6 +95,7 @@ class SlapOSControler(object):
stderr.seek(0) stderr.seek(0)
process_group_pid_set.remove(slapgrid.pid) process_group_pid_set.remove(slapgrid.pid)
status_dict = {'status_code':slapgrid.returncode, status_dict = {'status_code':slapgrid.returncode,
'command': repr(command),
'stdout':stdout.read(), 'stdout':stdout.read(),
'stderr':stderr.read()} 'stderr':stderr.read()}
stdout.close() stdout.close()
...@@ -98,13 +105,14 @@ class SlapOSControler(object): ...@@ -98,13 +105,14 @@ class SlapOSControler(object):
def runComputerPartition(self, config, environment, def runComputerPartition(self, config, environment,
process_group_pid_set=None, process_group_pid_set=None,
stdout=None, stderr=None): stdout=None, stderr=None):
print "SlapOSControler.runSoftwareRelease" self.log("SlapOSControler.runComputerPartition")
slap = slapos.slap.slap() slap = slapos.slap.slap()
slap.registerOpenOrder().request(self.software_profile, slap.registerOpenOrder().request(self.software_profile,
partition_reference='testing partition', partition_reference='testing partition',
partition_parameter_kw=config['instance_dict']) partition_parameter_kw=config['instance_dict'])
slapgrid = subprocess.Popen([config['slapgrid_partition_binary'], command = [config['slapgrid_partition_binary'],
config['slapos_config'], '-c', '-v'], config['slapos_config'], '-c', '-v']
slapgrid = subprocess.Popen(command,
stdout=stdout, stderr=stderr, stdout=stdout, stderr=stderr,
close_fds=True, preexec_fn=os.setsid) close_fds=True, preexec_fn=os.setsid)
process_group_pid_set.add(slapgrid.pid) process_group_pid_set.add(slapgrid.pid)
...@@ -113,6 +121,7 @@ class SlapOSControler(object): ...@@ -113,6 +121,7 @@ class SlapOSControler(object):
stderr.seek(0) stderr.seek(0)
process_group_pid_set.remove(slapgrid.pid) process_group_pid_set.remove(slapgrid.pid)
status_dict = {'status_code':slapgrid.returncode, status_dict = {'status_code':slapgrid.returncode,
'command': repr(command),
'stdout':stdout.read(), 'stdout':stdout.read(),
'stderr':stderr.read()} 'stderr':stderr.read()}
stdout.close() stdout.close()
......
############################################################################## import errno
# import os
# Copyright (c) 2011 Nexedi SA and Contributors. All Rights Reserved. import re
# import subprocess
# WARNING: This program as such is intended to be used by professional import sys
# programmers who take the whole responsibility of assessing all potential import threading
# consequences resulting from its eventual inadequacies and bugs
# End users who are looking for a ready-to-use solution with commercial
# guarantees and support are strongly advised to contract a Free Software
# Service Company
#
# This program is Free Software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 3
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
##############################################################################
import os, sys, subprocess, re, threading
from testnode import SubprocessError from testnode import SubprocessError
_format_command_search = re.compile("[[\\s $({?*\\`#~';<>&|]").search _format_command_search = re.compile("[[\\s $({?*\\`#~';<>&|]").search
...@@ -79,7 +59,13 @@ class Updater(object): ...@@ -79,7 +59,13 @@ class Updater(object):
realtime_output = True realtime_output = True
stdin = file(os.devnull) stdin = file(os.devnull)
def __init__(self, repository_path, revision=None, git_binary=None): def log(self, message):
print message
def __init__(self, repository_path, revision=None, git_binary=None,
log=None):
if log is not None:
self.log = log
self.revision = revision self.revision = revision
self._path_list = [] self._path_list = []
self.repository_path = repository_path self.repository_path = repository_path
...@@ -120,7 +106,7 @@ class Updater(object): ...@@ -120,7 +106,7 @@ class Updater(object):
quiet = kw.pop('quiet', False) quiet = kw.pop('quiet', False)
env = kw and dict(os.environ, **kw) or None env = kw and dict(os.environ, **kw) or None
command = format_command(*args, **kw) command = format_command(*args, **kw)
print '\n$ ' + command self.log('$ ' + command)
sys.stdout.flush() sys.stdout.flush()
p = subprocess.Popen(args, stdin=self.stdin, stdout=subprocess.PIPE, p = subprocess.Popen(args, stdin=self.stdin, stdout=subprocess.PIPE,
stderr=subprocess.PIPE, env=env, stderr=subprocess.PIPE, env=env,
......
...@@ -53,7 +53,12 @@ def main(*args): ...@@ -53,7 +53,12 @@ def main(*args):
return config.get('testnode', o) return config.get('testnode', o)
CONFIG['slapos_directory'] = geto('slapos_directory') CONFIG['slapos_directory'] = geto('slapos_directory')
CONFIG['working_directory'] = geto('working_directory') CONFIG['working_directory'] = geto('working_directory')
for d in CONFIG['slapos_directory'], CONFIG['working_directory']: CONFIG['test_suite_directory'] = geto('test_suite_directory')
CONFIG['log_directory'] = geto('log_directory')
CONFIG['run_directory'] = geto('run_directory')
for d in CONFIG['slapos_directory'], CONFIG['working_directory'], \
CONFIG['test_suite_directory'], CONFIG['log_directory'], \
CONFIG['run_directory']:
if not os.path.isdir(d): if not os.path.isdir(d):
raise ValueError('Directory %r does not exists.' % d) raise ValueError('Directory %r does not exists.' % d)
CONFIG['software_root'] = os.path.join(CONFIG['slapos_directory'], CONFIG['software_root'] = os.path.join(CONFIG['slapos_directory'],
...@@ -87,7 +92,6 @@ def main(*args): ...@@ -87,7 +92,6 @@ def main(*args):
vcs_repository_list.append(dict(config.items(section))) vcs_repository_list.append(dict(config.items(section)))
CONFIG['vcs_repository_list'] = vcs_repository_list CONFIG['vcs_repository_list'] = vcs_repository_list
CONFIG['profile_path'] = geto('profile_path')
CONFIG['test_suite_title'] = geto('test_suite_title') CONFIG['test_suite_title'] = geto('test_suite_title')
CONFIG['test_node_title'] = geto('test_node_title') CONFIG['test_node_title'] = geto('test_node_title')
CONFIG['test_suite'] = geto('test_suite') CONFIG['test_suite'] = geto('test_suite')
......
This diff is collapsed.
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