Skip to content

Commit

Permalink
Fix libcnb-tests's integration tests with newer Rosetta/Docker Desktop (
Browse files Browse the repository at this point in the history
#707)

libcnb-test's own integration tests were failing locally when run using
newer versions of Docker Desktop and/or the Rosetta feature in
macOS 14.1.

Rosetta now creates a `$HOME/.cache/rosetta` directory that was breaking
the directory listing assertions in the `app_dir_preprocessor` test:

```
---- app_dir_preprocessor stdout ----
thread 'app_dir_preprocessor' panicked at libcnb-test/tests/integration_test.rs:189:13:
assertion `left == right` failed
  left: ".\n./.cache\n./.cache/rosetta\n./Procfile\n./subdir1\n./subdir1/file2.txt\n./subdir1/subdir2\n./subdir1/subdir2/subdir3\n./subdir1/subdir2/subdir3/file3.txt\n"
 right: ".\n./Procfile\n./subdir1\n./subdir1/file2.txt\n./subdir1/subdir2\n./subdir1/subdir2/subdir3\n./subdir1/subdir2/subdir3/file3.txt\n"
```

In addition, it seems the newer Docker daemon now supports port 0,
which was the port used by the `expose_port_invalid_port` test. There
isn't another bogus port we can use (since the data types use an unsigned
16 bit int, whose max value is the same as the max port allowed - so we
can't use a port like 99999), and the test itself is somewhat redundant,
since failing `start_container()` is already tested in other ways.

As such the `expose_port_invalid_port` test has been removed.

Fixes #706.
GUS-W-14395756.
  • Loading branch information
edmorley authored Oct 31, 2023
1 parent cdd2eb4 commit 2698a71
Showing 1 changed file with 4 additions and 17 deletions.
21 changes: 4 additions & 17 deletions libcnb-test/tests/integration_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -184,14 +184,16 @@ fn app_dir_preprocessor() {
./subdir1/subdir2/subdir3/file3.txt
"};

let log_output = context.run_shell_command("find . | sort");
// The cache path exclusion is required since when using Rosetta on macOS
// a cache directory is created at `$HOME/.cache/rosetta`.
let log_output = context.run_shell_command("find . -not -path './.cache*' | sort");
assert_empty!(log_output.stderr);
assert_eq!(log_output.stdout, expected_directory_listing);

// Check that rebuilds get a new/clean ephemeral fixture directory.
let config = context.config.clone();
context.rebuild(config, |context| {
let log_output = context.run_shell_command("find . | sort");
let log_output = context.run_shell_command("find . -not -path './.cache*' | sort");
assert_empty!(log_output.stderr);
assert_eq!(log_output.stdout, expected_directory_listing);
});
Expand Down Expand Up @@ -477,21 +479,6 @@ fn logs_work_after_container_crashed() {
);
}

#[test]
#[ignore = "integration test"]
#[should_panic(expected = "Port `0' not valid")]
fn expose_port_invalid_port() {
TestRunner::default().build(
BuildConfig::new("heroku/builder:22", "tests/fixtures/procfile")
.buildpacks([BuildpackReference::Other(String::from(PROCFILE_URL))]),
|context| {
context.start_container(ContainerConfig::new().expose_port(0), |_| {
unreachable!("The test should fail before the ContainerContext is invoked.");
});
},
);
}

#[test]
#[ignore = "integration test"]
#[should_panic(
Expand Down

0 comments on commit 2698a71

Please sign in to comment.