예제 #1
0
def start_docker_compose(clients=1):
    docker_compose_cmd("up -d")

    if clients > 1:
        docker_compose_cmd("scale mender-client=%d" % clients)

    ssh_is_opened()

    common.set_setup_type(common.ST_OneClient)
예제 #2
0
def stop_docker_compose():
    with conftest.docker_lock:
        # Take down all docker instances in this namespace.
        cmd = "docker ps -aq -f name=%s | xargs -r docker rm -fv" % conftest.docker_compose_instance
        logger.info("running %s" % cmd)
        subprocess.check_call(cmd, shell=True)
        cmd = "docker network list -q -f name=%s | xargs -r docker network rm" % conftest.docker_compose_instance
        logger.info("running %s" % cmd)
        subprocess.check_call(cmd, shell=True)

    common.set_setup_type(None)
예제 #3
0
def start_docker_compose(clients=1):
    inline_logs = conftest.inline_logs

    docker_compose_cmd("up -d")
    if clients > 1:
        docker_compose_cmd("scale mender-client=%d" % clients)

    if inline_logs:
        docker_compose_cmd("logs -f &")
    else:
        tfile = tempfile.mktemp("mender_testing")
        docker_compose_cmd("logs -f --no-color > %s 2>&1 &" % tfile)
        logger.info("docker-compose log file stored here: %s" % tfile)
        log_files.append(tfile)

    ssh_is_opened()

    common.set_setup_type(common.ST_OneClient)
예제 #4
0
def stop_docker_compose():
    # take down all COMPOSE_FILES and the s3 specific files
    docker_compose_cmd(
        " -f ../docker-compose.storage.s3.yml -f ../extra/travis-testing/s3.yml -f ../docker-compose.tenant.yml down -v"
    )

    # docker-compose issue: https://github.com/docker/compose/issues/4046
    # under some unknown circumstances, docker-compose log fails to quit, and hangs pytest
    for p in psutil.process_iter():
        if "docker-compose -p %s" % (
                conftest.docker_compose_instance) in p.cmdline(
                ) and "logs" in p.cmdline():
            logger.info(
                "killing lingering 'docker-compose log' process (pid: %s)" %
                p.cmdline())
            p.kill()

    common.set_setup_type(None)