Back to home page

Enduro/X

 
 

    


0001 #!/bin/bash
0002 ##
0003 ## @brief Test tpsprio, tpgprio - test 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 
0036 export TESTNAME="test085_prio"
0037 
0038 PWD=`pwd`
0039 if [ `echo $PWD | grep $TESTNAME ` ]; then
0040     # Do nothing 
0041     echo > /dev/null
0042 else
0043     # started from parent folder
0044     pushd .
0045     echo "Doing cd"
0046     cd $TESTNAME
0047 fi;
0048 
0049 . ../testenv.sh
0050 
0051 export TESTDIR="$NDRX_APPHOME/atmitest/$TESTNAME"
0052 export PATH=$PATH:$TESTDIR
0053 export NDRX_ULOG=$TESTDIR
0054 export NDRX_TOUT=30
0055 export NDRX_SILENT=Y
0056 
0057 #
0058 # Domain 1 - here client will live
0059 #
0060 set_dom1() {
0061     echo "Setting domain 1"
0062     . ../dom1.sh
0063     export NDRX_CONFIG=$TESTDIR/ndrxconfig-dom1.xml
0064     export NDRX_DMNLOG=$TESTDIR/ndrxd-dom1.log
0065     export NDRX_LOG=$TESTDIR/ndrx-dom1.log
0066     export NDRX_DEBUG_CONF=$TESTDIR/debug-dom1.conf
0067 }
0068 
0069 
0070 
0071 #
0072 # Generic exit function
0073 #
0074 function go_out {
0075     echo "Test exiting with: $1"
0076     
0077     set_dom1;
0078     xadmin stop -y
0079     xadmin down -y
0080 
0081 
0082 
0083     # If some alive stuff left...
0084     xadmin killall atmiclt85
0085 
0086     popd 2>/dev/null
0087     exit $1
0088 }
0089 
0090 rm *.log
0091 # Any bridges that are live must be killed!
0092 xadmin killall tpbridge
0093 
0094 set_dom1;
0095 xadmin down -y
0096 xadmin start -y || go_out 1
0097 
0098 xadmin psc
0099 xadmin ppm
0100 echo "Running off client"
0101 
0102 set_dom1;
0103 (./atmiclt85 2>&1) > ./atmiclt-dom1.log
0104 #(valgrind --leak-check=full --log-file="v.out" -v ./atmiclt85 2>&1) > ./atmiclt-dom1.log
0105 
0106 RET=$?
0107 
0108 if [[ "X$RET" != "X0" ]]; then
0109     go_out $RET
0110 fi
0111 
0112 
0113 # if poller is epoll very that priority actually works
0114 
0115 POLLER=`xadmin poller`
0116 
0117 if [[ "$POLLER" == "epoll" || "$POLLER" == "kqueue" ]]; then
0118 
0119     xadmin psc
0120 
0121     echo ">>> Benchmark the system, to check is test applicable"
0122     echo ">>>> Single process performance..."
0123     export NDRX_BENCH_FILE="perf1.log"
0124     export NDRX_BENCH_CONFIGNAME="results"
0125     exbenchcl -n1 -P  -t20 -b "{\"T_LONG_FLD\":5}" -f T_CARRAY_FLD -S1024
0126 
0127     echo ">>>> MT process performance..."
0128     export NDRX_BENCH_FILE="perf2.log"
0129     export NDRX_BENCH_CONFIGNAME="results"
0130     exbenchcl -n2 -P  -t20 -b "{\"T_LONG_FLD\":5}" -f T_CARRAY_FLD -S1024
0131 
0132     PERF1=`cat perf1.log | grep results | awk '{print $3}'`
0133     PERF2=`cat perf2.log | grep results | awk '{print $3}'`
0134 
0135     echo "Results: 1 x thread [$PERF1] 2 x thread [$PERF2]"
0136 
0137     # if MT is not faster than 20% of the single thread, then test cannot be run
0138     # i.e. we have 1x cpu, and due to scheduler, threads may be fully processed.
0139     # without any priority.
0140     let "PERF1 = PERF1 + (PERF1 / 4)"
0141 
0142     if [ $PERF2 -lt $PERF1 ]; then
0143         echo "Cannot continue - system too slow ($PERF2 < $PERF1) (increase vcpu count?)"
0144         go_out 0
0145     fi
0146 
0147     echo ">>> Default is lower"
0148     export NDRX_BENCH_FILE="bench.def.log"
0149     export NDRX_BENCH_CONFIGNAME="results"
0150     exbenchcl -n5 -P  -t20 -b "{\"T_LONG_FLD\":5}" -f T_CARRAY_FLD -S1024 &
0151     BENCHPIDDEF_PID=$!
0152 
0153     # event this is started later, it shall fill take a priority over...
0154     export NDRX_BENCH_FILE="bench.70.log"
0155     export NDRX_BENCH_CONFIGNAME="results"
0156     exbenchcl -n5 -P  -t20 -b "{\"T_LONG_FLD\":5}" -f T_CARRAY_FLD -S1024 -p 70 &
0157     BENCHPID70_PID=$!
0158 
0159     # wait for pids...
0160     wait $BENCHPIDDEF_PID
0161     wait $BENCHPID70_PID
0162 
0163     RESDEF=`cat bench.def.log | grep results | awk '{print $3}'`
0164     RES70=`cat bench.70.log | grep results | awk '{print $3}'`
0165 
0166     echo "[$RESDEF] vs [$RES70]"
0167 
0168     if [[ "X$RESDEF" == "X" || "X$RES70" == "X" ]]; then
0169         echo "Missing results"
0170         go_out 1
0171     fi
0172 
0173     if [[ "$RESDEF" -ge "$RES70" ]]; then
0174         echo "Priority does not work prio DEF processed $RESDEF (shall be <) prio 70 processed $RES70 (1)"
0175         go_out 1
0176     fi
0177 
0178     rm bench.def.log
0179     rm bench.70.log
0180 
0181     echo ">>> Default is higher"
0182     xadmin stop -y
0183     export NDRX_CONFIG=$TESTDIR/ndrxconfig-dom1_svcprio.xml
0184     xadmin start -y
0185 
0186     export NDRX_BENCH_FILE="bench.def.log"
0187     export NDRX_BENCH_CONFIGNAME="results"
0188     exbenchcl -n5 -P  -t20 -b "{\"T_LONG_FLD\":5}" -f T_CARRAY_FLD -S1024 &
0189     BENCHPIDDEF_PID=$!
0190 
0191     # event this is started later, it shall fill take a priority over...
0192     export NDRX_BENCH_FILE="bench.70.log"
0193     export NDRX_BENCH_CONFIGNAME="results"
0194     exbenchcl -n5 -P  -t20 -b "{\"T_LONG_FLD\":5}" -f T_CARRAY_FLD -S1024 -p 70 &
0195     BENCHPID70_PID=$!
0196 
0197     # wait for pids...
0198     wait $BENCHPIDDEF_PID
0199     wait $BENCHPID70_PID
0200 
0201     RESDEF=`cat bench.def.log | grep results | awk '{print $3}'`
0202     RES70=`cat bench.70.log | grep results | awk '{print $3}'`
0203 
0204     echo "[$RESDEF] vs [$RES70]"
0205 
0206     if [[ "X$RESDEF" == "X" || "X$RES70" == "X" ]]; then
0207         echo "Missing results"
0208         go_out 1
0209     fi
0210 
0211     if [[ "$RESDEF" -le "$RES70" ]]; then
0212         echo "Priority does not work prio DEF processed $RESDEF (shall be >) prio 70 processed $RES70 (2)"
0213         go_out 1
0214     fi
0215 
0216 
0217 fi
0218 
0219 # Catch is there is test error!!!
0220 if [ "X`grep TESTERROR *.log`" != "X" ]; then
0221     echo "Test error detected!"
0222     RET=-2
0223 fi
0224 
0225 
0226 go_out $RET
0227 
0228 
0229 # vim: set ts=4 sw=4 et smartindent:
0230