1
- set -e
2
-
1
+ # cd to this directory
2
+ cd " ${BASH_SOURCE%/* } /"
3
+ rm -rf .venv
4
+ # Override the virtual environment so we use the package
5
+ # from this repo, not from pypi
6
+ python -m venv .venv
7
+ source .venv/bin/activate
8
+ pip install ../../..
3
9
# Run the quickstart code in the background
4
- bash ./ quickstart_example.sh 2>&1 &
10
+ bash " quickstart_example.sh" 2>&1 &
5
11
quickstart_example_pid=$!
6
12
echo " Spawned example with PID $quickstart_example_pid "
7
13
14
+ function killserver {
15
+ # Stop the server that we spawned.
16
+ children=$( ps -o pid= --ppid " $quickstart_example_pid " )
17
+ kill $children
18
+ echo " Killed spawned processes: $children "
19
+
20
+ wait
21
+ }
22
+ trap killserver EXIT
23
+
8
24
# Wait for it to respond
9
25
# Loop until the command is successful or the maximum number of attempts is reached
10
26
ret=7
11
27
attempt_num=0
12
- while [[ $ret == 7 ]] && [ $attempt_num -le 50 ]; do
28
+ while [[ $ret == 7 ]]; do # && [ $attempt_num -le 50 ]
13
29
# Execute the command
14
30
ret=0
15
31
curl -sf -m 10 http://localhost:5000/counter/counter || ret=$?
@@ -29,22 +45,17 @@ while [[ $ret == 7 ]] && [ $attempt_num -le 50 ]; do
29
45
done
30
46
echo " Final return value $ret on attempt $attempt_num "
31
47
32
- # Check the Python client code
33
- echo " Running Python client code"
34
- (. .venv/bin/activate && python counter_client.py)
35
-
36
-
37
- # Get the spawned server's PID
38
- children=$( ps -o pid= --ppid " $quickstart_example_pid " )
39
- kill $children
40
- echo " Killed spawned processes: $children "
41
-
42
- wait
43
-
44
48
if [[ $ret == 0 ]]; then
45
49
echo " Success"
46
- exit 0
47
50
else
48
51
echo " Curl returned $ret , likely something went wrong."
49
52
exit -1
50
- fi
53
+ fi
54
+
55
+ # Check the Python client code
56
+ echo " Running Python client code"
57
+ (source .venv/bin/activate && python counter_client.py)
58
+ if [[ $? != 0 ]]; then
59
+ echo " Python client code did not run OK."
60
+ exit -1
61
+ fi
0 commit comments