@@ -20,6 +20,23 @@ test_signal_handler_nomad_job() {
2020 exit 1
2121 fi
2222
23+ # Even though $(nomad job status) reports signal job status as "running"
24+ # The actual container process might not be running yet.
25+ # We need to wait for actual container to start running before trying to send invalid signal.
26+ echo " INFO: Wait for signal container to get into RUNNING state, before trying to send invalid signal."
27+ is_signal_container_active
28+
29+ echo " INFO: Test invalid signal."
30+ alloc_id=$( nomad job status signal| awk ' END{print}' | cut -d ' ' -f 1)
31+ local outfile=$( mktemp /tmp/signal.XXXXXX)
32+ nomad alloc signal -s INVALID $alloc_id >> $outfile 2>&1
33+ if ! grep -q " Invalid signal" $outfile ; then
34+ echo " ERROR: Invalid signal didn't error out."
35+ cleanup " $outfile "
36+ exit 1
37+ fi
38+ cleanup " $outfile "
39+
2340 echo " INFO: Stopping nomad signal handler job."
2441 nomad job stop signal
2542 signal_status=$( nomad job status -short signal| grep Status| awk ' {split($0,a,"="); print a[2]}' | tr -d ' ' )
@@ -33,4 +50,29 @@ test_signal_handler_nomad_job() {
3350 popd
3451}
3552
53+ cleanup () {
54+ local tmpfile=$1
55+ rm $tmpfile > /dev/null 2>&1
56+ }
57+
58+ is_signal_container_active () {
59+ i=" 0"
60+ while test $i -lt 5
61+ do
62+ sudo CONTAINERD_NAMESPACE=nomad ctr task ls| grep -q RUNNING
63+ if [ $? -eq 0 ]; then
64+ echo " INFO: signal container is up and running"
65+ break
66+ fi
67+ echo " INFO: signal container is down, sleep for 4 seconds."
68+ sleep 4s
69+ i=$[$i +1]
70+ done
71+
72+ if [ $i -ge 5 ]; then
73+ echo " ERROR: signal container didn't come up. exit 1."
74+ exit 1
75+ fi
76+ }
77+
3678test_signal_handler_nomad_job
0 commit comments