|
| 1 | +#!/usr/bin/sh |
| 2 | + |
| 3 | +. includes/common.sh |
| 4 | + |
| 5 | +httpd_all_clean |
| 6 | +tomcat_all_remove |
| 7 | +MPC_NAME=JBCS-1236 httpd_run |
| 8 | + |
| 9 | +# Start a bunch ($1, or 6 if no argument is given) of tomcat |
| 10 | +# containers, then test them and stop them |
| 11 | +runtomcatbatch() { |
| 12 | + if [ $1 ]; then |
| 13 | + t=$1 |
| 14 | + else |
| 15 | + t=5 # default value when no argument is given |
| 16 | + fi |
| 17 | + |
| 18 | + for i in $(seq $t 10); |
| 19 | + do |
| 20 | + tomcat_start $i 0 |
| 21 | + done |
| 22 | + |
| 23 | + tomcat_count=$(expr 3 + 11 - $t) |
| 24 | + tomcat_wait_for_n_nodes $tomcat_count || clean_and_exit |
| 25 | + for i in $(seq $t 10); |
| 26 | + do |
| 27 | + tomcat_start_webapp $i || clean_and_exit |
| 28 | + done |
| 29 | + |
| 30 | + # test the tomcats |
| 31 | + sleep 20 |
| 32 | + tomcat_all_test_app $tomcat_count |
| 33 | + if [ $? -ne 0 ]; then |
| 34 | + echo "runtomcatbatch tomcat_all_test_app 9 FAILED!" |
| 35 | + clean_and_exit |
| 36 | + fi |
| 37 | + |
| 38 | + # "load test" 9 of them |
| 39 | + tomcat_all_run_ab $tomcat_count |
| 40 | + if [ $? -ne 0 ]; then |
| 41 | + echo "runtomcatbatch tomcat_all_run_ab 9 FAILED!" |
| 42 | + clean_and_exit |
| 43 | + fi |
| 44 | + |
| 45 | + # retest |
| 46 | + tomcat_all_test_app $tomcat_count |
| 47 | + if [ $? -ne 0 ]; then |
| 48 | + echo "runtomcatbatch tomcat_all_test_app 9 FAILED!" |
| 49 | + clean_and_exit |
| 50 | + fi |
| 51 | + |
| 52 | + # stop the tomcats |
| 53 | + for i in $(seq $t 10); |
| 54 | + do |
| 55 | + tomcat_shutdown $i 0 |
| 56 | + done |
| 57 | + |
| 58 | + tomcat_wait_for_n_nodes 3 |
| 59 | + if [ $? -ne 0 ]; then |
| 60 | + echo "runtomcatbatch tomcat_wait_for_n_nodes 3 FAILED!" |
| 61 | + clean_and_exit |
| 62 | + fi |
| 63 | + |
| 64 | + # remove the tomcats |
| 65 | + for i in $(seq $t 10); |
| 66 | + do |
| 67 | + tomcat_remove $i |
| 68 | + done |
| 69 | + echo "runtomcatbatch Done!" |
| 70 | +} |
| 71 | + |
| 72 | +# single tomcat testing |
| 73 | +# we start the tomcat, put the webapp, test it and later stop and clean up |
| 74 | +singlecycle() { |
| 75 | + echo "singlecycle: Testing tomcat$1" |
| 76 | + R=$1 |
| 77 | + if [ "X$2" -eq "Xuseran" ]; then |
| 78 | + R=$(expr 1 + $RANDOM % 10 + 10) |
| 79 | + R=$(expr $R + 2) |
| 80 | + # TODO |
| 81 | + tomcat_start $1 $R || clean_and_exit |
| 82 | + else |
| 83 | + R=0 |
| 84 | + tomcat_start $1 $R || clean_and_exit |
| 85 | + fi |
| 86 | + # Wait for it to start |
| 87 | + echo "Testing(0) tomcat$1 waiting..." |
| 88 | + while true |
| 89 | + do |
| 90 | + curl -s http://localhost:6666/mod_cluster_manager | grep Node | grep tomcat$1 > /dev/null |
| 91 | + if [ $? -eq 0 ]; then |
| 92 | + break |
| 93 | + fi |
| 94 | + sleep 1 |
| 95 | + done |
| 96 | + echo "Testing(0) tomcat$1 started" |
| 97 | + tomcat_start_webapp $1 || clean_and_exit |
| 98 | + echo "Testing(0) tomcat$1 with webapp" |
| 99 | + while true |
| 100 | + do |
| 101 | + curl -s http://localhost:6666/mod_cluster_manager | grep /tomcat$1 > /dev/null |
| 102 | + if [ $? -eq 0 ]; then |
| 103 | + break |
| 104 | + fi |
| 105 | + curl -s http://localhost:6666/mod_cluster_manager | grep /tomcat$1 |
| 106 | + sleep 1 |
| 107 | + done |
| 108 | + echo "Testing(1) tomcat$1" |
| 109 | + tomcat_test_app $1 || clean_and_exit |
| 110 | + echo "Testing(2) tomcat$1" |
| 111 | + tomcat_test_app $1 || clean_and_exit |
| 112 | + tomcat_run_ab $1 || clean_and_exit |
| 113 | + echo "Testing(3) tomcat$1" |
| 114 | + tomcat_shutdown $1 $R || clean_and_exit |
| 115 | + while true |
| 116 | + do |
| 117 | + curl -s http://localhost:6666/mod_cluster_manager | grep Node | grep tomcat$1 > /dev/null |
| 118 | + if [ $? -ne 0 ]; then |
| 119 | + break |
| 120 | + fi |
| 121 | + sleep 1 |
| 122 | + done |
| 123 | + tomcat_remove $1 || clean_and_exit |
| 124 | + echo "singlecycle Done tomcat$1" |
| 125 | +} |
| 126 | + |
| 127 | +# Run neverending testing loop of a single tomcat |
| 128 | +looptomcatforever() { |
| 129 | + while true |
| 130 | + do |
| 131 | + singlecycle $1 || clean_and_exit |
| 132 | + done |
| 133 | +} |
| 134 | + |
| 135 | +# Start a bunch of looping tomcats and kill them after $FOREVER_PAUSE (default is 3600 seconds) |
| 136 | +forevertomcat() { |
| 137 | + (looptomcatforever 12) & |
| 138 | + pid12=$! |
| 139 | + (looptomcatforever 13) & |
| 140 | + pid13=$! |
| 141 | + # wait a little to prevent synchronization |
| 142 | + sleep 5 |
| 143 | + (looptomcatforever 14) & |
| 144 | + pid14=$! |
| 145 | + (looptomcatforever 15) & |
| 146 | + pid15=$! |
| 147 | + (looptomcatforever 16) & |
| 148 | + pid16=$! |
| 149 | + |
| 150 | + sleep ${FOREVER_PAUSE:-3600} |
| 151 | + |
| 152 | + echo "Doing: kill -15 $pid12 $pid13 $pid14 $pid15 $pid16" |
| 153 | + kill -15 $pid12 $pid13 $pid14 $pid15 $pid16 |
| 154 | + if [ $? -ne 0 ]; then |
| 155 | + echo "kill -15 $pid12 $pid13 $pid14 $pid15 $pid16 failed" |
| 156 | + clean_and_exit |
| 157 | + fi |
| 158 | + echo "Tests done, cleaning" |
| 159 | + # stop & remove the containers |
| 160 | + tomcat_remove_by_name tomcat12 |
| 161 | + tomcat_remove_by_name tomcat13 |
| 162 | + tomcat_remove_by_name tomcat14 |
| 163 | + tomcat_remove_by_name tomcat15 |
| 164 | + tomcat_remove_by_name tomcat16 |
| 165 | + sleep 10 |
| 166 | +} |
| 167 | + |
| 168 | +# Start and stop successively (one after another) $1 tomcats |
| 169 | +cyclestomcats() { |
| 170 | + i=1 |
| 171 | + while true |
| 172 | + do |
| 173 | + i=$(expr $i + 1) |
| 174 | + if [ $i -gt $1 ]; then |
| 175 | + echo "Looks OK, Done!" |
| 176 | + break |
| 177 | + fi |
| 178 | + singlecycle $i useran || clean_and_exit |
| 179 | + done |
| 180 | +} |
| 181 | + |
| 182 | +# run test for https://issues.redhat.com/browse/JBCS-1236 |
| 183 | +# basically start and stop random tomcats... |
| 184 | +runjbcs1236() { |
| 185 | + # start 3 tomcats |
| 186 | + tomcat_start 2 0 |
| 187 | + tomcat_start 3 0 |
| 188 | + tomcat_start 4 0 |
| 189 | + tomcat_wait_for_n_nodes 3 || clean_and_exit |
| 190 | + # check them |
| 191 | + tomcat_start_webapp 2 || clean_and_exit |
| 192 | + tomcat_start_webapp 3 || clean_and_exit |
| 193 | + tomcat_start_webapp 4 || clean_and_exit |
| 194 | + sleep 20 |
| 195 | + tomcat_test_app 2 || clean_and_exit |
| 196 | + tomcat_test_app 3 || clean_and_exit |
| 197 | + tomcat_test_app 4 || clean_and_exit |
| 198 | + |
| 199 | + # start a bunch of tomcats, test, shutdown, remove and try in a loop. |
| 200 | + runjbcs1236=0 |
| 201 | + while true |
| 202 | + do |
| 203 | + runjbcs1236=$(expr $runjbcs1236 + 1) |
| 204 | + if [ $runjbcs1236 -gt 2 ]; then |
| 205 | + echo "Looks OK, runjbcs1236 stopping!" |
| 206 | + break |
| 207 | + fi |
| 208 | + # cycle the tomcats |
| 209 | + runtomcatbatch |
| 210 | + |
| 211 | + if [ $? -ne 0 ]; then |
| 212 | + echo "runtomcatbatch: runjbcs1236 Failed!" |
| 213 | + clean_and_exit |
| 214 | + fi |
| 215 | + tomcat_shutdown 2 0 |
| 216 | + |
| 217 | + tomcat_wait_for_n_nodes 2 |
| 218 | + if [ $? -ne 0 ]; then |
| 219 | + echo "tomcat_wait_for_n_nodes 2: runjbcs1236 Failed!" |
| 220 | + clean_and_exit |
| 221 | + fi |
| 222 | + tomcat_remove 2 |
| 223 | + tomcat_start 5 0 |
| 224 | + |
| 225 | + tomcat_wait_for_n_nodes 3 |
| 226 | + if [ $? -ne 0 ]; then |
| 227 | + echo "tomcat_wait_for_n_nodes 3: runjbcs1236 Failed!" |
| 228 | + clean_and_exit |
| 229 | + fi |
| 230 | + tomcat_start_webapp 5 |
| 231 | + if [ $? -ne 0 ]; then |
| 232 | + echo "tomcat_start_webapp 5: runjbcs1236 Failed!" |
| 233 | + clean_and_exit |
| 234 | + fi |
| 235 | + sleep 20 |
| 236 | + tomcat_test_app 5 |
| 237 | + if [ $? -ne 0 ]; then |
| 238 | + echo "tomcat_test_app 5: runjbcs1236 Failed!" |
| 239 | + clean_and_exit |
| 240 | + fi |
| 241 | + # we have 5 3 4 in shared memory |
| 242 | + # read 2 |
| 243 | + tomcat_start 2 0 |
| 244 | + tomcat_wait_for_n_nodes 4 |
| 245 | + if [ $? -ne 0 ]; then |
| 246 | + echo "tomcat_wait_for_n_nodes 4: runjbcs1236 Failed!" |
| 247 | + clean_and_exit |
| 248 | + fi |
| 249 | + tomcat_start_webapp 2 |
| 250 | + if [ $? -ne 0 ]; then |
| 251 | + echo "tomcat_start_webapp 2: runjbcs1236 Failed!" |
| 252 | + clean_and_exit |
| 253 | + fi |
| 254 | + sleep 20 |
| 255 | + tomcat_test_app 2 |
| 256 | + if [ $? -ne 0 ]; then |
| 257 | + echo "tomcat_test_app 2: runjbcs1236 Failed!" |
| 258 | + clean_and_exit |
| 259 | + fi |
| 260 | + |
| 261 | + sleep 20 |
| 262 | + |
| 263 | + # we have 5 3 4 2 in shared memory |
| 264 | + # if something was wrong 2 points to 5 |
| 265 | + tomcat_shutdown 5 0 |
| 266 | + |
| 267 | + tomcat_wait_for_n_nodes 3 |
| 268 | + if [ $? -ne 0 ]; then |
| 269 | + echo "tomcat_wait_for_n_nodes 3: runjbcs1236 Failed!" |
| 270 | + clean_and_exit |
| 271 | + fi |
| 272 | + tomcat_remove 5 |
| 273 | + |
| 274 | + tomcat_test_app 2 |
| 275 | + if [ $? -ne 0 ]; then |
| 276 | + echo "tomcat_test_app 2: runjbcs1236 Failed!" |
| 277 | + clean_and_exit |
| 278 | + fi |
| 279 | + |
| 280 | + tomcat_test_app 3 |
| 281 | + if [ $? -ne 0 ]; then |
| 282 | + echo "tomcat_test_app 3: runjbcs1236 Failed!" |
| 283 | + clean_and_exit |
| 284 | + fi |
| 285 | + |
| 286 | + tomcat_test_app 4 |
| 287 | + if [ $? -ne 0 ]; then |
| 288 | + echo "tomcat_test_app 4: runjbcs1236 Failed!" |
| 289 | + clean_and_exit |
| 290 | + fi |
| 291 | + echo "runjbcs1236 loop: $runjbcs1236 DONE" |
| 292 | + done |
| 293 | + |
| 294 | + # cleanup |
| 295 | + tomcat_shutdown 4 0 |
| 296 | + tomcat_shutdown 3 0 |
| 297 | + tomcat_shutdown 2 0 |
| 298 | + tomcat_wait_for_n_nodes 0 || clean_and_exit |
| 299 | + tomcat_remove 2 |
| 300 | + tomcat_remove 3 |
| 301 | + tomcat_remove 4 |
| 302 | +} |
| 303 | + |
| 304 | +# JBCS-1236 |
| 305 | +echo "Testing JBCS-1236" |
| 306 | +cyclestomcats ${TOMCAT_CYCLE_COUNT:-10} |
| 307 | +if [ $? -ne 0 ]; then |
| 308 | + echo "JBCS-1236 cyclestomcats 100 FAILED!" |
| 309 | + clean_and_exit |
| 310 | +fi |
| 311 | +forevertomcat |
| 312 | +if [ $? -ne 0 ]; then |
| 313 | + echo "JBCS-1236 forevertomcat FAILED!" |
| 314 | + clean_and_exit |
| 315 | +fi |
| 316 | +runjbcs1236 |
| 317 | +if [ $? -ne 0 ]; then |
| 318 | + echo "JBCS-1236 runjbcs1236 FAILED!" |
| 319 | + clean_and_exit |
| 320 | +fi |
| 321 | + |
| 322 | +httpd_shutdown JBCS-1236 |
| 323 | +tomcat_all_remove |
0 commit comments