diff --git a/buildout/instance-profiles/cloudooo.cfg b/buildout/instance-profiles/cloudooo.cfg index b70b2c1575fb2e6bc9d3abf67219a29ad36bf679..f53e3a6a41e37589ddbd3054efea4f3e244ff8ab 100644 --- a/buildout/instance-profiles/cloudooo.cfg +++ b/buildout/instance-profiles/cloudooo.cfg @@ -1,7 +1,6 @@ [buildout] extends = ../profiles/software-definition.cfg - ../profiles/links.cfg parts = cloudooo-instance-template diff --git a/buildout/profiles/test-cloudooo.cfg b/buildout/profiles/test-cloudooo.cfg index 7521d9d1842066a874e7d6b0f12d088b1409b950..85f92868da957b74005c53e4cc5a241b4538c33b 100644 --- a/buildout/profiles/test-cloudooo.cfg +++ b/buildout/profiles/test-cloudooo.cfg @@ -1,20 +1,2 @@ [buildout] 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} diff --git a/buildout/templates/runCloudOOoUnitTest.py.in b/buildout/templates/runCloudOOoUnitTest.py.in deleted file mode 100644 index fdc67486646cc5b3d6e8d017a8598b1d274d07f0..0000000000000000000000000000000000000000 --- a/buildout/templates/runCloudOOoUnitTest.py.in +++ /dev/null @@ -1,107 +0,0 @@ -#!${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)