-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathintegration_tests.sh
78 lines (63 loc) · 3.11 KB
/
integration_tests.sh
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
#!/bin/bash
set -e
PKGARGS="$*"
rm -rf covdatafiles
mkdir covdatafiles
export GOCOVERDIR=covdatafiles
# Start HTTP server in the background
python3 -m http.server 8000 &
# Store the PID of the server process
SERVER_PID=$!
# Wait for the server to start
# sleep 1
# Send a request to the server
# curl http://localhost:8000
go build -cover $BUILDARGS .
./devprivops schema attack-tree > res.json
cmp res.json schema/schemas/atk-tree-schema.json
./devprivops schema query > res.json
cmp res.json schema/schemas/query-schema.json
./devprivops schema report > res.json
cmp res.json schema/schemas/report_data-schema.json
./devprivops schema requirement > res.json
cmp res.json schema/schemas/requirement-schema.json
rm res.json
cnt=0
diff "test_files/expected_outputs/out_$cnt.txt" <(./devprivops analyse user pass 127.0.0.1 3030 tmp --report-endpoint http://localhost:8000 2>&1)
echo "================== TEST DONE!"
cnt=$((cnt + 1))
diff "test_files/expected_outputs/out_$cnt.txt" <(./devprivops test user pass 127.0.0.1 3030 tmp 2>&1)
echo "================== TEST DONE!"
cnt=$((cnt + 1))
diff "test_files/expected_outputs/out_$cnt.txt" <(./devprivops analyse user pass 127.0.0.1 3030 tmp --local-dir test_files/test_1 2>&1)
echo "================== TEST DONE!"
cnt=$((cnt + 1))
diff "test_files/expected_outputs/out_$cnt.txt" <(./devprivops analyse user pass 127.0.0.1 3030 tmp --local-dir test_files/test_2 2>&1)
echo "================== TEST DONE!"
cnt=$((cnt + 1))
diff "test_files/expected_outputs/out_$cnt.txt" <(./devprivops analyse user pass 127.0.0.1 3030 tmp --local-dir test_files/test_3 2>&1)
echo "================== TEST DONE!"
cnt=$((cnt + 1))
diff "test_files/expected_outputs/out_$cnt.txt" <(./devprivops analyse user pass 127.0.0.1 3030 tmp --local-dir test_files/test_4 2>&1)
echo "================== TEST DONE!"
cnt=$((cnt + 1))
diff "test_files/expected_outputs/out_$cnt.txt" <(./devprivops analyse user pass 127.0.0.1 3030 tmp --local-dir test_files/test_5 2>&1)
echo "================== TEST DONE!"
cnt=$((cnt + 1))
diff "test_files/expected_outputs/out_$cnt.txt" <(./devprivops analyse user pass 127.0.0.1 3030 tmp --local-dir test_files/test_6 2>&1)
echo "================== TEST DONE!"
cnt=$((cnt + 1))
diff "test_files/expected_outputs/out_$cnt.txt" <(./devprivops analyse user pass 127.0.0.1 3030 tmp --local-dir test_files/test_7 2>&1)
echo "================== TEST DONE!"
cnt=$((cnt + 1))
diff "test_files/expected_outputs/out_$cnt.txt" <(./devprivops test user pass 127.0.0.1 3030 tmp --local-dir test_files/test_7 2>&1)
echo "================== TEST DONE!"
cnt=$((cnt + 1))
# diff <(grep -vE "$timestamp_regex" "test_files/expected_outputs/out_$cnt.txt") <(./devprivops test user pass 127.0.0.1 3030 tmp --pipeline --local-dir test_files/test_7 2>&1 | grep -vE "$timestamp_regex")
diff <(sed 's/time=[^ ]* //g' "test_files/expected_outputs/out_$cnt.txt") <(./devprivops test user pass 127.0.0.1 3030 tmp --pipeline --local-dir test_files/test_7 2>&1 | sed 's/time=[^ ]* //g')
echo "================== TEST DONE!"
# Close the server
kill $SERVER_PID
rm devprivops
go tool covdata percent -i=covdatafiles
# go tool covdata func -i=covdatafiles