-
Notifications
You must be signed in to change notification settings - Fork 19
Expand file tree
/
Copy pathtest.sh
More file actions
executable file
·112 lines (92 loc) · 2.6 KB
/
test.sh
File metadata and controls
executable file
·112 lines (92 loc) · 2.6 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
103
104
105
106
107
108
109
110
111
112
set -euo pipefail
# Build the npm package
cd ..
for d in packages/*; do
echo "Building $d"
cd $d
# Legacy peer deps will allow us to ignore the unmet peer dependency warning for build-tools, which is not needed for building the packages themselves.
# We only need it when we build apps that consume said packages.
npm install --legacy-peer-deps
npm audit
npm run build
cd -
done
cd test
isFailed=false
# Build test app
echo "Building the test app"
cd test-app
npm install
spin build
echo "built the test app successfully"
# Start the spin app in the background
echo "Starting Spin app"
spin up &
# wait for app to be up and running
echo "Waiting for Spin app to be ready"
timeout 60s bash -c 'until curl --silent -f http://localhost:3000/health > /dev/null; do sleep 2; done'
# start the test
echo "Starting test\n"
curl -f http://localhost:3000/testFunctionality || isFailed=true
echo "\n\nTest completed"
# kill the spin app
echo "Stopping Spin"
killall spin
if [ "$isFailed" = true ] ; then
echo "Some tests failed"
exit 1
fi
# return back to test folder
cd ..
# Test the no regex precompile
cd test-empty-precompile
spin build
spin up &
echo "Teting app with no regex to precompile"
if ! timeout 60s bash -c '
until status=$(curl -s -o /dev/null -w "%{http_code}" http://localhost:3000/health) && [ "$status" -eq 200 ]; do
echo "Current status: $status, waiting..."
sleep 2
done
'; then
echo "Spin app did not return HTTP 200 in 60 seconds"
exit 1
fi
killall spin
# Test the AOT compilation
cd ../aot-test
spin build
spin up &
echo "Testing app with AOT compilation"
if ! timeout 60s bash -c '
until status=$(curl -s -o /dev/null -w "%{http_code}" http://localhost:3000/.well-known/spin/health) && [ "$status" -eq 200 ]; do
echo "Current status: $status, waiting..."
sleep 2
done
'; then
echo "Spin app did not return HTTP 200 in 60 seconds"
exit 1
fi
# test the fibonacci function for 32
response=$(curl -s http://localhost:3000/fibonacci/32)
echo "Fibonacci(32) = $response"
killall spin
# Test the component dependencies
cd ../deps-test
npm install
npm run build-dependency-component
spin build
spin up &
echo "Testing component dependencies"
if ! timeout 60s bash -c '
until status=$(curl -s -o /dev/null -w "%{http_code}" http://localhost:3000/.well-known/spin/health) && [ "$status" -eq 200 ]; do
echo "Current status: $status, waiting..."
sleep 2
done
'; then
echo "Spin app did not return HTTP 200 in 60 seconds"
exit 1
fi
response=$(curl -s http://localhost:3000/)
echo "Response from component with dependencies: $response"
killall spin