diff --git a/test/e2e/tests/bup_test_whales.sh b/test/e2e/tests/bup_test_whales.sh deleted file mode 100755 index 2b8b4611..00000000 --- a/test/e2e/tests/bup_test_whales.sh +++ /dev/null @@ -1,70 +0,0 @@ -#!/usr/bin/env bash - -# Tests the whale examples in the examples/whales directory - -set -euo pipefail - -WHALES_DIR=$(dirname $0)/../../../examples/whales -BINARY_ENV_VERSION=latest - -# TODO move to util file -# retry function adapted from: -# https://unix.stackexchange.com/questions/82598/how-do-i-write-a-retry-logic-in-script-to-keep-retrying-to-run-it-upto-5-times/82610 -function retry { - local n=1 - local max=5 - local delay=5 - while true; do - "$@" && break || { - if [[ ${n} -lt ${max} ]]; then - ((n++)) - echo "Command '$@' failed. Attempt $n/$max:" - sleep ${delay}; - else - >&2 echo "The command has failed after $n attempts." - exit 1; - fi - } - done -} - -# Deploy required functions and environments -echo "Deploying required fission functions and environments..." -fission env create --name binary --image fission/binary-env:${BINARY_ENV_VERSION} -fission fn create --name whalesay --env binary --deploy ${WHALES_DIR}/whalesay.sh -fission fn create --name fortune --env binary --deploy ${WHALES_DIR}/fortune.sh - -# Ensure that functions are available -retry curl ${FISSION_ROUTER}/fission-function/fortune - -# test 1: fortunewhale - simplest example -echo "Test 1: fortunewhale" -fission fn create --name fortunewhale --env workflow --src ${WHALES_DIR}/fortunewhale.wf.yaml -sleep 5 # TODO remove this once we can initiate synchronous commands -curl -sL ${FISSION_ROUTER}/fission-function/fortunewhale | tee /dev/tty | grep "## ## ## ## ##" - -# test 2: echowhale - parses body input -echo "Test 2: echowhale" -fission fn create --name echowhale --env workflow --src ${WHALES_DIR}/echowhale.wf.yaml -sleep 5 # TODO remove this once we can initiate synchronous commands -curl -sL -d "Test plz ignore" ${FISSION_ROUTER}/fission-function/echowhale | tee /dev/tty | grep "Test plz ignore" - -# test 3: metadata - parses metadata (headers, query params...) -echo "Test 3: metadata" -fission fn create --name metadatawhale --env workflow --src ${WHALES_DIR}/metadatawhale.wf.yaml -sleep 5 # TODO remove this once we can initiate synchronous commands -curl -sL -H "Prefix: The test says:" ${FISSION_ROUTER}/fission-function/metadatawhale | tee /dev/tty | grep "Prefix: The test says:" - -# Test 4: nestedwhale - shows nesting workflows -echo "Test 4: nestedwhale" -fission fn create --name nestedwhale --env workflow --src ${WHALES_DIR}/nestedwhale.wf.yaml -sleep 5 # TODO remove this once we can initiate synchronous commands -curl -sL ${FISSION_ROUTER}/fission-function/nestedwhale | tee /dev/tty | grep "## ## ## ## ##" - -# Test 5: maybewhale - shows of dynamic tasks -echo "Test 5: maybewhale" -fission fn create --name maybewhale --env workflow --src ${WHALES_DIR}/maybewhale.wf.yaml -sleep 5 # TODO remove this once we can initiate synchronous commands -curl -sL ${FISSION_ROUTER}/fission-function/maybewhale | tee /dev/tty | grep "## ## ## ## ##" - -# TODO cleanup \ No newline at end of file diff --git a/test/e2e/tests/test_example_inputs.sh b/test/e2e/tests/test_example_inputs.sh index db5b14ee..0bd2b7cf 100755 --- a/test/e2e/tests/test_example_inputs.sh +++ b/test/e2e/tests/test_example_inputs.sh @@ -11,4 +11,9 @@ trap cleanup EXIT fission fn create --name inputs --env workflow --src ${EXAMPLE_DIR}/inputs.wf.yaml sleep 5 # TODO remove this once we can initiate synchronous commands -fission fn test --name inputs -b 'foobar' -H 'HEADER_KEY: HEADER_VAL' --method PUT | grep HEADER_KEY | grep HEADER_VAL | grep PUT | grep foobar \ No newline at end of file +fission fn test --name inputs -b 'foobar' -H 'HEADER_KEY: HEADER_VAL' --method PUT \ + | tee /dev/tty \ + | grep -i Header_Val \ + | grep HEADER_VAL \ + | grep -i PUT \ + | grep -q foobar \ No newline at end of file diff --git a/test/e2e/tests/test_example_sleepalot.sh b/test/e2e/tests/test_example_sleepalot.sh deleted file mode 100755 index 59b8de94..00000000 --- a/test/e2e/tests/test_example_sleepalot.sh +++ /dev/null @@ -1,14 +0,0 @@ -#!/usr/bin/env bash - -set -euo pipefail - -EXAMPLE_DIR=$(dirname $0)/../../../examples/misc - -cleanup() { - fission fn delete --name sleepalot -} -trap cleanup EXIT - -fission fn create --name sleepalot --env workflow --src ${EXAMPLE_DIR}/sleepalot.wf.yaml -sleep 5 # TODO remove this once we can initiate synchronous commands -fission fn test --name sleepalot \ No newline at end of file diff --git a/test/e2e/tests/test_whales.sh b/test/e2e/tests/test_whales.sh new file mode 100755 index 00000000..e80d5b12 --- /dev/null +++ b/test/e2e/tests/test_whales.sh @@ -0,0 +1,119 @@ +#!/usr/bin/env bash + +# Tests the whale examples in the examples/whales directory + +set -euo pipefail + +WHALES_DIR=$(dirname $0)/../../../examples/whales +BINARY_ENV_VERSION=latest + +# TODO move to util file +# retry function adapted from: +# https://unix.stackexchange.com/questions/82598/how-do-i-write-a-retry-logic-in-script-to-keep-retrying-to-run-it-upto-5-times/82610 +function retry { + local n=1 + local max=5 + local delay=5 + while true; do + "$@" && break || { + if [[ ${n} -lt ${max} ]]; then + ((n++)) + echo "Command '$@' failed. Attempt $n/$max:" + sleep ${delay}; + else + >&2 echo "The command has failed after $n attempts." + exit 1; + fi + } + done +} + +cleanup() { + echo "cleaning up..." + set +e + fission fn delete --name whalesay + fission fn delete --name fortune + fission fn delete --name fortunewhale + fission fn delete --name echowhale + fission fn delete --name metadatawhale + fission fn delete --name nestedwhale + fission fn delete --name maybewhale + fission fn delete --name failwhale + fission fn delete --name foreachwhale + fission fn delete --name switchwhale + fission fn delete --name whilewhale + fission fn delete --name httpwhale + fission fn delete --name scopedwhale +} +trap cleanup EXIT + +# Deploy required functions and environments +echo "Deploying required fission functions and environments..." +fission env create --name binary --image fission/binary-env:${BINARY_ENV_VERSION} || true +fission fn create --name whalesay --env binary --deploy ${WHALES_DIR}/whalesay.sh +fission fn create --name fortune --env binary --deploy ${WHALES_DIR}/fortune.sh + +# Ensure that functions are available +retry fission fn test --name fortune + +# test 1: fortunewhale - simplest example +echo "[Test 1]: fortunewhale" +fission fn create --name fortunewhale --env workflow --src ${WHALES_DIR}/fortunewhale.wf.yaml +sleep 5 # TODO remove this once we can initiate synchronous commands +fission fn test --name fortunewhale | tee /dev/tty | grep -q "## ## ## ## ##" + +# test 2: echowhale - parses body input +echo "[Test 2]: echowhale" +fission fn create --name echowhale --env workflow --src ${WHALES_DIR}/echowhale.wf.yaml +sleep 5 # TODO remove this once we can initiate synchronous commands +fission fn test --name echowhale -b "Test plz ignore" | tee /dev/tty | grep -q "Test plz ignore" + +# test 3: metadata - parses metadata (headers, query params...) +echo "[Test 3]: metadatawhale" +fission fn create --name metadatawhale --env workflow --src ${WHALES_DIR}/metadatawhale.wf.yaml +sleep 5 # TODO remove this once we can initiate synchronous commands +fission fn test --name metadatawhale -H "Prefix: The test says:" | tee /dev/tty | grep -q "The test says:" + +# Test 4: nestedwhale - shows nesting workflows +echo "[Test 4]: nestedwhale" +fission fn create --name nestedwhale --env workflow --src ${WHALES_DIR}/nestedwhale.wf.yaml +sleep 5 # TODO remove this once we can initiate synchronous commands +fission fn test --name nestedwhale | tee /dev/tty | grep -q "## ## ## ## ##" + +# Test 5: maybewhale - shows of dynamic tasks +echo "[Test 5]: maybewhale" +fission fn create --name maybewhale --env workflow --src ${WHALES_DIR}/maybewhale.wf.yaml +sleep 5 # TODO remove this once we can initiate synchronous commands +fission fn test --name maybewhale | tee /dev/tty | grep -q "## ## ## ## ##" + +echo "[Test 6]: failwhale" +fission fn create --name failwhale --env workflow --src ${WHALES_DIR}/failwhale.wf.yaml +sleep 5 # TODO remove this once we can initiate synchronous commands +fission fn test --name failwhale | tee /dev/tty | grep -q "all has failed" + +echo "[Test 7]: foreachwhale" +fission fn create --name foreachwhale --env workflow --src ${WHALES_DIR}/foreachwhale.wf.yaml +sleep 5 # TODO remove this once we can initiate synchronous commands +fission fn test --name foreachwhale | tee /dev/tty | grep -q "[10,20,30,40,50]" + +echo "[Test 8]: switchwhale" +fission fn create --name switchwhale --env workflow --src ${WHALES_DIR}/switchwhale.wf.yaml +sleep 5 # TODO remove this once we can initiate synchronous commands +fission fn test --name switchwhale -b 'hello' | tee /dev/tty | grep -q "world" +fission fn test --name switchwhale -b 'foo' | tee /dev/tty | grep -q "bar" +fission fn test --name switchwhale -b 'acme' | tee /dev/tty | grep -q "right..." + +echo "[Test 9]: whilewhale" +fission fn create --name whilewhale --env workflow --src ${WHALES_DIR}/whilewhale.wf.yaml +sleep 5 # TODO remove this once we can initiate synchronous commands +fission fn test --name whilewhale | tee /dev/tty | grep "5" + +echo "[Test 10]: httpwhale" +fission fn create --name httpwhale --env workflow --src ${WHALES_DIR}/httpwhale.wf.yaml +sleep 5 # TODO remove this once we can initiate synchronous commands +fission fn test --name httpwhale | tee /dev/tty | grep -q "## ## ## ## ##" + +echo "[Test 11]: scopedwhale" +fission fn create --name scopedwhale --env workflow --src ${WHALES_DIR}/scopedwhale.wf.yaml +sleep 5 # TODO remove this once we can initiate synchronous commands +fission fn test --name scopedwhale | tee /dev/tty | grep -q "## ## ## ## ##" \ No newline at end of file