From cb8d3a969f7af4647e77ba06f3b355ab2a3ddabc Mon Sep 17 00:00:00 2001 From: Ralf Hubert Date: Fri, 3 Jan 2025 10:10:29 +0100 Subject: [PATCH] test: add bundle blackbox test --- test/black-box/bundle/.gitignore | 2 + test/black-box/bundle/config.yaml | 1 + test/black-box/bundle/recipes/bundle.yaml | 19 ++++++ test/black-box/bundle/recipes/input.yaml | 34 +++++++++++ test/black-box/bundle/run.sh | 72 +++++++++++++++++++++++ 5 files changed, 128 insertions(+) create mode 100644 test/black-box/bundle/.gitignore create mode 100644 test/black-box/bundle/config.yaml create mode 100644 test/black-box/bundle/recipes/bundle.yaml create mode 100644 test/black-box/bundle/recipes/input.yaml create mode 100755 test/black-box/bundle/run.sh diff --git a/test/black-box/bundle/.gitignore b/test/black-box/bundle/.gitignore new file mode 100644 index 00000000..0f6c4218 --- /dev/null +++ b/test/black-box/bundle/.gitignore @@ -0,0 +1,2 @@ +_input/ +test_bundle.tar diff --git a/test/black-box/bundle/config.yaml b/test/black-box/bundle/config.yaml new file mode 100644 index 00000000..703af468 --- /dev/null +++ b/test/black-box/bundle/config.yaml @@ -0,0 +1 @@ +bobMinimumVersion: "0.25" diff --git a/test/black-box/bundle/recipes/bundle.yaml b/test/black-box/bundle/recipes/bundle.yaml new file mode 100644 index 00000000..7e8e4222 --- /dev/null +++ b/test/black-box/bundle/recipes/bundle.yaml @@ -0,0 +1,19 @@ +root: True + +depends: + - input-a + - input-b + - input-c + - input-d + - name: input-indeterministic + if: ${TEST_INDETERMINISTIC_INPUT:-False} + +checkoutDeterministic: True +checkoutScript: | + echo "it works" >> bundled_script.txt + +buildScript: | + cat $1/bundled_script.txt + +packageScript: | + /bin/true diff --git a/test/black-box/bundle/recipes/input.yaml b/test/black-box/bundle/recipes/input.yaml new file mode 100644 index 00000000..e2bb4dc3 --- /dev/null +++ b/test/black-box/bundle/recipes/input.yaml @@ -0,0 +1,34 @@ +multiPackage: + "a": + checkoutSCM: + scm: url + url: "${INPUT_BASE}/a/test.tgz" + digestSHA1: "${INPUT_A_DIGEST}" + stripComponents: 1 + "b": + checkoutSCM: + scm: url + url: "${INPUT_BASE}/b/test.tgz" + digestSHA1: "${INPUT_B_DIGEST}" + stripComponents: 1 + "c": + checkoutSCM: + scm: url + url: "${INPUT_BASE}/c/test.tgz" + digestSHA1: "${INPUT_C_DIGEST}" + stripComponents: 1 + "d": + checkoutSCM: + scm: url + url: "${INPUT_BASE}/d/test.tgz" + digestSHA1: "${INPUT_D_DIGEST}" + stripComponents: 1 + "indeterministic": + checkoutScript: | + echo foo + +buildScript: | + /bin/true + +packageScript: | + /bin/true diff --git a/test/black-box/bundle/run.sh b/test/black-box/bundle/run.sh new file mode 100755 index 00000000..2b08dff4 --- /dev/null +++ b/test/black-box/bundle/run.sh @@ -0,0 +1,72 @@ +#!/bin/bash -e +. ../../test-lib.sh 2>/dev/null || { echo "Must run in script directory!" ; exit 1 ; } + +cleanup +rm -f test_bundle.tar + +trap 'rm -f test_bundle.tar' EXIT + +# generate some input +if [[ ! -d _input ]]; then + mkdir -p _input + pushd _input + mkdir -p a b c d + + for x in a b c d; do + dd if=/dev/urandom of=$x/test.dat bs=1M count=10 + tar czf $x/test.tgz $x/test.dat + done + + popd # _input +fi + +run_bob dev bundle -j 5 \ + -DINPUT_BASE="$PWD/_input" \ + -DINPUT_A_DIGEST="$(sha1sum _input/a/test.tgz | cut -d ' ' -f 1)" \ + -DINPUT_B_DIGEST="$(sha1sum _input/b/test.tgz | cut -d ' ' -f 1)" \ + -DINPUT_C_DIGEST="$(sha1sum _input/c/test.tgz | cut -d ' ' -f 1)" \ + -DINPUT_D_DIGEST="$(sha1sum _input/d/test.tgz | cut -d ' ' -f 1)" +expect_exist dev/src/input/1/workspace/.bob-download + +run_bob dev bundle -j 5 \ + -DINPUT_BASE="$PWD/_input" \ + -DINPUT_A_DIGEST="$(sha1sum _input/a/test.tgz | cut -d ' ' -f 1)" \ + -DINPUT_B_DIGEST="$(sha1sum _input/b/test.tgz | cut -d ' ' -f 1)" \ + -DINPUT_C_DIGEST="$(sha1sum _input/c/test.tgz | cut -d ' ' -f 1)" \ + -DINPUT_D_DIGEST="$(sha1sum _input/d/test.tgz | cut -d ' ' -f 1)" \ + --bundle test_bundle.tar +expect_exist test_bundle.tar + +cleanup +rm -f test_bundle.tar + +run_bob dev bundle -j 5 \ + -DINPUT_BASE="$PWD/_input" \ + -DINPUT_A_DIGEST="$(sha1sum _input/a/test.tgz | cut -d ' ' -f 1)" \ + -DINPUT_B_DIGEST="$(sha1sum _input/b/test.tgz | cut -d ' ' -f 1)" \ + -DINPUT_C_DIGEST="$(sha1sum _input/c/test.tgz | cut -d ' ' -f 1)" \ + -DINPUT_D_DIGEST="$(sha1sum _input/d/test.tgz | cut -d ' ' -f 1)" \ + --bundle test_bundle.tar +expect_exist test_bundle.tar + +cleanup +run_bob dev bundle -j 5 \ + -DINPUT_BASE="/notexisting" \ + -DINPUT_A_DIGEST="$(sha1sum _input/a/test.tgz | cut -d ' ' -f 1)" \ + -DINPUT_B_DIGEST="$(sha1sum _input/b/test.tgz | cut -d ' ' -f 1)" \ + -DINPUT_C_DIGEST="$(sha1sum _input/c/test.tgz | cut -d ' ' -f 1)" \ + -DINPUT_D_DIGEST="$(sha1sum _input/d/test.tgz | cut -d ' ' -f 1)" \ + --bundle test_bundle.tar --unbundle +expect_not_exist dev/src/input/1/workspace/.bob-download + +cleanup +rm -f test_bundle.tar + +expect_fail run_bob dev bundle -j 5 \ + -DINPUT_BASE="$PWD/_input" \ + -DINPUT_A_DIGEST="$(sha1sum _input/a/test.tgz | cut -d ' ' -f 1)" \ + -DINPUT_B_DIGEST="$(sha1sum _input/b/test.tgz | cut -d ' ' -f 1)" \ + -DINPUT_C_DIGEST="$(sha1sum _input/c/test.tgz | cut -d ' ' -f 1)" \ + -DINPUT_D_DIGEST="$(sha1sum _input/d/test.tgz | cut -d ' ' -f 1)" \ + -DTEST_INDETERMINISTIC_INPUT=True \ + --bundle test_bundle.tar