55httpd_remove
66tomcat_all_remove
77
8+ tomcat_jdbsuspend_prepare () {
9+ # Create files we need
10+ docker exec -i tomcat$1 sh -c ' echo cont > continue.txt; echo exit >> continue.txt'
11+ docker exec -i tomcat$1 sh -c ' echo suspend all > hang.txt; echo exit >> hang.txt'
12+ docker exec -i tomcat$1 sh -c ' jdb -attach 6660 < continue.txt'
13+ }
814
915# This should suspend the tomcat for ~ 1000 seconds ~ causing it gets removed afterwhile.
10- jdbsuspend () {
11- rm -f /tmp/testpipein
12- mkfifo /tmp/testpipein
13- rm -f /tmp/testpipeout
14- mkfifo /tmp/testpipeout
15- sleep 1000 > /tmp/testpipein &
16- jdb -attach 6660 < /tmp/testpipein > /tmp/testpipeout &
17- echo " suspend" > /tmp/testpipein
18- cat < /tmp/testpipeout &
16+ tomcat_jdbsuspend_start () {
17+ # suspend
18+ docker exec -i tomcat$1 sh -c ' rm -f /tmp/testpipein'
19+ docker exec -i tomcat$1 sh -c ' mkfifo /tmp/testpipein'
20+ docker exec -i tomcat$1 sh -c ' rm -f /tmp/testpipeout'
21+ docker exec -i tomcat$1 sh -c ' mkfifo /tmp/testpipeout'
22+ docker exec -i tomcat$1 sh -c ' sleep 1000 > /tmp/testpipein &'
23+ docker exec -i tomcat$1 sh -c ' jdb -attach 6660 < /tmp/testpipein > /tmp/testpipeout &'
24+ docker exec -i tomcat$1 sh -c ' echo "suspend" > /tmp/testpipein'
25+ docker exec -i tomcat$1 sh -c ' cat < /tmp/testpipeout &'
1926}
2027
21- jdbexit () {
22- cat > /tmp/testpipeout &
23- echo " exit" > /tmp/testpipein
28+ tomcat_jdbsuspend_exit () {
29+ docker exec -i tomcat $1 sh -c ' cat > /tmp/testpipeout &'
30+ docker exec -i tomcat $1 sh -c ' echo "exit" > /tmp/testpipein'
2431}
2532
2633# ###################################
2734# ## S T A R T T E S T S ###
2835# ###################################
2936httpd_start
3037
31- # Create files we need
32- cat << EOF > continue.txt
33- cont
34- exit
35- EOF
36- cat << EOF > hang.txt
37- suspend all
38- exit
39- EOF
40-
4138# Check that hanging tomcat will be removed
4239echo " hanging a tomcat checking it is removed after a while no requests"
4340tomcat_start_two
@@ -46,58 +43,59 @@ tomcat_wait_for_n_nodes 2 || exit 1
4643# curlloop.sh checks for http://localhost:8090/testapp/test.jsp
4744docker cp testapp tomcat1:/usr/local/tomcat/webapps
4845docker cp testapp tomcat2:/usr/local/tomcat/webapps
49-
5046docker cp setenv.sh tomcat1:/usr/local/tomcat/bin
47+
5148docker commit tomcat1 ${IMG} -debug
5249tomcat_remove 1
5350tomcat_wait_for_n_nodes 1
5451# Start the node.
5552IMG=${IMG} -debug tomcat_start 1
5653sleep 10
57- docker exec tomcat1 jdb -attach 6660 < continue.txt
54+ tomcat_jdbsuspend_prepare 1
5855tomcat_wait_for_n_nodes 2 || exit 1
5956echo " 2 tomcat started"
6057# Hang the node,
6158# jdb and a pipe to hang the tomcat.
62- jdbsuspend
59+ tomcat_jdbsuspend_start 1
6360tomcat_wait_for_n_nodes 1 || exit 1
6461echo " 1 tomcat hanging and gone"
65- jdbexit
62+ tomcat_jdbsuspend_exit 1
6663# The tomcat is comming up again
6764tomcat_wait_for_n_nodes 2 || exit 1
6865echo " the tomcat is back"
6966
7067# Same test with requests, make them in a loop
7168echo " hanging tomcat removed after a while with requests"
7269sh curlloop.sh 200 000 &
73- jdbsuspend
70+ tomcat_jdbsuspend_start 1
7471tomcat_wait_for_n_nodes 1 || exit 1
7572ps -ef | grep curlloop | grep -v grep
7673if [ $? -ne 0 ]; then
7774 echo " curlloop.sh FAILED!"
7875 exit 1
7976fi
8077ps -ef | grep curlloop | grep -v grep | awk ' { print $2 } ' | xargs kill
81- jdbexit
78+ tomcat_jdbsuspend_exit 1
8279# The tomcat is comming up again
8380tomcat_wait_for_n_nodes 2 || exit 1
8481
8582# Same test with requets but stop the other tomcat
8683echo " single hanging tomcat removed after a while with requests"
87- tomcat_remove 2
84+ # kill because we want to keep it in the DNS records
85+ tomcat_kill 2
8886tomcat_wait_for_n_nodes 1 || exit 1
89- jdbsuspend
87+ tomcat_jdbsuspend_start 1
9088sleep 10
9189sh curlloop.sh 000 404 503 &
92- tomcat_wait_for_n_nodes 0 || exit 1
90+ tomcat_wait_for_n_nodes 0 || exit 1
9391ps -ef | grep curlloop | grep -v grep
9492if [ $? -ne 0 ]; then
9593 echo " curlloop.sh FAILED!"
9694 exit 1
9795fi
9896ps -ef | grep curlloop | grep -v grep | awk ' { print $2 } ' | xargs kill
99- jdbexit
100- # The tomcat is comming up again
97+ tomcat_jdbsuspend_exit 1
98+ # The tomcat is coming up again
10199tomcat_wait_for_n_nodes 1 || exit 1
102100
103101# Cleanup at the end
0 commit comments