Back to home page

Enduro/X

 
 

    


0001 #!/bin/bash
0002 ##
0003 ## @brief Test process groups - test launcher
0004 ##  Validate process group operations. Invluding configuration checking
0005 ##
0006 ## @file run.sh
0007 ##
0008 ## -----------------------------------------------------------------------------
0009 ## Enduro/X Middleware Platform for Distributed Transaction Processing
0010 ## Copyright (C) 2009-2016, ATR Baltic, Ltd. All Rights Reserved.
0011 ## Copyright (C) 2017-2023, Mavimax, Ltd. All Rights Reserved.
0012 ## This software is released under one of the following licenses:
0013 ## AGPL (with Java and Go exceptions) or Mavimax's license for commercial use.
0014 ## See LICENSE file for full text.
0015 ## -----------------------------------------------------------------------------
0016 ## AGPL license:
0017 ## 
0018 ## This program is free software; you can redistribute it and/or modify it under
0019 ## the terms of the GNU Affero General Public License, version 3 as published
0020 ## by the Free Software Foundation;
0021 ##
0022 ## This program is distributed in the hope that it will be useful, but WITHOUT ANY
0023 ## WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
0024 ## PARTICULAR PURPOSE. See the GNU Affero General Public License, version 3
0025 ## for more details.
0026 ##
0027 ## You should have received a copy of the GNU Affero General Public License along 
0028 ## with this program; if not, write to the Free Software Foundation, Inc., 
0029 ## 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
0030 ##
0031 ## -----------------------------------------------------------------------------
0032 ## A commercial use license is available from Mavimax, Ltd
0033 ## contact@mavimax.com
0034 ## -----------------------------------------------------------------------------
0035 ##
0036 
0037 export TESTNAME="test102_procgrp"
0038 
0039 PWD=`pwd`
0040 if [ `echo $PWD | grep $TESTNAME ` ]; then
0041     # Do nothing 
0042     echo > /dev/null
0043 else
0044     # started from parent folder
0045     pushd .
0046     echo "Doing cd"
0047     cd $TESTNAME
0048 fi;
0049 
0050 . ../testenv.sh
0051 
0052 export TESTDIR="$NDRX_APPHOME/atmitest/$TESTNAME"
0053 export PATH=$PATH:$TESTDIR
0054 export NDRX_ULOG=$TESTDIR
0055 export NDRX_TOUT=10
0056 export NDRX_SILENT=Y
0057 
0058 #
0059 # Domain 1 - here client will live
0060 #
0061 set_dom1() {
0062     echo "Setting domain 1"
0063     . ../dom1.sh
0064     export NDRX_CONFIG=$TESTDIR/ndrxconfig-dom1.xml
0065     export NDRX_DMNLOG=$TESTDIR/ndrxd-dom1.log
0066     export NDRX_LOG=$TESTDIR/ndrx-dom1.log
0067     export NDRX_DEBUG_CONF=$TESTDIR/debug-dom1.conf
0068 }
0069 
0070 #
0071 # Generic exit function
0072 #
0073 function go_out {
0074     echo "Test exiting with: $1"
0075     
0076     set_dom1;
0077     xadmin stop -y
0078     xadmin down -y
0079 
0080     # If some alive stuff left...
0081     xadmin killall atmiclt102
0082 
0083     popd 2>/dev/null
0084     exit $1
0085 }
0086 
0087 #
0088 # Check ndrxconfig.xml for errors
0089 #
0090 function validate_invalid_config {
0091 
0092     cfg_file=$1
0093     code=$2
0094     message=$3
0095     
0096     export NDRX_CONFIG=$TESTDIR/$cfg_file
0097     
0098     xadmin stop -y
0099     xadmin ldcf
0100     OUT=`xadmin ldcf 2>&1`
0101     
0102     if [[ $OUT != *"$code"* ]]; then
0103         echo "Missing error code [$code] in ldcf output for $cfg_file"
0104         go_out -1
0105     fi
0106     
0107     if [[ $OUT != *"$message"* ]]; then
0108         echo "Missing message code [$message] in ldcf output for $cfg_file"
0109         go_out -1
0110     fi
0111     
0112 }
0113 
0114 #
0115 # Check ndrxconfig.xml for errors
0116 #
0117 function validate_invalid_config_reload {
0118 
0119     code=$1
0120     message=$2
0121     
0122     xadmin reload
0123     OUT=`xadmin reload 2>&1`
0124 
0125     if [[ $OUT != *"$code"* ]]; then
0126         echo "Missing error code [$code] in ldcf output for $cfg_file"
0127         go_out -1
0128     fi
0129     
0130     if [[ $OUT != *"$message"* ]]; then
0131         echo "Missing message code [$message] in ldcf output for $cfg_file"
0132         go_out -1
0133     fi
0134     
0135 }
0136 
0137 rm *.log 2>/dev/null
0138 rm ULOG* 2>/dev/null
0139 rm -f lock_* 2>/dev/null
0140 # Any bridges that are live must be killed!
0141 #xadmin killall tpbridge
0142 
0143 set_dom1;
0144 
0145 # grpno outside 1..64 range:
0146 
0147 
0148 # Running LP changed group...
0149 # reload test:
0150 export NDRX_CCONFIG="$TESTDIR"
0151 export NDRX_CONFIG="ndrxconfig-dom1-lp_tmp.xml.tmp"
0152 cp ndrxconfig-dom1-lp_ok.xml ndrxconfig-dom1-lp_tmp.xml.tmp
0153 xadmin start -y
0154 cp ndrxconfig-dom1-lp_changed.xml ndrxconfig-dom1-lp_tmp.xml.tmp
0155 validate_invalid_config_reload "NDRXD_EREBBINARYRUN" "Lock provider [exsinglesv]/10 must be shutdown prior changing locking group (from 12 to 13)"
0156 
0157 # load config tests:
0158 # # no dup checks, as we might have support server ckr, ckl
0159 #validate_invalid_config "ndrxconfig-dom1-dup_lp.xml" "NDRXD_ECFGINVLD" "Lock provider [exsinglesv]/11 duplicate for process group [OK]. Lock already provided by srvid 10"
0160 validate_invalid_config "ndrxconfig-dom1-singlegrp_inval1.xml" "NDRXD_EINVAL" "Invalid \`singleton' setting [X] in <procgroup>"
0161 validate_invalid_config "ndrxconfig-dom1-noorder_inval.xml" "NDRXD_EINVAL" "Invalid \`noorder' setting [X] in <procgroup>"
0162 validate_invalid_config "ndrxconfig-dom1-no-name.xml" "NDRXD_ECFGINVLD" "\`name' not set in <procgroup> section"
0163 validate_invalid_config "ndrxconfig-dom1-no-id.xml" "NDRXD_ECFGINVLD" "\`grpno' not set in <procgroup> section"
0164 validate_invalid_config "ndrxconfig-dom1-lp_missing.xml" "NDRXD_ECFGINVLD" "Singleton process group [OK] does not have lock provider defined"
0165 validate_invalid_config "ndrxconfig-dom1-inval_procgrp_lp.xml" "NDRXD_ENOENT" "Failed to resolve procgrp_lp"
0166 validate_invalid_config "ndrxconfig-dom1-inval_procgrp.xml" "NDRXD_ENOENT" "Failed to resolve procgrp"
0167 validate_invalid_config "ndrxconfig-dom1-defaults-dup_no.xml" "NDRXD_EINVAL" "is duplicate in <procgroup> section"
0168 validate_invalid_config "ndrxconfig-dom1-defaults-dup_name.xml" "NDRXD_EINVAL" "is duplicate in <procgroup> section"
0169 validate_invalid_config "ndrxconfig-dom1-bad-no.xml" "NDRXD_EINVAL" "Invalid \`grpno'"
0170 validate_invalid_config "ndrxconfig-dom1-bad-name.xml" "NDRXD_EINVAL" "invalid characters used in"
0171 
0172 validate_invalid_config "ndrxconfig-dom1-no-def-procgrp.xml" "NDRXD_ENOENT" "Failed to resolve procgrp"
0173 validate_invalid_config "ndrxconfig-dom1-no-def-procgrp_lp.xml" "NDRXD_ENOENT" "Failed to resolve procgrp_lp"
0174 
0175 # in this case config is OK, config was loaded
0176 validate_invalid_config "ndrxconfig-dom1-ok-name.xml" "NDRXD_ECFGLDED" "NDRXD_ECFGLDED"
0177 
0178 # test server group operations:
0179 export NDRX_CONFIG="ndrxconfig-dom1-procgroups.xml"
0180 xadmin stop -y
0181 xadmin start -y
0182 # let clients to boot:
0183 sleep 6
0184 xadmin pc
0185 
0186 ################################################################################
0187 CMD="xadmin ppm -3"
0188 echo "$CMD"
0189 ################################################################################
0190 
0191 OUT=`$CMD 2>&1`
0192 
0193 echo "got output [$OUT]"
0194 # check that 5x atmi.sv102 processs are running
0195 # shall have in output 
0196 PATTERN="BINARY[[:space:]]*SRVID[[:space:]]*PID[[:space:]]*SVPID[[:space:]]*PROCGRP[[:space:]]*PGNO[[:space:]]*PROCGRPL[[:space:]]*PGLNO[[:space:]]*PGNLA
0197 --------[[:space:]]*-----[[:space:]]*--------[[:space:]]*--------[[:space:]]*--------[[:space:]]*-----[[:space:]]*--------[[:space:]]*-----[[:space:]]*-----
0198 atmi.sv1[[:space:]]*10[[:space:]]*[0-9]+[[:space:]]*[0-9]+[[:space:]]*OK[[:space:]]*28[[:space:]]*-[[:space:]]*0[[:space:]]*0
0199 atmi.sv1[[:space:]]*11[[:space:]]*[0-9]+[[:space:]]*[0-9]+[[:space:]]*OK[[:space:]]*28[[:space:]]*-[[:space:]]*0[[:space:]]*0
0200 atmi.sv1[[:space:]]*12[[:space:]]*[0-9]+[[:space:]]*[0-9]+[[:space:]]*OK[[:space:]]*28[[:space:]]*-[[:space:]]*0[[:space:]]*0
0201 atmi.sv1[[:space:]]*100[[:space:]]*[0-9]+[[:space:]]*[0-9]+[[:space:]]*OK2[[:space:]]*1[[:space:]]*-[[:space:]]*0[[:space:]]*0
0202 atmi.sv1[[:space:]]*101[[:space:]]*[0-9]+[[:space:]]*[0-9]+[[:space:]]*OK2[[:space:]]*1[[:space:]]*-[[:space:]]*0[[:space:]]*0
0203 atmi.sv1[[:space:]]*102[[:space:]]*[0-9]+[[:space:]]*[0-9]+[[:space:]]*OK2[[:space:]]*1[[:space:]]*-[[:space:]]*0[[:space:]]*0
0204 atmi.sv1[[:space:]]*103[[:space:]]*[0-9]+[[:space:]]*[0-9]+[[:space:]]*OK2[[:space:]]*1[[:space:]]*-[[:space:]]*0[[:space:]]*0
0205 atmi.sv1[[:space:]]*104[[:space:]]*[0-9]+[[:space:]]*[0-9]+[[:space:]]*OK2[[:space:]]*1[[:space:]]*-[[:space:]]*0[[:space:]]*0
0206 exsingle[[:space:]]*200[[:space:]]*[0-9]+[[:space:]]*[0-9]+[[:space:]]*-[[:space:]]*0[[:space:]]*_this_I\+[[:space:]]*64[[:space:]]*64
0207 cpmsrv[[:space:]]*1000[[:space:]]*[0-9]+[[:space:]]*[0-9]+[[:space:]]*-[[:space:]]*0[[:space:]]*-[[:space:]]*0[[:space:]]*0"
0208 
0209 if ! [[ "$OUT" =~ $PATTERN ]]; then
0210     echo "ppm -3 page invalid"
0211     go_out -1
0212 fi
0213 
0214 ################################################################################
0215 CMD="xadmin stop -g OK"
0216 echo "$CMD"
0217 ################################################################################
0218 
0219 OUT=`$CMD 2>&1`
0220 
0221 echo "got output [$OUT]"
0222 # check that 5x atmi.sv102 processs are running
0223 # shall have in output 
0224 PATTERN="Server executable = atmi.sv102 Id = 12 :       Shutdown succeeded.
0225 Server executable = atmi.sv102  Id = 11 :       Shutdown succeeded.
0226 Server executable = atmi.sv102  Id = 10 :       Shutdown succeeded.
0227 Shutdown finished. 3 processes stopped."
0228 
0229 if [[ $OUT != *"$PATTERN"* ]]; then
0230     echo "Expected 3x servers to be stopped"
0231     go_out -1
0232 fi
0233 
0234 # check that we have 5x servers running
0235 xadmin ps -a atmi.sv102
0236 CNT=`xadmin ps -a atmi.sv102 | wc | awk '{print $1}'`
0237 if [ "$CNT" -ne "5" ]; then
0238     echo "Expected 5 servers after group shutdown, got [$CNT]"
0239     go_out -1
0240 fi
0241 
0242 ################################################################################
0243 CMD="xadmin start -g OK"
0244 echo "$CMD"
0245 ################################################################################
0246 
0247 OUT=`$CMD 2>&1`
0248 
0249 echo "got output [$OUT]"
0250 
0251 PATTERN="exec atmi.sv102 -k nre38Kff1kz -i 10 -e .*/test102_procgrp/atmisv-dom1.log -r --  :
0252         process id=[0-9]+ ... Started.
0253 exec atmi.sv102 -k nre38Kff1kz -i 11 -e .*/test102_procgrp/atmisv-dom1.log -r --  :
0254         process id=[0-9]+ ... Started.
0255 exec atmi.sv102 -k nre38Kff1kz -i 12 -e .*/test102_procgrp/atmisv-dom1.log -r --  :
0256         process id=[0-9]+ ... Started.
0257 Startup finished. 3 processes started."
0258 
0259 if ! [[ "$OUT" =~ $PATTERN ]]; then
0260     echo "Expected 3x servers to be started"
0261     go_out -1
0262 fi
0263 
0264 # check that we have 8x servers running
0265 xadmin ps -a atmi.sv102
0266 CNT=`xadmin ps -a atmi.sv102 | wc | awk '{print $1}'`
0267 if [ "$CNT" -ne "8" ]; then
0268     echo "Expected 8 servers after group shutdown, got [$CNT]"
0269     go_out -1
0270 fi
0271 
0272 ################################################################################
0273 CMD="xadmin sreload -g OK"
0274 echo "$CMD"
0275 ################################################################################
0276 
0277 OUT=`$CMD 2>&1`
0278 
0279 echo "got output [$OUT]"
0280 
0281 PATTERN="Server executable = atmi.sv102 Id = 10 :       Shutdown succeeded.
0282 exec atmi.sv102 -k nre38Kff1kz -i 10 -e .*/test102_procgrp/atmisv-dom1.log -r --  :
0283         process id=[0-9]+ ... Started.
0284 Server executable = atmi.sv102  Id = 11 :       Shutdown succeeded.
0285 exec atmi.sv102 -k nre38Kff1kz -i 11 -e .*/test102_procgrp/atmisv-dom1.log -r --  :
0286         process id=[0-9]+ ... Started.
0287 Server executable = atmi.sv102  Id = 12 :       Shutdown succeeded.
0288 exec atmi.sv102 -k nre38Kff1kz -i 12 -e .*/test102_procgrp/atmisv-dom1.log -r --  :
0289         process id=[0-9]+ ... Started.
0290 Reload finished. 3 processes reloaded."
0291 
0292 if ! [[ "$OUT" =~ $PATTERN ]]; then
0293     echo "Expected 3x servers to be started"
0294     go_out -1
0295 fi
0296 
0297 # check that we have 8x servers running
0298 xadmin ps -a atmi.sv102
0299 CNT=`xadmin ps -a atmi.sv102 | wc | awk '{print $1}'`
0300 if [ "$CNT" -ne "8" ]; then
0301     echo "Expected 8 servers after group shutdown, got [$CNT]"
0302     go_out -1
0303 fi
0304 
0305 ################################################################################
0306 CMD="xadmin stop -g OK -s JJJ"
0307 echo "$CMD"
0308 ################################################################################
0309 
0310 OUT=`$CMD 2>&1`
0311 
0312 echo "got output [$OUT]"
0313 
0314 PATTERN="-i, -s and -g cannot be combined!"
0315 
0316 if [[ "$OUT" != *"$PATTERN"* ]]; then
0317     echo "Pattern [$PATTERN] not found in output"
0318     go_out -1
0319 fi
0320 
0321 ################################################################################
0322 CMD="xadmin stop -g OK -i 500"
0323 echo "$CMD"
0324 ################################################################################
0325 
0326 OUT=`$CMD 2>&1`
0327 
0328 echo "got output [$OUT]"
0329 
0330 PATTERN="-i, -s and -g cannot be combined!"
0331 
0332 if [[ "$OUT" != *"$PATTERN"* ]]; then
0333     echo "Pattern [$PATTERN] not found in output"
0334     go_out -1
0335 fi
0336 
0337 ################################################################################
0338 CMD="xadmin stop -g KK"
0339 echo "$CMD"
0340 ################################################################################
0341 
0342 OUT=`$CMD 2>&1`
0343 
0344 echo "got output [$OUT]"
0345 
0346 PATTERN="NDRXD_ENOENT.*Process group \[KK\] is not defined"
0347 
0348 if ! [[ "$OUT" =~ $PATTERN ]]; then
0349     echo "pattern [$PATTERN] not found in output"
0350     go_out -1
0351 fi
0352 
0353 ################################################################################
0354 CMD="xadmin sc -g OK"
0355 echo "$CMD"
0356 ################################################################################
0357 
0358 OUT=`$CMD 2>&1`
0359 echo "got output [$OUT]"
0360 
0361 PATTERN="Client process CLT1/- stopped
0362 Client process CLT2/- stopped
0363 Client process CLT3/- stopped
0364 3 client(s) stopped."
0365 
0366 if [[ "$OUT" != *"$PATTERN"* ]]; then
0367     echo "pattern [$PATTERN] not found in output"
0368     go_out -1
0369 fi
0370 
0371 # check that we have 4x clients running
0372 xadmin ps -a atmiclt102
0373 CNT=`xadmin ps -a atmiclt102 | wc | awk '{print $1}'`
0374 if [ "$CNT" -ne "4" ]; then
0375     echo "Expected 4x atmiclt102, got [$CNT]"
0376     go_out -1
0377 fi
0378 
0379 
0380 ################################################################################
0381 CMD="xadmin bc -g OK"
0382 echo "$CMD"
0383 ################################################################################
0384 
0385 OUT=`$CMD 2>&1`
0386 echo "got output [$OUT]"
0387 
0388 PATTERN="Client process CLT1/- marked for start
0389 Client process CLT2/- marked for start
0390 Client process CLT3/- marked for start
0391 3 client(s) marked for start."
0392 
0393 # let clients to boot..
0394 sleep 7
0395 
0396 if [[ "$OUT" != *"$PATTERN"* ]]; then
0397     echo "pattern [$PATTERN] not found in output"
0398     go_out -1
0399 fi
0400 
0401 # check that we have 7x clients running
0402 xadmin ps -a atmiclt102
0403 CNT=`xadmin ps -a atmiclt102 | wc | awk '{print $1}'`
0404 if [ "$CNT" -ne "7" ]; then
0405     echo "Expected 7x atmiclt102, got [$CNT]"
0406     go_out -1
0407 fi
0408 
0409 ################################################################################
0410 CMD="xadmin rc -g OK"
0411 echo "$CMD"
0412 ################################################################################
0413 
0414 OUT=`$CMD 2>&1`
0415 echo "got output [$OUT]"
0416 
0417 PATTERN="Client process CLT1/- stopped
0418 Client process CLT1/- marked for start
0419 Client process CLT2/- stopped
0420 Client process CLT2/- marked for start
0421 Client process CLT3/- stopped
0422 Client process CLT3/- marked for start
0423 3 client(s) restarted."
0424 
0425 # let clients to boot..
0426 sleep 7
0427 
0428 if [[ "$OUT" != *"$PATTERN"* ]]; then
0429     echo "pattern [$PATTERN] not found in output"
0430     go_out -1
0431 fi
0432 
0433 # check that we have 7x clients running
0434 xadmin ps -a atmiclt102
0435 CNT=`xadmin ps -a atmiclt102 | wc | awk '{print $1}'`
0436 if [ "$CNT" -ne "7" ]; then
0437     echo "Expected 7x atmiclt102, got [$CNT]"
0438     go_out -1
0439 fi
0440 
0441 
0442 ################################################################################
0443 CMD="xadmin pc"
0444 echo "$CMD"
0445 ################################################################################
0446 
0447 OUT=`$CMD 2>&1`
0448 
0449 echo "got output [$OUT]"
0450 
0451 PATTERN="CLT1/- - running pid.*
0452 CLT2/- - running pid.*
0453 CLT3/- - running pid.*
0454 CLT4/- - running pid.*
0455 CLT5/- - running pid.*
0456 CLT6/- - running pid.*
0457 CLT7/- - running pid.*"
0458 
0459 if ! [[ "$OUT" =~ $PATTERN ]]; then
0460     echo "Expected 3x servers to be started"
0461     go_out -1
0462 fi
0463 
0464 RET=$?
0465 
0466 if [[ "X$RET" != "X0" ]]; then
0467     go_out $RET
0468 fi
0469 
0470 # Catch is there is test error!!!
0471 if [ "X`grep TESTERROR *.log`" != "X" ]; then
0472     echo "Test error detected!"
0473     RET=-2
0474 fi
0475 
0476 go_out $RET
0477 # vim: set ts=4 sw=4 et smartindent:
0478