Exemple #1
0
def push_branch():
    if args.branch not in args.push_branches.split(','):
        print('Skip push branch: {}'.format(args.branch))
        return
    print('Push branch {}'.format(args.branch))
    succ(['docker tag ', args.temp_name, FULL_BRANCH])
    succ(['docker push ', FULL_BRANCH])
Exemple #2
0
def push_tag():
    if not args.tag:
        print('Skip push tag')
        return
    print('Push tag: {}'.format(args.tag))
    succ(['docker tag', args.temp_name, FULL_TAG])
    succ(['docker push', FULL_TAG])
def create_database():
    print('Create database')
    c = 0
    while c < 30:
        try:
            succ('echo create database plugin | '
                 'PGPASSWORD=password psql -h localhost -p 40001 -U postgres')
            return
        except ExecError as e:
            print(e)
            c += 1
            time.sleep(1)
    print('Cannot create database')
    c, out, err = succ('docker logs testpostgres')
    print('\n'.join(out))
    print('=' * 80)
    print('\n'.join(err))
    exit(1)
Exemple #4
0
def run_traefik(args):
    compose = rel_path('../resources/traefik.compose.yaml')
    print(f'CMD: {args}')
    cmd = ' '.join(args.cmd)

    full_cmd = f'docker-compose -p traefik -f {compose} {cmd}'
    log.debug(f'Run: {full_cmd}')
    code, out, err = succ(full_cmd)
    for line in chain(out, err):
        print(line)
Exemple #5
0
def pytest_configure(config):
    if config.getoption('docker_skip'):
        return

    with suppress(Exception):
        print('Stop old container if exists')
        os.system('docker stop testpostgres')
        time.sleep(1)
    with suppress(Exception):
        os.system('docker rm testpostgres')
    try:
        print('Start docker')
        succ('docker run -d -p 40001:5432  -e POSTGRES_PASSWORD=password '
             '--name=testpostgres postgres:13')
        time.sleep(5)
        wait_socket('localhost', 40001, timeout=15)
        create_database()
    except Exception as e:
        print('EXCEPTION: {}'.format(e))
        exit(1)
Exemple #6
0
def write_dyn_cfg(myid, myip, others=None):
    if others:
        role = 'observer'
    else:
        role = 'participant'

    with open(DYN_CFG, 'w') as f:
        if others:
            f.write(others)
            f.write('\n')
            f.write(pat(myid=myid, myip=myip, role=role))
        else:
            f.write(pat(myid=myid, myip=myip, role=role))
    init(myid)
    with open(DYN_CFG) as f:
        printe('CONFIG: {}\n\n'.format(f.read()))
    if others:
        init(myid)
        succ(['/opt/zookeeper/bin/zkServer.sh start'])
        cfg = pat(myid=myid, myip=myip, role='participant')
        seed = os.environ.get('ZK_SEED')
        wait_socket('localhost', 2181)
        printe('Reconfiguring...')
        succ([RECONF(seed=seed, cfg=cfg)], check_stderr=True)
Exemple #7
0
def cpp_module():
    with cd(rel_path('../..')):
        succ('make example.so')
Exemple #8
0
def cache():
    print('Cache image as: {}'.format(args.cache_name))
    succ([
        'docker tag', args.temp_name, args.cache_name, '&& docker rmi',
        args.temp_name
    ])
Exemple #9
0
def run_test():
    succ([args.test], check_stderr=False)
Exemple #10
0
def build():
    sha = args.temp_name
    cmd = ['docker build -t', sha, '-f', args.docker_file, '.']
    print('Build: {}'.format(' '.join(cmd)))
    succ(cmd)
Exemple #11
0
def run():
    with open(DYN_CFG) as f:
        printe('RUN EXISTING CONFIG: {}'.format(f.read()))
    succ([RUN], False)
Exemple #12
0
def init(myid):
    succ([INIT(myid=myid)])
Exemple #13
0
def test_succ_handle_error():
    stderr = []
    with pytest.raises(ExecError) as e:
        succ('bash randomcommand', stderr=stderr)
    assert stderr, 'Should have something: {}'.format(stderr)
    assert e.value.exit_code == 127, e.value