Skip to content

Commit

Permalink
test: add bundle blackbox test
Browse files Browse the repository at this point in the history
  • Loading branch information
rhubert committed Jan 14, 2025
1 parent 6dbf755 commit 198136b
Show file tree
Hide file tree
Showing 5 changed files with 128 additions and 0 deletions.
2 changes: 2 additions & 0 deletions test/black-box/bundle/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
_input/
test_bundle.tar
1 change: 1 addition & 0 deletions test/black-box/bundle/config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
bobMinimumVersion: "0.25.1.dev43"
19 changes: 19 additions & 0 deletions test/black-box/bundle/recipes/bundle.yaml
Original file line number Diff line number Diff line change
@@ -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
34 changes: 34 additions & 0 deletions test/black-box/bundle/recipes/input.yaml
Original file line number Diff line number Diff line change
@@ -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
72 changes: 72 additions & 0 deletions test/black-box/bundle/run.sh
Original file line number Diff line number Diff line change
@@ -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/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/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

0 comments on commit 198136b

Please sign in to comment.