Example #1
0
def setup_package():
    assert os.path.exists(CONFIG_FILE), 'Config file %s must exist' % CONFIG_FILE
    load_config(configfile=CONFIG_FILE)
    log_to_stream(sys.stdout, level=logging.DEBUG)

    from bkr.inttest import data_setup
    if not 'BEAKER_SKIP_INIT_DB' in os.environ:
        data_setup.setup_model()
    with session.begin():
        data_setup.create_labcontroller() #always need a labcontroller
        data_setup.create_task(name=u'/distribution/install', requires=
                u'make gcc nfs-utils wget procmail redhat-lsb ntp '
                u'@development-tools @development-libs @development '
                u'@desktop-platform-devel @server-platform-devel '
                u'libxml2-python expect pyOpenSSL'.split())
        data_setup.create_task(name=u'/distribution/reservesys',
                requires=u'emacs vim-enhanced unifdef sendmail'.split())
        data_setup.create_distro()

    if not os.path.exists(turbogears.config.get('basepath.rpms')):
        os.mkdir(turbogears.config.get('basepath.rpms'))

    setup_slapd()

    turbogears.testutil.make_app(Root)
    turbogears.testutil.start_server()

    if 'BEAKER_SERVER_BASE_URL' not in os.environ:
        # need to start the server ourselves
        # Usual pkg_resources ugliness is needed to ensure gunicorn doesn't
        # import pkg_resources before we get a chance to specify our
        # requirements in bkr.server.wsgi
        processes.extend([
            Process('gunicorn', args=[sys.executable, '-c',
                '__requires__ = ["CherryPy < 3.0"]; import pkg_resources; ' \
                'from gunicorn.app.wsgiapp import run; run()',
                '--bind', ':%s' % turbogears.config.get('server.socket_port'),
                '--workers', '8', '--access-logfile', '-', '--preload',
                'bkr.server.wsgi:application'],
                listen_port=turbogears.config.get('server.socket_port')),
        ])
    processes.extend([
        Process('slapd', args=['slapd', '-d0', '-F/tmp/beaker-tests-slapd-config',
                '-hldap://127.0.0.1:3899/'],
                listen_port=3899, stop_signal=signal.SIGINT),
    ])
    try:
        for process in processes:
            process.start()
    except:
        for process in processes:
            process.stop()
        raise
Example #2
0
def setup_package():
    log.info('Loading test configuration from %s', CONFIG_FILE)
    assert os.path.exists(CONFIG_FILE), 'Config file %s must exist' % CONFIG_FILE
    update_config(configfile=CONFIG_FILE, modulename='bkr.server.config')

    # Override loaded logging config, in case we are using the server's config file
    # (we really always want our tests' logs to go to stdout, not /var/log/beaker/)
    log_to_stream(sys.stdout, level=logging.NOTSET)

    from bkr.inttest import data_setup
    if not 'BEAKER_SKIP_INIT_DB' in os.environ:
        data_setup.setup_model()
    with session.begin():
        data_setup.create_labcontroller() #always need a labcontroller
        data_setup.create_task(name=u'/distribution/install', requires=
                u'make gcc nfs-utils wget procmail redhat-lsb ntp '
                u'@development-tools @development-libs @development '
                u'@desktop-platform-devel @server-platform-devel '
                u'libxml2-python expect pyOpenSSL'.split())
        data_setup.create_task(name=u'/distribution/reservesys',
                requires=u'emacs vim-enhanced unifdef sendmail'.split())
        data_setup.create_distro()

    if not os.path.exists(turbogears.config.get('basepath.rpms')):
        os.mkdir(turbogears.config.get('basepath.rpms'))

    setup_slapd()

    turbogears.testutil.make_app(Root)
    turbogears.testutil.start_server()

    if 'BEAKER_SERVER_BASE_URL' not in os.environ:
        # need to start the server ourselves
        # (this only works from the IntegrationTests dir of a Beaker checkout)
        processes.extend([
            Process('beaker', args=['../Server/start-server.py', CONFIG_FILE],
                    listen_port=turbogears.config.get('server.socket_port'),
                    stop_signal=signal.SIGINT)
        ])
    processes.extend([
        Process('slapd', args=['slapd', '-d0', '-F/tmp/beaker-tests-slapd-config',
                '-hldap://127.0.0.1:3899/'],
                listen_port=3899, stop_signal=signal.SIGINT),
    ])
    try:
        for process in processes:
            process.start()
    except:
        for process in processes:
            process.stop()
        raise