示例#1
0
def test_trace_local(trace_info):
    with patch("reproman.resource.ResourceManager._get_inventory") as get_inv:
        config = {
            "status": "running",
            "type": "shell",
            "name": "testing-local"
        }
        get_inv.return_value = {"testing-local": config}
        with patch("reproman.interface.execute.get_manager",
                   return_value=ResourceManager()):
            with patch("reproman.interface.execute.CMD_CLASSES",
                       {"trace": trace_info["class"]}):
                execute("ls", ["-l"], trace=True, resref="testing-local")

    local_dir = trace_info["local"]
    assert set(os.listdir(local_dir)) == {"traces", "tracers"}
    trace_dirs = os.listdir(op.join(local_dir, "traces"))
    assert len(trace_dirs) == 1

    prov = RepromanProvenance(
        op.join(local_dir, "traces", trace_dirs[0], "reproman.yml"))
    deb_dists = [
        dist for dist in prov.get_distributions() if dist.name == "debian"
    ]
    assert len(deb_dists) == 1

    expect = {"packages": [{"files": ["/bin/ls"], "name": "coreutils"}]}
    assert_is_subset_recur(expect, attr.asdict(deb_dists[0]), [dict, list])
示例#2
0
def test_trace_docker(docker_container, trace_info):
    with patch("reproman.resource.ResourceManager._get_inventory") as get_inv:
        config = {"status": "running",
                  "engine_url": "unix:///var/run/docker.sock",
                  "type": "docker-container",
                  "name": "testing-container"}
        get_inv.return_value = {"testing-container": config}
        manager = ResourceManager()
        with patch("reproman.interface.execute.get_manager",
                   return_value=ResourceManager()):
            with patch("reproman.interface.execute.CMD_CLASSES",
                       {"trace": trace_info["class"]}):
                execute("ls", ["-l"],
                        trace=True, resref="testing-container")
            # Barely more than a smoke test.  The test_trace_docker will look
            # at the generated spec.
            session = manager.get_resource("testing-container").get_session()
            assert session.exists(trace_info["remote"])
            # The tracer didn't doing anything with the local test directory:
            assert not os.listdir(trace_info["remote"])
示例#3
0
def test_invalid_trace_internal():
    with pytest.raises(RuntimeError):
        execute("doesn't matter", [], internal=True, trace=True)