def is_running(): # Does it look like tools/ci/setup-slurm-container.sh was called? try: out, _ = Runner().run( ["docker", "port", "reproman-slurm-container"], expect_fail=True, expect_stderr=True) except (CommandError, FileNotFoundError): return False return out.strip()
def docker_fixture(): """The actual fixture code generated by get_docker_fixture on setup, this fixture ensures that a docker container is running and starts one if necessary. Fixture yields parameters of the container with a `custom` field passed into the `get_docker_container`. on teardown, this fixture stops the docker container it started """ skip_if_no_network() args = [ 'docker', 'run', '-d', '--rm', ] if seccomp_unconfined: args.extend(['--security-opt', 'seccomp=unconfined']) params = {} if name: args += ['--name', name] params['name'] = name if portmaps: for from_to in portmaps.items(): args += ['-p', '%d:%d' % from_to] params['port'] = from_to[0] args += [image] stdout, _ = Runner().run(args) params['container_id'] = container_id = stdout.strip() params['custom'] = custom_params yield params Runner().run(['docker', 'stop', container_id])