Commit de94565b authored by Gabriel Monnerat's avatar Gabriel Monnerat

remove template and clean up the profile. This template was moved to cloudooo tests

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@40343 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 96ec5194
[buildout] [buildout]
extends = extends =
../profiles/software-definition.cfg ../profiles/software-definition.cfg
../profiles/links.cfg
parts = parts =
cloudooo-instance-template cloudooo-instance-template
......
[buildout] [buildout]
extends = ../instance-profiles/cloudooo.cfg extends = ../instance-profiles/cloudooo.cfg
parts +=
runUnitTest
chmod
[runUnitTest]
recipe = z3c.recipe.template
input = ${buildout:directory}/templates/runCloudOOoUnitTest.py.in
output = ${buildout:bin-directory}/runCloudOOoUnitTest.py
tests-directory = ${software_definition:software_home}/src/cloudooo/cloudooo/tests
cloudoooctl-path = ${cloudooo-instance-template:ctl-output}
conf-path = ${cloudooo-instance-template:conf-output}
timeout-limit = 60
[chmod]
recipe = plone.recipe.command
command =
chmod a+x ${buildout:bin-directory}/runCloudOOoUnitTest.py
update = {:command}
#!${buildout:executable}
import sys
import unittest
import psutil
from psutil.error import AccessDenied
from getopt import getopt, GetoptError
from time import sleep
from cloudooo.utils import socketStatus, waitStopDaemon
from ConfigParser import ConfigParser
from os import chdir
from os.path import join, exists
from os import remove
from getpass import getuser
from subprocess import Popen
log_path = '${buildout:directory}/log/cloudooo.log'
environment_path = '${tests-directory}'
cloudooo_runner = '${cloudoooctl-path}'
server_cloudooo_conf = '${conf-path}'
timeout_limit = ${timeout-limit}
sys.path.append(environment_path)
chdir(environment_path)
from cloudoooTestCase import loadConfig, startFakeEnvironment, stopFakeEnvironment
def wait_liberate_port(hostname, port):
for n in range(timeout_limit):
if not socketStatus(hostname, port):
break
sleep(1)
def wait_use_port(hostname, port):
for n in range(timeout_limit):
if socketStatus(hostname, port):
return
sleep(1)
def get_partial_log():
if exists(log_path):
return '\n'.join(open(log_path).read().split('\n')[-30:])
return ''
def exit(msg):
sys.stderr.write(msg)
sys.exit(0)
def run_test(test_name):
module = __import__(test_name)
if not hasattr(module, "test_suite"):
exit("No test suite to run, exiting immediately")
TestRunner = unittest.TextTestRunner
suite = unittest.TestSuite()
suite.addTest(module.test_suite())
TestRunner(verbosity=2).run(suite)
DAEMON = OPENOFFICE = XVFB = False
config = ConfigParser()
config.read(server_cloudooo_conf)
openoffice_port = int(config.get("app:main", "openoffice_port"))
xvfb_port = int(config.get("app:main", "virtual_display_port"))
xvfb_display_id = int(config.get("app:main", "virtual_display_id"))
hostname = config.get("app:main", "application_hostname")
server_port = int(config.get("server:main", "port"))
run_dir = config.get('app:main', 'working_path')
try:
opt_list, arg_list = getopt(sys.argv[1:-1], "", ["with-daemon",
"with-openoffice",
"with-xvfb"])
except GetoptError, msg:
exit(msg.msg)
for opt, arg in opt_list:
if opt == "--with-daemon":
DAEMON = True
elif opt == "--with-openoffice":
OPENOFFICE = True
elif opt == "--with-xvfb":
XVFB = True
test_name = sys.argv[-1]
if not exists(join(environment_path, '%s.py' % test_name)):
exit("%s not exists\n" % test_name)
if DAEMON:
loadConfig(server_cloudooo_conf)
Popen([cloudooo_runner, 'start']).communicate()
wait_use_port(hostname, server_port)
print get_partial_log()
try:
run_test(test_name)
finally:
Popen([cloudooo_runner, 'stop']).communicate()
wait_liberate_port(hostname, server_port)
elif OPENOFFICE:
openoffice, xvfb = startFakeEnvironment(conf_path=server_cloudooo_conf)
run_test(test_name)
stopFakeEnvironment()
elif XVFB:
xvfb = startFakeEnvironment(start_openoffice=False,
conf_path=server_cloudooo_conf)
run_test(test_name)
stopFakeEnvironment(stop_openoffice=False)
else:
loadConfig(server_cloudooo_conf)
run_test(test_name)
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