Skip to content

Commit

Permalink
Fix starting_containers test after release of Procfile CNB v3.0.0 (#…
Browse files Browse the repository at this point in the history
…801)

Procfile CNB v3.0.0 was just released with an intentional change to the
way that `command` vs `args` are handled in the CNB process type
definition. (Before the `Procfile` file entry would be set as the
process `command`, but now it's set as `args`.)

That change improves the overall UX of running images that use the
Procfile CNB, but is breaking in some lesser used scenarios that
happened to be tested via the `starting_containers` test in this repo.

See:
- heroku/buildpacks-procfile#205 (comment)
- heroku/buildpacks-procfile@v2.0.2...v3.0.0#diff-782521a81713992d3a07e85975d367cfac60afc78583133551efcddc2026bd3eL19-R20

The tests have been updated to account for the new behaviour, and an
additional test added for the "overriding command only" scenario (that
wasn't possible to easily test before due to the way the Procfile CNB
was previously implemented).

Fixes #800.
GUS-W-15139634.
  • Loading branch information
edmorley committed Feb 28, 2024
1 parent 5c78f1d commit f098399
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 7 deletions.
1 change: 0 additions & 1 deletion libcnb-test/tests/fixtures/procfile/Procfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
web: python3 -u -m http.server ${PORT:+"${PORT}"}
worker: echo 'this is the worker process!'
echo-args: echo
25 changes: 19 additions & 6 deletions libcnb-test/tests/integration_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ fn build_other_buildpack() {
context.pack_stdout,
indoc! {"
[Discovering process types]
Procfile declares types -> web, worker, echo-args
Procfile declares types -> web, worker
"}
);
},
Expand Down Expand Up @@ -79,7 +79,7 @@ fn build_workspace_composite_buildpack() {
Buildpack B
[Discovering process types]
Procfile declares types -> web, worker, echo-args
Procfile declares types -> web, worker
"}
);
},
Expand All @@ -103,7 +103,7 @@ fn build_multiple_buildpacks() {
Buildpack B
[Discovering process types]
Procfile declares types -> web, worker, echo-args
Procfile declares types -> web, worker
Buildpack A
"}
);
Expand Down Expand Up @@ -484,18 +484,31 @@ fn starting_containers() {
},
);

// Overriding the default entrypoint, but using the default command.
// Overriding the entrypoint only.
context.start_container(ContainerConfig::new().entrypoint("worker"), |container| {
let all_log_output = container.logs_wait();
assert_empty!(all_log_output.stderr);
assert_eq!(all_log_output.stdout, "this is the worker process!\n");
});

// Overriding the command only.
context.start_container(
// The whole command has to be quoted since the Procfile CNB uses `bash -c`, which
// expects the next arg passed to it to be the entire bash command/script. See:
// https://github.com/heroku/procfile-cnb/pull/205#discussion_r1505866192
ContainerConfig::new().command(["echo 'this is a custom command!'"]),
|container| {
let all_log_output = container.logs_wait();
assert_empty!(all_log_output.stderr);
assert_eq!(all_log_output.stdout, "this is a custom command!\n");
},
);

// Overriding both the entrypoint and command.
context.start_container(
ContainerConfig::new()
.entrypoint("echo-args")
.command(["$GREETING", "$DESIGNATION"])
.entrypoint("launcher")
.command(["echo", "$GREETING", "$DESIGNATION"])
.envs([("GREETING", "Hello"), ("DESIGNATION", "World")]),
|container| {
let all_log_output = container.logs_wait();
Expand Down

0 comments on commit f098399

Please sign in to comment.