Back to home page

Enduro/X

 
 

    


0001 #!/bin/bash
0002 ##
0003 ## @brief @(#) Test021 - XA testing, common functions, include
0004 ##
0005 ## @file test-func-include.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 ##
0037 # Ensure that given number of keys exists in db
0038 ##
0039 ensure_keys () {
0040 
0041         db=$1
0042         count=$2
0043 
0044         REC_OUT=`xadmin cs -d $db | wc | awk '{ print $1 }'`
0045         echo "Record count: [$REC_OUT] must be: [$count]"
0046         if [[ "$REC_OUT" != "$count" ]]; then
0047                 echo "TESTERROR: Invalid record count in cache db!"
0048                 exit 1
0049         fi
0050 }
0051 
0052 ##
0053 # Ensure that given field is cached somewhere in dump
0054 ##
0055 ensure_field () {
0056 
0057         db=$1
0058         key=$2
0059         fb=$3
0060         value=$4
0061         count=$5
0062 
0063         xadmin cd -d $db -k $key -i | grep $fb | grep $value
0064 
0065         REC_OUT=`xadmin cd -d $db -k $key -i | grep $fb | grep $value | wc | awk '{ print $1 }'`
0066 
0067         echo "Buffer $fb/$value: [$REC_OUT] must be: [$count]"
0068 
0069         if [ $count -eq 0 ]; then
0070 
0071             if [[ $REC_OUT -ne 0 ]]; then
0072                     echo "TESTERROR: Field must not be present!"
0073                     exit 1
0074             fi
0075 
0076         else
0077             if [[ $REC_OUT -lt 1 ]]; then
0078                     echo "TESTERROR: Field must be present!"
0079                     exit 1
0080             fi
0081         fi
0082 }
0083 # vim: set ts=4 sw=4 et smartindent: