-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathintegrationTestRunner.sh
More file actions
executable file
·103 lines (84 loc) · 2.65 KB
/
integrationTestRunner.sh
File metadata and controls
executable file
·103 lines (84 loc) · 2.65 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
#! /usr/bin/env bash
# Test runner script for running both desci-server and nodes-lib tests
# This script orchestrates the test infrastructure and runs tests sequentially
set -e # Exit on error
cleanup() {
echo "🧹 cleaning up..."
cd "$(git rev-parse --show-toplevel)"
docker compose -f docker-compose.test.yml stop || true
}
logs_or_notice() {
if [ -n "$GITHUB_ACTIONS" ]; then
echo "::group::Full compose logs"
echo "note: sync worker logs are hidden"
docker compose -f docker-compose.test.yml logs | grep -v "nodes_sync_test_worker"
echo "::endgroup::"
else
echo "🔎 Check logs with 'docker compose -f docker-compose.test.yml logs [container]'"
fi
}
# shellcheck disable=SC2329
handle_error() {
echo "💥 test runner failed"
logs_or_notice
cleanup
exit 1
}
trap handle_error ERR
# Cleanup old containers
docker compose -f docker-compose.test.yml down
# 0. Build all images, utilising cache
echo "🔨 Building test cluster images..."
docker compose -f docker-compose.test.yml build
echo "⚒️ Starting test infrastructure..."
# 1. Start infrastructure services, blocking until healthy
docker compose -f docker-compose.test.yml up \
--remove-orphans \
--wait \
--wait-timeout 120 \
nodes_test_db \
nodes_test_sync_service \
nodes_test_ipfs \
dpid_resolver_test
if [ "$SKIP_SERVER" != "1" ]; then
# 2. Run desci-server tests
echo "🤞 Running desci-server tests..."
if ! docker compose -f docker-compose.test.yml run nodes_backend_test; then
echo "❌ desci-server tests failed!"
logs_or_notice
cleanup
exit 1
fi
echo "✅ desci-server tests passed"
else
echo "👀 skipping desci-server tests"
fi
if [ "$SKIP_NODES_LIB" != "1" ]; then
# 3. Bring the backend back up, in server mode
RUN_SERVER=1 docker compose -f docker-compose.test.yml up \
--remove-orphans \
--wait \
--wait-timeout 600 \
nodes_backend_test \
test_blockchain \
ceramic_one_test
if [ -z "$GITHUB_ACTIONS" ]; then
CERAMIC_ADMIN_SEED=$(grep "CERAMIC_ADMIN_SEED" .env | cut -d"=" -f2)
fi
CERAMIC_ONE_RPC_URL="http://localhost:5101" PRIVATE_KEY="$CERAMIC_ADMIN_SEED" npx --yes @desci-labs/desci-codex-models deploy
CERAMIC_ONE_RPC_URL="http://localhost:5101" npx --yes @desci-labs/desci-codex-models register
# 4. Run nodes-lib tests
echo "🤞 Running nodes-lib tests..."
if ! RUN_SERVER=1 docker compose -f docker-compose.test.yml run nodes_lib_test; then
echo "❌ nodes-lib tests failed!"
logs_or_notice
cleanup
exit 1
fi
echo "✅ nodes-lib tests passed"
else
echo "👀 skipping nodes-lib tests"
fi
# 5. Cleanup
cleanup
echo "🎊 All tests passed successfully!"