forked from wl-buildingtools/nightfall
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnightfall-test
More file actions
executable file
·98 lines (75 loc) · 2.72 KB
/
nightfall-test
File metadata and controls
executable file
·98 lines (75 loc) · 2.72 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
#!/bin/bash
set -e
GREEN='\033[0;32m'
RED='\033[0;31m'
NC='\033[0m'
dir="$(pwd)"
declare isTestPassed=true
systemInfo="$(uname -s)"
case "${systemInfo}" in
Linux*) machine=Linux;;
Darwin*) machine=Mac;;
CYGWIN*) machine=Cygwin;;
MINGW*) machine=MinGw;;
*) machine="UNKNOWN:${systemInfo}"
esac
printf "${GREEN}*** Cleaning up all test containers ***${NC}\n"
docker-compose -f docker-compose.test.yml down -v || true
printf "${GREEN}*** Build image for all Containers ***${NC}\n"
docker-compose -f docker-compose.test.yml build
printf "${GREEN}*** Pull zokrates docker image ***${NC}\n"
docker pull zokrates/zokrates:0.4.11
printf "${GREEN}*** Install node modules dependencies of nightfall ***${NC}\n"
npm ci
printf "${GREEN}*** Installing zkp-util dependencies"
pushd zkp-utils
npm ci
popd
printf "${GREEN}*** Launching containerized ganache-test ***${NC}\n"
docker-compose -f docker-compose.test.yml up -d ganache_test
printf "${GREEN}*** Deploying all contracts ***${NC}\n"
make offchain-test-migrate
printf "${GREEN}*** Launching containerized microservices ***${NC}\n"
docker-compose -f docker-compose.test.yml up -d
# Create a child Terminal to see docker log, while running testcases.
if [ "${machine}" == "Mac" ]; then
childTab=$(osascript -e "
tell application \"Terminal\"
set currentTab to do script \"cd $dir\"
delay 2
do script \"docker-compose -f docker-compose.test.yml logs -f\" in currentTab
end tell")
fi
# delay needed to ensure all container are in running state.
sleep 30
# save all test logs to a file in background
printf "${GREEN}*** Saving the test logs to nightfall_test.log file ***${NC}\n"
docker-compose -f docker-compose.test.yml logs -f &> nightfall_test.log &disown
# RUN test suits and remove test containers
printf "${GREEN}*** Run Integration test ***${NC}\n"
npm run test || {
isTestPassed=false
printf "${RED}*** Integration test failed ***${NC}\n"
}
printf "${GREEN}*** Cleaning up all test containers ***${NC}\n"
docker-compose -f docker-compose.test.yml down -v || {
# delay need as waiting time so all container are properly done
# nightfall_test_net network have no dependency left.
sleep 3
printf "${GREEN}*** Remove network ***${NC}\n"
docker network rm nightfall_test_net
printf "${GREEN}*** Remove mongo volume ***${NC}\n"
docker volume rm nightfall_mongo_volume_test
printf "${GREEN}*** Remove zkp-code volume ***${NC}\n"
docker volume rm nightfall_zkp_code_test
}
# Stop child terminal if all testcases passed.
if [ "${machine}" == "Mac" ] && [ "${isTestPassed}" == "true" ]; then
osascript -e "
tell application \"Terminal\"
do script \"exit\" in $childTab
end tell"
fi
if [ "${isTestPassed}" == "false" ]; then
exit 1
fi