From 852e13e8f06e4a386e44fd2a14e79432eb1ef97d Mon Sep 17 00:00:00 2001 From: Ed Morley <501702+edmorley@users.noreply.github.com> Date: Wed, 28 Feb 2024 12:39:42 +0000 Subject: [PATCH] Fix `starting_containers` test after release of Procfile CNB v3.0.0 Procfile 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. This change improves the overall UX, but was breaking in some lesser used scenarios that happened to be tested via the `starting_containers` test in this repo. Specifically, before the `Procfile` file entry would be set as the process `command`, but now it's set as `args`. See: - https://github.com/heroku/procfile-cnb/pull/205#discussion_r1495090822 - https://github.com/heroku/procfile-cnb/compare/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. --- libcnb-test/tests/fixtures/procfile/Procfile | 1 - libcnb-test/tests/integration_test.rs | 25 +++++++++++++++----- 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/libcnb-test/tests/fixtures/procfile/Procfile b/libcnb-test/tests/fixtures/procfile/Procfile index 0d0f91f8..a84f7513 100644 --- a/libcnb-test/tests/fixtures/procfile/Procfile +++ b/libcnb-test/tests/fixtures/procfile/Procfile @@ -1,3 +1,2 @@ web: python3 -u -m http.server ${PORT:+"${PORT}"} worker: echo 'this is the worker process!' -echo-args: echo diff --git a/libcnb-test/tests/integration_test.rs b/libcnb-test/tests/integration_test.rs index 531377ed..2b816f42 100644 --- a/libcnb-test/tests/integration_test.rs +++ b/libcnb-test/tests/integration_test.rs @@ -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 "} ); }, @@ -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 "} ); }, @@ -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 "} ); @@ -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();