0001 #!/usr/bin/pscript
0002
0003 userlog("Generate local unit test");
0004
0005 //Include wizard base.
0006 compilestring(getwizardbase())();
0007
0008 //Provision class
0009 class CLocalTestCase extends WizardBase {
0010
0011 constructor()
0012 {
0013 base.constructor();
0014 }
0015
0016 //Configure it:
0017
0018 </ order=1, name = "test number", type = "number", min=0, max=999 />
0019 testid = "";
0020
0021 </ order=2, name = "test code name", type = "string", min=1, max=16 />
0022 testcode = "";
0023
0024 </ order=3, name = "Unit test description", type = "string", min=1, max=999 />
0025 descr = "";
0026
0027 </ order=4, name = "Domain 1", type = "yn"/>
0028 dom1 = "n";
0029
0030 </ order=5, name = "Domain 2", depend="(::prov.dom1==\"y\")", type = "yn"/>
0031 dom2 = "n";
0032
0033 testname = "";
0034 client = "";
0035 server = "";
0036 make = "";
0037 debug = "";
0038 run = "";
0039 hdr = "";
0040
0041 dom1_debug = "";
0042 dom1_ndrxconf = "";
0043
0044 dom2_debug = "";
0045 dom2_ndrxconf = "";
0046
0047 function getOutputFiles()
0048 {
0049 testname = format("test%03d_%s", testid.tointeger(), testcode);
0050
0051 mkdir (testname);
0052
0053 client = format("%s/atmiclt%d.c", testname, testid.tointeger());
0054 server = format("%s/atmisv%d.c", testname, testid.tointeger());
0055 make = format("%s/CMakeLists.txt", testname);
0056 debug = format("%s/debug.conf", testname);
0057 run = format("%s/run.sh", testname);
0058 hdr = format("%s/test%d.h", testname, testid.tointeger());
0059
0060 dom1_debug = format("%s/debug-dom1.conf", testname);
0061 dom1_ndrxconf = format("%s/ndrxconfig-dom1.xml", testname);
0062
0063 dom2_debug = format("%s/debug-dom2.conf", testname);
0064 dom2_ndrxconf = format("%s/ndrxconfig-dom2.xml", testname);
0065
0066 }
0067
0068 }
0069
0070
0071 //Run the mater installer
0072 function install()
0073 {
0074 local root = getroottable();
0075
0076 //Create a provision object
0077 root["prov"] <- CLocalTestCase();
0078
0079 if (!::prov.isDefaulted)
0080 {
0081 ::prov.runInteractive();
0082 }
0083
0084 if (::prov.validatAndPrintConfig())
0085 {
0086 ::prov.getOutputFiles();
0087 print(format("Test case: [%s]\n", ::prov.testname));
0088
0089
0090 //
0091 // Common header file
0092 //
0093 if (!::prov.writeFile(::prov.hdr,
0094
0095 @"/**
0096 * @brief "+::prov.descr+@" - common header
0097 *
0098 * @file test"+::prov.testname+@".h
0099 */
0100 /* -----------------------------------------------------------------------------
0101 * Enduro/X Middleware Platform for Distributed Transaction Processing
0102 * Copyright (C) 2009-2016, ATR Baltic, Ltd. All Rights Reserved.
0103 * Copyright (C) 2017-2023, Mavimax, Ltd. All Rights Reserved.
0104 * This software is released under one of the following licenses:
0105 * AGPL (with Java and Go exceptions) or Mavimax's license for commercial use.
0106 * See LICENSE file for full text.
0107 * -----------------------------------------------------------------------------
0108 * AGPL license:
0109 *
0110 * This program is free software; you can redistribute it and/or modify it under
0111 * the terms of the GNU Affero General Public License, version 3 as published
0112 * by the Free Software Foundation;
0113 *
0114 * This program is distributed in the hope that it will be useful, but WITHOUT ANY
0115 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
0116 * PARTICULAR PURPOSE. See the GNU Affero General Public License, version 3
0117 * for more details.
0118 *
0119 * You should have received a copy of the GNU Affero General Public License along
0120 * with this program; if not, write to the Free Software Foundation, Inc.,
0121 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
0122 *
0123 * -----------------------------------------------------------------------------
0124 * A commercial use license is available from Mavimax, Ltd
0125 * contact@mavimax.com
0126 * -----------------------------------------------------------------------------
0127 */
0128 #ifndef TEST"+::prov.testid+@"_H
0129 #define TEST"+::prov.testid+@"_H
0130
0131 #ifdef __cplusplus
0132 extern ""C"" {
0133 #endif
0134
0135
0136 #define VALUE_EXPECTED ""Hello EnduroX""
0137
0138 #ifdef __cplusplus
0139 }
0140 #endif
0141
0142 #endif /* TEST"+::prov.testid+@"_H */
0143
0144 /* vim: set ts=4 sw=4 et smartindent: */
0145 "))
0146 {
0147 return false;
0148 }
0149 //
0150 // Client code
0151 //
0152 if (!::prov.writeFile(::prov.client,
0153
0154 @"/**
0155 * @brief "+::prov.descr+@" - client
0156 *
0157 * @file atmiclt"+::prov.testid+@".c
0158 */
0159 /* -----------------------------------------------------------------------------
0160 * Enduro/X Middleware Platform for Distributed Transaction Processing
0161 * Copyright (C) 2009-2016, ATR Baltic, Ltd. All Rights Reserved.
0162 * Copyright (C) 2017-2023, Mavimax, Ltd. All Rights Reserved.
0163 * This software is released under one of the following licenses:
0164 * AGPL (with Java and Go exceptions) or Mavimax's license for commercial use.
0165 * See LICENSE file for full text.
0166 * -----------------------------------------------------------------------------
0167 * AGPL license:
0168 *
0169 * This program is free software; you can redistribute it and/or modify it under
0170 * the terms of the GNU Affero General Public License, version 3 as published
0171 * by the Free Software Foundation;
0172 *
0173 * This program is distributed in the hope that it will be useful, but WITHOUT ANY
0174 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
0175 * PARTICULAR PURPOSE. See the GNU Affero General Public License, version 3
0176 * for more details.
0177 *
0178 * You should have received a copy of the GNU Affero General Public License along
0179 * with this program; if not, write to the Free Software Foundation, Inc.,
0180 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
0181 *
0182 * -----------------------------------------------------------------------------
0183 * A commercial use license is available from Mavimax, Ltd
0184 * contact@mavimax.com
0185 * -----------------------------------------------------------------------------
0186 */
0187 #include <string.h>
0188 #include <stdio.h>
0189 #include <stdlib.h>
0190 #include <memory.h>
0191 #include <math.h>
0192
0193 #include <atmi.h>
0194 #include <ubf.h>
0195 #include <ndebug.h>
0196 #include <test.fd.h>
0197 #include <ndrstandard.h>
0198 #include <nstopwatch.h>
0199 #include <fcntl.h>
0200 #include <unistd.h>
0201 #include <nstdutil.h>
0202 #include ""test"+::prov.testid+@".h""
0203 /*---------------------------Externs------------------------------------*/
0204 /*---------------------------Macros-------------------------------------*/
0205 /*---------------------------Enums--------------------------------------*/
0206 /*---------------------------Typedefs-----------------------------------*/
0207 /*---------------------------Globals------------------------------------*/
0208 /*---------------------------Statics------------------------------------*/
0209 /*---------------------------Prototypes---------------------------------*/
0210
0211 /**
0212 * Do the test call to the server
0213 */
0214 int main(int argc, char** argv)
0215 {
0216
0217 UBFH *p_ub = (UBFH *)tpalloc(""UBF"", NULL, 56000);
0218 long rsplen;
0219 int i;
0220 int ret=EXSUCCEED;
0221
0222 if (EXFAIL==CBchg(p_ub, T_STRING_FLD, 0, VALUE_EXPECTED, 0, BFLD_STRING))
0223 {
0224 NDRX_LOG(log_debug, ""Failed to set T_STRING_FLD[0]: %s"", Bstrerror(Berror));
0225 ret=EXFAIL;
0226 goto out;
0227 }
0228
0229 if (EXFAIL == tpcall(""TESTSV"", (char *)p_ub, 0L, (char **)&p_ub, &rsplen,0))
0230 {
0231 NDRX_LOG(log_error, ""TESTSV failed: %s"", tpstrerror(tperrno));
0232 ret=EXFAIL;
0233 goto out;
0234 }
0235
0236 out:
0237 tpterm();
0238 fprintf(stderr, ""Exit with %d\n"", ret);
0239
0240 return ret;
0241 }
0242
0243 /* vim: set ts=4 sw=4 et smartindent: */
0244 "))
0245 {
0246 return false;
0247 }
0248
0249 //
0250 // server code
0251 //
0252 if (!::prov.writeFile(::prov.server,
0253
0254 @"/**
0255 * @brief "+::prov.descr+@" - server
0256 *
0257 * @file atmisv"+::prov.testid+@".c
0258 */
0259 /* -----------------------------------------------------------------------------
0260 * Enduro/X Middleware Platform for Distributed Transaction Processing
0261 * Copyright (C) 2009-2016, ATR Baltic, Ltd. All Rights Reserved.
0262 * Copyright (C) 2017-2023, Mavimax, Ltd. All Rights Reserved.
0263 * This software is released under one of the following licenses:
0264 * AGPL (with Java and Go exceptions) or Mavimax's license for commercial use.
0265 * See LICENSE file for full text.
0266 * -----------------------------------------------------------------------------
0267 * AGPL license:
0268 *
0269 * This program is free software; you can redistribute it and/or modify it under
0270 * the terms of the GNU Affero General Public License, version 3 as published
0271 * by the Free Software Foundation;
0272 *
0273 * This program is distributed in the hope that it will be useful, but WITHOUT ANY
0274 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
0275 * PARTICULAR PURPOSE. See the GNU Affero General Public License, version 3
0276 * for more details.
0277 *
0278 * You should have received a copy of the GNU Affero General Public License along
0279 * with this program; if not, write to the Free Software Foundation, Inc.,
0280 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
0281 *
0282 * -----------------------------------------------------------------------------
0283 * A commercial use license is available from Mavimax, Ltd
0284 * contact@mavimax.com
0285 * -----------------------------------------------------------------------------
0286 */
0287 #include <stdio.h>
0288 #include <stdlib.h>
0289 #include <ndebug.h>
0290 #include <atmi.h>
0291 #include <ndrstandard.h>
0292 #include <ubf.h>
0293 #include <test.fd.h>
0294 #include <string.h>
0295 #include <unistd.h>
0296 #include ""test"+::prov.testid+@".h""
0297
0298 /*---------------------------Externs------------------------------------*/
0299 /*---------------------------Macros-------------------------------------*/
0300 /*---------------------------Enums--------------------------------------*/
0301 /*---------------------------Typedefs-----------------------------------*/
0302 /*---------------------------Globals------------------------------------*/
0303 /*---------------------------Statics------------------------------------*/
0304 /*---------------------------Prototypes---------------------------------*/
0305
0306 /**
0307 * Standard service entry
0308 */
0309 void TESTSV (TPSVCINFO *p_svc)
0310 {
0311 int ret=EXSUCCEED;
0312 char testbuf[1024];
0313 UBFH *p_ub = (UBFH *)p_svc->data;
0314
0315 NDRX_LOG(log_debug, ""%s got call"", __func__);
0316
0317 /* Just print the buffer */
0318 Bprint(p_ub);
0319
0320 if (EXFAIL==Bget(p_ub, T_STRING_FLD, 0, testbuf, 0))
0321 {
0322 NDRX_LOG(log_error, ""TESTERROR: Failed to get T_STRING_FLD: %s"",
0323 Bstrerror(Berror));
0324 ret=EXFAIL;
0325 goto out;
0326 }
0327
0328 if (0!=strcmp(testbuf, VALUE_EXPECTED))
0329 {
0330 NDRX_LOG(log_error, ""TESTERROR: Expected: [%s] got [%s]"",
0331 VALUE_EXPECTED, testbuf);
0332 ret=EXFAIL;
0333 goto out;
0334 }
0335
0336
0337 out:
0338 tpreturn( ret==EXSUCCEED?TPSUCCESS:TPFAIL,
0339 0L,
0340 (char *)p_ub,
0341 0L,
0342 0L);
0343 }
0344
0345 /**
0346 * Do initialisation
0347 */
0348 int NDRX_INTEGRA(tpsvrinit)(int argc, char **argv)
0349 {
0350 int ret = EXSUCCEED;
0351 NDRX_LOG(log_debug, ""tpsvrinit called"");
0352
0353 if (EXSUCCEED!=tpadvertise(""TESTSV"", TESTSV))
0354 {
0355 NDRX_LOG(log_error, ""Failed to initialise TESTSV!"");
0356 EXFAIL_OUT(ret);
0357 }
0358 out:
0359 return ret;
0360 }
0361
0362 /**
0363 * Do de-initialisation
0364 */
0365 void NDRX_INTEGRA(tpsvrdone)(void)
0366 {
0367 NDRX_LOG(log_debug, ""tpsvrdone called"");
0368 }
0369
0370 /* vim: set ts=4 sw=4 et smartindent: */
0371 "))
0372 {
0373 return false;
0374 }
0375 //
0376 // Makefile
0377 //
0378 if (!::prov.writeFile(::prov.make,
0379
0380 @"##
0381 ## @brief "+::prov.descr+@" - server
0382 ##
0383 ## @file atmisv"+::prov.testid+@".c
0384 ##
0385 ## -----------------------------------------------------------------------------
0386 ## Enduro/X Middleware Platform for Distributed Transaction Processing
0387 ## Copyright (C) 2009-2016, ATR Baltic, Ltd. All Rights Reserved.
0388 ## Copyright (C) 2017-2023, Mavimax, Ltd. All Rights Reserved.
0389 ## This software is released under one of the following licenses:
0390 ## AGPL (with Java and Go exceptions) or Mavimax's license for commercial use.
0391 ## See LICENSE file for full text.
0392 ## -----------------------------------------------------------------------------
0393 ## AGPL license:
0394 ##
0395 ## This program is free software; you can redistribute it and/or modify it under
0396 ## the terms of the GNU Affero General Public License, version 3 as published
0397 ## by the Free Software Foundation;
0398 ##
0399 ## This program is distributed in the hope that it will be useful, but WITHOUT ANY
0400 ## WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
0401 ## PARTICULAR PURPOSE. See the GNU Affero General Public License, version 3
0402 ## for more details.
0403 ##
0404 ## You should have received a copy of the GNU Affero General Public License along
0405 ## with this program; if not, write to the Free Software Foundation, Inc.,
0406 ## 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
0407 ##
0408 ## -----------------------------------------------------------------------------
0409 ## A commercial use license is available from Mavimax, Ltd
0410 ## contact@mavimax.com
0411 ## -----------------------------------------------------------------------------
0412 ##
0413
0414 cmake_minimum_required(VERSION 3.1)
0415
0416 # Make sure the compiler can find include files from UBF library
0417 include_directories (${ENDUROX_SOURCE_DIR}/libubf
0418 ${ENDUROX_SOURCE_DIR}/include
0419 ${ENDUROX_SOURCE_DIR}/libnstd
0420 ${ENDUROX_SOURCE_DIR}/ubftest)
0421
0422
0423 # Add debug options
0424 # By default if RELEASE_BUILD is not defined, then we run in debug!
0425 IF ($ENV{RELEASE_BUILD})
0426 # do nothing
0427 ELSE ($ENV{RELEASE_BUILD})
0428 ADD_DEFINITIONS(""-D NDRX_DEBUG"")
0429 ENDIF ($ENV{RELEASE_BUILD})
0430
0431 # Make sure the linker can find the UBF library once it is built.
0432 link_directories (${ENDUROX_BINARY_DIR}/libubf)
0433
0434 ############################# Test - executables ###############################
0435 add_executable (atmi.sv"+::prov.testid+@" atmisv"+::prov.testid+@".c ../../libatmisrv/rawmain_integra.c)
0436 add_executable (atmiclt"+::prov.testid+@" atmiclt"+::prov.testid+@".c)
0437 ################################################################################
0438 ############################# Test - executables ###############################
0439 # Link the executable to the ATMI library & others...
0440 target_link_libraries (atmi.sv"+::prov.testid+@" atmisrvinteg atmi ubf nstd m pthread ${RT_LIB})
0441 target_link_libraries (atmiclt"+::prov.testid+@" atmiclt atmi ubf nstd m pthread ${RT_LIB})
0442
0443 set_target_properties(atmi.sv"+::prov.testid+@" PROPERTIES LINK_FLAGS ""$ENV{MYLDFLAGS}"")
0444 set_target_properties(atmiclt"+::prov.testid+@" PROPERTIES LINK_FLAGS ""$ENV{MYLDFLAGS}"")
0445 ################################################################################
0446
0447 # vim: set ts=4 sw=4 et smartindent:
0448 "))
0449 {
0450 return false;
0451 }
0452
0453 //
0454 // Debug configuration
0455 //
0456 if ("n"==::prov.dom1 && "n"==::prov.dom2 && !::prov.writeFile(::prov.debug,
0457
0458 @"* ndrx=5 ubf=1 lines=1 bufsz=1000 file=${TESTDIR}/ndrx.log
0459 atmiclt"+::prov.testid+@" file=${TESTDIR}/atmiclt"+::prov.testid+@".log
0460 atmi.sv"+::prov.testid+@" file=${TESTDIR}/atmisv"+::prov.testid+@".log
0461
0462 "))
0463 {
0464 return false;
0465 }
0466 //
0467 // Run file (local one)
0468 //
0469 if ("n"==::prov.dom1 && "n"==::prov.dom2 && !::prov.writeFile(::prov.run,
0470
0471 @"#!/bin/bash
0472 ##
0473 ## @brief "+::prov.descr+@" - test launcher
0474 ##
0475 ## @file run.sh
0476 ##
0477 ## -----------------------------------------------------------------------------
0478 ## Enduro/X Middleware Platform for Distributed Transaction Processing
0479 ## Copyright (C) 2009-2016, ATR Baltic, Ltd. All Rights Reserved.
0480 ## Copyright (C) 2017-2023, Mavimax, Ltd. All Rights Reserved.
0481 ## This software is released under one of the following licenses:
0482 ## AGPL (with Java and Go exceptions) or Mavimax's license for commercial use.
0483 ## See LICENSE file for full text.
0484 ## -----------------------------------------------------------------------------
0485 ## AGPL license:
0486 ##
0487 ## This program is free software; you can redistribute it and/or modify it under
0488 ## the terms of the GNU Affero General Public License, version 3 as published
0489 ## by the Free Software Foundation;
0490 ##
0491 ## This program is distributed in the hope that it will be useful, but WITHOUT ANY
0492 ## WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
0493 ## PARTICULAR PURPOSE. See the GNU Affero General Public License, version 3
0494 ## for more details.
0495 ##
0496 ## You should have received a copy of the GNU Affero General Public License along
0497 ## with this program; if not, write to the Free Software Foundation, Inc.,
0498 ## 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
0499 ##
0500 ## -----------------------------------------------------------------------------
0501 ## A commercial use license is available from Mavimax, Ltd
0502 ## contact@mavimax.com
0503 ## -----------------------------------------------------------------------------
0504 ##
0505
0506 TESTNAME="""+::prov.testname+@"""
0507
0508 PWD=`pwd`
0509 if [ `echo $PWD | grep $TESTNAME ` ]; then
0510 # Do nothing
0511 echo > /dev/null
0512 else
0513 # started from parent folder
0514 pushd .
0515 echo ""Doing cd""
0516 cd "+::prov.testname+@"
0517 fi;
0518
0519 . ../testenv.sh
0520
0521 export TESTDIR=""$NDRX_APPHOME/atmitest/$TESTNAME""
0522 export PATH=$PATH:$TESTDIR
0523 export NDRX_ULOG=$TESTDIR
0524
0525 xadmin killall atmi.sv"+::prov.testid+@" 2>/dev/null
0526 xadmin killall atmiclt"+::prov.testid+@" 2>/dev/null
0527
0528 # client timeout
0529 export NDRX_TOUT=10
0530 export NDRX_ULOG=$TESTDIR
0531 export NDRX_DEBUG_CONF=`pwd`/debug.conf
0532
0533 function go_out {
0534 echo ""Test exiting with: $1""
0535 xadmin killall atmi.sv"+::prov.testid+@" 2>/dev/null
0536 xadmin killall atmiclt"+::prov.testid+@" 2>/dev/null
0537
0538 popd 2>/dev/null
0539 exit $1
0540 }
0541
0542
0543 rm *.log
0544
0545 (./atmi.sv"+::prov.testid+@" -i123 2>&1) > ./atmisv"+::prov.testid+@".log &
0546 sleep 1
0547 (./atmiclt"+::prov.testid+@" 2>&1) > ./atmiclt"+::prov.testid+@".log
0548
0549 RET=$?
0550
0551 # Catch is there is test error!!!
0552 if [ ""X`grep TESTERROR *.log`"" != ""X"" ]; then
0553 echo ""Test error detected!""
0554 go_out -2
0555 fi
0556
0557 go_out $RET
0558
0559 # vim: set ts=4 sw=4 et smartindent:
0560
0561 "))
0562 {
0563 return false;
0564 }
0565 //
0566 // Domain 1 XML configuration
0567 //
0568 if ("y"==::prov.dom1 && !::prov.writeFile(::prov.dom1_ndrxconf,
0569
0570 @"<?xml version=""1.0"" ?>
0571 <endurox>
0572 <appconfig>
0573 <!-- ALL BELLOW ONES USES <sanity> periodical timer -->
0574 <!-- Sanity check time, sec -->
0575 <sanity>1</sanity>
0576 <!-- If process have been state changed to other than dead, exit or not running
0577 but PID of program does not exists in system, then send internel message, then
0578 program have been stopped.
0579 In Seconds.
0580 -->
0581 <checkpm>5</checkpm>
0582 <!-- <sanity> timer, end -->
0583 <!-- ALL BELLOW ONES USES <respawn> periodical timer -->
0584 <!-- Do process reset after 1 sec -->
0585 <restart_min>1</restart_min>
0586 <!-- If restart fails, then boot after +5 sec of previous wait time -->
0587 <restart_step>10</restart_step>
0588 <!-- If still not started, then max boot time is a 30 sec. -->
0589 <restart_max>30</restart_max>
0590 <!-- <sanity> timer, end -->
0591
0592 <!-- Time after attach when program will start do sanity & respawn checks,
0593 starts counting after configuration load -->
0594 <restart_to_check>20</restart_to_check>
0595 <!-- Send full service table every 5 seconds -->
0596 <brrefresh>5</brrefresh>
0597 </appconfig>
0598 <defaults>
0599 <min>1</min>
0600 <max>1</max>
0601 <autokill>1</autokill>
0602 <!-- Do not need respawning! -->
0603 <respawn>1</respawn>
0604 <!-- The maximum time while process can hang in 'starting' state i.e.
0605 have not completed initialisation, sec -->
0606 <start_max>20</start_max>
0607 <!--
0608 Ping server in every X sanity units
0609 -->
0610 <pingtime>9</pingtime>
0611 <!--
0612 Max number of sanity units in which server must respond.
0613 The granularity is sanity time.
0614 -->
0615 <ping_max>40</ping_max>
0616 <!--
0617 Max time to wait until process should exit on shutdown
0618 -->
0619 <end_max>30</end_max>
0620 <!-- Interval, in seconds, by which signal sequence -2, -15, -9, -9.... will be sent
0621 to process until it have been terminated. -->
0622 <killtime>20</killtime>
0623 </defaults>
0624 <servers>
0625 " +("n"==::prov.dom2?
0626 @" <server name=""atmi.sv"+::prov.testid+@""">
0627 <min>1</min>
0628 <max>1</max>
0629 <srvid>10</srvid>
0630 <sysopt>-e ${TESTDIR}/atmisv-dom1.log -r</sysopt>
0631 </server>
0632 ":""
0633 )+
0634 @" <server name=""tpbridge"">
0635 <max>1</max>
0636 <srvid>101</srvid>
0637 <sysopt>-e ${TESTDIR}/tpbridge-dom1.log -r</sysopt>
0638 <appopt>-f -n2 -r -i 127.0.0.1 -p 20003 -tA -z30 -P0</appopt>
0639 </server>
0640 </servers>
0641 </endurox>
0642
0643 "))
0644 {
0645 return false;
0646 }
0647
0648 //
0649 // Domain 2 XML configuration
0650 //
0651 if ("y"==::prov.dom2 && !::prov.writeFile(::prov.dom2_ndrxconf,
0652
0653 @"<?xml version=""1.0"" ?>
0654 <endurox>
0655 <appconfig>
0656 <!-- ALL BELLOW ONES USES <sanity> periodical timer -->
0657 <!-- Sanity check time, sec -->
0658 <sanity>1</sanity>
0659 <!-- If process have been state changed to other than dead, exit or not running
0660 but PID of program does not exists in system, then send internel message, then
0661 program have been stopped.
0662 In Seconds.
0663 -->
0664 <checkpm>5</checkpm>
0665 <!-- <sanity> timer, end -->
0666
0667 <!-- ALL BELLOW ONES USES <respawn> periodical timer -->
0668 <!-- Do process reset after 1 sec -->
0669 <restart_min>1</restart_min>
0670 <!-- If restart fails, then boot after +5 sec of previous wait time -->
0671 <restart_step>10</restart_step>
0672 <!-- If still not started, then max boot time is a 30 sec. -->
0673 <restart_max>30</restart_max>
0674 <!-- <sanity> timer, end -->
0675
0676 <!-- Time after attach when program will start do sanity & respawn checks,
0677 starts counting after configuration load -->
0678 <restart_to_check>20</restart_to_check>
0679 <!-- Send full service table every 5 seconds -->
0680 <brrefresh>5</brrefresh>
0681 </appconfig>
0682 <defaults>
0683 <min>1</min>
0684 <max>1</max>
0685 <autokill>1</autokill>
0686 <!-- Do not need respawning! -->
0687 <respawn>1</respawn>
0688 <!-- The maximum time while process can hang in 'starting' state i.e.
0689 have not completed initialisation, sec -->
0690 <start_max>20</start_max>
0691 <!--
0692 Ping server in every X sanity checks
0693 -->
0694 <pingtime>9</pingtime>
0695 <!--
0696 Max number of sanity units in which server must respond.
0697 -->
0698 <ping_max>40</ping_max>
0699 <!--
0700 Max time to wait until process should exit on shutdown
0701 -->
0702 <end_max>30</end_max>
0703 <!-- Interval, in seconds, by which signal sequence -2, -15, -9, -9.... will be sent
0704 to process until it have been terminated. -->
0705 <killtime>20</killtime>
0706 </defaults>
0707 <servers>
0708 <server name=""atmi.sv"+::prov.testid+@""">
0709 <min>1</min>
0710 <max>1</max>
0711 <srvid>10</srvid>
0712 <sysopt>-e ${TESTDIR}/atmisv-dom2.log -r</sysopt>
0713 </server>
0714 <server name=""tpbridge"">
0715 <max>1</max>
0716 <srvid>101</srvid>
0717 <sysopt>-e ${TESTDIR}/bridge-dom2.log -r</sysopt>
0718 <appopt>-f -n1 -r -i 0.0.0.0 -p 20003 -tP -z30 -P0</appopt>
0719 </server>
0720 </servers>
0721 </endurox>
0722
0723
0724 "))
0725 {
0726 return false;
0727 }
0728 //
0729 // Debug dom1 configuration
0730 //
0731 if ("y"==::prov.dom1 && !::prov.writeFile(::prov.dom1_debug,
0732
0733 @"* ndrx=5 ubf=1 lines=1 bufsz=1000 file=${TESTDIR}/ndrx-dom1.log
0734 xadmin file=${TESTDIR}/xadmin-dom1.log
0735 ndrxd file=${TESTDIR}/ndrxd-dom1.log
0736 atmiclt"+::prov.testid+@" file=${TESTDIR}/atmiclt-dom1.log
0737 "+("y"==::prov.dom1 && "n"==::prov.dom2?@"
0738 atmi.sv"+::prov.testid+@" file=${TESTDIR}/atmisv-dom1.log
0739 ":"")+@"
0740 tpbridge file=${TESTDIR}/tpbridge-dom1.log threaded=y
0741 "))
0742 {
0743 return false;
0744 }
0745
0746 //
0747 // Debug dom2 configuration
0748 //
0749 if ("y"==::prov.dom2 && !::prov.writeFile(::prov.dom2_debug,
0750 @"* ndrx=5 ubf=1 lines=1 bufsz=1000 file=${TESTDIR}/ndrx-dom2.log
0751 xadmin file=${TESTDIR}/xadmin-dom2.log
0752 ndrxd file=${TESTDIR}/ndrxd-dom2.log
0753 atmi.sv"+::prov.testid+@" file=${TESTDIR}/atmisv-dom2.log
0754 tpbridge file=${TESTDIR}/tpbridge-dom2.log threaded=y
0755 "))
0756 {
0757 return false;
0758 }
0759
0760 //
0761 // Run config for domains..
0762 //
0763 if ("y"==::prov.dom1 && !::prov.writeFile(::prov.run,
0764
0765 @"#!/bin/bash
0766 ##
0767 ## @brief "+::prov.descr+@" - test launcher
0768 ##
0769 ## @file run.sh
0770 ##
0771 ## -----------------------------------------------------------------------------
0772 ## Enduro/X Middleware Platform for Distributed Transaction Processing
0773 ## Copyright (C) 2009-2016, ATR Baltic, Ltd. All Rights Reserved.
0774 ## Copyright (C) 2017-2023, Mavimax, Ltd. All Rights Reserved.
0775 ## This software is released under one of the following licenses:
0776 ## AGPL (with Java and Go exceptions) or Mavimax's license for commercial use.
0777 ## See LICENSE file for full text.
0778 ## -----------------------------------------------------------------------------
0779 ## AGPL license:
0780 ##
0781 ## This program is free software; you can redistribute it and/or modify it under
0782 ## the terms of the GNU Affero General Public License, version 3 as published
0783 ## by the Free Software Foundation;
0784 ##
0785 ## This program is distributed in the hope that it will be useful, but WITHOUT ANY
0786 ## WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
0787 ## PARTICULAR PURPOSE. See the GNU Affero General Public License, version 3
0788 ## for more details.
0789 ##
0790 ## You should have received a copy of the GNU Affero General Public License along
0791 ## with this program; if not, write to the Free Software Foundation, Inc.,
0792 ## 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
0793 ##
0794 ## -----------------------------------------------------------------------------
0795 ## A commercial use license is available from Mavimax, Ltd
0796 ## contact@mavimax.com
0797 ## -----------------------------------------------------------------------------
0798 ##
0799
0800 export TESTNAME="""+::prov.testname+@"""
0801
0802 PWD=`pwd`
0803 if [ `echo $PWD | grep $TESTNAME ` ]; then
0804 # Do nothing
0805 echo > /dev/null
0806 else
0807 # started from parent folder
0808 pushd .
0809 echo ""Doing cd""
0810 cd $TESTNAME
0811 fi;
0812
0813 . ../testenv.sh
0814
0815 export TESTDIR=""$NDRX_APPHOME/atmitest/$TESTNAME""
0816 export PATH=$PATH:$TESTDIR
0817 export NDRX_ULOG=$TESTDIR
0818 export NDRX_TOUT=10
0819
0820 #
0821 # Domain 1 - here client will live
0822 #
0823 set_dom1() {
0824 echo ""Setting domain 1""
0825 . ../dom1.sh
0826 export NDRX_CONFIG=$TESTDIR/ndrxconfig-dom1.xml
0827 export NDRX_DMNLOG=$TESTDIR/ndrxd-dom1.log
0828 export NDRX_LOG=$TESTDIR/ndrx-dom1.log
0829 export NDRX_DEBUG_CONF=$TESTDIR/debug-dom1.conf
0830 }
0831
0832 "+("y"==::prov.dom2?@"
0833 #
0834 # Domain 2 - here server will live
0835 #
0836 set_dom2() {
0837 echo ""Setting domain 2""
0838 . ../dom2.sh
0839 export NDRX_CONFIG=$TESTDIR/ndrxconfig-dom2.xml
0840 export NDRX_DMNLOG=$TESTDIR/ndrxd-dom2.log
0841 export NDRX_LOG=$TESTDIR/ndrx-dom2.log
0842 export NDRX_DEBUG_CONF=$TESTDIR/debug-dom2.conf
0843 }":"")+@"
0844
0845 #
0846 # Generic exit function
0847 #
0848 function go_out {
0849 echo ""Test exiting with: $1""
0850
0851 set_dom1;
0852 xadmin stop -y
0853 xadmin down -y
0854
0855 "+("y"==::prov.dom2?@"
0856 set_dom2;
0857 xadmin stop -y
0858 xadmin down -y":"")+@"
0859
0860 # If some alive stuff left...
0861 xadmin killall atmiclt"+::prov.testid+@"
0862
0863 popd 2>/dev/null
0864 exit $1
0865 }
0866
0867 rm *dom*.log
0868 # Any bridges that are live must be killed!
0869 xadmin killall tpbridge
0870
0871 set_dom1;
0872 xadmin down -y
0873 xadmin start -y || go_out 1
0874
0875 "+("y"==::prov.dom2?@"
0876 set_dom2;
0877 xadmin down -y
0878 xadmin start -y || go_out 2
0879 ":"")+@"
0880
0881 # Have some wait for ndrxd goes in service - wait for connection establishment.
0882 sleep 30
0883 RET=0
0884
0885 xadmin psc
0886 xadmin ppm
0887 echo ""Running off client""
0888
0889 set_dom1;
0890 (./atmiclt"+::prov.testid+@" 2>&1) > ./atmiclt-dom1.log
0891 #(valgrind --leak-check=full --log-file=""v.out"" -v ./atmiclt"+::prov.testid+@" 2>&1) > ./atmiclt-dom1.log
0892
0893 RET=$?
0894
0895 if [[ ""X$RET"" != ""X0"" ]]; then
0896 go_out $RET
0897 fi
0898
0899 # Catch is there is test error!!!
0900 if [ ""X`grep TESTERROR *.log`"" != ""X"" ]; then
0901 echo ""Test error detected!""
0902 RET=-2
0903 fi
0904
0905
0906 go_out $RET
0907
0908
0909 # vim: set ts=4 sw=4 et smartindent:
0910
0911 "))
0912 {
0913 return false;
0914 }
0915 //
0916 // Give execute permissions for runner
0917 //
0918 if (!::prov.setExec(::prov.run))
0919 {
0920 return false;
0921 }
0922
0923 }
0924 else
0925 {
0926 return false;
0927 }
0928
0929 return true;
0930 }
0931
0932 if (::install())
0933 {
0934 print("local test case gen succeed!\n");
0935
0936 return 0;
0937 }
0938 else
0939 {
0940 print("local test case gen failed!\n");
0941 return -1;
0942 }