Back to home page

Enduro/X

 
 

    


0001 #!/bin/bash
0002 ##
0003 ## @brief @(#) Test007, advertise & unadvertise
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 export TESTNAME="test007_advertise"
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 . ../testenv.sh
0049 
0050 export TESTDIR="$NDRX_APPHOME/atmitest/$TESTNAME"
0051 export PATH=$PATH:$TESTDIR
0052 # Configure the runtime - override stuff here!
0053 export NDRX_CONFIG=$TESTDIR/ndrxconfig.xml
0054 export NDRX_DMNLOG=$TESTDIR/ndrxd.log
0055 export NDRX_LOG=$TESTDIR/ndrx.log
0056 export NDRX_DEBUG_CONF=$TESTDIR/debug.conf
0057 
0058 
0059 #
0060 # Generic exit function
0061 #
0062 function go_out {
0063     echo "Test exiting with: $1"
0064     xadmin down -y
0065     popd 2>/dev/null
0066     exit $1
0067 }
0068 
0069 rm *.log
0070 
0071 xadmin down -y
0072 xadmin start -y || go_out 1
0073 
0074 # Have some wait for ndrxd goes in service
0075 sleep 2
0076 
0077 # Stuff should not be advertised
0078 
0079 if [ "X`xadmin psc | grep TESTSVFN`" != "X" ]; then
0080         echo "TESTSVFN should not be advertised"
0081         go_out 2
0082 fi
0083 
0084 echo "Sending DOADV to sv"
0085 xadmin psc
0086 xadmin psvc
0087 atmiclt_007 DOADV || go_out 4
0088 
0089 if [ "X`xadmin psc | grep TESTSVFN`" == "X" ]; then
0090         echo "TESTSVFN must be appeared"
0091         go_out 2
0092 fi
0093 
0094 echo "Sending TEST to sv"
0095 xadmin psc
0096 xadmin psvc
0097 atmiclt_007 TEST || go_out 5
0098 
0099 
0100 echo "Sending UNADV to sv"
0101 xadmin psc
0102 xadmin psvc
0103 atmiclt_007 UNADV || go_out 6
0104 
0105 if [ "X`xadmin psc | grep TESTSVFN`" != "X" ]; then
0106         echo "TESTSVFN must be dissapeared"
0107         go_out 7
0108 fi
0109 
0110 echo "Testing again client TEST call, service dissapeared, should be bad call"
0111 atmiclt_007 TEST
0112 
0113 if [ $? -eq 0 ]; then
0114         echo "For some reason test call after UNADV succeeded!!!"
0115         go_out 8
0116 fi
0117 
0118 echo "Sending DOADV to sv"
0119 atmiclt_007 DOADV || go_out 9
0120 sleep 3
0121 
0122 if [ "X`xadmin psc | grep TESTSVFN`" == "X" ]; then
0123         echo "TESTSVFN must be appeared"
0124         go_out 10
0125 fi
0126 
0127 echo "Testing again client TEST call, service dissapeared, should be ok call"
0128 atmiclt_007 TEST || go_out 11
0129 
0130 
0131 # Catch is there is test error!!!
0132 if [ "X`grep TESTERROR *.log`" != "X" ]; then
0133         echo "Test error detected!"
0134         go_out 12
0135 fi
0136 
0137 
0138 
0139 go_out 0
0140 
0141 # vim: set ts=4 sw=4 et smartindent: