예제 #1
0
 def test_generates_unique_config(self):
     config.setInstance('testrunner')
     orig_instance = config.instance_name
     self.useFixture(
         EnvironmentVariableFixture('LP_PERSISTENT_TEST_SERVICES'))
     self.useFixture(EnvironmentVariableFixture('LP_TEST_INSTANCE'))
     self.useFixture(EnvironmentVariableFixture('LPCONFIG'))
     with LayerFixture(BaseLayer):
         self.assertEqual('testrunner_%s' % os.environ['LP_TEST_INSTANCE'],
                          config.instance_name)
     self.assertEqual(orig_instance, config.instance_name)
 def test_generates_unique_config(self):
     config.setInstance('testrunner')
     orig_instance = config.instance_name
     self.useFixture(
         EnvironmentVariableFixture('LP_PERSISTENT_TEST_SERVICES'))
     self.useFixture(EnvironmentVariableFixture('LP_TEST_INSTANCE'))
     self.useFixture(EnvironmentVariableFixture('LPCONFIG'))
     with LayerFixture(BaseLayer):
         self.assertEqual(
             'testrunner_%s' % os.environ['LP_TEST_INSTANCE'],
             config.instance_name)
     self.assertEqual(orig_instance, config.instance_name)
예제 #3
0
def configure_environment():
    # Make tests run in a timezone no launchpad developers live in.
    # Our tests need to run in any timezone.
    # (This is no longer actually required, as PQM does this.)
    os.environ['TZ'] = 'Asia/Calcutta'
    time.tzset()

    # Httplib2 0.7 started validating SSL certificates, and the test suite
    # uses a self-signed certificate, so disable it with an env variable.
    os.environ['LP_DISABLE_SSL_CERTIFICATE_VALIDATION'] = '1'

    # Storm's C extensions should already be enabled from
    # lp_sitecustomize.py, which our custom sitecustomize.py ran.
    assert os.environ['STORM_CEXTENSIONS'] == '1'

    # Install the import fascist import hook and atexit handler.
    importfascist.install_import_fascist()

    # Install the warning handler hook and atexit handler.
    warninghandler.install_warning_handler()

    # Ensure that atexit handlers are executed on TERM.
    def exit_with_atexit_handlers(*ignored):
        sys.exit(-1 * signal.SIGTERM)

    signal.signal(signal.SIGTERM, exit_with_atexit_handlers)

    # Tell lp.services.config to use the testrunner config instance.
    config.setInstance('testrunner')
    config.generate_overrides()

    # Remove this module's directory from path, so that zope.testbrowser
    # can import pystone from test:
    sys.path[:] = [p for p in sys.path if os.path.abspath(p) != config.root]

    # Turn on psycopg debugging wrapper
    #import lp.services.database.debug
    #lp.services.database.debug.install()

    # Unset the http_proxy environment variable, because we're going to make
    # requests to localhost and we don't want this to be proxied.
    os.environ.pop('http_proxy', None)

    # Suppress accessibility warning because the test runner does not have UI.
    os.environ['GTK_MODULES'] = ''
예제 #4
0
def main():
    args = sys.argv[1:]
    if '-h' in args or '--help' in args:
        print(__doc__)
        return 0
    # Tell lp.services.config to use the testrunner config instance, so that
    # we don't kill the real services.
    config.setInstance('testrunner')
    config.generate_overrides()
    print("Killing Memcached....", end="")
    kill_by_pidfile(MemcachedLayer.getPidFile())
    print("done.")
    print("Killing Librarian....", end="")
    librarian_fixture = LibrarianServerFixture(None)
    kill_by_pidfile(librarian_fixture.pidfile)
    librarian_fixture.tearDownRoot()
    print("done.")
    return 0
예제 #5
0
def process_config_arguments(args):
    """Process the arguments related to the config.

    -i  Will set the instance name aka LPCONFIG env.

    If there is no ZConfig file passed, one will add to the argument
    based on the selected instance.
    """
    if '-i' in args:
        index = args.index('-i')
        config.setInstance(args[index + 1])
        del args[index:index + 2]

    if '-C' not in args:
        zope_config_file = config.zope_config_file
        if not os.path.isfile(zope_config_file):
            raise ValueError("Cannot find ZConfig file for instance %s: %s" %
                             (config.instance_name, zope_config_file))
        args.extend(['-C', zope_config_file])
    return args
예제 #6
0
    def test_sigdumpmem(self):
        # XXX: AaronBentley 2010-04-07 bug=557356: Test breaks other tests.
        return
        # Remove the dump file, if one exists.
        if os.path.exists(DUMP_FILE):
            os.unlink(DUMP_FILE)
        self.assertFalse(os.path.exists(DUMP_FILE))

        # Get the pid for the process spawned by the AppServerLayer, which is
        # the one we'll be sending the signal to.
        orig_instance_name = config.instance_name
        config.setInstance('testrunner-appserver')
        pid = get_pid('launchpad')
        config.setInstance(orig_instance_name)

        # Send the signal and ensure the dump file is created.
        os.kill(pid, SIGDUMPMEM)
        timeout = 10
        start_time = time.time()
        while time.time() < start_time + timeout:
            if os.path.exists(DUMP_FILE):
                break
        self.assertTrue(os.path.exists(DUMP_FILE))
예제 #7
0
    def test_sigdumpmem(self):
        # XXX: AaronBentley 2010-04-07 bug=557356: Test breaks other tests.
        return
        # Remove the dump file, if one exists.
        if os.path.exists(DUMP_FILE):
            os.unlink(DUMP_FILE)
        self.assertFalse(os.path.exists(DUMP_FILE))

        # Get the pid for the process spawned by the AppServerLayer, which is
        # the one we'll be sending the signal to.
        orig_instance_name = config.instance_name
        config.setInstance('testrunner-appserver')
        pid = get_pid('launchpad')
        config.setInstance(orig_instance_name)

        # Send the signal and ensure the dump file is created.
        os.kill(pid, SIGDUMPMEM)
        timeout = 10
        start_time = time.time()
        while time.time() < start_time + timeout:
            if os.path.exists(DUMP_FILE):
                break
        self.assertTrue(os.path.exists(DUMP_FILE))
예제 #8
0
 def setUp(self):
     super(ConfigUseFixture, self).setUp()
     self.addCleanup(config.setInstance, config.instance_name)
     config.setInstance(self.instance_name)
예제 #9
0
 def _setUp(self):
     self.addCleanup(config.setInstance, config.instance_name)
     config.setInstance(self.instance_name)