From ec3b541939ea7cac1a20da39083be1498442994d Mon Sep 17 00:00:00 2001 From: George Adams Date: Mon, 6 Nov 2023 12:40:37 +0000 Subject: [PATCH 1/2] add dotted environment variables test --- .../tests/dotted-environment-variables/container.java | 11 +++++++++++ .../dotted-environment-variables/expected-std-out.txt | 1 + test/tests/dotted-environment-variables/run.sh | 1 + test/tests/run-java-in-container.sh | 7 ++++++- 4 files changed, 19 insertions(+), 1 deletion(-) create mode 100644 test/tests/dotted-environment-variables/container.java create mode 100644 test/tests/dotted-environment-variables/expected-std-out.txt create mode 120000 test/tests/dotted-environment-variables/run.sh diff --git a/test/tests/dotted-environment-variables/container.java b/test/tests/dotted-environment-variables/container.java new file mode 100644 index 0000000000000..de94c36f02784 --- /dev/null +++ b/test/tests/dotted-environment-variables/container.java @@ -0,0 +1,11 @@ +public class container { + /** + * Check if dotted env vars are supported. + */ + public static void main(String[] args) { + // get value of variable.with.a.dot and print it out + String value = System.getenv("variable.with.a.dot"); + System.out.println(value); + System.exit(0); + } +} diff --git a/test/tests/dotted-environment-variables/expected-std-out.txt b/test/tests/dotted-environment-variables/expected-std-out.txt new file mode 100644 index 0000000000000..f0a7151bbeae9 --- /dev/null +++ b/test/tests/dotted-environment-variables/expected-std-out.txt @@ -0,0 +1 @@ +a.dotted.value diff --git a/test/tests/dotted-environment-variables/run.sh b/test/tests/dotted-environment-variables/run.sh new file mode 120000 index 0000000000000..7a0c67fbd4297 --- /dev/null +++ b/test/tests/dotted-environment-variables/run.sh @@ -0,0 +1 @@ +../run-java-in-container.sh \ No newline at end of file diff --git a/test/tests/run-java-in-container.sh b/test/tests/run-java-in-container.sh index 48d941966f9e7..31c79aaf7dd0c 100755 --- a/test/tests/run-java-in-container.sh +++ b/test/tests/run-java-in-container.sh @@ -51,4 +51,9 @@ COPY --from=jdk /container /container WORKDIR /container EOD -docker run --rm "$newImage" java -cp . container +# if testDir contains dotted-environment-variables we need to add an environment variable to the docker run command +if [ $testDir == *"dotted-environment-variables"* ]; then + docker run --rm -e "variable.with.a.dot=a.dotted.value" "$newImage" java -cp . container +else + docker run --rm "$newImage" java -cp . container +fi From 561aff1e3be8e90abbb3e2f3a1c09e83ffdc3ed2 Mon Sep 17 00:00:00 2001 From: George Adams Date: Mon, 22 Apr 2024 11:53:15 +0200 Subject: [PATCH 2/2] Update run-java-in-container.sh --- test/tests/run-java-in-container.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/tests/run-java-in-container.sh b/test/tests/run-java-in-container.sh index 31c79aaf7dd0c..a6b030737e522 100755 --- a/test/tests/run-java-in-container.sh +++ b/test/tests/run-java-in-container.sh @@ -52,7 +52,7 @@ WORKDIR /container EOD # if testDir contains dotted-environment-variables we need to add an environment variable to the docker run command -if [ $testDir == *"dotted-environment-variables"* ]; then +if [[ "$testDir" == *"dotted-environment-variables"* ]]; then docker run --rm -e "variable.with.a.dot=a.dotted.value" "$newImage" java -cp . container else docker run --rm "$newImage" java -cp . container