-
Notifications
You must be signed in to change notification settings - Fork 1
/
launch-tests.sh
executable file
·113 lines (89 loc) · 2.94 KB
/
launch-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
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
113
#!/bin/bash
# https://stackoverflow.com/questions/63982271/start-server-in-background-run-code-and-stop-server-again-in-single-script
start_servers() {
echo "Start servers ..."
echo "Start net-io-bound-processing-server"
./bin/net-io-bound-processing-server -sleep 100 -port 8080 &
server_1_pid=$!
# wait for the messages produced by the ./bin/net-io-bound-processing-server to be printed before continuing
sleep 0.1
echo
# Wait for the server to start (max 10 seconds)
for attempt in {1..10}; do
my_pid=$(lsof -t -i tcp:8080)
if [[ -n $my_pid ]]; then
# Make sure the running server is the one we just started.
if [[ $my_pid -ne $server_1_pid ]]; then
echo "ERROR: Multiple Servers running."
echo "Kill the other server with the command"
echo "lsof -t -i tcp:8080 | xargs kill"
echo "and then launch again this program"
exit 1
fi
break
fi
sleep 1
done
if [[ -z $my_pid ]]; then
echo "ERROR: Timeout while waiting for Server to start"
exit 1
fi
echo "Start interfaces/reader-writer/server/"
./bin/reader-writer-server &
server_2_pid=$!
# wait for the messages produced by the ./bin/net-io-bound-processing-server to be printed before continuing
sleep 0.1
echo
# Wait for the server to start (max 10 seconds)
for attempt in {1..10}; do
my_pid=$(lsof -t -i tcp:8081)
if [[ -n $my_pid ]]; then
# Make sure the running server is the one we just started.
if [[ $my_pid -ne $server_2_pid ]]; then
echo "ERROR: Multiple Servers running."
echo "Kill the other server with the command"
echo "lsof -t -i tcp:8081 | xargs kill"
echo "and then launch again this program"
exit 1
fi
break
fi
sleep 1
done
if [[ -z $my_pid ]]; then
echo "ERROR: Timeout while waiting for Server to start"
exit 1
fi
}
stop_servers() {
echo "Stop Servers ..."
kill $server_1_pid
kill $server_2_pid
}
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
go build -o ./bin/net-io-bound-processing-server ./src/goroutines/io-bound-processing/net-io/server
go build -o ./bin/reader-writer-server ./src/interfaces/reader-writer/server
# create the directories used for the tests
mkdir out
mkdir out/local
start_servers
printf "\n run the tests \n\n"
# -count=1 forces to run also the cached tests
go test ./... -count=1
testExit=$?
# if [ "$testExit" -eq 0 ]; then
# echo "There are test failures!"
# else
# echo "There are test failures!"
# fi
# echo ">>>>>>"
# echo "$T1"
# echo "$?"
# RETVAL=$?
# if [[ ${RETVAL} != 0 ]]; then
# echo "There are test failures!"
# else
# echo "All tests passed"
# fi
stop_servers
exit $testExit