8000 libcnb-test: `TestContext::start_container` leaves behind the container if it failed to start · Issue #737 · heroku/libcnb.rs · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
8000 Skip to content
libcnb-test: TestContext::start_container leaves behind the container if it failed to start #737
Closed
@edmorley

Description

@edmorley

libcnb-test tears down started containers in TestContext::drop, however, if the test panics prior to the creation of the TestContext this teardown never occurs. This can happen when the container spawn failed (eg invalid command).

util::run_command(docker_run_command)
.unwrap_or_else(|command_err| panic!("Error starting container:\n\n{command_err}"));
f(ContainerContext {
container_name,
config: config.clone(),
});

This can be seen by running the start_container_spawn_failure test:

$ docker ps -a
CONTAINER ID   IMAGE     COMMAND   CREATED   STATUS    PORTS     NAMES

$ cargo test -p libcnb-test  -- --ignored start_container_spawn_failure
    Finished test [unoptimized + debuginfo] target(s) in 0.04s
     Running unittests src/lib.rs (/Users/emorley/src/libcnb.rs/target/debug/deps/libcnb_test-52afd8d3986e3490)

running 0 tests

test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 32 filtered out; finished in 0.00s

     Running tests/integration_test.rs (/Users/emorley/src/libcnb.rs/target/debug/deps/integration_test-766c079bdc09c04d)

running 1 test
test start_container_spawn_failure - should panic ... ok

test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 26 filtered out; finished in 1.03s

   Doc-tests libcnb-test

running 0 tests

test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 38 filtered out; finished in 0.01s

$ docker ps -a
CONTAINER ID   IMAGE          COMMAND                 CREATED         STATUS    PORTS     NAMES
bd1eba167270   73a710102aa6   "nonexistent-command"   2 seconds ago   Created             libcnbtest_vqvzlpmsjirt

GUS-W-14504389.

4420

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

    0