[Erp5-report] r40813 lucas - in /erp5/trunk/utils/erp5.appliance.test: CHANGES.txt src/test.py
nobody at svn.erp5.org
nobody at svn.erp5.org
Fri Nov 26 21:27:55 CET 2010
Author: lucas
Date: Fri Nov 26 21:27:55 2010
New Revision: 40813
URL: http://svn.erp5.org?rev=40813&view=rev
Log:
The steps to run the buildout to install Zope2.8 must be the same of Zope2.12.
Modified:
erp5/trunk/utils/erp5.appliance.test/CHANGES.txt
erp5/trunk/utils/erp5.appliance.test/src/test.py
Modified: erp5/trunk/utils/erp5.appliance.test/CHANGES.txt
URL: http://svn.erp5.org/erp5/trunk/utils/erp5.appliance.test/CHANGES.txt?rev=40813&r1=40812&r2=40813&view=diff
==============================================================================
--- erp5/trunk/utils/erp5.appliance.test/CHANGES.txt [utf8] (original)
+++ erp5/trunk/utils/erp5.appliance.test/CHANGES.txt [utf8] Fri Nov 26 21:27:55 2010
@@ -1,6 +1,10 @@
-1.10 (unreleased)
+1.10 (2010-11-26)
-----------------
+ - The steps to run the buildout to install Zope2.8 must be the same
+ of Zope2.12.
+ [Lucas Carvalho]
+
1.9 (2010-11-25)
----------------
Modified: erp5/trunk/utils/erp5.appliance.test/src/test.py
URL: http://svn.erp5.org/erp5/trunk/utils/erp5.appliance.test/src/test.py?rev=40813&r1=40812&r2=40813&view=diff
==============================================================================
--- erp5/trunk/utils/erp5.appliance.test/src/test.py [utf8] (original)
+++ erp5/trunk/utils/erp5.appliance.test/src/test.py [utf8] Fri Nov 26 21:27:55 2010
@@ -34,8 +34,6 @@ import subprocess
import time
import signal
import logging
-from logging import StreamHandler, FileHandler
-from optparse import OptionParser, Option
import ConfigParser
import pexpect
import urlparse
@@ -47,17 +45,24 @@ import mimetools
import mimetypes
import stat
import zipfile
+from logging import StreamHandler, FileHandler
+from optparse import OptionParser, Option
+
CONFIG_SECTION = "appliancetest"
TB_SEP = "============================================================="\
"========="
+
+
def get_content_type(f):
return mimetypes.guess_type(f.name)[0] or 'application/octet-stream'
+
class DummyConn:
pass
+
class ConnectionHelper:
def _simulateConn(self):
# older python, time to simulate
@@ -101,39 +106,38 @@ class ConnectionHelper:
def POST(self, path, parameter_dict, file_list=None):
self._connect()
- parameter_dict.update(
- __ac_name = self.conn.username,
- __ac_password = self.conn.password
- )
+ parameter_dict.update(__ac_name=self.conn.username,
+ __ac_password=self.conn.password)
header_dict = {'Content-type': "application/x-www-form-urlencoded"}
if file_list is None:
body = urllib.urlencode(parameter_dict)
else:
boundary = mimetools.choose_boundary()
- header_dict['Content-type'] = 'multipart/form-data; boundary=%s' %(
+ header_dict['Content-type'] = 'multipart/form-data; boundary=%s' % (
boundary,)
body = ''
- for k,v in parameter_dict.iteritems():
+ for k, v in parameter_dict.iteritems():
body += '--%s\r\n' % boundary
body += 'Content-Disposition: form-data; name="%s"\r\n' % k
body += '\r\n'
body += '%s\r\n' % v
for name, filename in file_list:
- f = open(filename,'r')
+ f = open(filename, 'r')
body += '--%s\r\n' % boundary
- body += 'Content-Disposition: form-data; name="%s"; filename="%s"\r\n'%(
- name, name)
+ body += 'Content-Disposition: form-data; name="%s"; filename="%s"\r\n'\
+ % (name, name)
body += 'Content-Type: %s\r\n' % get_content_type(f)
body += 'Content-Length: %d\r\n' % os.fstat(f.fileno())[stat.ST_SIZE]
body += '\r\n'
body += f.read()
f.close()
- body +='\r\n'
+ body += '\r\n'
self.connection.request("POST", self.conn.path + '/' + path,
body, header_dict)
self.response = self.connection.getresponse()
+
def getMachineIdString(config):
"""Returns machine identification string"""
kw = dict(stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
@@ -174,6 +178,7 @@ def getMachineIdString(config):
return idstr
+
def getDistributionList():
"""Returns list of all detected distribution flavours"""
detected_list = []
@@ -196,7 +201,9 @@ def getDistributionList():
return detected_list
+
class ERP5TestReportHandler(FileHandler):
+
def __init__(self, url, machine_id, suite_name):
# random test id
self.test_id = uuid.uuid4()
@@ -227,7 +234,7 @@ class ERP5TestReportHandler(FileHandler)
tl = open(templog, 'w')
tl.write(TB_SEP + '\n')
tl.write('%s\n' % self.machine_id)
- tl.write(distribution_info+'\n\n')
+ tl.write(distribution_info + '\n\n')
if len(log_lines) > 900:
tl.write('...[truncated]... \n\n')
for log_line in log_lines[-900:]:
@@ -235,7 +242,7 @@ class ERP5TestReportHandler(FileHandler)
if starts('Ran') or starts('FAILED') or starts('OK') or starts(TB_SEP):
continue
if starts('ERROR: ') or starts('FAIL: '):
- tl.write('internal-test: '+log_line)
+ tl.write('internal-test: ' + log_line)
continue
tl.write(log_line)
@@ -270,16 +277,19 @@ Revision: %s""" % (distribution_info, se
)
os.unlink(tempzip)
+
class SubFailed(Exception):
pass
+
class TimeoutException(Exception):
pass
+
instance_buildout_first_run = """[buildout]
extends-cache = instance-profiles/extends-cache
extends =
- profiles/development-2.12.cfg
+ profiles/%s
instance-profiles/software-home.inc
parts =
@@ -287,9 +297,11 @@ parts =
oood-instance
supervisor-instance"""
+
instance_buildout_complete = instance_buildout_first_run + """
runUnitTest"""
+
def detectRevision(config, path):
revision_command = ['svn', 'info', '--non-interactive',
'--trust-server-cert', path]
@@ -308,6 +320,7 @@ def detectRevision(config, path):
strumpf, revision = line.split(':')
return int(revision.strip(' '))
+
def callWithTimeout(command_list, config, timeout=60, cwd=None,
input_list=None):
@@ -341,8 +354,8 @@ def callWithTimeout(command_list, config
command.close()
returncode = command.exitstatus
except TimeoutException:
- config.logger.error(
- 'Command %r run exceeded timeout %s, killed\n' % (command_list, timeout))
+ config.logger.error('Command %r run exceeded timeout %s, killed\n' % \
+ (command_list, timeout))
returncode = 1
command.close()
finally:
@@ -354,83 +367,14 @@ def callWithTimeout(command_list, config
raise SubFailed
return returncode
-def run_once28(config, software_path, instance_path,
- previous_software_revision=-1):
- status = False
- begin = time.time()
- # Checkout/update public buildout repository
- if os.path.isdir(software_path):
- checkout_command = [
- 'svn', 'up', '--non-interactive', '--trust-server-cert',
- software_path]
- else:
- checkout_command = [
- 'svn', 'co', '--non-interactive', '--trust-server-cert',
- 'https://svn.erp5.org/repos/public/erp5/trunk/buildout/',
- software_path]
- callWithTimeout(checkout_command, config)
-
- # Do not continue if unneeded
- revision = detectRevision(config, software_path)
- if revision == previous_software_revision:
- return
- # Configure ERP5 test reporting handler
- erp5_handler = None
- if config.erp5_log is not None:
- config.logger.debug('Configuring external logging system.')
- erp5_handler = ERP5TestReportHandler(config.erp5_log,
- getMachineIdString(config), "ERP5Appliance28")
- config.logger.addHandler(erp5_handler)
- erp5_handler.revision = revision
- exc_info = None
- try:
- try:
- # Bootstrap buildout
- bootstrap_command = [config.python, '-S', 'bootstrap/bootstrap.py',
- '-v', '1.4.4']
- callWithTimeout(bootstrap_command, config, timeout=600, cwd=software_path)
-
- # Install software
- buildout_command = [config.python, '-S', '%s/bin/buildout' % software_path]
- if config.verbose is True:
- buildout_command.append('-v')
- callWithTimeout(buildout_command, config, timeout=14400, cwd=software_path)
-
- # Assert software
- assert_command = [os.path.join(software_path, 'bin', 'python2.4'),
- os.path.join('tests', 'assertSoftware.py')]
- callWithTimeout(assert_command, config, timeout=3600, cwd=software_path)
- # Create instance place
- if not os.path.exists(instance_path):
- mkdir = ['mkdir', instance_path]
- callWithTimeout(mkdir, config)
- raise NotImplementedError
- except SubFailed:
- pass
- except:
- exc_info = sys.exc_info()
- raise
- else:
- status = True
- finally:
- if exc_info is not None:
- config.logger.warning('Test stopped with exception:\n', exc_info=exc_info)
- ran_trick_list = ["------------------------------------------------------"
- "----------------"]
- a = ran_trick_list.append
- a('Ran 1 test in %.2fs' % (time.time() - begin,))
- if status:
- a('OK')
- else:
- a('FAILED (failures=1)')
- if erp5_handler is not None:
- erp5_handler.ran_trick = '\n'.join(ran_trick_list)
- erp5_handler.close()
- config.logger.removeHandler(erp5_handler)
+def run_once(config, software_path,
+ instance_path,
+ buildout_file_name,
+ development_file_name,
+ binary_bootstrap_file_name,
+ previous_software_revision=-1):
-def run_once212(config, software_path, instance_path,
- previous_software_revision=-1):
status = False
begin = time.time()
# Checkout/update public buildout repository
@@ -462,25 +406,28 @@ def run_once212(config, software_path, i
try:
# Download bootstrap file
download_command = ['curl', '-o', 'bootstrap.py',
- 'http://svn.zope.org/*checkout*/zc.buildout/trunk/bootstrap/bootstrap.py']
+ 'http://svn.zope.org/*checkout*/zc.buildout/trunk/bootstrap/bootstrap.py']
callWithTimeout(download_command, config, cwd=software_path)
# Bootstrap buildout
bootstrap_command = [config.python, '-S', 'bootstrap.py',
- '-c', 'buildout-2.12.cfg']
+ '-c', buildout_file_name]
callWithTimeout(bootstrap_command, config, timeout=600, cwd=software_path)
# Install software
buildout_command = ['%s/bin/buildout' % software_path]
if config.verbose is True:
buildout_command.append('-v')
- buildout_command.extend(['-c', 'buildout-2.12.cfg'])
+ buildout_command.extend(['-c', buildout_file_name])
callWithTimeout(buildout_command, config, timeout=14400, cwd=software_path)
# Assert software
assert_command = [config.python, 'tests/assertSoftware.py']
callWithTimeout(assert_command, config, timeout=1800, cwd=software_path)
+ ##############################################
+ # Start to build the instance
+ ##############################################
# Create instance place
if not os.path.exists(instance_path):
mkdir = ['mkdir', instance_path]
@@ -497,11 +444,13 @@ def run_once212(config, software_path, i
config, cwd=instance_path)
# Create buildout profile
+
file(os.path.join(instance_path, 'buildout.cfg'), 'w').write(
- instance_buildout_first_run)
+ instance_buildout_first_run % development_file_name)
# Bootstrap instance
- instance_bootstrap = [os.path.join(software_path, 'bin', 'bootstrap2.6')]
+ instance_bootstrap = [os.path.join(software_path, 'bin',
+ binary_bootstrap_file_name)]
callWithTimeout(instance_bootstrap, config, cwd=instance_path)
# Run buildout for first time
@@ -597,7 +546,11 @@ def run_once212(config, software_path, i
erp5_handler.close()
config.logger.removeHandler(erp5_handler)
-def run(config, method):
+
+def run(config, method,
+ buildout_file_name,
+ development_file_name,
+ binary_bootstrap_file_name):
software_path = os.path.abspath(os.path.join(config.run_directory_path,
'software_checkout'))
instance_path = os.path.abspath(os.path.join(config.run_directory_path,
@@ -631,7 +584,8 @@ def run(config, method):
while 1:
# Run buildout once
- method(config, software_path, instance_path)
+ method(config, software_path, instance_path, buildout_file_name,
+ development_file_name, binary_bootstrap_file_name)
# Clean directory
if not config.update:
for path in software_path, instance_path:
@@ -719,27 +673,31 @@ class Config:
self.logger = logging.getLogger("erp5app212test")
-def main212():
- """Test ERP5 Appliance for 2.12 with full checkout."""
+def parserConfig():
+ # Parse arguments
usage = "usage: %s [options] RUN_DIRECTORY" % sys.argv[0]
+ config = Config()
+ config.setConfig(*Parser(usage=usage).check_args())
+ if config.config is not None:
+ if not os.path.exists(config.config):
+ raise ValueError("Configuration file %r cannot be found." %
+ config.config)
+ else:
+ file_config = ConfigParser.SafeConfigParser()
+ file_config.read(config.config)
+ file_config = dict(file_config.items(CONFIG_SECTION))
+ for k, v in file_config.iteritems():
+ if getattr(config, k) is None:
+ setattr(config, k, v)
+ return config
- try:
- # Parse arguments
- config = Config()
- config.setConfig(*Parser(usage=usage).check_args())
- if config.config is not None:
- if not os.path.exists(config.config):
- raise ValueError("Configuration file %r cannot be found." %
- config.config)
- else:
- file_config = ConfigParser.SafeConfigParser()
- file_config.read(config.config)
- file_config = dict(file_config.items(CONFIG_SECTION))
- for k,v in file_config.iteritems():
- if getattr(config, k) is None:
- setattr(config, k, v)
- run(config, run_once212)
+def main212():
+ """Test ERP5 Appliance for 2.12 with full checkout."""
+ try:
+ config = parserConfig()
+ run(config, run_once, 'buildout-2.12.cfg', 'development-2.12.cfg',
+ 'bootstrap2.6')
return_code = 0
except SystemExit, err:
# Catch exception raise by optparse
@@ -747,31 +705,17 @@ def main212():
sys.exit(return_code)
+
def mainex212():
"""Test ERP5 Appliance for 2.12 with buildout extends."""
raise NotImplementedError
+
def main28():
"""Test ERP5 Appliance for 2.8 with full checkout."""
- usage = "usage: %s [options] RUN_DIRECTORY" % sys.argv[0]
-
try:
- # Parse arguments
- config = Config()
- config.setConfig(*Parser(usage=usage).check_args())
- if config.config is not None:
- if not os.path.exists(config.config):
- raise ValueError("Configuration file %r cannot be found." %
- config.config)
- else:
- file_config = ConfigParser.SafeConfigParser()
- file_config.read(config.config)
- file_config = dict(file_config.items(CONFIG_SECTION))
- for k,v in file_config.iteritems():
- if getattr(config, k) is None:
- setattr(config, k, v)
-
- run(config, run_once28)
+ config = parserConfig()
+ run(config, run_once, 'buildout.cfg', 'development.cfg', 'bootstrap2.4')
return_code = 0
except SystemExit, err:
# Catch exception raise by optparse
@@ -779,6 +723,7 @@ def main28():
sys.exit(return_code)
+
def mainex28():
"""Test ERP5 Appliance for 2.8 with buildout extends."""
raise NotImplementedError
More information about the Erp5-report
mailing list