2022-11-03 14:06:12 +01:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
|
|
|
# Script for running the functional tests in CI, outputting an Istambul coverage
|
|
|
|
# report. When running the intetgration tests locally, it's probably better to
|
2022-12-12 10:28:06 +01:00
|
|
|
# simply run `pnpm functional_tests` directly which will allow e.g. to watch for
|
2022-11-03 14:06:12 +01:00
|
|
|
# changes. This script is intended to handle the complexities of spinning up the
|
|
|
|
# plugin server with the appropriate environment vars setup, and ensuring we
|
|
|
|
# bring down the server such that c8 produces the coverage report.
|
|
|
|
# Context is this was originally written in the GitHub Actions workflow file,
|
|
|
|
# but it's easier to debug in a script.
|
|
|
|
|
2022-12-02 16:45:21 +01:00
|
|
|
set -e -o pipefail
|
2022-11-03 14:06:12 +01:00
|
|
|
|
|
|
|
export WORKER_CONCURRENCY=1
|
|
|
|
export KAFKA_MAX_MESSAGE_BATCH_SIZE=0
|
2023-11-27 19:41:36 +01:00
|
|
|
export APP_METRICS_FLUSH_FREQUENCY_MS=0 # Reduce the potential for spurious errors in tests that wait for metrics
|
2022-11-03 17:37:04 +01:00
|
|
|
export APP_METRICS_GATHERED_FOR_ALL=true
|
2023-11-23 10:46:01 +01:00
|
|
|
export PLUGINS_DEFAULT_LOG_LEVEL=0 # All logs, as debug logs are used in synchronization barriers
|
2023-11-03 12:58:30 +01:00
|
|
|
export NODE_ENV=production-functional-tests
|
2024-07-17 14:11:49 +02:00
|
|
|
export PLUGIN_SERVER_MODE=functional-tests # running all capabilities is too slow
|
2022-11-03 14:06:12 +01:00
|
|
|
|
2022-12-15 17:56:13 +01:00
|
|
|
# Not important at all, but I like to see nice red/green for tests
|
|
|
|
export FORCE_COLOR=true
|
|
|
|
|
2022-11-17 19:32:00 +01:00
|
|
|
LOG_FILE=$(mktemp)
|
|
|
|
|
|
|
|
echo '::group::Starting plugin server'
|
|
|
|
|
2023-08-28 11:44:49 +02:00
|
|
|
NODE_OPTIONS='--max_old_space_size=4096' ./node_modules/.bin/c8 --reporter html node dist/index.js >"$LOG_FILE" 2>&1 &
|
2022-11-03 14:06:12 +01:00
|
|
|
SERVER_PID=$!
|
2023-01-05 20:55:46 +01:00
|
|
|
SECONDS=0
|
2022-11-03 14:06:12 +01:00
|
|
|
|
|
|
|
until curl http://localhost:6738/_ready; do
|
2023-03-08 12:46:56 +01:00
|
|
|
if ((SECONDS > 60)); then
|
2023-01-05 20:55:46 +01:00
|
|
|
echo 'Timed out waiting for plugin-server to be ready'
|
|
|
|
echo '::endgroup::'
|
|
|
|
echo '::group::Plugin Server logs'
|
2023-03-08 12:46:56 +01:00
|
|
|
cat "$LOG_FILE"
|
2023-01-05 20:55:46 +01:00
|
|
|
echo '::endgroup::'
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2022-11-03 14:06:12 +01:00
|
|
|
echo ''
|
|
|
|
echo 'Waiting for plugin-server to be ready...'
|
|
|
|
sleep 1
|
|
|
|
done
|
|
|
|
|
2022-11-17 19:32:00 +01:00
|
|
|
echo ''
|
|
|
|
|
|
|
|
echo '::endgroup::'
|
|
|
|
|
2022-11-03 14:06:12 +01:00
|
|
|
set +e
|
2022-12-12 10:28:06 +01:00
|
|
|
pnpm functional_tests --maxConcurrency=10 --verbose
|
2022-11-03 14:06:12 +01:00
|
|
|
exit_code=$?
|
|
|
|
set -e
|
|
|
|
|
|
|
|
kill $SERVER_PID
|
2023-01-05 20:55:46 +01:00
|
|
|
SECONDS=0
|
2022-11-03 14:06:12 +01:00
|
|
|
|
2022-12-02 16:45:21 +01:00
|
|
|
while kill -0 $SERVER_PID; do
|
2023-03-08 12:46:56 +01:00
|
|
|
if ((SECONDS > 60)); then
|
2023-01-05 20:55:46 +01:00
|
|
|
echo 'Timed out waiting for plugin-server to exit'
|
|
|
|
break
|
|
|
|
fi
|
|
|
|
|
2022-12-02 16:45:21 +01:00
|
|
|
echo "Waiting for plugin-server to exit, pid $SERVER_PID..."
|
|
|
|
sleep 1
|
|
|
|
done
|
|
|
|
|
|
|
|
echo '::group::Plugin Server logs'
|
2023-03-08 12:46:56 +01:00
|
|
|
cat "$LOG_FILE"
|
2022-12-02 16:45:21 +01:00
|
|
|
echo '::endgroup::'
|
2022-11-17 19:32:00 +01:00
|
|
|
|
2022-11-03 14:06:12 +01:00
|
|
|
exit $exit_code
|