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 ../../..
39# Run the quickstart code in the background
4- bash ./ quickstart_example.sh 2>&1 &
10+ bash " quickstart_example.sh" 2>&1 &
511quickstart_example_pid=$!
612echo " Spawned example with PID $quickstart_example_pid "
713
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+
824# Wait for it to respond
925# Loop until the command is successful or the maximum number of attempts is reached
1026ret=7
1127attempt_num=0
12- while [[ $ret == 7 ]] && [ $attempt_num -le 50 ]; do
28+ while [[ $ret == 7 ]]; do # && [ $attempt_num -le 50 ]
1329 # Execute the command
1430 ret=0
1531 curl -sf -m 10 http://localhost:5000/counter/counter || ret=$?
@@ -29,22 +45,17 @@ while [[ $ret == 7 ]] && [ $attempt_num -le 50 ]; do
2945done
3046echo " Final return value $ret on attempt $attempt_num "
3147
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-
4448if [[ $ret == 0 ]]; then
4549 echo " Success"
46- exit 0
4750else
4851 echo " Curl returned $ret , likely something went wrong."
4952 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