Beispiel #1
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])
Beispiel #2
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])
Beispiel #3
0
def create_database():
    print('Create database')
    c = 0
    while c < 30:
        try:
            succ(
                'echo create database plugin | psql -h localhost -p 40001 -U postgres'
            )
            return
        except:
            c += 1
            time.sleep(1)
Beispiel #4
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'], False)
        cfg = pat(myid=myid, myip=myip, role='participant')
        seed = os.environ.get('ZK_SEED')
        printe('Reconfiguring...')
        succ([RECONF(seed=seed, cfg=cfg)])
Beispiel #5
0
def run():
    with open(DYN_CFG) as f:
        printe('RUN EXISTING CONFIG: {}'.format(f.read()))
    succ([RUN], False)
Beispiel #6
0
def init(myid):
    succ([INIT(myid=myid)])
Beispiel #7
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])
Beispiel #8
0
def run_test():
    succ([args.test], check_stderr=False)
Beispiel #9
0
def build():
    sha = args.temp_name
    cmd = ['docker build -t', sha, '-f', args.docker_file, '.']
    print('Build: {}'.format(' '.join(cmd)))
    succ(cmd)
Beispiel #10
0
def run(cmd):
    return succ(cmd, check_stderr=False)
Beispiel #11
0
def test_succ_handle_error():
    stderr = []
    with pytest.raises(AssertionError):
        succ('bash randomcommand', stderr=stderr)
    assert stderr, 'Should have something: {}'.format(stderr)