Back to home page

Enduro/X

 
 

    


0001 #!/bin/bash
0002 ##
0003 ## @brief @(#) Test31 Launcher
0004 ##
0005 ## @file run.sh
0006 ##
0007 ## -----------------------------------------------------------------------------
0008 ## Enduro/X Middleware Platform for Distributed Transaction Processing
0009 ## Copyright (C) 2009-2016, ATR Baltic, Ltd. All Rights Reserved.
0010 ## Copyright (C) 2017-2023, Mavimax, Ltd. All Rights Reserved.
0011 ## This software is released under one of the following licenses:
0012 ## AGPL (with Java and Go exceptions) or Mavimax's license for commercial use.
0013 ## See LICENSE file for full text.
0014 ## -----------------------------------------------------------------------------
0015 ## AGPL license:
0016 ##
0017 ## This program is free software; you can redistribute it and/or modify it under
0018 ## the terms of the GNU Affero General Public License, version 3 as published
0019 ## by the Free Software Foundation;
0020 ##
0021 ## This program is distributed in the hope that it will be useful, but WITHOUT ANY
0022 ## WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
0023 ## PARTICULAR PURPOSE. See the GNU Affero General Public License, version 3
0024 ## for more details.
0025 ##
0026 ## You should have received a copy of the GNU Affero General Public License along 
0027 ## with this program; if not, write to the Free Software Foundation, Inc.,
0028 ## 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
0029 ##
0030 ## -----------------------------------------------------------------------------
0031 ## A commercial use license is available from Mavimax, Ltd
0032 ## contact@mavimax.com
0033 ## -----------------------------------------------------------------------------
0034 ##
0035 TESTNAME="test031_logging"
0036 
0037 PWD=`pwd`
0038 if [ `echo $PWD | grep $TESTNAME ` ]; then
0039     # Do nothing 
0040     echo > /dev/null
0041 else
0042     # started from parent folder
0043     pushd .
0044     echo "Doing cd"
0045     cd $TESTNAME
0046 fi;
0047 
0048 
0049 . ../testenv.sh
0050 
0051 export TESTDIR="$NDRX_APPHOME/atmitest/$TESTNAME"
0052 export NDRX_ULOG=`pwd`
0053 rm *.log 2>/dev/null
0054 rm ULOG*  2>/dev/null
0055 
0056 # Clean up log dir
0057 rm -rf ./logs 2>/dev/null
0058 mkdir ./logs
0059 
0060 rm -rf ./logs_cfg 2>/dev/null
0061 mkdir ./logs_cfg
0062 
0063 rm -rf ./non_exist
0064 rm -rf ./non_write
0065 mkdir non_write
0066 
0067 # no write for others..
0068 chmod 555 non_write
0069 
0070 # default ndrx=5
0071 #export NDRX_DEBUG_CONF="debug.conf"
0072 
0073 (./atmisv31FIRST -t 4 -i 1 2>&1) > ./atmisv31FIRST.log &
0074 (./atmisv31SECOND -i 1 2>&1) > ./atmisv31SECOND.log &
0075 sleep 2
0076 (./atmiclt31 2>&1) > ./atmiclt31.log
0077 
0078 RET=$?
0079 
0080 if [ "X$RET" != "X0" ]; then
0081     echo "atmiclt31 failed!"
0082     RET=-2
0083 fi
0084 
0085 (./atmiclt31_inv 2>&1) > ./atmiclt31_inv.log
0086 XRET=$?
0087 
0088 if [ "X$XRET" != "X0" ]; then
0089     echo "atmiclt31_inv failed!"
0090     RET=-2
0091 fi
0092 
0093 # could lines of "HELLO" in ./atmiclt31_inv.log
0094 # shall be over 1000
0095 CNT=`grep HELLO ./atmiclt31_inv.log | wc -l | awk '{print $1}'`
0096 
0097 echo "CNT=[$CNT]"
0098 
0099 if [ "$CNT" -lt "1000" ]; then
0100     echo "atmiclt31_inv expected at least 1000 HELLO, got $CNT!"
0101     RET=-2
0102 fi
0103 
0104 # Catch is there is test error!!!
0105 if [ "X`grep TESTERROR *.log`" != "X" ]; then
0106     echo "Test error detected!"
0107     RET=-2
0108 fi
0109 
0110 xadmin killall atmisv31FIRST 2>/dev/null
0111 xadmin killall atmisv31SECOND 2>/dev/null
0112 xadmin killall exbenchsv 2>/dev/null
0113 xadmin killall exbenchcl 2>/dev/null
0114 xadmin killall atmiclt31 2>/dev/null
0115 
0116 #killall atmiclt1
0117 
0118 
0119 # Check the log files
0120 if [ "X`grep 'Hello from NDRX' clt-endurox.log`" == "X" ]; then
0121     echo "error in clt-endurox.log!"
0122     RET=-2
0123 fi
0124 
0125 #if [ "X`grep 'THIS IS NDRX IN PROCLOG' clt-endurox.log`" == "X" ]; then
0126 #        echo "error in clt-endurox.log missing 'THIS IS NDRX IN PROCLOG'!"
0127 
0128 if [ "X`grep 'THIS IS NDRX IN PROCLOG' clt-tp.log`" == "X" ]; then
0129     echo "error in clt-tp.log missing 'THIS IS NDRX IN PROCLOG'!"
0130     RET=-2
0131 fi
0132 
0133 #if [ "X`grep 'THIS IS UBF IN PROCLOG' clt-endurox.log`" == "X" ]; then
0134 #        echo "error in clt-endurox.log missing 'THIS IS UBF IN PROCLOG'!"
0135 if [ "X`grep 'THIS IS UBF IN PROCLOG' clt-tp.log`" == "X" ]; then
0136     echo "error in clt-tp.log missing 'THIS IS UBF IN PROCLOG'!"
0137     RET=-2
0138 fi
0139 
0140 # Feature #470
0141 if [ "X`grep 'THIS IS TP IN PROCLOG' clt-tp.log`" == "X" ]; then
0142     echo "error in clt-tp.log missing 'THIS IS TP IN PROCLOG'!"
0143     RET=-2
0144 fi
0145 
0146 if [ "X`grep 'Hello from tp' clt-tp.log`" == "X" ]; then
0147     echo "error in clt-tp.log (Hello from tp not found)!"
0148     RET=-2
0149 fi
0150 
0151 if [ "X`grep 'Hello from fprintf' clt-tp.log`" == "X" ]; then
0152     echo "error in clt-tp.log (Hello from fprintf not found)!"
0153     RET=-2
0154 fi
0155 
0156 if [ "X`grep 'hello from thread 1' clt-tp-th1.log`" == "X" ]; then
0157     echo "error in clt-tp-th1.log!"
0158     RET=-2
0159 fi
0160 
0161 if [ "X`grep 'hello from thread 2' clt-tp-th2.log`" == "X" ]; then
0162     echo "error in clt-tp-th2.log!"
0163     RET=-2
0164 fi
0165 
0166 if [ "X`grep 'hello from main thread' clt-tp.log`" == "X" ]; then
0167     echo "error in clt-tp.log (hello from main thread not found)!"
0168     RET=-2
0169 fi
0170 
0171 if [ "X`grep 'Thread 1 logs to main' clt-tp.log`" == "X" ]; then
0172     echo "error in clt-tp.log (missing Thread 1 logs to main in main)!"
0173     RET=-2
0174 fi
0175 
0176 if [ "X`grep 'Thread 2 logs to main' clt-tp.log`" == "X" ]; then
0177     echo "error in clt-tp.log (missing Thread 2 logs to main in main)!"
0178     RET=-2
0179 fi
0180 
0181 # There shall be 1000 files in log directory
0182 FILES=` ls -1 ./logs/*.log | wc | awk '{print $1}'`
0183 
0184 echo "Got request files: [$FILES]"
0185 if [ "X$FILES" != "X1000" ]; then
0186     echo "Invalid files count [$FILES] should be 1000!"
0187     RET=-2
0188 fi
0189 
0190 ################################################################################
0191 # there shall be in each log file:
0192 # - Hello from SETREQFILE
0193 # - Hello from atmicl31
0194 # - Hello from TEST31_2ND
0195 ################################################################################
0196 
0197 # Test all 1000 files
0198 
0199 for ((i=1;i<=100;i++)); do
0200 echo "Testing sequence: $i"
0201 
0202     if [ "X`grep 'Hello from SETREQFILE' ./logs/request_$i.log`" == "X" ]; then
0203         echo "Missing 'Hello from SETREQFILE' file $i"
0204         RET=-2
0205     fi
0206 
0207     if [ "X`grep 'Hello from atmicl31' ./logs/request_$i.log`" == "X" ]; then
0208         echo "Missing 'Hello from atmicl31' file $i"
0209         RET=-2
0210     fi
0211 
0212     if [ "X`grep 'Hello from TEST31_2ND' ./logs/request_$i.log`" == "X" ]; then
0213         echo "Missing 'Hello from TEST31_2ND' file $i"
0214         RET=-2
0215     fi
0216 
0217     # Feature #470
0218     if [ "X`grep 'THIS IS NDRX IN REQLOG' ./logs/request_$i.log`" == "X" ]; then
0219         echo "Missing 'THIS IS NDRX IN REQLOG' file $i"
0220         RET=-2
0221     fi
0222 
0223     if [ "X`grep 'THIS IS UBF IN REQLOG' ./logs/request_$i.log`" == "X" ]; then
0224         echo "Missing 'THIS IS UBF IN REQLOG' file $i"
0225         RET=-2
0226     fi
0227 
0228 done
0229 
0230 if [ "X`grep 'Finishing off' ./clt-tp.log`" == "X" ]; then
0231     echo "Missing 'Finishing off'"
0232     RET=-2
0233 fi
0234 
0235 # start the exbenchsv to 
0236 (NDRX_DEBUG_CONF="debug_threaded_y.conf" exbenchsv -i 100 2>&1) > ./exbenchsv.log &
0237 
0238 # start the benchmark in threads...
0239 (NDRX_DEBUG_CONF="debug_threaded_y.conf" exbenchcl -n5 -P -t20 -b "{}" -f EX_DATA -S1024 -R5 2>&1) > ./exbenchcl.log
0240 XRET=$?
0241 if [ "X$XRET" != "X0" ]; then
0242     echo "exbenchcl 1 failed"
0243     RET=$XRET
0244 fi
0245 
0246 # start the benchmark in threads...
0247 (NDRX_DEBUG_CONF="debug_threaded_perc.conf" exbenchcl -n5 -P -t20 -b "{}" -f EX_DATA -S1024 -R5 2>&1) > ./exbenchcl.log
0248 XRET=$?
0249 if [ "X$XRET" != "X0" ]; then
0250     echo "exbenchcl 2 failed"
0251     RET=$XRET
0252 fi
0253 
0254 export SOME_TEST="THIS_IS_ENV"
0255 (NDRX_DEBUG_CONF="debug_env_sub.conf" exbenchcl -n5 -P -t20 -b "{}" -f EX_DATA -S1024 -R5 2>&1) > ./exbenchcl.log
0256 XRET=$?
0257 if [ "X$XRET" != "X0" ]; then
0258     echo "exbenchcl 3 failed"
0259     RET=$XRET
0260 fi
0261 
0262 export SOME_TEST="THIS_IS_ENV2"
0263 (NDRX_DEBUG_CONF="debug_env_sub_th.conf" exbenchcl -n5 -P -t20 -b "{}" -f EX_DATA -S1024 -R5 2>&1) > ./exbenchcl.log
0264 XRET=$?
0265 if [ "X$XRET" != "X0" ]; then
0266     echo "exbenchcl 4 failed"
0267     RET=$XRET
0268 fi
0269 
0270 #
0271 # Validate log files..., with context id
0272 # 
0273 if [ ! -f "logs_cfg/exbenchcl.0.log_loger_extension" ]; then
0274     echo "Missing [exbenchcl.0.log_loger_extension]"
0275     RET=-2
0276 fi
0277 
0278 if [ ! -f "logs_cfg/exbenchcl%d.0.log_perc" ]; then
0279     echo "Missing [exbenchcl%d.0.log_perc]"
0280     RET=-2
0281 fi
0282 
0283 if [ ! -f "logs_cfg/exbenchcl%d.0.log_perc" ]; then
0284     echo "Missing [exbenchcl%d.0.log_perc]"
0285     RET=-2
0286 fi
0287 
0288 if [ ! -f "logs_cfg/exbenchcl.log_THIS_IS_ENV" ]; then
0289     echo "Missing [exbenchcl.log_THIS_IS_ENV]"
0290     RET=-2
0291 fi
0292 
0293 if [ ! -f "logs_cfg/exbenchcl.0.log_THIS_IS_ENV2" ]; then
0294     echo "Missing [exbenchcl.0.log_THIS_IS_ENV2]"
0295     RET=-2
0296 fi
0297 
0298 if [ ! -f "logs_cfg/exbenchsv.0.log" ]; then
0299     echo "Missing [exbenchsv.0.log]"
0300     RET=-2
0301 fi
0302 
0303 ################################################################################
0304 # Test common configuration parsing order, and regexp binaries
0305 ################################################################################
0306 
0307 unset NDRX_DEBUG_CONF
0308 export NDRX_CCONFIG=$TESTDIR/cconf
0309 
0310 echo ">>> Checking match by regexp"
0311 if [[ "`./atmiclt31_cc 2>&1`" != *"This is TP_LOG 5"* ]]; then
0312     echo "Missing message from atmiclt31_cc (1)"
0313     RET=-2
0314 fi
0315 
0316 echo ">>> Check no match according to the NDRX_SVPROCNAME"
0317 export NDRX_SVPROCNAME="hello_test"
0318 if [[ "`./atmiclt31_cc 2>&1`" == *"This is TP_LOG"* ]]; then
0319     echo "Expected no output from atmiclt31_cc (2)"
0320     RET=-2
0321 fi
0322 
0323 echo ">>> Checking match by proc name, missing regexp, still works..."
0324 export NDRX_SVPROCNAME="bin2"
0325 if [[ "`./atmiclt31_cc 2>&1`" != *"This is TP_LOG 4"* ]]; then
0326     echo "Missing message from atmiclt31_cc (3)"
0327     RET=-2
0328 fi
0329 
0330 xadmin killall atmisv31FIRST 2>/dev/null
0331 xadmin killall atmisv31SECOND 2>/dev/null
0332 xadmin killall exbenchsv 2>/dev/null
0333 xadmin killall exbenchcl 2>/dev/null
0334 xadmin killall atmiclt31 2>/dev/null
0335 
0336 popd 2>/dev/null
0337 
0338 exit $RET
0339 
0340 # vim: set ts=4 sw=4 et smartindent: