def test_ReproZipMinimizer_no_ptrace(): client = get_docker_client() container = client.containers.run("debian:stretch", detach=True, tty=True) commands = ["du --help", "ls --help"] tmpdir = tempfile.mkdtemp() try: minimizer = ReproZipMinimizer(container.id, commands, packfile_save_dir=tmpdir) with pytest.raises(RuntimeError): # ptrace should fail minimizer.run() except Exception: raise finally: container.stop() container.remove()
def _create_packfile(commands, dir): """Create packfile from list `commands` in debian:stretch container.""" client = get_docker_client() image = "debian@sha256:427752aa7da803378f765f5a8efba421df5925cbde8ab011717f3642f406fb15" container = client.containers.run( image, detach=True, tty=True, security_opt=['seccomp:unconfined']) try: minimizer = ReproZipMinimizer( container.id, commands, packfile_save_dir=dir) packfile_path = minimizer.run() except Exception: raise finally: container.stop() container.remove() return packfile_path
def _create_packfile(commands, dir): """Create packfile from list `commands` in debian:stretch container.""" container = client.containers.run('debian:stretch', detach=True, tty=True, security_opt=['seccomp:unconfined']) try: minimizer = ReproZipMinimizer(container.id, commands, packfile_save_dir=dir) packfile_path = minimizer.run() except: raise finally: container.stop() container.remove() return packfile_path
def test_ReproZipMinimizer(): client = get_docker_client() container = client.containers.run( "debian:stretch", detach=True, tty=True, security_opt=["seccomp:unconfined"] ) commands = ["du --help", "ls --help"] tmpdir = tempfile.mkdtemp() try: minimizer = ReproZipMinimizer(container.id, commands, packfile_save_dir=tmpdir) packfile_path = minimizer.run() except Exception: raise finally: container.stop() container.remove() assert os.path.isfile(packfile_path), "Pack file not saved."