Пример #1
0
def env(test_results, config='init-myapp.yaml', workdir='/tmp/lago-workdir'):
    lago_env = sdk.init(
        config=config,
        workdir=workdir,
    )
    lago_env.start()
    yield lago_env
    collect_path = os.path.join(test_results, 'collect')
    lago_env.collect_artifacts(output_dir=collect_path, ignore_nopath=True)
    lago_env.destroy()
Пример #2
0
    def test_init_logger_new_env(self, tmpdir, monkeypatch, mock_workdir,
                                 empty_prefix, level):
        log_path = tmpdir.mkdir('logs').join('test.log')
        monkeypatch.setattr('lago.cmd.do_init', lambda **kwargs:
                            (mock_workdir, empty_prefix))
        sdk.init(config=None,
                 workdir=None,
                 logfile=str(log_path),
                 loglevel=level)
        handlers = [
            h for h in logging.root.handlers
            if isinstance(h, logging.FileHandler)
        ]
        assert len(handlers) == 1
        handler = handlers.pop()
        assert handler.stream.name == str(log_path)
        assert handler.level == getattr(logging, level)

        logging.root.removeHandler(handler)
Пример #3
0
    def test_init_logger_new_env(
        self, tmpdir, monkeypatch, mock_workdir, empty_prefix, level
    ):
        log_path = tmpdir.mkdir('logs').join('test.log')
        monkeypatch.setattr(
            'lago.cmd.do_init', lambda **kwargs: (mock_workdir, empty_prefix)
        )
        sdk.init(
            config=None, workdir=None, logfile=str(log_path), loglevel=level
        )
        handlers = [
            h for h in logging.root.handlers
            if isinstance(h, logging.FileHandler)
        ]
        assert len(handlers) == 1
        handler = handlers.pop()
        assert handler.stream.name == str(log_path)
        assert handler.level == getattr(logging, level)

        logging.root.removeHandler(handler)
Пример #4
0
def env(request, init_fname, test_results, tmp_workdir, external_log):
    workdir = os.path.join(str(tmp_workdir), 'lago')
    env = sdk.init(
        init_fname,
        workdir=workdir,
        logfile=str(external_log),
        loglevel=logging.DEBUG,
    )
    env.start()
    try:
        yield env
        collect_path = os.path.join(test_results, 'collect')
        env.collect_artifacts(output_dir=collect_path, ignore_nopath=True)
        shutil.copytree(workdir,
                        os.path.join(test_results, 'workdir'),
                        ignore=shutil.ignore_patterns('*images*'))
    finally:
        env.stop()
        env.destroy()
Пример #5
0
def env(request, init_fname, test_results, tmp_workdir, external_log):
    workdir = os.path.join(str(tmp_workdir), 'lago')
    env = sdk.init(
        init_fname,
        workdir=workdir,
        logfile=str(external_log),
        loglevel=logging.DEBUG,
    )
    env.start()
    try:
        yield env
        collect_path = os.path.join(test_results, 'collect')
        env.collect_artifacts(output_dir=collect_path, ignore_nopath=True)
        shutil.copytree(
            workdir,
            os.path.join(test_results, 'workdir'),
            ignore=shutil.ignore_patterns('*images*')
        )
    finally:
        env.stop()
        env.destroy()
Пример #6
0
def env(cls_results_path):
    config = 'init-jenkins.yaml'
    workdir = '/tmp/lago-workdir'

    raise NotImplementedError('Implement me')

    try:
        lago_env = sdk.init(
            config=config,
            workdir=workdir,
            logfile=os.path.join(cls_results_path, 'lago.log'),
            loglevel=logging.DEBUG
        )
    except PrefixAlreadyExists:
        lago_env = sdk.load_env(
            workdir=workdir,
            logfile=os.path.join(cls_results_path, 'lago.log'),
            loglevel=logging.DEBUG
        )
    lago_env.start()

    yield lago_env
Пример #7
0
def env(cls_results_path):
    config = 'init-jenkins.yaml'
    workdir = '/tmp/lago-workdir'

    try:
        lago_env = sdk.init(config=config,
                            workdir=workdir,
                            logfile=os.path.join(cls_results_path, 'lago.log'),
                            loglevel=logging.DEBUG)
    except PrefixAlreadyExists:
        lago_env = sdk.load_env(workdir=workdir,
                                logfile=os.path.join(cls_results_path,
                                                     'lago.log'),
                                loglevel=logging.DEBUG)
    lago_env.start()

    yield lago_env

    # Task: Add log collection. The logs should be collected to a
    # sub directory of 'cls_result_path
    collect_path = os.path.join(cls_results_path, 'collect')
    lago_env.collect_artifacts(output_dir=collect_path, ignore_nopath=True)