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:

02666ca Enclose runTestSuite in its workspace.
d029684 Use safeRpcCall always during calling master.
70d2e4b Setup process group for test suite.
e94ff72 Always kill supervisord.
677895a Remove not filled kill lists.
b228b13 Make import list diff/patch friendly.
8ef8b9b Missing import.
37da900 Always set partition's permission.
346ff3b Cleanup test result when SubprocessError is raised.
5515a97 Reuse SubprocessError exception in more error cases.
e72a7c8 Remove no-op.
048d47d Remove debugging log.
dc8276c Increase verbosity.
2d47034 Get rid of empty lines between each commands.
bdd79ce Use timestamped logger in Updater & SlapOSControler.
e0ec540 Fix typo in log message.
d46f496 Output formated timestamp in front of each message.
2dfa0a9 Don't write to some dynamically-named, pwd-relative file.
de91c1f Catch all RPC exceptions.
d413f61 Move log files to testrunner's log_directory.
4d357a4 Provide and use run_directory instead of computing it.
0cd300b Define profile_path on individual repository list entry.
1f5e7a3 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
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
# By erasing everything, we make sure that we are able to "update"
# existing profiles. This is quite dirty way to do updates...
......@@ -54,7 +59,7 @@ class SlapOSControler(object):
partition_path = os.path.join(config['instance_root'], partition_reference)
if not os.path.exists(partition_path):
os.mkdir(partition_path)
os.chmod(partition_path, 0750)
os.chmod(partition_path, 0750)
computer.updateConfiguration(xml_marshaller.dumps({
'address': config['ipv4_address'],
'instance_root': config['instance_root'],
......@@ -74,13 +79,14 @@ class SlapOSControler(object):
def runSoftwareRelease(self, config, environment, process_group_pid_set=None,
stdout=None, stderr=None):
print "SlapOSControler.runSoftwareRelease"
self.log("SlapOSControler.runSoftwareRelease")
cpu_count = os.sysconf("SC_NPROCESSORS_ONLN")
os.putenv('MAKEFLAGS', '-j%s' % cpu_count)
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",
config['slapos_config']],
config['slapos_config']]
slapgrid = subprocess.Popen(command,
stdout=stdout, stderr=stderr,
close_fds=True, preexec_fn=os.setsid)
process_group_pid_set.add(slapgrid.pid)
......@@ -89,6 +95,7 @@ class SlapOSControler(object):
stderr.seek(0)
process_group_pid_set.remove(slapgrid.pid)
status_dict = {'status_code':slapgrid.returncode,
'command': repr(command),
'stdout':stdout.read(),
'stderr':stderr.read()}
stdout.close()
......@@ -98,13 +105,14 @@ class SlapOSControler(object):
def runComputerPartition(self, config, environment,
process_group_pid_set=None,
stdout=None, stderr=None):
print "SlapOSControler.runSoftwareRelease"
self.log("SlapOSControler.runComputerPartition")
slap = slapos.slap.slap()
slap.registerOpenOrder().request(self.software_profile,
partition_reference='testing partition',
partition_parameter_kw=config['instance_dict'])
slapgrid = subprocess.Popen([config['slapgrid_partition_binary'],
config['slapos_config'], '-c', '-v'],
command = [config['slapgrid_partition_binary'],
config['slapos_config'], '-c', '-v']
slapgrid = subprocess.Popen(command,
stdout=stdout, stderr=stderr,
close_fds=True, preexec_fn=os.setsid)
process_group_pid_set.add(slapgrid.pid)
......@@ -113,6 +121,7 @@ class SlapOSControler(object):
stderr.seek(0)
process_group_pid_set.remove(slapgrid.pid)
status_dict = {'status_code':slapgrid.returncode,
'command': repr(command),
'stdout':stdout.read(),
'stderr':stderr.read()}
stdout.close()
......
##############################################################################
#
# Copyright (c) 2011 Nexedi SA and Contributors. All Rights Reserved.
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsibility of assessing all potential
# 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
import errno
import os
import re
import subprocess
import sys
import threading
from testnode import SubprocessError
_format_command_search = re.compile("[[\\s $({?*\\`#~';<>&|]").search
......@@ -79,7 +59,13 @@ class Updater(object):
realtime_output = True
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._path_list = []
self.repository_path = repository_path
......@@ -120,7 +106,7 @@ class Updater(object):
quiet = kw.pop('quiet', False)
env = kw and dict(os.environ, **kw) or None
command = format_command(*args, **kw)
print '\n$ ' + command
self.log('$ ' + command)
sys.stdout.flush()
p = subprocess.Popen(args, stdin=self.stdin, stdout=subprocess.PIPE,
stderr=subprocess.PIPE, env=env,
......
......@@ -53,7 +53,12 @@ def main(*args):
return config.get('testnode', o)
CONFIG['slapos_directory'] = geto('slapos_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):
raise ValueError('Directory %r does not exists.' % d)
CONFIG['software_root'] = os.path.join(CONFIG['slapos_directory'],
......@@ -87,7 +92,6 @@ def main(*args):
vcs_repository_list.append(dict(config.items(section)))
CONFIG['vcs_repository_list'] = vcs_repository_list
CONFIG['profile_path'] = geto('profile_path')
CONFIG['test_suite_title'] = geto('test_suite_title')
CONFIG['test_node_title'] = geto('test_node_title')
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