diff options
Diffstat (limited to 'TAO/orbsvcs/tests/ImplRepo')
18 files changed, 2533 insertions, 463 deletions
diff --git a/TAO/orbsvcs/tests/ImplRepo/README b/TAO/orbsvcs/tests/ImplRepo/README index d55a9c2f33d..91042fca6f3 100644 --- a/TAO/orbsvcs/tests/ImplRepo/README +++ b/TAO/orbsvcs/tests/ImplRepo/README @@ -9,10 +9,27 @@ nt_service_ir same as above but runs ImplRepo as an NT service. nestea runs nestea client and server without ImplRepo. nestea_ir same as above but uses ImplRepo. both_ir combines airplane_ir and nestea_ir. -persistent_ir same as airplane_ir, but using persistent ImplRepo. - -The nt_service_ir test will work only on Win32 platforms. For the test to -run successfully, these conditions must be met: +persistent_ir same as airplane_ir, but using persistent + "-x <file>" flag for the ImplRepo. +persistent_ir_hash same as persistent_ir, but using "-p <file>" flag. +persistent_ir_registry same as persistent_ir, but using "-r" flag + (windows registry flag). +persistent_ir_shared same as persistent_ir, but using + "--directory <dir>" flag. +persistent_ft runs a primary and backup ImR Locator, verifying + persistence works in different scenarios of + the primary or backup being shutdown. Must also + pass the "-replica" command to run_test.pl for + this test to run. +failover runs a primary and backup ImR Locator, verifying + different scenarios of the primary or backup being + shutdown and clients, servers, activators, and + tao_imr activities being unaffected. Must also + pass the "-replica" command to run_test.pl for + this test to run. + +The nt_service_ir and persistent_ir_registry tests will work only on Win32 +platforms. For the test to run successfully, these conditions must be met: -- The user must be logged in as administrator, or have administrative priveleges (in order to register an NT service). diff --git a/TAO/orbsvcs/tests/ImplRepo/ReconnectServer/client.cpp b/TAO/orbsvcs/tests/ImplRepo/ReconnectServer/client.cpp index bc61035a1b9..114f0be51cc 100755 --- a/TAO/orbsvcs/tests/ImplRepo/ReconnectServer/client.cpp +++ b/TAO/orbsvcs/tests/ImplRepo/ReconnectServer/client.cpp @@ -118,10 +118,6 @@ ACE_TMAIN(int argc, ACE_TCHAR *argv[]) } CORBA::Object_var object = orb->resolve_initial_references ("RootPOA"); - PortableServer::POA_var rootPOA = PortableServer::POA::_narrow (object.in ()); - - PortableServer::POAManager_var poa_manager = rootPOA->the_POAManager (); - poa_manager->activate (); object = orb->string_to_object(ior_input_file); @@ -142,8 +138,6 @@ ACE_TMAIN(int argc, ACE_TCHAR *argv[]) task.wait (); - // Destroy the POA, waiting until the destruction terminates - rootPOA->destroy (1, 1); orb->destroy (); if (task.test_passed ()) diff --git a/TAO/orbsvcs/tests/ImplRepo/RestartServer/Messenger.idl b/TAO/orbsvcs/tests/ImplRepo/RestartServer/Messenger.idl new file mode 100644 index 00000000000..880e7790199 --- /dev/null +++ b/TAO/orbsvcs/tests/ImplRepo/RestartServer/Messenger.idl @@ -0,0 +1,18 @@ +// $Id$ + +// messenger.idl + +interface Messenger +{ + boolean send_message ( in string user_name, + in string subject, + inout string message ); + + // After replying, abort process in + // delay_secs seconds. + void abort ( in short delay_secs ); + + // Perform a graceful shutdown. + oneway void shutdown (); +}; + diff --git a/TAO/orbsvcs/tests/ImplRepo/RestartServer/MessengerClient.cpp b/TAO/orbsvcs/tests/ImplRepo/RestartServer/MessengerClient.cpp new file mode 100644 index 00000000000..7cd8c1d5d08 --- /dev/null +++ b/TAO/orbsvcs/tests/ImplRepo/RestartServer/MessengerClient.cpp @@ -0,0 +1,82 @@ +// $Id$ + +#include "MessengerC.h" +#include <iostream> +#include "ace/Get_Opt.h" +#include "ace/OS_NS_unistd.h" + +const ACE_TCHAR *ior = ACE_TEXT("file://Messenger.ior"); + +int +parse_args (int argc, ACE_TCHAR *argv[]) +{ + ACE_Get_Opt get_opts (argc, argv, ACE_TEXT("k:")); + int c; + + while ((c = get_opts ()) != -1) + switch (c) + { + case 'k': + ior = get_opts.opt_arg (); + break; + + case '?': + default: + ACE_ERROR_RETURN ((LM_ERROR, + "usage: %s " + "-k <ior> " + "\n", + argv [0]), + -1); + } + // Indicates successful parsing of the command line + return 0; +} + +int +ACE_TMAIN (int argc, ACE_TCHAR *argv[]) +{ + try { + // Initialize orb + CORBA::ORB_var orb = CORBA::ORB_init( argc, argv ); + + if (parse_args (argc, argv) != 0) + return 1; + + // Destringify ior + CORBA::Object_var obj = orb->string_to_object( ior ); + if (CORBA::is_nil(obj.in())) { + std::cerr << "Nil Messenger reference" << std::endl; + return 1; + } + + // Narrow + Messenger_var messenger = Messenger::_narrow( obj.in() ); + if (CORBA::is_nil(messenger.in())) { + std::cerr << "Argument is not a Messenger reference" << std::endl; + return 1; + } + + CORBA::String_var message = CORBA::string_dup( "Hello!" ); + + messenger->send_message( "TAO User", "Test 1", message.inout() ); + + // Force server to abort to verify it will be brought + // back up when send_message() is called. + messenger->abort(2); + ACE_OS::sleep(4); + + ACE_DEBUG ((LM_INFO, + "(%P|%t) - Sending another message after abort of server\n")); + + messenger->send_message( "TAO User", "Test 2", message.inout() ); + + std::cout << "messages were sent" << std::endl; + } + catch(const CORBA::Exception& ex) { + std::cerr << "Client main() Caught CORBA::Exception: " << ex << std::endl; + return 1; + } + + return 0; +} diff --git a/TAO/orbsvcs/tests/ImplRepo/RestartServer/MessengerServer.cpp b/TAO/orbsvcs/tests/ImplRepo/RestartServer/MessengerServer.cpp new file mode 100644 index 00000000000..370144b98d7 --- /dev/null +++ b/TAO/orbsvcs/tests/ImplRepo/RestartServer/MessengerServer.cpp @@ -0,0 +1,117 @@ +// $Id$ + +// MessengerServer.cpp +// This version uses the Implementation Repository. + +#include "Messenger_i.h" +#include "Terminator.h" + +#include "tao/IORTable/IORTable.h" +#include "tao/PortableServer/Root_POA.h" + +#include <iostream> + +PortableServer::POA_ptr +createPOA(PortableServer::POA_ptr root_poa, const char* poa_name) +{ + PortableServer::LifespanPolicy_var life = + root_poa->create_lifespan_policy(PortableServer::PERSISTENT); + + PortableServer::IdAssignmentPolicy_var assign = + root_poa->create_id_assignment_policy(PortableServer::USER_ID); + + CORBA::PolicyList pols; + pols.length(2); + pols[0] = PortableServer::LifespanPolicy::_duplicate(life.in()); + pols[1] = PortableServer::IdAssignmentPolicy::_duplicate(assign.in()); + + PortableServer::POAManager_var mgr = root_poa->the_POAManager(); + PortableServer::POA_var poa = + root_poa->create_POA(poa_name, mgr.in(), pols); + + life->destroy(); + assign->destroy(); + + return poa._retn(); +} + +int +ACE_TMAIN (int argc, ACE_TCHAR *argv[]) +{ + try { + CORBA::ORB_var orb = CORBA::ORB_init(argc, argv); + + CORBA::Object_var obj = orb->resolve_initial_references("RootPOA"); + PortableServer::POA_var root_poa = PortableServer::POA::_narrow(obj.in()); + + PortableServer::POAManager_var mgr = root_poa->the_POAManager(); + + const char* poa_name = "MessengerService"; + + PortableServer::POA_var messenger_poa = createPOA(root_poa.in(), poa_name); + + Terminator terminator; + if (terminator.open (0) == -1) + ACE_ERROR_RETURN((LM_ERROR, + ACE_TEXT ("main Error opening terminator\n")),-1); + + PortableServer::Servant_var<Messenger_i> messenger_servant = + new Messenger_i(orb.in(), terminator); + + PortableServer::ObjectId_var object_id = + PortableServer::string_to_ObjectId("messenger_object"); + + // + // Activate the servant with the messenger POA, + // obtain its object reference, and get a + // stringified IOR. + // + messenger_poa->activate_object_with_id(object_id.in(), messenger_servant.in()); + + // + // Create binding between "MessengerService" and + // the messenger object reference in the IOR Table. + // Use a TAO extension to get the non imrified poa + // to avoid forwarding requests back to the ImR. + + TAO_Root_POA* tpoa = dynamic_cast<TAO_Root_POA*>(messenger_poa.in()); + obj = tpoa->id_to_reference_i(object_id.in(), false); + CORBA::String_var messenger_ior = orb->object_to_string(obj.in()); + obj = orb->resolve_initial_references("IORTable"); + IORTable::Table_var table = IORTable::Table::_narrow(obj.in()); + table->bind(poa_name, messenger_ior.in()); + + // + // This server is now ready to run. + // This version does not create an IOR + // file as demonstrated in the + // Developer's Guide. It assumes that + // users create IORs for the client using + // the tao_imr utility. + // + // + // Stop discarding requests. + // + mgr->activate(); + + std::cout << "Messenger server ready." << std::endl; + + orb->run(); + + std::cout << "Messenger server shutting down." << std::endl; + + root_poa->destroy(1,1); + orb->destroy(); + + ACE_Message_Block *mb; + ACE_NEW_RETURN(mb, ACE_Message_Block(0, ACE_Message_Block::MB_HANGUP), -1); + terminator.putq(mb); + terminator.wait(); + } + catch(const CORBA::Exception& ex) { + std::cerr << "Server main() Caught CORBA::Exception" << ex << std::endl; + return 1; + } + + return 0; +} diff --git a/TAO/orbsvcs/tests/ImplRepo/RestartServer/Messenger_i.cpp b/TAO/orbsvcs/tests/ImplRepo/RestartServer/Messenger_i.cpp new file mode 100644 index 00000000000..a701f84a1f5 --- /dev/null +++ b/TAO/orbsvcs/tests/ImplRepo/RestartServer/Messenger_i.cpp @@ -0,0 +1,53 @@ +/* -*- C++ -*- $Id$ */ + +// ****** Code generated by the The ACE ORB (TAO) IDL Compiler ******* +// TAO and the TAO IDL Compiler have been developed by the Center for +// Distributed Object Computing at Washington University, St. Louis. +// +// Information about TAO is available at: +// http://www.cs.wustl.edu/~schmidt/TAO.html + +#include "Messenger_i.h" +#include "Terminator.h" + +#include <iostream> + +// Implementation skeleton constructor +Messenger_i::Messenger_i (CORBA::ORB_ptr orb, Terminator &terminator) + : orb_ (CORBA::ORB::_duplicate (orb)) + , message_count_ (0) + , terminator_ (terminator) +{ +} + +// Implementation skeleton destructor +Messenger_i::~Messenger_i (void) +{ +} + +CORBA::Boolean Messenger_i::send_message ( + const char * user_name, + const char * subject, + char *& message) +{ + std::cout << "Message count: " << message_count_++ << std::endl; + std::cout << "Message from: " << user_name << std::endl + << "Subject: " << subject << std::endl + << "Message: " << message << std::endl; + return 1; +} + +void +Messenger_i::abort (CORBA::Short delay_secs) +{ + ACE_Message_Block *mb = 0; + ACE_NEW(mb, ACE_Message_Block(2)); + ACE_OS::sprintf(mb->wr_ptr (), "%d", delay_secs); + terminator_.putq(mb); +} + +void +Messenger_i::shutdown (void) +{ + this->orb_->shutdown (0); +} diff --git a/TAO/orbsvcs/tests/ImplRepo/RestartServer/Messenger_i.h b/TAO/orbsvcs/tests/ImplRepo/RestartServer/Messenger_i.h new file mode 100644 index 00000000000..45e7389c8df --- /dev/null +++ b/TAO/orbsvcs/tests/ImplRepo/RestartServer/Messenger_i.h @@ -0,0 +1,43 @@ +/* -*- C++ -*- $Id$ */ + +#ifndef MESSENGERI_H_ +#define MESSENGERI_H_ + +#include "MessengerS.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +#pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +class Terminator; + +//Class Messenger_i +class Messenger_i : public virtual POA_Messenger +{ +public: + //Constructor + Messenger_i (CORBA::ORB_ptr orb, Terminator &terminator); + + //Destructor + virtual ~Messenger_i (void); + + virtual CORBA::Boolean send_message ( + const char * user_name, + const char * subject, + char *& message); + + virtual void abort (CORBA::Short delay_secs); + + virtual void shutdown (void); + +private: + /// Use an ORB reference to shutdown the application. + CORBA::ORB_var orb_; + + int message_count_; + + Terminator& terminator_; +}; + + +#endif /* MESSENGERI_H_ */ diff --git a/TAO/orbsvcs/tests/ImplRepo/RestartServer/README b/TAO/orbsvcs/tests/ImplRepo/RestartServer/README new file mode 100644 index 00000000000..f69485fb4c1 --- /dev/null +++ b/TAO/orbsvcs/tests/ImplRepo/RestartServer/README @@ -0,0 +1,10 @@ +$Id$ + +This test verifies that if a server launched by the ImR activator is terminated, +then it will be relaunched transparently by the ORB if the client makes another +request if -ORBForwardOnTransientLimit and -ORBForwardOnReplyClosedLimit options +are used. + +Note that TAO does not have a way of knowing if server actually processed the +request, so that the CORBA "at most once" guarantee may be violated if +-ORBForwardOnReplyClosedLimit is used. diff --git a/TAO/orbsvcs/tests/ImplRepo/RestartServer/RestartServer.mpc b/TAO/orbsvcs/tests/ImplRepo/RestartServer/RestartServer.mpc new file mode 100644 index 00000000000..c619da302e2 --- /dev/null +++ b/TAO/orbsvcs/tests/ImplRepo/RestartServer/RestartServer.mpc @@ -0,0 +1,37 @@ +// $Id$ + +project(*idl): taoidldefaults { + IDL_Files { + Messenger.idl + } + custom_only = 1 +} + +project(*Server): taoserver, iortable, avoids_minimum_corba, avoids_corba_e_micro { + exename = MessengerServer + after += *idl + Source_Files { + Messenger_i.cpp + MessengerServer.cpp + Terminator.cpp + } + Source_Files { + MessengerC.cpp + MessengerS.cpp + } + IDL_Files { + } +} + +project(*Client): taoclient, anytypecode, avoids_minimum_corba { + exename = MessengerClient + after += *idl + Source_Files { + MessengerClient.cpp + } + Source_Files { + MessengerC.cpp + } + IDL_Files { + } +} diff --git a/TAO/orbsvcs/tests/ImplRepo/RestartServer/Terminator.cpp b/TAO/orbsvcs/tests/ImplRepo/RestartServer/Terminator.cpp new file mode 100644 index 00000000000..23b4a0475e4 --- /dev/null +++ b/TAO/orbsvcs/tests/ImplRepo/RestartServer/Terminator.cpp @@ -0,0 +1,40 @@ +/* -*- C++ -*- $Id$ */ + +#include "Terminator.h" +#include "ace/Log_Msg.h" +#include "ace/OS_NS_unistd.h" + +int +Terminator::open(void*) +{ + if(this->activate (THR_NEW_LWP | THR_JOINABLE, + 1) == -1) + { + ACE_ERROR_RETURN((LM_ERROR, + ACE_TEXT("Terminator::open Error spawning thread %p\n"), + "err="), + -1); + } + return 0; +} + +int +Terminator::svc() +{ + while (1) + { + ACE_Message_Block* mb; + ACE_ASSERT(this->getq(mb) != -1); + if (mb->msg_type () == ACE_Message_Block::MB_HANGUP) + { + mb->release (); + break; + } + int delay_secs = ACE_OS::atoi(mb->rd_ptr()); + ACE_DEBUG ((LM_DEBUG, + "(%P|%t|%T) Terminator::svc() Sleeping %d seconds before aborting\n", delay_secs)); + ACE_OS::sleep(delay_secs); + ACE_OS::abort(); + } + return 0; +} diff --git a/TAO/orbsvcs/tests/ImplRepo/RestartServer/Terminator.h b/TAO/orbsvcs/tests/ImplRepo/RestartServer/Terminator.h new file mode 100644 index 00000000000..29be200f03e --- /dev/null +++ b/TAO/orbsvcs/tests/ImplRepo/RestartServer/Terminator.h @@ -0,0 +1,13 @@ +/* -*- C++ -*- $Id$ */ + +#include "ace/Task_T.h" + +class Terminator : public ACE_Task<ACE_MT_SYNCH> +{ + public: + + virtual int open(void*); + + virtual int svc(); +}; + diff --git a/TAO/orbsvcs/tests/ImplRepo/RestartServer/client.conf b/TAO/orbsvcs/tests/ImplRepo/RestartServer/client.conf new file mode 100644 index 00000000000..409ad4afe86 --- /dev/null +++ b/TAO/orbsvcs/tests/ImplRepo/RestartServer/client.conf @@ -0,0 +1,3 @@ +# $Id$ + +static Client_Strategy_Factory "-ORBForwardOnTransientLimit 20" diff --git a/TAO/orbsvcs/tests/ImplRepo/RestartServer/run_test.pl b/TAO/orbsvcs/tests/ImplRepo/RestartServer/run_test.pl new file mode 100755 index 00000000000..cc398aa4f03 --- /dev/null +++ b/TAO/orbsvcs/tests/ImplRepo/RestartServer/run_test.pl @@ -0,0 +1,245 @@ +# $Id$ + +eval '(exit $?0)' && eval 'exec perl -S $0 ${1+"$@"}' + & eval 'exec perl -S $0 $argv:q' + if 0; + +use lib "$ENV{ACE_ROOT}/bin"; +use PerlACE::TestTarget; + +$status = 0; +$debug_level = '0'; + +foreach $i (@ARGV) { + if ($i eq '-debug') { + $debug_level = '10'; + } +} + +my $extra_timeout = 45; + +my $c1 = PerlACE::TestTarget::create_target (1) || die "Create target 1 failed\n"; +my $imr = PerlACE::TestTarget::create_target (3) || die "Create target 3 failed\n"; +my $act = PerlACE::TestTarget::create_target (4) || die "Create target 4 failed\n"; +my $ti = PerlACE::TestTarget::create_target (5) || die "Create target 5 failed\n"; +my $si = PerlACE::TestTarget::create_target (6) || die "Create target 6 failed\n"; +my $sdn = PerlACE::TestTarget::create_target (7) || die "Create target 7 failed\n"; + +my $implrepo_server = "$ENV{TAO_ROOT}/orbsvcs/ImplRepo_Service/tao_imr_locator"; +my $imr_activator = "$ENV{TAO_ROOT}/orbsvcs/ImplRepo_Service/tao_imr_activator"; +my $tao_imr = "$ENV{ACE_ROOT}/bin/tao_imr"; + +$implrepo_ior = "implrepo.ior"; +$activator_ior = "activator.ior"; +$messenger_ior = "Messenger.ior"; + +# Use client strategy factory for one of retry parameters. +$c1_conf = "client.conf"; + +my $imr_imriorfile = $imr->LocalFile ($implrepo_ior); +my $act_imriorfile = $act->LocalFile ($implrepo_ior); +my $ti_imriorfile = $ti->LocalFile ($implrepo_ior); +my $si_imriorfile = $si->LocalFile ($implrepo_ior); +my $sdn_imriorfile = $sdn->LocalFile ($implrepo_ior); +my $act_actiorfile = $act->LocalFile ($activator_ior); +my $imr_srviorfile = $imr->LocalFile ($messenger_ior); +my $c1_srviorfile = $c1->LocalFile ($messenger_ior); +my $c1_conffile = $c1->LocalFile ($c1_conf); +my $si_srviorfile = $si->LocalFile ($messenger_ior); + +# Make sure the files are gone, so we can wait on them. +$imr->DeleteFile ($implrepo_ior); +$act->DeleteFile ($implrepo_ior); +$ti->DeleteFile ($implrepo_ior); +$si->DeleteFile ($implrepo_ior); +$sdn->DeleteFile ($implrepo_ior); +$act->DeleteFile ($activator_ior); +$imr->DeleteFile ($messenger_ior); +$c1->DeleteFile ($messenger_ior); +$si->DeleteFile ($messenger_ior); + +# Note : We don't actually use SVR, but we need a way to get the +# path to the -ExeSubDir +$SVR = $imr->CreateProcess ("MessengerServer", "-ORBdebuglevel $debug_level"); +my $server = $SVR->Executable (); +my $srv_server = $imr->LocalFile ($server); + +$IR = $imr->CreateProcess ($implrepo_server, "-d 1 ". + "orbobjrefstyle url ". + "-t 5 ". + "-o $imr_imriorfile"); +print ">>> " . $IR->CommandLine() . "\n"; + +$ACT = $act->CreateProcess ($imr_activator, "-d 1 ". + "orbobjrefstyle url ". + "-o $act_actiorfile ". + "-ORBInitRef ImplRepoService=file://$act_imriorfile"); + +$TI = $ti->CreateProcess ($tao_imr, "-ORBInitRef ImplRepoService=file://$ti_imriorfile ". + "add MessengerService ". + "-c \"$srv_server -orbobjrefstyle url -ORBUseIMR 1 -ORBInitRef ImplRepoService=file://$imr_imriorfile\" "); + + + +$SI = $si->CreateProcess ($tao_imr, "-ORBInitRef ImplRepoService=file://$si_imriorfile ". + "ior MessengerService ". + "-f $si_srviorfile "); + +$C1 = $c1->CreateProcess ("MessengerClient", "-k file://$c1_srviorfile ". + "-ORBForwardOnReplyClosedLimit 20 -ORBForwardDelay 500 ". + "-ORBSvcConf $c1_conffile -ORBdebuglevel $debug_level"); + +$SDN = $sdn->CreateProcess ("$tao_imr", "-ORBInitRef ImplRepoService=file://$sdn_imriorfile ". + "shutdown MessengerService"); + + +$IR_status = $IR->Spawn (); + +if ($IR_status != 0) { + print STDERR "ERROR: ImplRepo Service returned $IR_status\n"; + exit 1; +} + +if ($imr->WaitForFileTimed ($implrepo_ior,$imr->ProcessStartWaitInterval() + $extra_timeout) == -1) { + print STDERR "ERROR: cannot find file <$imr_imriorfile>\n"; + $IR->Kill (); $IR->TimedWait (1); + exit 1; +} + +if ($imr->GetFile ($implrepo_ior) == -1) { + print STDERR "ERROR: cannot retrieve file <$imr_imriorfile>\n"; + $IR->Kill (); $IR->TimedWait (1); + exit 1; +} +if ($act->PutFile ($implrepo_ior) == -1) { + print STDERR "ERROR: cannot set file <$act_imriorfile>\n"; + $IR->Kill (); $IR->TimedWait (1); + exit 1; +} +if ($ti->PutFile ($implrepo_ior) == -1) { + print STDERR "ERROR: cannot set file <$ti_imriorfile>\n"; + $IR->Kill (); $IR->TimedWait (1); + exit 1; +} +if ($si->PutFile ($implrepo_ior) == -1) { + print STDERR "ERROR: cannot set file <$si_imriorfile>\n"; + $IR->Kill (); $IR->TimedWait (1); + exit 1; +} +if ($sdn->PutFile ($implrepo_ior) == -1) { + print STDERR "ERROR: cannot set file <$sdn_imriorfile>\n"; + $IR->Kill (); $IR->TimedWait (1); + exit 1; +} + +print ">>> " . $ACT->CommandLine() . "\n"; +$ACT_status = $ACT->Spawn (); + +if ($ACT_status != 0) { + print STDERR "ERROR: ImR_Activator returned $ACT_status\n"; + exit 1; +} + +if ($act->WaitForFileTimed ($activator_ior,$act->ProcessStartWaitInterval() + $extra_timeout) == -1) { + print STDERR "ERROR: cannot find file <$act_actiorfile>\n"; + $IR->Kill (); $IR->TimedWait (1); + $ACT->Kill (); $ACT->TimedWait (1); + exit 1; +} + +print ">>> " . $TI->CommandLine() . "\n"; +# We want the tao_imr executable to be found exactly in the path +# given, without being modified by the value of -ExeSubDir. +# So, we tell its Process object to ignore the setting of -ExeSubDir. + +$TI->IgnoreExeSubDir (1); + +$TI_status = $TI->SpawnWaitKill ($ti->ProcessStartWaitInterval() + $extra_timeout); + +if ($TI_status != 0) { + print STDERR "ERROR: tao_imr returned $TI_status\n"; + $IR->Kill (); $IR->TimedWait (1); + $ACT->Kill (); $ACT->TimedWait (1); + exit 1; +} + +print ">>> " . $SI->CommandLine() . "\n"; +$SI->IgnoreExeSubDir (1); + + +$SI_status = $SI->SpawnWaitKill ($si->ProcessStartWaitInterval() + $extra_timeout); + +if ($SI_status != 0) { + print STDERR "ERROR: tao_imr returned $SI_status\n"; + $IR->Kill (); $IR->TimedWait (1); + $ACT->Kill (); $ACT->TimedWait (1); + exit 1; +} + +if ($si->WaitForFileTimed ($messenger_ior,$si->ProcessStartWaitInterval() + $extra_timeout) == -1) { + print STDERR "ERROR: cannot find file <$si_srviorfile>\n"; + $IR->Kill (); $IR->TimedWait (1); + $ACT->Kill (); $ACT->TimedWait (1); + exit 1; +} + +if ($si->GetFile ($messenger_ior) == -1) { + print STDERR "ERROR: cannot retrieve file <$si_srviorfile>\n"; + $IR->Kill (); $IR->TimedWait (1); + $ACT->Kill (); $ACT->TimedWait (1); + exit 1; +} +if ($c1->PutFile ($messenger_ior) == -1) { + print STDERR "ERROR: cannot set file <$c1_srviorfile>\n"; + $IR->Kill (); $IR->TimedWait (1); + $ACT->Kill (); $ACT->TimedWait (1); + exit 1; +} + + +print ">>> " . $C1->CommandLine() . "\n"; +$C1_status = $C1->SpawnWaitKill ($c1->ProcessStartWaitInterval() + $extra_timeout); + +if ($C1_status != 0) { + print STDERR "ERROR: Client1 returned $C1_status\n"; + $IR->Kill (); $IR->TimedWait (1); + $ACT->Kill (); $ACT->TimedWait (1); + exit 1; +} + +$SDN->IgnoreExeSubDir (1); +$SDN_status = $SDN->SpawnWaitKill ($sdn->ProcessStartWaitInterval() + $extra_timeout); + +if ($SDN_status != 0) { + print STDERR "ERROR: Shutdown returned $SDN_status\n"; + $IR->Kill (); $IR->TimedWait (1); + $ACT->Kill (); $ACT->TimedWait (1); + exit 1; +} + + +$IR_status = $IR->TerminateWaitKill ($imr->ProcessStopWaitInterval() + $extra_timeout); + +if ($IR_status != 0) { + print STDERR "ERROR: ImplRepo Server returned $IR_status\n"; + $status = 1; +} + +$ACT_status = $ACT->TerminateWaitKill ($act->ProcessStopWaitInterval() + $extra_timeout); + +if ($ACT_status != 0) { + print STDERR "ERROR: ImR_Activator returned $ACT_status\n"; + $status = 1; +} + +$imr->DeleteFile ($implrepo_ior); +$act->DeleteFile ($implrepo_ior); +$ti->DeleteFile ($implrepo_ior); +$si->DeleteFile ($implrepo_ior); +$sdn->DeleteFile ($implrepo_ior); +$act->DeleteFile ($activator_ior); +$imr->DeleteFile ($messenger_ior); +$c1->DeleteFile ($messenger_ior); +$si->DeleteFile ($messenger_ior); + +exit $status; diff --git a/TAO/orbsvcs/tests/ImplRepo/airplane_client_i.cpp b/TAO/orbsvcs/tests/ImplRepo/airplane_client_i.cpp index df7a00e9391..cd1f1ff6878 100644 --- a/TAO/orbsvcs/tests/ImplRepo/airplane_client_i.cpp +++ b/TAO/orbsvcs/tests/ImplRepo/airplane_client_i.cpp @@ -56,9 +56,10 @@ Airplane_Client_i::parse_args (void) // Retreives <count> paper airplanes from the server. -void +int Airplane_Client_i::get_planes (size_t count) { + int rc = 0; for (size_t i = 0; i < count; i++) { try @@ -72,8 +73,10 @@ Airplane_Client_i::get_planes (size_t count) { ACE_ERROR ((LM_ERROR, "Plane %d exception:\n", i)); ex._tao_print_exception ("get_planes"); + rc = 1; } } + return rc; } @@ -82,9 +85,7 @@ Airplane_Client_i::get_planes (size_t count) int Airplane_Client_i::run () { - this->get_planes (this->loop_count_); - - return 0; + return this->get_planes (this->loop_count_); } Airplane_Client_i::~Airplane_Client_i (void) diff --git a/TAO/orbsvcs/tests/ImplRepo/airplane_client_i.h b/TAO/orbsvcs/tests/ImplRepo/airplane_client_i.h index 5c949a386c1..67497a0720c 100644 --- a/TAO/orbsvcs/tests/ImplRepo/airplane_client_i.h +++ b/TAO/orbsvcs/tests/ImplRepo/airplane_client_i.h @@ -46,7 +46,7 @@ private: int parse_args (void); /// Ask the Paper Airplane Server for <count> planes. - void get_planes (size_t count); + int get_planes (size_t count); /// # of arguments on the command line. int argc_; diff --git a/TAO/orbsvcs/tests/ImplRepo/airplane_server_i.cpp b/TAO/orbsvcs/tests/ImplRepo/airplane_server_i.cpp index 58dd5d3959e..873ec9dde5e 100644 --- a/TAO/orbsvcs/tests/ImplRepo/airplane_server_i.cpp +++ b/TAO/orbsvcs/tests/ImplRepo/airplane_server_i.cpp @@ -17,7 +17,8 @@ const char SERVER_NAME[] = "airplane_server"; Airplane_Server_i::Airplane_Server_i (void) : server_impl_ (0), - ior_output_file_ (0) + ior_output_file_ (0), + server_name_(SERVER_NAME) { // Nothing } @@ -25,7 +26,7 @@ Airplane_Server_i::Airplane_Server_i (void) int Airplane_Server_i::parse_args (void) { - ACE_Get_Opt get_opts (this->argc_, this->argv_, ACE_TEXT("do:")); + ACE_Get_Opt get_opts (this->argc_, this->argv_, ACE_TEXT("do:s:")); int c; while ((c = get_opts ()) != -1) @@ -41,12 +42,16 @@ Airplane_Server_i::parse_args (void) "Unable to open %s for writing: %p\n", get_opts.opt_arg ()), -1); break; + case 's': // extension to the server name. + this->server_name_ = get_opts.opt_arg (); + break; case '?': // display help for use of the server. default: ACE_ERROR_RETURN ((LM_ERROR, "usage: %s" " [-d]" - " [-o] <ior_output_file>" + " [-o <ior_output_file>]" + " [-s <the server name>]" "\n", argv_ [0]), 1); @@ -59,10 +64,6 @@ Airplane_Server_i::parse_args (void) int Airplane_Server_i::init (int argc, ACE_TCHAR** argv) { - // Since the Implementation Repository keys off of the POA name, we need - // to use the SERVER_NAME as the POA's name. - const char *poa_name = SERVER_NAME; - try { // Initialize the ORB @@ -101,10 +102,12 @@ Airplane_Server_i::init (int argc, ACE_TCHAR** argv) policies[1] = this->root_poa_->create_lifespan_policy (PortableServer::PERSISTENT); + // Since the Implementation Repository keys off of the POA name, we need + // to use the server_name_ as the POA's name. this->airplane_poa_ = - this->root_poa_->create_POA (poa_name, - this->poa_manager_.in (), - policies); + this->root_poa_->create_POA (this->server_name_.c_str(), + this->poa_manager_.in (), + policies); // Creation of the new POA is over, so destroy the Policy_ptr's. for (CORBA::ULong i = 0; i < policies.length (); ++i) @@ -142,7 +145,7 @@ Airplane_Server_i::init (int argc, ACE_TCHAR** argv) IORTable::Table_var adapter = IORTable::Table::_narrow (obj.in ()); ACE_ASSERT(! CORBA::is_nil (adapter.in ())); - adapter->bind (poa_name, plain_ior.in ()); + adapter->bind (this->server_name_.c_str(), plain_ior.in ()); this->poa_manager_->activate (); diff --git a/TAO/orbsvcs/tests/ImplRepo/airplane_server_i.h b/TAO/orbsvcs/tests/ImplRepo/airplane_server_i.h index c3ffc51f973..1be339107b6 100644 --- a/TAO/orbsvcs/tests/ImplRepo/airplane_server_i.h +++ b/TAO/orbsvcs/tests/ImplRepo/airplane_server_i.h @@ -70,6 +70,9 @@ private: /// File where the IOR of the server object is stored. FILE *ior_output_file_; + + /// the server name + ACE_CString server_name_; }; #endif /* AIRPLANE_SERVER_I_H */ diff --git a/TAO/orbsvcs/tests/ImplRepo/run_test.pl b/TAO/orbsvcs/tests/ImplRepo/run_test.pl index 318943a5fc9..43edcf5be04 100755 --- a/TAO/orbsvcs/tests/ImplRepo/run_test.pl +++ b/TAO/orbsvcs/tests/ImplRepo/run_test.pl @@ -8,50 +8,90 @@ eval '(exit $?0)' && eval 'exec perl -S $0 ${1+"$@"}' ############################################################################### +use strict; use lib "$ENV{ACE_ROOT}/bin"; use PerlACE::TestTarget; use File::Copy; -$debug_level = '0'; +my $debug_level = '0'; +my $srv_debug_level = '0'; +my $test_debug_level = '2'; +my $num_srvr = 1; +my $replica = 0; +my $all_tests = 0; -foreach $i (@ARGV) { +foreach my $i (@ARGV) { if ($i eq '-debug') { $debug_level = '10'; + $srv_debug_level = '10'; + } + elsif ($i eq '-tdebug') { + $test_debug_level = 10; + } + elsif ($i eq '-tsilent') { + $test_debug_level = 0; + } + elsif ($i eq '-servers') { + $num_srvr = 3; + } + elsif ($i eq '-replica') { + $num_srvr = 2; + $replica = 1; + } + elsif ($i eq '-all') { + $all_tests = 1; } } -my $imr = PerlACE::TestTarget::create_target (1) || die "Create target 1 failed\n"; -my $act = PerlACE::TestTarget::create_target (2) || die "Create target 2 failed\n"; -my $ti = PerlACE::TestTarget::create_target (3) || die "Create target 3 failed\n"; -my $a_srv = PerlACE::TestTarget::create_target (4) || die "Create target 4 failed\n"; -my $a_cli = PerlACE::TestTarget::create_target (5) || die "Create target 5 failed\n"; -my $n_srv = PerlACE::TestTarget::create_target (6) || die "Create target 6 failed\n"; -my $n_cli = PerlACE::TestTarget::create_target (7) || die "Create target 7 failed\n"; -my $p_srv = PerlACE::TestTarget::create_target (8) || die "Create target 8 failed\n"; -my $bin_imr = PerlACE::TestTarget::create_target (9) || die "Create target 9 failed\n"; -my $bin_act = PerlACE::TestTarget::create_target (10) || die "Create target 10 failed\n"; +my $tgt_num = 0; +my $imr = PerlACE::TestTarget::create_target (++$tgt_num) || die "Create target $tgt_num failed\n"; +my $act = PerlACE::TestTarget::create_target (++$tgt_num) || die "Create target $tgt_num failed\n"; +my $ti = PerlACE::TestTarget::create_target (++$tgt_num) || die "Create target $tgt_num failed\n"; +my $n_srv = PerlACE::TestTarget::create_target (++$tgt_num) || die "Create target $tgt_num failed\n"; +my $n_cli = PerlACE::TestTarget::create_target (++$tgt_num) || die "Create target $tgt_num failed\n"; +my $bin_imr = PerlACE::TestTarget::create_target (++$tgt_num) || die "Create target $tgt_num failed\n"; +my $bin_act = PerlACE::TestTarget::create_target (++$tgt_num) || die "Create target $tgt_num failed\n"; +my @a_cli; +my @a_srv; +my @p_srv; +my $index; +for ($index = 0; $index < $num_srvr; ++$index) { + push(@a_cli, PerlACE::TestTarget::create_target (++$tgt_num)) || die "Create a_cli target $tgt_num failed\n"; + push(@a_srv, PerlACE::TestTarget::create_target (++$tgt_num)) || die "Create a_srv target $tgt_num failed\n"; + push(@p_srv, PerlACE::TestTarget::create_target (++$tgt_num)) || die "Create p_srv target $tgt_num failed\n"; +} + +my $replica_imr; +if ($replica) { + $replica_imr = PerlACE::TestTarget::create_target (++$tgt_num) || die "Create replica_imr target $tgt_num failed\n"; + $replica_imr->AddLibPath ("$ENV{ACE_ROOT}/lib"); +} $imr->AddLibPath ("$ENV{ACE_ROOT}/lib"); my $imriorfile = "imr_locator.ior"; my $actiorfile = "imr_activator.ior"; -my $airplaneiorfile = "airplane.ior"; +my $primaryiorfile = "ImR_ReplicaPrimary.ior"; +my $backupiorfile = "ImR_ReplicaBackup.ior"; +my $replica_imriorfile = "replica_imr_locator.ior"; my $nesteaiorfile = "nestea.ior"; -my $backing_store = "imr_backing_store.xml"; my $nestea_dat = "nestea.dat"; -my $a_cli_airplaneiorfile = $a_cli->LocalFile ($airplaneiorfile); +my $stdout_file = "test.out"; +my $stderr_file = "test.err"; + my $n_cli_nesteaiorfile = $n_cli->LocalFile ($nesteaiorfile); my $refstyle = " -ORBObjRefStyle URL"; +my $imr_refstyle = "";# = " -ORBObjRefStyle URL"; my $protocol = "iiop"; my $imr_host = $imr->HostName (); my $port = 12345; my $endpoint = "-ORBEndpoint " . "$protocol" . "://:" . $port; -$IMR = $imr->CreateProcess ("../../ImplRepo_Service/tao_imr_locator"); -$ACT = $act->CreateProcess ("../../ImplRepo_Service/tao_imr_activator"); -$TI = $ti->CreateProcess ("$ENV{ACE_ROOT}/bin/tao_imr"); +my $IMR = $imr->CreateProcess ("../../ImplRepo_Service/tao_imr_locator"); +my $ACT = $act->CreateProcess ("../../ImplRepo_Service/tao_imr_activator"); +my $TI = $ti->CreateProcess ("$ENV{ACE_ROOT}/bin/tao_imr"); # We want the tao_imr executable to be found exactly in the path # given, without being modified by the value of -ExeSubDir. @@ -59,79 +99,460 @@ $TI = $ti->CreateProcess ("$ENV{ACE_ROOT}/bin/tao_imr"); $TI->IgnoreExeSubDir (1); +my $replica_IMR; +if ($replica) { + $replica_IMR = $replica_imr->CreateProcess ("../../ImplRepo_Service/tao_imr_locator"); +} + +my @airplaneiorfile; +my @a_cli_airplaneiorfile; +for ($index = 0; $index < $num_srvr; ++$index) { + push(@airplaneiorfile, "airplane$index.ior"); + push(@a_cli_airplaneiorfile, $a_cli[$index]->LocalFile ($airplaneiorfile[$index])); +} + sub create_acli { - return $a_cli->CreateProcess ("airplane_client", " -k file://$a_cli_airplaneiorfile "); + my $select = shift; + return $a_cli[$select]->CreateProcess ("airplane_client", " -k file://$a_cli_airplaneiorfile[$select] "); } sub create_ncli { return $n_cli->CreateProcess ("nestea_client", " -k file://$n_cli_nesteaiorfile "); } -my $A_SRV = $a_srv->CreateProcess ("airplane_server"); -my $A_CLI = create_acli(); -my $N_SRV = $a_cli->CreateProcess ("nestea_server"); -my $N_CLI = create_ncli(); -my $P_SRV = $p_srv->CreateProcess ("persist server"); +my @A_SRV; +my @a_srv_name; +my @A_SRV_cmd; +my @imr_A_SRV_cmd; +my @P_SRV; +my @P_SRV_cmd; +my @imr_P_SRV_cmd; +for ($index = 0; $index < $num_srvr; ++$index) { + push(@a_srv_name, "airplane_server$index"); + push(@A_SRV, $a_srv[$index]->CreateProcess ("airplane_server")); + my $p_srv_name = "persist server$index"; + push(@P_SRV, $p_srv[$index]->CreateProcess ($p_srv_name)); + + push(@A_SRV_cmd, $A_SRV[$index]->Executable()); + push(@imr_A_SRV_cmd, $imr->LocalFile ($A_SRV_cmd[$index])); + push(@P_SRV_cmd, $P_SRV[$index]->Executable()); + push(@imr_P_SRV_cmd, $imr->LocalFile ($P_SRV_cmd[$index])); +} -my $A_SRV_cmd = $A_SRV->Executable(); -my $imr_A_SRV_cmd = $imr->LocalFile ($A_SRV_cmd); +my @A_CLI; +for ($index = 0; $index < $num_srvr; ++$index) { + push(@A_CLI, create_acli($index)); +} +my $N_SRV = $a_cli[0]->CreateProcess ("nestea_server"); +my $N_CLI = create_ncli(); my $N_SRV_cmd = $N_SRV->Executable(); my $imr_N_SRV_cmd = $imr->LocalFile ($N_SRV_cmd); -my $P_SRV_cmd = $P_SRV->Executable(); -my $imr_P_SRV_cmd = $imr->LocalFile ($P_SRV_cmd); -# The Tests +############################################################################### +# Helper subroutines +############################################################################### + +sub setup_repo +{ + my $repo_ref = shift; + my $the_imr = shift; + my $the_IMR = shift; + my $the_imriorfile = shift; + my $the_act = shift; + my $the_ACT = shift; + my $the_actiorfile = shift; + my $the_ti = shift; + my $the_TI = shift; + my $port = shift; + my $replication_role = shift; + my $the_replicaiorfile = shift; + my $explicit_act = shift; + + my $the_imr_imriorfile = $the_imr->LocalFile ($the_imriorfile); + my $the_act_imriorfile = $the_act->LocalFile ($the_imriorfile); + my $the_ti_imriorfile = $the_ti->LocalFile ($the_imriorfile); + my $the_act_actiorfile = $the_act->LocalFile ($the_actiorfile); + my $the_imr_replicaiorfile = $the_imr->LocalFile ($the_replicaiorfile); + + $repo_ref->{imr} = $the_imr; + $repo_ref->{IMR} = $the_IMR; + $repo_ref->{imriorfile} = $the_imriorfile; + $repo_ref->{imr_imriorfile} = $the_imr_imriorfile; + $repo_ref->{imr_endpoint_flag} = "-ORBEndpoint iiop://:$port "; + if ($replica) { + $repo_ref->{imr_backing_store} = "."; + $repo_ref->{imr_backing_store_flag} = + "--directory $repo_ref->{imr_backing_store} $replication_role "; + } + $repo_ref->{replicaiorfile} = $the_replicaiorfile; + $repo_ref->{imr_replicaiorfile} = $the_imr_replicaiorfile; + + $repo_ref->{act} = $the_act; + $repo_ref->{ACT} = $the_ACT; + $repo_ref->{actiorfile} = $the_actiorfile; + $repo_ref->{act_imriorfile} = $the_act_imriorfile; + $repo_ref->{act_actiorfile} = $the_act_actiorfile; + if (defined($explicit_act)) { + $repo_ref->{server_act_flag} = "-l $explicit_act "; + $repo_ref->{act_explicit_flag} = "-n $explicit_act "; + } + + $repo_ref->{ti} = $the_ti; + $repo_ref->{TI} = $the_TI; + $repo_ref->{ti_imriorfile} = $the_ti_imriorfile; +} ############################################################################### -sub airplane_test +sub cleanup_replication { - my $status = 0; + my $dir = shift; + if (!defined($dir)) { + $dir = "."; + } + + my $listings = "$dir/imr_listing.xml"; + my $fnd = 0; + if (open FILE, "<$listings") { + while (<FILE>) { + if ($_ =~ /fname="([^"]+)"?/) { + $fnd = 1; + my $file = "$dir/$1"; + test_info("deleting $file\n"); + $imr->DeleteFile ($file); + $imr->DeleteFile ($file . ".bak"); + } + } + close FILE; + } + +# If the primary listings file has been corrupt then perform the +# deletions from the backup file. + + if (!$fnd) { + if (open FILE, "<$listings" . ".bak") { + while (<FILE>) { + if ($_ =~ /fname="([^"]+)"?/) { + my $file = "$dir/$1"; + test_info("deleting $file\n"); + $imr->DeleteFile ($file); + $imr->DeleteFile ($file . ".bak"); + } + } + close FILE; + } + } + test_info("deleting $listings\n"); + $imr->DeleteFile ("$listings"); + $imr->DeleteFile ("$listings" . ".bak"); + $imr->DeleteFile ("$dir/$primaryiorfile"); + $imr->DeleteFile ("$dir/$backupiorfile"); +} - my $a_srv_airplaneiorfile = $a_srv->LocalFile ($airplaneiorfile); - $a_srv->DeleteFile ($airplaneiorfile); - $a_cli->DeleteFile ($airplaneiorfile); +############################################################################### - $A_SRV->Arguments ("-o $a_srv_airplaneiorfile $refstyle -ORBDebugLevel $debug_level"); - $A_SRV_status = $A_SRV->Spawn (); - if ($A_SRV_status != 0) { - print STDERR "ERROR: Airplane Server returned $A_SRV_status\n"; - return 1; +sub test_info { + if ($test_debug_level < 10) { + return; } - if ($a_srv->WaitForFileTimed ($airplaneiorfile,$a_srv->ProcessStartWaitInterval()) == -1) { - print STDERR "ERROR: cannot find file <$a_srv_airplaneiorfile>\n"; - $A_SRV->Kill (); $A_SRV->TimedWait (1); - return 1; + + my $info = shift; + print "$info"; +} + +############################################################################### + +sub kill_imr +{ + $IMR->Kill (); $IMR->TimedWait (1); + if ($replica) { + $replica_IMR->Kill (); $replica_IMR->TimedWait (1); } - if ($a_srv->GetFile ($airplaneiorfile) == -1) { - print STDERR "ERROR: cannot retrieve file <$a_srv_airplaneiorfile>\n"; - $A_SRV->Kill (); $A_SRV->TimedWait (1); - return 1; +} + +############################################################################### + +sub kill_act +{ + $ACT->Kill (); $ACT->TimedWait (1); +} + +############################################################################### + +sub add_servers +{ + my $repo_ref = shift; + my $iorfiles_ref = shift; + + for ($index = 0; $index < $num_srvr; ++$index) { + print "\n\nadding server $index using tao_imr\n"; + $repo_ref->[$index]->{TI}->Arguments ("-ORBInitRef ImplRepoService" . + "=file://$repo_ref->[$index]->{ti_imriorfile} $refstyle " . + "add $a_srv_name[$index] -c \"$imr_A_SRV_cmd[$index] " . + "-o $iorfiles_ref->[$index] -s $a_srv_name[$index]\" " . + "$repo_ref->[$index]->{server_act_flag} "); + my $TI_status = $repo_ref->[$index]->{TI}->SpawnWaitKill ( + $repo_ref->[$index]->{ti}->ProcessStartWaitInterval()); + if ($TI_status != 0) { + print STDERR "ERROR: tao_imr ($index) returned $TI_status\n"; + kill_act(); + kill_imr(); + return 1; + } + print "added server $index with the locator using tao_imr\n"; } - if ($a_cli->PutFile ($airplaneiorfile) == -1) { - print STDERR "ERROR: cannot set file <$a_cli_airplaneiorfile>\n"; - $A_SRV->Kill (); $A_SRV->TimedWait (1); - return 1; + return 0; +} + +############################################################################### + +sub add_servers_again +{ + my $repo_ref = shift; + my $iorfiles_ref = shift; + + for ($index = 0; $index < $num_srvr; ++$index) { + print "\n\nadding server $index again using tao_imr\n"; + $repo_ref->[$index]->{TI}->Arguments ("-ORBInitRef ImplRepoService" . + "=file://$repo_ref->[$index]->{ti_imriorfile} $refstyle " . + "add $a_srv_name[$index] -c \"$imr_A_SRV_cmd[$index] " . + "-o $iorfiles_ref->[$index] -s $a_srv_name[$index]\" " . + "$repo_ref->[$index]->{server_act_flag} "); + my $TI_status = $repo_ref->[$index]->{TI}->SpawnWaitKill ( + $repo_ref->[$index]->{ti}->ProcessStartWaitInterval()); + if ($TI_status eq 0) { + print STDERR "ERROR: tao_imr ($index) returned $TI_status\n"; + kill_act(); + kill_imr(); + return 1; + } + print "tao_imr returned $TI_status when attempting to add server $index again\n"; } + return 0; +} -#$A_CLI = $a_cli->CreateProcess ("airplane_client", " -k file://$a_cli_airplaneiorfile"); - $A_CLI_status = $A_CLI->SpawnWaitKill ($a_cli->ProcessStartWaitInterval()); - if ($A_CLI_status != 0) { - print STDERR "ERROR: Airplane Client returned $A_CLI_status\n"; - $status = 1; +############################################################################### + +sub remove_servers +{ + my $repo_ref = shift; + + for ($index = 0; $index < $num_srvr; ++$index) { + print "\n\nremoving server $index using tao_imr\n"; + $repo_ref->[$index]->{TI}->Arguments ("-ORBInitRef ImplRepoService" . + "=file://$repo_ref->[$index]->{ti_imriorfile} $refstyle " . + "remove $a_srv_name[$index]"); + my $TI_status = $repo_ref->[$index]->{TI}->SpawnWaitKill ( + $repo_ref->[$index]->{ti}->ProcessStartWaitInterval()); + if ($TI_status != 0) { + print STDERR "ERROR: tao_imr ($index) returned $TI_status\n"; + kill_act(); + kill_imr(); + return 1; + } + print "removed server $index\n"; } + return 0; +} - $A_SRV_status = $A_SRV->TerminateWaitKill ($a_srv->ProcessStopWaitInterval()); - if ($A_SRV_status != 0) { - print STDERR "ERROR: Airplane Server returned $A_SRV_status\n"; - $status = 1; +############################################################################### + +sub start_clients +{ + for ($index = 0; $index < $num_srvr; ++$index) { + test_info("starting client for $a_srv_name[$index]=" . + $A_CLI[$index]->CommandLine() . "\n"); + my $A_CLI_status = $A_CLI[$index]->Spawn (); + if ($A_CLI_status != 0) { + print STDERR + "ERROR: Airplane Client ($index) failed to spawn returning $A_CLI_status\n"; + kill_then_timed_wait(\@A_SRV, 1); + $ACT->Kill (); $ACT->TimedWait (1); + $IMR->Kill (); $IMR->TimedWait (1); + return 1; + } + } + return 0; +} + +############################################################################### + +sub stop_clients +{ + for ($index = 0; $index < $num_srvr; ++$index) { + my $A_CLI_status = $A_CLI[$index]->WaitKill ($a_cli[$index]->ProcessStartWaitInterval()); + if ($A_CLI_status != 0) { + print STDERR "ERROR: Airplane Client $index returned $A_CLI_status\n"; + return 1; + } + print "\n\nstopped client $index\n\n\n"; + } + return 0; +} + +############################################################################### + +sub shutdown_servers_using_tao_imr +{ + my $repo_ref = shift; + for ($index = 0; $index < $num_srvr; ++$index) { + print "\n\nshutting down server $index using tao_imr\n"; + $repo_ref->[$index]->{TI}->Arguments ("-ORBInitRef ImplRepoService" . + "=file://$repo_ref->[$index]->{ti_imriorfile} $refstyle " . + "shutdown $a_srv_name[$index]"); + my $TI_status = $repo_ref->[$index]->{TI}->SpawnWaitKill ( + $repo_ref->[$index]->{ti}->ProcessStartWaitInterval()); + if ($TI_status != 0) { + print STDERR "ERROR: tao_imr ($index) returned $TI_status\n"; + kill_act(); + kill_imr(); + return 1; + } + print "\n\nshut down server $index using tao_imr\n"; } + return 0; +} + +############################################################################### + +sub wait_for_imr +{ + my $repo_ref = shift; + my $filekey = shift; + + if (!defined($filekey)) { + $filekey = "imriorfile"; + } + my $imr_only = ($filekey eq "imriorfile"); + + if ($repo_ref->{imr}->WaitForFileTimed ( + $repo_ref->{$filekey}, + $repo_ref->{imr}->ProcessStartWaitInterval()) == -1) { + print STDERR "ERROR: cannot find file <" . + $repo_ref->{"imr_$filekey"} . ">\n"; + kill_imr(); + return 1; + } + if ($repo_ref->{imr}->GetFile ($repo_ref->{$filekey}) == -1) { + print STDERR "ERROR: cannot retrieve file <" . + $repo_ref->{"imr_$filekey"} . ">\n"; + kill_imr(); + return 1; + } + if (!$imr_only) { + if ($repo_ref->{act}->PutFile ($repo_ref->{$filekey}) == -1) { + print STDERR "ERROR: cannot set file <" . + $repo_ref->{"act_$filekey"} . ">\n"; + kill_imr(); + return 1; + } + if ($repo_ref->{ti}->PutFile ($repo_ref->{$filekey}) == -1) { + print STDERR "ERROR: cannot set file <" . + $repo_ref->{"act_$filekey"} . ">\n"; + kill_imr(); + return 1; + } + } + return 0; +} + +############################################################################### + +sub kill_then_timed_wait +{ + my $srvrs = shift; + my $time = shift; + my $length = scalar(@{$srvrs}); + for ($index = 0; $index < $length; ++$index) { + $srvrs->[$index]->Kill (); $srvrs->[$index]->TimedWait (1); + } +} + + +############################################################################### + +sub redirect_output +{ + + my $test_stdout_file = shift; + my $test_stderr_file = shift; + open (OLDOUT, ">&", \*STDOUT) or die "Can't dup STDOUT: $!"; + open (OLDERR, ">&", \*STDERR) or die "Can't dup STDERR: $!"; + open STDOUT, '>', $test_stdout_file; + open STDERR, '>', $test_stderr_file; +} - $a_srv->DeleteFile ($airplaneiorfile); - $a_cli->DeleteFile ($airplaneiorfile); +############################################################################### + +sub restore_output() +{ + open (STDERR, ">&OLDERR") or die "Can't dup OLDERR: $!"; + open (STDOUT, ">&OLDOUT") or die "Can't dup OLDOUT: $!"; +} + + +############################################################################### +# The Tests +############################################################################### + +sub airplane_test +{ + my $status = 0; + my @a_srv_airplaneiorfile; + for ($index = 0; $index < $num_srvr; ++$index) { + push(@a_srv_airplaneiorfile, $a_srv[$index]->LocalFile ($airplaneiorfile[$index])); + $a_srv[$index]->DeleteFile ($airplaneiorfile[$index]); + $a_cli[$index]->DeleteFile ($airplaneiorfile[$index]); + + $A_SRV[$index]->Arguments ( + "-o $a_srv_airplaneiorfile[$index] $refstyle -ORBDebugLevel " . + "$srv_debug_level -s $a_srv_name[$index]"); + my $A_SRV_status = $A_SRV[$index]->Spawn (); + if ($A_SRV_status != 0) { + print STDERR "ERROR: Airplane Server returned $A_SRV_status\n"; + return 1; + } + } + + for ($index = 0; $index < $num_srvr; ++$index) { + if ($a_srv[$index]->WaitForFileTimed ($airplaneiorfile[$index],$a_srv[$index]->ProcessStartWaitInterval()) == -1) { + print STDERR "ERROR: cannot find file <$a_srv_airplaneiorfile[$index]>\n"; + kill_then_timed_wait(\@A_SRV, 1); + return 1; + } + if ($a_srv[$index]->GetFile ($airplaneiorfile[$index]) == -1) { + print STDERR "ERROR: cannot retrieve file <$a_srv_airplaneiorfile[$index]>\n"; + kill_then_timed_wait(\@A_SRV, 1); + return 1; + } + if ($a_cli[$index]->PutFile ($airplaneiorfile[$index]) == -1) { + print STDERR "ERROR: cannot set file <$a_cli_airplaneiorfile[$index]>\n"; + kill_then_timed_wait(\@A_SRV, 1); + return 1; + } + } + + for ($index = 0; $index < $num_srvr; ++$index) { + my $A_CLI_status = $A_CLI[$index]->SpawnWaitKill ($a_cli[$index]->ProcessStartWaitInterval()); + if ($A_CLI_status != 0) { + print STDERR "ERROR: Airplane Client returned $A_CLI_status\n"; + $status = 1; + } + } + + for ($index = 0; $index < $num_srvr; ++$index) { + my $A_SRV_status = $A_SRV[$index]->TerminateWaitKill ($a_srv[$index]->ProcessStopWaitInterval()); + if ($A_SRV_status != 0) { + print STDERR "ERROR: Airplane Server returned $A_SRV_status\n"; + $status = 1; + } + + $a_srv[$index]->DeleteFile ($airplaneiorfile[$index]); + $a_cli[$index]->DeleteFile ($airplaneiorfile[$index]); + } return $status; } @@ -145,8 +566,9 @@ sub nestea_test $n_srv->DeleteFile ($nesteaiorfile); $n_cli->DeleteFile ($nesteaiorfile); - $N_SRV->Arguments ("-o $n_srv_nesteaiorfile $refstyle -ORBDebugLevel $debug_level"); - $N_SRV_status = $N_SRV->Spawn (); + $N_SRV->Arguments ("-o $n_srv_nesteaiorfile $refstyle -ORBDebugLevel " . + "$srv_debug_level"); + my $N_SRV_status = $N_SRV->Spawn (); if ($N_SRV_status != 0) { print STDERR "ERROR: Nestea Server returned $N_SRV_status\n"; return 1; @@ -167,7 +589,7 @@ sub nestea_test return 1; } - $N_CLI_status = $N_CLI->SpawnWaitKill ($n_cli->ProcessStartWaitInterval()); + my $N_CLI_status = $N_CLI->SpawnWaitKill ($n_cli->ProcessStartWaitInterval()); if ($N_CLI_status != 0) { print STDERR "ERROR: Nestea Client returned $N_CLI_status\n"; $status = 1; @@ -185,23 +607,25 @@ sub nestea_test return $status; } +############################################################################### + sub nt_service_test_i { my ($imr_initref, $BIN_ACT, $BIN_IMR) = @_; - my $a_srv_airplaneiorfile = $a_srv->LocalFile ($airplaneiorfile); + my $a_srv_airplaneiorfile = $a_srv[0]->LocalFile ($airplaneiorfile[0]); print "Installing TAO ImR Services\n"; - $BIN_ACT->Arguments ("-c install $imr_initref -d 0 -ORBDebugLevel $debug_level"); - $BIN_IMR->Arguments ("-c install -d 0 -orbendpoint iiop://:8888"); + $BIN_ACT->Arguments ("-c install $imr_initref -d $test_debug_level -ORBDebugLevel $debug_level"); + $BIN_IMR->Arguments ("-c install -d $test_debug_level -orbendpoint iiop://:8888"); - $BIN_IMR_status = $BIN_IMR->SpawnWaitKill ($bin_imr->ProcessStartWaitInterval()); + my $BIN_IMR_status = $BIN_IMR->SpawnWaitKill ($bin_imr->ProcessStartWaitInterval()); if ($BIN_IMR_status != 0) { print STDERR "ERROR: ImR Service returned $BIN_IMR_status\n"; return 1; } - $BIN_ACT_status = $BIN_ACT->SpawnWaitKill ($bin_act->ProcessStartWaitInterval()); + my $BIN_ACT_status = $BIN_ACT->SpawnWaitKill ($bin_act->ProcessStartWaitInterval()); if ($BIN_ACT_status != 0) { print STDERR "ERROR: ImR Activator returned $BIN_ACT_status\n"; return 1; @@ -214,11 +638,11 @@ sub nt_service_test_i system("net start taoimractivator 2>&1"); # No need to specify imr_initref or -orbuseimr 1 for servers spawned by activator - $TI->Arguments ("$imr_initref add airplane_server -c \"$imr_A_SRV_cmd\" ". + $TI->Arguments ("$imr_initref add $a_srv_name[0] -c \"$imr_A_SRV_cmd[0] -s $a_srv_name[0]\" ". "-w \"$ENV{ACE_ROOT}/lib\""); - $TI_status = $TI->SpawnWaitKill ($ti->ProcessStartWaitInterval()); + my $TI_status = $TI->SpawnWaitKill ($ti->ProcessStartWaitInterval()); if ($TI_status != 0) { - print STDERR "ERROR: tao_imr add airplane_server returned $TI_status\n"; + print STDERR "ERROR: tao_imr add $a_srv_name[0] returned $TI_status\n"; return 1; } @@ -229,53 +653,55 @@ sub nt_service_test_i return 1; } - $TI->Arguments ("$imr_initref ior airplane_server -f $a_srv_airplaneiorfile"); + $TI->Arguments ("$imr_initref ior $a_srv_name[0] -f $a_srv_airplaneiorfile"); $TI_status = $TI->SpawnWaitKill ($ti->ProcessStartWaitInterval()); if ($TI_status != 0) { - print STDERR "ERROR: tao_imr ior airplane_server returned $TI_status\n"; + print STDERR "ERROR: tao_imr ior $a_srv_name[0] returned $TI_status\n"; return 1; } - if ($a_srv->WaitForFileTimed ($airplaneiorfile,$a_srv->ProcessStartWaitInterval()) == -1) { + if ($a_srv[0]->WaitForFileTimed ($airplaneiorfile[0],$a_srv[0]->ProcessStartWaitInterval()) == -1) { print STDERR "ERROR: cannot find file <$a_srv_airplaneiorfile>\n"; - $A_SRV->Kill (); $A_SRV->TimedWait (1); + kill_then_timed_wait(\@A_SRV, 1); return 1; } - if ($a_srv->GetFile ($airplaneiorfile) == -1) { + if ($a_srv[0]->GetFile ($airplaneiorfile[0]) == -1) { print STDERR "ERROR: cannot retrieve file <$a_srv_airplaneiorfile>\n"; - $A_SRV->Kill (); $A_SRV->TimedWait (1); + kill_then_timed_wait(\@A_SRV, 1); return 1; } - if ($a_cli->PutFile ($airplaneiorfile) == -1) { - print STDERR "ERROR: cannot set file <$a_cli_airplaneiorfile>\n"; - $A_SRV->Kill (); $A_SRV->TimedWait (1); + if ($a_cli[0]->PutFile ($airplaneiorfile[0]) == -1) { + print STDERR "ERROR: cannot set file <$a_cli_airplaneiorfile[$index]>\n"; + kill_then_timed_wait(\@A_SRV, 1); return 1; } - $A_CLI_status = $A_CLI->SpawnWaitKill ($a_cli->ProcessStartWaitInterval()+5); + my $A_CLI_status = $A_CLI[0]->SpawnWaitKill ($a_cli[0]->ProcessStartWaitInterval()+5); if ($A_CLI_status != 0) { print STDERR "ERROR: airplane client returned $A_CLI_status\n"; - $A_SRV->Kill (); $A_SRV->TimedWait (1); + kill_then_timed_wait(\@A_SRV, 1); return 1; } - $TI->Arguments ("$imr_initref shutdown airplane_server"); + $TI->Arguments ("$imr_initref shutdown $a_srv_name[0]"); $TI_status = $TI->SpawnWaitKill ($ti->ProcessStartWaitInterval()+5); if ($TI_status != 0) { - print STDERR "ERROR: tao_imr shutdown airplane_server returned $TI_status\n"; - $A_SRV->Kill (); $A_SRV->TimedWait (1); + print STDERR "ERROR: tao_imr shutdown $a_srv_name[0] returned $TI_status\n"; + kill_then_timed_wait(\@A_SRV, 1); return 1; } return 0; } +############################################################################### + sub nt_service_test { my $result = 0; - my $a_srv_airplaneiorfile = $a_srv->LocalFile ($airplaneiorfile); - $a_srv->DeleteFile ($airplaneiorfile); - $a_cli->DeleteFile ($airplaneiorfile); + my $a_srv_airplaneiorfile = $a_srv[0]->LocalFile ($airplaneiorfile[0]); + $a_srv[0]->DeleteFile ($airplaneiorfile[0]); + $a_cli[0]->DeleteFile ($airplaneiorfile[0]); my $bin_imr_host = $bin_imr->HostName (); @@ -304,11 +730,11 @@ sub nt_service_test print "Removing any existing TAO ImR Services\n"; $BIN_ACT->Arguments ("-c remove"); $BIN_IMR->Arguments ("-c remove"); - $BIN_ACT_status = $BIN_ACT->SpawnWaitKill ($bin_act->ProcessStartWaitInterval()); + my $BIN_ACT_status = $BIN_ACT->SpawnWaitKill ($bin_act->ProcessStartWaitInterval()); if ($BIN_ACT_status < 0) { print STDERR "ERROR: BIN Activator returned $BIN_ACT_status\n"; } - $BIN_IMR_status = $BIN_IMR->SpawnWaitKill ($bin_imr->ProcessStartWaitInterval()); + my $BIN_IMR_status = $BIN_IMR->SpawnWaitKill ($bin_imr->ProcessStartWaitInterval()); if ($BIN_IMR_status < 0) { print STDERR "ERROR: BIN ImR Service returned $BIN_IMR_status\n"; } @@ -335,8 +761,8 @@ sub nt_service_test $bin_imr->DeleteFile ($BIN_IMR->Executable ()); $bin_act->DeleteFile ($BIN_ACT->Executable ()); - $a_srv->DeleteFile ($airplaneiorfile); - $a_cli->DeleteFile ($airplaneiorfile); + $a_srv[0]->DeleteFile ($airplaneiorfile[0]); + $a_cli[0]->DeleteFile ($airplaneiorfile[0]); return $result; } @@ -347,163 +773,293 @@ sub airplane_ir_test { my $status = 0; - my $imr_imriorfile = $imr->LocalFile ($imriorfile); - my $act_imriorfile = $act->LocalFile ($imriorfile); - my $ti_imriorfile = $ti->LocalFile ($imriorfile); - my $a_srv_imriorfile = $a_srv->LocalFile ($imriorfile); - my $act_actiorfile = $act->LocalFile ($actiorfile); - my $imr_airplaneiorfile = $imr->LocalFile ($airplaneiorfile); - my $a_srv_airplaneiorfile = $a_srv->LocalFile ($airplaneiorfile); + if ($srv_debug_level < 2 && $replica) { + $srv_debug_level = 2;#"2 -ORBLogFile server.log"; + } + + my $imr_port = 10001 + $imr->RandomPort (); + print "\n\nimr_port=$imr_port\n"; + my %repo; + setup_repo(\%repo, $imr, $IMR, $imriorfile, $act, $ACT, $actiorfile, $ti, + $TI, $imr_port, "--primary", $backupiorfile); + + my %backup_repo; + if ($replica) { + setup_repo(\%backup_repo, $replica_imr, $replica_IMR, + $replica_imriorfile, $act, $ACT, $actiorfile, + $ti, $TI, $imr_port + 1, "--backup", + $primaryiorfile); + } + + my @repo_for_srvr; + my @a_srv_imriorfile; + my @imr_airplaneiorfile; + my @a_srv_airplaneiorfile; + for ($index = 0; $index < $num_srvr; ++$index) { + if ($index == ($num_srvr - 1) && $replica) { + push(@repo_for_srvr, \%backup_repo); + } + else { + push(@repo_for_srvr, \%repo); + } + + push(@a_srv_imriorfile, $a_srv[$index]->LocalFile ($repo_for_srvr[$index]->{imriorfile})); + push(@imr_airplaneiorfile, $repo_for_srvr[$index]->{imr}->LocalFile ($airplaneiorfile[$index])); + push(@a_srv_airplaneiorfile, $a_srv[$index]->LocalFile ($airplaneiorfile[$index])); + $a_srv[$index]->DeleteFile ($repo_for_srvr[$index]->{imriorfile}); + $a_srv[$index]->DeleteFile ($airplaneiorfile[$index]); + $a_cli[$index]->DeleteFile ($airplaneiorfile[$index]); + $repo_for_srvr[$index]->{imr}->DeleteFile ($airplaneiorfile[$index]); + } $imr->DeleteFile ($imriorfile); $act->DeleteFile ($imriorfile); $ti->DeleteFile ($imriorfile); - $a_srv->DeleteFile ($imriorfile); $act->DeleteFile ($actiorfile); - $imr->DeleteFile ($airplaneiorfile); - $a_srv->DeleteFile ($airplaneiorfile); - $a_cli->DeleteFile ($airplaneiorfile); + if ($replica) { + $replica_imr->DeleteFile ($replica_imriorfile); + cleanup_replication($repo{imr_backing_store}); + } - $IMR->Arguments ("-d 2 -o $imr_imriorfile $refstyle"); - $IMR_status = $IMR->Spawn (); + print "\n\nstarting IMR\n"; + $repo{IMR}->Arguments ("-d $test_debug_level -o $repo{imr_imriorfile} " . + "$imr_refstyle $repo{imr_backing_store_flag} $repo{imr_endpoint_flag}"); + my $IMR_status = $repo{IMR}->Spawn (); if ($IMR_status != 0) { print STDERR "ERROR: ImR Service returned $IMR_status\n"; return 1; } - if ($imr->WaitForFileTimed ($imriorfile,$imr->ProcessStartWaitInterval()) == -1) { - print STDERR "ERROR: cannot find file <$imr_imriorfile>\n"; - $IMR->Kill (); $IMR->TimedWait (1); - return 1; - } - if ($imr->GetFile ($imriorfile) == -1) { - print STDERR "ERROR: cannot retrieve file <$imr_imriorfile>\n"; - $IMR->Kill (); $IMR->TimedWait (1); - return 1; - } - if ($act->PutFile ($imriorfile) == -1) { - print STDERR "ERROR: cannot set file <$act_imriorfile>\n"; - $IMR->Kill (); $IMR->TimedWait (1); - return 1; - } - if ($ti->PutFile ($imriorfile) == -1) { - print STDERR "ERROR: cannot set file <$ti_imriorfile>\n"; - $IMR->Kill (); $IMR->TimedWait (1); - return 1; - } - if ($a_srv->PutFile ($imriorfile) == -1) { - print STDERR "ERROR: cannot set file <$a_srv_imriorfile>\n"; - $IMR->Kill (); $IMR->TimedWait (1); - return 1; - } - - $ACT->Arguments ("-d 2 -o $act_actiorfile -ORBInitRef ImplRepoService=file://$act_imriorfile"); - $ACT_status = $ACT->Spawn (); + if ($replica) { + if (wait_for_imr(\%backup_repo, "replicaiorfile")) { + return 1; + } + print "\n\nstarting backup IMR\n"; + $backup_repo{IMR}->Arguments ("-d $test_debug_level -o " . + "$backup_repo{imr_imriorfile} $imr_refstyle " . + "$backup_repo{imr_backing_store_flag} " . + "$backup_repo{imr_endpoint_flag}"); + my $replica_IMR_status = $backup_repo{IMR}->Spawn (); + if ($replica_IMR_status != 0) { + print STDERR "ERROR: ImR Service replica returned $replica_IMR_status\n"; + return 1; + } + if (wait_for_imr(\%repo, "replicaiorfile")) { + return 1; + } + print "started backup IMR\n"; + } + if (wait_for_imr(\%repo)) { + return 1; + } + print "started IMR\n"; + + for ($index = 0; $index < $num_srvr; ++$index) { + if ($a_srv[$index]->PutFile ($repo_for_srvr[$index]->{imriorfile}) == -1) { + print STDERR "ERROR: cannot set file <$a_srv_imriorfile[$index]>\n"; + kill_imr(); + return 1; + } + } + + print "\n\nstarting ACT\n"; + $repo{ACT}->Arguments ("-d $test_debug_level -o $repo{act_actiorfile} " . + "-ORBInitRef ImplRepoService=file://$repo{act_imriorfile} $refstyle " . + $repo{act_explicit_flag}); + my $ACT_status = $repo{ACT}->Spawn (); if ($ACT_status != 0) { print STDERR "ERROR: ImR Activator returned $ACT_status\n"; return 1; } - if ($act->WaitForFileTimed ($actiorfile,$act->ProcessStartWaitInterval()) == -1) { - print STDERR "ERROR: cannot find file <$act_actiorfile>\n"; - $ACT->Kill (); $ACT->TimedWait (1); - $IMR->Kill (); $IMR->TimedWait (1); + + if ($repo{act}->WaitForFileTimed ( + $repo{actiorfile}, + $repo{act}->ProcessStartWaitInterval()) == -1) { + print STDERR "ERROR: cannot find file <" . + $repo{act_actiorfile} . ">\n"; + kill_act(); + kill_imr(); return 1; } + print "started ACT\n"; # No need to specify imr_initref or -orbuseimr 1 for servers spawned by activator # Can use update to add servers. - $TI->Arguments ("-ORBInitRef ImplRepoService=file://$ti_imriorfile ". - "update airplane_server -c \"$imr_A_SRV_cmd -o $imr_airplaneiorfile\""); - $TI_status = $TI->SpawnWaitKill ($ti->ProcessStartWaitInterval()); - if ($TI_status != 0) { - print STDERR "ERROR: tao_imr returned $TI_status\n"; - $ACT->Kill (); $ACT->TimedWait (1); - $IMR->Kill (); $IMR->TimedWait (1); - return 1; - } - - $A_SRV->Arguments ("-ORBUseIMR 1 -o $a_srv_airplaneiorfile ". - "-ORBInitRef ImplRepoService=file://$a_srv_imriorfile ". - "-ORBDebugLevel $debug_level"); - $A_SRV_status = $A_SRV->Spawn (); - if ($A_SRV_status != 0) { - print STDERR "ERROR: Airplane Server returned $A_SRV_status\n"; - return 1; - } - if ($a_srv->WaitForFileTimed ($airplaneiorfile,$a_srv->ProcessStartWaitInterval()) == -1) { - print STDERR "ERROR: cannot find file <$a_srv_airplaneiorfile>\n"; - $A_SRV->Kill (); $A_SRV->TimedWait (1); - $ACT->Kill (); $ACT->TimedWait (1); - $IMR->Kill (); $IMR->TimedWait (1); - return 1; - } - if ($a_srv->GetFile ($airplaneiorfile) == -1) { - print STDERR "ERROR: cannot retrieve file <$a_srv_airplaneiorfile>\n"; - $A_SRV->Kill (); $A_SRV->TimedWait (1); - $ACT->Kill (); $ACT->TimedWait (1); - $IMR->Kill (); $IMR->TimedWait (1); - return 1; - } - if ($a_cli->PutFile ($airplaneiorfile) == -1) { - print STDERR "ERROR: cannot set file <$a_cli_airplaneiorfile>\n"; - $A_SRV->Kill (); $A_SRV->TimedWait (1); - $ACT->Kill (); $ACT->TimedWait (1); - $IMR->Kill (); $IMR->TimedWait (1); - return 1; - } - - $A_CLI_status = $A_CLI->SpawnWaitKill ($a_cli->ProcessStartWaitInterval()); - if ($A_CLI_status != 0) { - print STDERR "ERROR: Airplane Client 1 returned $A_CLI_status\n"; - $status = 1; - } - - $TI->Arguments ("-ORBInitRef ImplRepoService=file://$ti_imriorfile shutdown airplane_server"); - - $TI_status = $TI->SpawnWaitKill ($ti->ProcessStartWaitInterval()); - if ($TI_status != 0) { - print STDERR "ERROR: tao_imr 1 returned $TI_status\n"; - $status = 1; - } - - # This client should force a new airplane_server to be started - $A_CLI_status = $A_CLI->SpawnWaitKill ($a_cli->ProcessStartWaitInterval()); - if ($A_CLI_status != 0) { - print STDERR "ERROR: Airplane Client 2 returned $A_CLI_status\n"; - $status = 1; - } - - $TI_status = $TI->SpawnWaitKill ($ti->ProcessStartWaitInterval()); - if ($TI_status != 0) { - print STDERR "ERROR: tao_imr 2 returned $TI_status\n"; - $status = 1; - } - - $A_SRV_status = $A_SRV->WaitKill ($a_srv->ProcessStopWaitInterval()); - if ($A_SRV_status != 0) { - print STDERR "ERROR: Airplane Server returned $A_SRV_status\n"; - $status = 1; - } - - $ACT_status = $ACT->TerminateWaitKill ($act->ProcessStopWaitInterval()); + for ($index = 0; $index < $num_srvr; ++$index) { + print "\n\nstarting TI $index\n"; + $repo_for_srvr[$index]->{TI}->Arguments ("-ORBInitRef ImplRepoService" . + "=file://$repo_for_srvr[$index]->{ti_imriorfile} $refstyle " . + "update $a_srv_name[$index] -c \"$imr_A_SRV_cmd[$index] " . + "-o $imr_airplaneiorfile[$index] -s $a_srv_name[$index]\" " . + "$repo_for_srvr[$index]->{server_act_flag} "); + my $TI_status = $repo_for_srvr[$index]->{TI}->SpawnWaitKill ( + $repo_for_srvr[$index]->{ti}->ProcessStartWaitInterval()); + if ($TI_status != 0) { + print STDERR "ERROR: tao_imr ($index) returned $TI_status\n"; + kill_act(); + kill_imr(); + return 1; + } + print "stopped TI $index\n"; + + print "\n\nstarting srv $index\n"; + $A_SRV[$index]->Arguments ( + "-ORBUseIMR 1 -o $a_srv_airplaneiorfile[$index] $refstyle ". + "-ORBInitRef ImplRepoService=file://$a_srv_imriorfile[$index] ". + "-ORBDebugLevel $srv_debug_level -s $a_srv_name[$index] "); + my $A_SRV_status = $A_SRV[$index]->Spawn (); + if ($A_SRV_status != 0) { + print STDERR "ERROR: Airplane Server returned $A_SRV_status\n"; + return 1; + } + } + + for ($index = 0; $index < $num_srvr; ++$index) { + if ($a_srv[$index]->WaitForFileTimed ($airplaneiorfile[$index],$a_srv[$index]->ProcessStartWaitInterval()) == -1) { + print STDERR "ERROR: cannot find file <$a_srv_airplaneiorfile[$index]>\n"; + kill_then_timed_wait(\@A_SRV, 1); + kill_act(); + kill_imr(); + return 1; + } + if ($a_srv[$index]->GetFile ($airplaneiorfile[$index]) == -1) { + print STDERR "ERROR: cannot retrieve file <$a_srv_airplaneiorfile[$index]>\n"; + kill_then_timed_wait(\@A_SRV, 1); + kill_act(); + kill_imr(); + return 1; + } + if ($a_cli[$index]->PutFile ($airplaneiorfile[$index]) == -1) { + print STDERR "ERROR: cannot set file <$a_cli_airplaneiorfile[$index]>\n"; + kill_then_timed_wait(\@A_SRV, 1); + kill_act(); + kill_imr(); + return 1; + } + print "\n\nstarted srv $index\n\n"; + } + + for ($index = 0; $index < $num_srvr; ++$index) { + print "\n\nstarting client $index\n"; + my $A_CLI_status = $A_CLI[$index]->Spawn (); + if ($A_CLI_status != 0) { + print STDERR "ERROR: Airplane Client $index failed to spawn returning $A_CLI_status\n"; + $status = 1; + } + } + + for ($index = 0; $index < $num_srvr; ++$index) { + my $A_CLI_status = $A_CLI[$index]->WaitKill ($a_cli[$index]->ProcessStartWaitInterval()); + if ($A_CLI_status != 0) { + print STDERR "ERROR: Airplane Client $index returned $A_CLI_status\n"; + $status = 1; + } + print "\n\nstopped client $index\n\n\n"; + } + + for ($index = 0; $index < $num_srvr; ++$index) { + print "\n\nstarting TI $index (2)\n"; + $repo_for_srvr[$index]->{TI}->Arguments ("-ORBInitRef " . + "ImplRepoService=file://$repo_for_srvr[$index]->{ti_imriorfile} " . + "$refstyle shutdown $a_srv_name[$index]"); + + my $TI_status = $repo_for_srvr[$index]->{TI}->SpawnWaitKill ( + $repo_for_srvr[$index]->{ti}->ProcessStartWaitInterval()); + if ($TI_status != 0) { + print STDERR "ERROR: tao_imr 1 ($index) returned $TI_status\n"; + $status = 1; + } + print "stopped TI $index (2)\n"; + } + + for ($index = 0; $index < $num_srvr; ++$index) { + print "\n\nstarting client $index\n"; + # This client should force a new airplane_server to be started + my $A_CLI_status = $A_CLI[$index]->SpawnWaitKill ( + $a_cli[$index]->ProcessStartWaitInterval()); + if ($A_CLI_status != 0) { + print STDERR "ERROR: restarted Airplane Client $index returned " . + "$A_CLI_status\n"; + $status = 1; + } + print "stopped client $index\n"; + + print "\n\nstarting client $index\n"; + $repo_for_srvr[$index]->{TI}->Arguments ("-ORBInitRef " . + "ImplRepoService=file://$repo_for_srvr[$index]->{ti_imriorfile} " . + "$refstyle shutdown $a_srv_name[$index]"); + + my $TI_status = $repo_for_srvr[$index]->{TI}->SpawnWaitKill ( + $repo_for_srvr[$index]->{ti}->ProcessStartWaitInterval()); + if ($TI_status != 0) { + print STDERR "ERROR: tao_imr 2 ($index) returned $TI_status\n"; + $status = 1; + } + print "stopped client $index\n"; + } + + for ($index = 0; $index < $num_srvr; ++$index) { + print "\n\nkilling srv $index\n"; + my $A_SRV_status = $A_SRV[$index]->WaitKill ($a_srv[$index]->ProcessStopWaitInterval()); + if ($A_SRV_status != 0) { + print STDERR "ERROR: Airplane Server returned $A_SRV_status\n"; + $status = 1; + } + print "stopped srv $index\n"; + } + + print "\n\nkilling ACT\n"; + $ACT_status = $repo{ACT}->TerminateWaitKill ( + $repo{act}->ProcessStopWaitInterval()); if ($ACT_status != 0) { print STDERR "ERROR: Activator returned $ACT_status\n"; $status = 1; } + print "stopped ACT\n"; - $IMR_status = $IMR->TerminateWaitKill ($imr->ProcessStopWaitInterval()); + print "\n\nkilling IMR\n"; + $IMR_status = $repo{IMR}->TerminateWaitKill ( + $repo{imr}->ProcessStopWaitInterval()); if ($IMR_status != 0) { print STDERR "ERROR: ImR returned $IMR_status\n"; $status = 1; } - - $imr->DeleteFile ($imriorfile); - $act->DeleteFile ($imriorfile); - $ti->DeleteFile ($imriorfile); - $a_srv->DeleteFile ($imriorfile); - $act->DeleteFile ($actiorfile); - $imr->DeleteFile ($airplaneiorfile); - $a_srv->DeleteFile ($airplaneiorfile); - $a_cli->DeleteFile ($airplaneiorfile); - + print "stopped IMR\n"; + + if ($replica) { + print "\n\nkilling backup IMR\n"; + $IMR_status = $backup_repo{IMR}->TerminateWaitKill ( + $backup_repo{imr}->ProcessStopWaitInterval()); + if ($IMR_status != 0) { + print STDERR "ERROR: replica ImR returned $IMR_status\n"; + $status = 1; + } + print "stopped backup IMR\n"; + } + + $repo{imr}->DeleteFile ($repo{imriorfile}); + $repo{act}->DeleteFile ($repo{imriorfile}); + $repo{ti}->DeleteFile ($repo{imriorfile}); + $repo{act}->DeleteFile ($repo{actiorfile}); + + if ($replica) { + $backup_repo{imr}->DeleteFile ( + $backup_repo{imriorfile}); + $backup_repo{act}->DeleteFile ( + $backup_repo{imriorfile}); + $backup_repo{ti}->DeleteFile ( + $backup_repo{imriorfile}); + $backup_repo{act}->DeleteFile ( + $backup_repo{actiorfile}); + cleanup_replication($repo{imr_backing_store}); + } + + for ($index = 0; $index < $num_srvr; ++$index) { + $repo_for_srvr[$index]->{imr}->DeleteFile ( + $airplaneiorfile[$index]); + $a_srv[$index]->DeleteFile ( + $repo_for_srvr[$index]->{imriorfile}); + $a_srv[$index]->DeleteFile ($airplaneiorfile[$index]); + $a_cli[$index]->DeleteFile ($airplaneiorfile[$index]); + } return $status; } @@ -529,13 +1085,14 @@ sub nestea_ir_test $n_srv->DeleteFile ($nesteaiorfile); $n_cli->DeleteFile ($nesteaiorfile); - $IMR->Arguments ("-d 2 -o $imr_imriorfile $refstyle"); - $IMR_status = $IMR->Spawn (); + $IMR->Arguments ("-d $test_debug_level -o $imr_imriorfile $imr_refstyle"); + my $IMR_status = $IMR->Spawn (); if ($IMR_status != 0) { print STDERR "ERROR: ImR Service returned $IMR_status\n"; return 1; } - if ($imr->WaitForFileTimed ($imriorfile,$imr->ProcessStartWaitInterval()) == -1) { + if ($imr->WaitForFileTimed ($imriorfile, + $imr->ProcessStartWaitInterval()) == -1) { print STDERR "ERROR: cannot find file <$imr_imriorfile>\n"; $IMR->Kill (); $IMR->TimedWait (1); return 1; @@ -561,9 +1118,10 @@ sub nestea_ir_test return 1; } - $ACT->Arguments ("-d 2 -o $act_actiorfile ". - "-orbobjrefstyle URL -ORBInitRef ImplRepoService=file://$act_imriorfile"); - $ACT_status = $ACT->Spawn (); + $ACT->Arguments ( + "-d $test_debug_level -o $act_actiorfile -orbobjrefstyle URL ". + "-ORBInitRef ImplRepoService=file://$act_imriorfile"); + my $ACT_status = $ACT->Spawn (); if ($ACT_status != 0) { print STDERR "ERROR: ImR Activator returned $ACT_status\n"; return 1; @@ -575,10 +1133,11 @@ sub nestea_ir_test return 1; } - $N_SRV->Arguments ("-ORBUseIMR 1 -o $n_srv_nesteaiorfile ". - "-orbobjrefstyle URL -ORBInitRef ImplRepoService=file://$n_srv_imriorfile ". - "-ORBDebugLevel $debug_level"); - $N_SRV_status = $N_SRV->Spawn (); + $N_SRV->Arguments ( + "-ORBUseIMR 1 -o $n_srv_nesteaiorfile -orbobjrefstyle URL ". + "-ORBInitRef ImplRepoService=file://$n_srv_imriorfile ". + "-ORBDebugLevel $srv_debug_level"); + my $N_SRV_status = $N_SRV->Spawn (); if ($N_SRV_status != 0) { print STDERR "ERROR: Nestea Server returned $N_SRV_status\n"; return 1; @@ -605,7 +1164,7 @@ sub nestea_ir_test return 1; } - $N_CLI_status = $N_CLI->SpawnWaitKill ($n_cli->ProcessStartWaitInterval()); + my $N_CLI_status = $N_CLI->SpawnWaitKill ($n_cli->ProcessStartWaitInterval()); if ($N_CLI_status != 0) { print STDERR "ERROR: Nestea Client 1 returned $N_CLI_status\n"; $N_SRV->Kill (); $N_SRV->TimedWait (1); @@ -617,7 +1176,7 @@ sub nestea_ir_test $TI->Arguments ("-orbobjrefstyle URL -ORBInitRef ImplRepoService=file://$ti_imriorfile ". " shutdown nestea_server"); - $TI_status = $TI->SpawnWaitKill ($ti->ProcessStartWaitInterval()); + my $TI_status = $TI->SpawnWaitKill ($ti->ProcessStartWaitInterval()); if ($TI_status != 0) { print STDERR "ERROR: tao_imr 1 returned $TI_status\n"; $N_SRV->Kill (); $N_SRV->TimedWait (1); @@ -741,14 +1300,16 @@ sub perclient my $imr_host = $imr->HostName (); # specify an endpoint so that we can use corbaloc url for the client. - $IMR->Arguments ("-d 2 -orbendpoint iiop://:8888 -o $imr_imriorfile $refstyle ". - "-ORBDebugLevel $debug_level"); - $IMR_status = $IMR->Spawn (); + $IMR->Arguments ( + "-d $test_debug_level -orbendpoint iiop://:8888 ". + "-o $imr_imriorfile $imr_refstyle -ORBDebugLevel $debug_level"); + my $IMR_status = $IMR->Spawn (); if ($IMR_status != 0) { print STDERR "ERROR: ImR Service returned $IMR_status\n"; return 1; } - if ($imr->WaitForFileTimed ($imriorfile,$imr->ProcessStartWaitInterval()) == -1) { + if ($imr->WaitForFileTimed ($imriorfile, + $imr->ProcessStartWaitInterval()) == -1) { print STDERR "ERROR: cannot find file <$imr_imriorfile>\n"; $IMR->Kill (); $IMR->TimedWait (1); return 1; @@ -769,9 +1330,9 @@ sub perclient return 1; } - $ACT->Arguments ("-d 2 -o $act_actiorfile ". + $ACT->Arguments ("-d $test_debug_level -o $act_actiorfile ". "-orbobjrefstyle URL -ORBInitRef ImplRepoService=file://$act_imriorfile"); - $ACT_status = $ACT->Spawn (); + my $ACT_status = $ACT->Spawn (); if ($ACT_status != 0) { print STDERR "ERROR: ImR Activator returned $ACT_status\n"; return 1; @@ -787,7 +1348,7 @@ sub perclient $TI->Arguments ("-orbobjrefstyle URL -ORBInitRef ImplRepoService=file://$ti_imriorfile ". "add nestea_server -a PER_CLIENT ". "-c \"$imr_N_SRV_cmd -o $imr_nesteaiorfile\""); - $TI_status = $TI->SpawnWaitKill ($ti->ProcessStartWaitInterval()); + my $TI_status = $TI->SpawnWaitKill ($ti->ProcessStartWaitInterval()); if ($TI_status != 0) { print STDERR "ERROR: tao_imr returned $TI_status\n"; $ACT->Kill (); $ACT->TimedWait (1); @@ -798,21 +1359,21 @@ sub perclient $N_CLI->Arguments("-k corbaloc::$imr_host:8888/nestea_server"); # Running the client should start a server instance - $N_CLI_status = $N_CLI->SpawnWaitKill ($n_cli->ProcessStartWaitInterval()+5); + my $N_CLI_status = $N_CLI->SpawnWaitKill ($n_cli->ProcessStartWaitInterval()+5); if ($N_CLI_status != 0) { print STDERR "ERROR: Nestea Client 1 returned $N_CLI_status\n"; $ACT->Kill (); $ACT->TimedWait (1); $IMR->Kill (); $IMR->TimedWait (1); return 1; } - if ($n_cli->WaitForFileTimed ($nesteaiorfile,$a_cli->ProcessStartWaitInterval()) == -1) { - print STDERR "ERROR: cannot find file <$a_cli_nesteaiorfile>\n"; + if ($n_cli->WaitForFileTimed ($nesteaiorfile,$a_cli[0]->ProcessStartWaitInterval()) == -1) { + print STDERR "ERROR: cannot find file <$n_cli_nesteaiorfile>\n"; $ACT->Kill (); $ACT->TimedWait (1); $IMR->Kill (); $IMR->TimedWait (1); return 1; } - $a_cli->DeleteFile ($nesteaiorfile); + $a_cli[0]->DeleteFile ($nesteaiorfile); $N_CLI->Arguments("-s -k corbaloc::$imr_host:8888/nestea_server"); @@ -824,8 +1385,8 @@ sub perclient $IMR->Kill (); $IMR->TimedWait (1); return 1; } - if ($n_cli->WaitForFileTimed ($nesteaiorfile,$a_cli->ProcessStartWaitInterval()) == -1) { - print STDERR "ERROR: cannot find file <$a_cli_nesteaiorfile>\n"; + if ($n_cli->WaitForFileTimed ($nesteaiorfile,$a_cli[0]->ProcessStartWaitInterval()) == -1) { + print STDERR "ERROR: cannot find file <$n_cli_nesteaiorfile>\n"; $ACT->Kill (); $ACT->TimedWait (1); $IMR->Kill (); $IMR->TimedWait (1); return 1; @@ -856,7 +1417,6 @@ sub perclient return $status; } - ############################################################################### sub shutdown_repo @@ -878,14 +1438,15 @@ sub shutdown_repo # Specify an endpoint so that we can restart on the same port. # Specify persistence so that we can test that shutdown-repo -a works after reconnect - $IMR->Arguments ("-p $imr_testrepo -d 1 -orbendpoint iiop://:8888 -o $imr_imriorfile $refstyle ". + $IMR->Arguments ("-p $imr_testrepo -d 1 -orbendpoint iiop://:8888 -o $imr_imriorfile $imr_refstyle ". "-ORBDebugLevel $debug_level"); - $IMR_status = $IMR->Spawn (); + my $IMR_status = $IMR->Spawn (); if ($IMR_status != 0) { print STDERR "ERROR: ImR Service returned $IMR_status\n"; return 1; } - if ($imr->WaitForFileTimed ($imriorfile,$imr->ProcessStartWaitInterval()) == -1) { + if ($imr->WaitForFileTimed ($imriorfile, + $imr->ProcessStartWaitInterval()) == -1) { print STDERR "ERROR: cannot find file <$imr_imriorfile>\n"; $IMR->Kill (); $IMR->TimedWait (1); return 1; @@ -908,7 +1469,7 @@ sub shutdown_repo $ACT->Arguments ("-d 1 -o $act_actiorfile ". "-orbobjrefstyle URL -ORBInitRef ImplRepoService=file://$act_imriorfile"); - $ACT_status = $ACT->Spawn (); + my $ACT_status = $ACT->Spawn (); if ($ACT_status != 0) { print STDERR "ERROR: ImR Activator returned $ACT_status\n"; return 1; @@ -923,7 +1484,7 @@ sub shutdown_repo # Kill the ImR, but leave the activator running $TI->Arguments ("-orbobjrefstyle URL -ORBInitRef ImplRepoService=file://$ti_imriorfile ". "shutdown-repo"); - $TI_status = $TI->SpawnWaitKill ($ti->ProcessStartWaitInterval()); + my $TI_status = $TI->SpawnWaitKill ($ti->ProcessStartWaitInterval()); if ($TI_status != 0) { print STDERR "ERROR: tao_imr returned $TI_status\n"; $ACT->Kill (); $ACT->TimedWait (1); @@ -944,7 +1505,8 @@ sub shutdown_repo print STDERR "ERROR: ImR Service returned $IMR_status\n"; return 1; } - if ($imr->WaitForFileTimed ($imriorfile,$imr->ProcessStartWaitInterval()) == -1) { + if ($imr->WaitForFileTimed ($imriorfile, + $imr->ProcessStartWaitInterval()) == -1) { print STDERR "ERROR: cannot find file <$imr_imriorfile>\n"; $IMR->Kill (); $IMR->TimedWait (1); return 1; @@ -993,35 +1555,65 @@ sub shutdown_repo sub persistent_ir_test { + my $backing_store_flag = shift; my $status = 0; + if ($srv_debug_level == 0) { + $srv_debug_level = 1; + } + + test_info("persistent_ir_test start\n"); + + my $backing_store; + if ($backing_store_flag eq "-p") { + $backing_store = "test.repo"; + } elsif ($backing_store_flag eq "--directory") { + $backing_store = "."; + } elsif ($backing_store_flag eq "-x") { + $backing_store = "imr_backing_store.xml"; + } + my $imr_imriorfile = $imr->LocalFile ($imriorfile); - my $imr_storefile = $imr->LocalFile ($backing_store); + my $imr_storefile; + if (defined($backing_store)) { + $imr_storefile = $imr->LocalFile ($backing_store); + } my $act_imriorfile = $act->LocalFile ($imriorfile); my $ti_imriorfile = $ti->LocalFile ($imriorfile); - my $a_srv_imriorfile = $a_srv->LocalFile ($imriorfile); my $act_actiorfile = $act->LocalFile ($actiorfile); - my $imr_airplaneiorfile = $imr->LocalFile ($airplaneiorfile); - my $a_srv_airplaneiorfile = $a_srv->LocalFile ($airplaneiorfile); + + my @a_srv_imriorfile; + my @imr_airplaneiorfile; + my @a_srv_airplaneiorfile; + for ($index = 0; $index < $num_srvr; ++$index) { + push(@a_srv_imriorfile, $a_srv[$index]->LocalFile ($imriorfile)); + push(@imr_airplaneiorfile, $imr->LocalFile ($airplaneiorfile[$index])); + push(@a_srv_airplaneiorfile, $a_srv[$index]->LocalFile ($airplaneiorfile[$index])); + $a_srv[$index]->DeleteFile ($imriorfile); + $a_srv[$index]->DeleteFile ($airplaneiorfile[$index]); + $a_cli[$index]->DeleteFile ($airplaneiorfile[$index]); + $imr->DeleteFile ($airplaneiorfile[$index]); + } $imr->DeleteFile ($imriorfile); - $imr->DeleteFile ($backing_store); + if ($backing_store_flag eq "--directory") { + cleanup_replication($imr_storefile); + } $act->DeleteFile ($imriorfile); $ti->DeleteFile ($imriorfile); - $a_srv->DeleteFile ($imriorfile); $act->DeleteFile ($actiorfile); - $imr->DeleteFile ($airplaneiorfile); - $a_srv->DeleteFile ($airplaneiorfile); - $a_cli->DeleteFile ($airplaneiorfile); ## Be sure to start the ImR on a consistent endpoint, so that any created IORs ## remain valid even if the ImR restarts. - $IMR->Arguments ("-orbendpoint iiop://:8888 -x $imr_storefile -d 2 -o $imr_imriorfile $refstyle"); - $IMR_status = $IMR->Spawn (); + my $imr_arguments = "-orbendpoint iiop://:8888 $backing_store_flag $imr_storefile -d $test_debug_level -o $imr_imriorfile $imr_refstyle "; + $IMR->Arguments ("$imr_arguments -e "); + test_info("starting IMR=" . $IMR->CommandLine() . "\n"); + my $IMR_status = $IMR->Spawn (); if ($IMR_status != 0) { print STDERR "ERROR: ImR Service returned $IMR_status\n"; return 1; } - if ($imr->WaitForFileTimed ($imriorfile,$imr->ProcessStartWaitInterval()) == -1) { + if ($imr->WaitForFileTimed ($imriorfile, + $imr->ProcessStartWaitInterval()) == -1) { print STDERR "ERROR: cannot find file <$imr_imriorfile>\n"; $IMR->Kill (); $IMR->TimedWait (1); return 1; @@ -1041,18 +1633,23 @@ sub persistent_ir_test $IMR->Kill (); $IMR->TimedWait (1); return 1; } - if ($a_srv->PutFile ($imriorfile) == -1) { - print STDERR "ERROR: cannot set file <$a_srv_imriorfile>\n"; - $IMR->Kill (); $IMR->TimedWait (1); - return 1; + + for ($index = 0; $index < $num_srvr; ++$index) { + if ($a_srv[$index]->PutFile ($imriorfile) == -1) { + print STDERR "ERROR: cannot set file <$a_srv_imriorfile[$index]>\n"; + $IMR->Kill (); $IMR->TimedWait (1); + return 1; + } } - $ACT->Arguments ("-d 2 -o $act_actiorfile -ORBInitRef ImplRepoService=file://$act_imriorfile"); - $ACT_status = $ACT->Spawn (); + $ACT->Arguments ("-d $test_debug_level -o $act_actiorfile -ORBInitRef ImplRepoService=file://$act_imriorfile"); + test_info("starting ACT=" . $ACT->CommandLine() . "\n"); + my $ACT_status = $ACT->Spawn (); if ($ACT_status != 0) { print STDERR "ERROR: ImR Activator returned $ACT_status\n"; return 1; } + if ($act->WaitForFileTimed ($actiorfile,$act->ProcessStartWaitInterval()) == -1) { print STDERR "ERROR: cannot find file <$act_actiorfile>\n"; $ACT->Kill (); $ACT->TimedWait (1); @@ -1066,190 +1663,923 @@ sub persistent_ir_test return 1; } - $p_srv->DeleteFile ($P_SRV_cmd); - # Copy the server to a path with spaces to ensure that these - # work corrrectly. - copy ($A_SRV_cmd, $P_SRV_cmd); - chmod(0755, $P_SRV_cmd); + for ($index = 0; $index < $num_srvr; ++$index) { + $p_srv[$index]->DeleteFile ($P_SRV_cmd[$index]); + # Copy the server to a path with spaces to ensure that these + # work corrrectly. + copy ($A_SRV_cmd[$index], $P_SRV_cmd[$index]); + chmod(0755, $P_SRV_cmd[$index]); + } + + for ($index = 0; $index < $num_srvr; ++$index) { + # No need to specify imr_initref or -orbuseimr 1 for servers spawned by activator + $TI->Arguments ( + "-ORBInitRef ImplRepoService=file://$ti_imriorfile ". + "add $a_srv_name[$index] -c \"\\\"$imr_P_SRV_cmd[$index]\\\" " . + "$refstyle -s $a_srv_name[$index]\""); + test_info("starting TI=" . $TI->CommandLine() . "\n"); + my $TI_status = $TI->SpawnWaitKill ($ti->ProcessStartWaitInterval()); + if ($TI_status != 0) { + print STDERR "ERROR: tao_imr ($index) returned $TI_status\n"; + $p_srv[$index]->DeleteFile ($P_SRV_cmd[$index]); + $ACT->Kill (); $ACT->TimedWait (1); + $IMR->Kill (); $IMR->TimedWait (1); + return 1; + } + } + + for ($index = 0; $index < $num_srvr; ++$index) { + ## This will write out the imr-ified IOR. Note : If you don't use -orbendpoint + ## when starting the ImR, then this IOR will no longer be valid when the ImR + ## restarts below. You can fix this by creating a new valid IOR, or starting + ## the ImR on a consistent endpoint. + $A_SRV[$index]->Arguments ( + "-o $a_srv_airplaneiorfile[$index] -ORBUseIMR 1 $refstyle ". + "-ORBInitRef ImplRepoService=file://$a_srv_imriorfile[$index] ". + "-ORBDebugLevel $srv_debug_level -s $a_srv_name[$index]"); + test_info("starting $a_srv_name[$index]=" . + $A_SRV[$index]->CommandLine() . "\n"); + my $A_SRV_status = $A_SRV[$index]->Spawn (); + if ($A_SRV_status != 0) { + print STDERR "ERROR: Airplane Server returned $A_SRV_status\n"; + return 1; + } + } + + for ($index = 0; $index < $num_srvr; ++$index) { + if ($a_srv[$index]->WaitForFileTimed ( + $airplaneiorfile[$index], + $a_srv[$index]->ProcessStartWaitInterval()) == -1) { + print STDERR + "ERROR: cannot find file <$a_srv_airplaneiorfile[$index]>\n"; + kill_then_timed_wait(\@A_SRV, 1); + $ACT->Kill (); $ACT->TimedWait (1); + $IMR->Kill (); $IMR->TimedWait (1); + return 1; + } + if ($a_srv[$index]->GetFile ($airplaneiorfile[$index]) == -1) { + print STDERR + "ERROR: cannot retrieve file <$a_srv_airplaneiorfile[$index]>\n"; + kill_then_timed_wait(\@A_SRV, 1); + $ACT->Kill (); $ACT->TimedWait (1); + $IMR->Kill (); $IMR->TimedWait (1); + return 1; + } + if ($a_cli[$index]->PutFile ($airplaneiorfile[$index]) == -1) { + print STDERR "ERROR: cannot set file <$a_cli_airplaneiorfile[$index]>\n"; + kill_then_timed_wait(\@A_SRV, 1); + $ACT->Kill (); $ACT->TimedWait (1); + $IMR->Kill (); $IMR->TimedWait (1); + return 1; + } + } + + for ($index = 0; $index < $num_srvr; ++$index) { + test_info("starting client for $a_srv_name[$index]=" . + $A_CLI[$index]->CommandLine() . "\n"); + my $A_CLI_status = $A_CLI[$index]->Spawn (); + if ($A_CLI_status != 0) { + print STDERR + "ERROR: Airplane Client ($index) failed to spawn returning $A_CLI_status\n"; + kill_then_timed_wait(\@A_SRV, 1); + $ACT->Kill (); $ACT->TimedWait (1); + $IMR->Kill (); $IMR->TimedWait (1); + return 1; + } + } + + for ($index = 0; $index < $num_srvr; ++$index) { + test_info("killing client for $a_srv_name[$index]\n"); + my $A_CLI_status = $A_CLI[$index]->WaitKill ($a_cli[$index]->ProcessStartWaitInterval()); + if ($A_CLI_status != 0) { + print STDERR "ERROR: Airplane Client ($index) returned $A_CLI_status\n"; + kill_then_timed_wait(\@A_SRV, 1); + $ACT->Kill (); $ACT->TimedWait (1); + $IMR->Kill (); $IMR->TimedWait (1); + return 1; + } + } + + for ($index = 0; $index < $num_srvr; ++$index) { + $TI->Arguments ("-ORBInitRef ImplRepoService=file://$ti_imriorfile ". + "shutdown $a_srv_name[$index]"); + test_info("starting TI=" . $TI->CommandLine() . "\n"); + my $TI_status = $TI->SpawnWaitKill ($ti->ProcessStartWaitInterval()); + if ($TI_status != 0) { + print STDERR "ERROR: tao_imr shutdown returned $TI_status\n"; + kill_then_timed_wait(\@A_SRV, 1); + $ACT->Kill (); $ACT->TimedWait (1); + $IMR->Kill (); $IMR->TimedWait (1); + return 1; + } + } + + for ($index = 0; $index < $num_srvr; ++$index) { + test_info("killing $a_srv_name[$index]\n"); + my $A_SRV_status = $A_SRV[$index]->WaitKill ($a_srv[$index]->ProcessStartWaitInterval()); + if ($A_SRV_status != 0) { + print STDERR "ERROR: Airplane Server returned $A_SRV_status\n"; + $ACT->Kill (); $ACT->TimedWait (1); + $IMR->Kill (); $IMR->TimedWait (1); + return 1; + } + } + + for ($index = 0; $index < $num_srvr; ++$index) { + test_info("starting client for $a_srv_name[$index]\n"); + # Should cause the activator to spawn another server. + my $A_CLI_status = $A_CLI[$index]->Spawn (); + if ($A_CLI_status != 0) { + print STDERR "ERROR: Airplane Client 2 ($index) failed to spawn returning $A_CLI_status\n"; + $ACT->Kill (); $ACT->TimedWait (1); + $IMR->Kill (); $IMR->TimedWait (1); + return 1; + } + } + + for ($index = 0; $index < $num_srvr; ++$index) { + test_info("killing client for $a_srv_name[$index]\n"); + # Should cause the activator to spawn another server. + my $A_CLI_status = $A_CLI[$index]->WaitKill ($a_cli[$index]->ProcessStartWaitInterval()); + if ($A_CLI_status != 0) { + print STDERR "ERROR: Airplane Client 2 ($index) returned $A_CLI_status\n"; + $ACT->Kill (); $ACT->TimedWait (1); + $IMR->Kill (); $IMR->TimedWait (1); + return 1; + } + } + + for ($index = 0; $index < $num_srvr; ++$index) { + # Shutdown airplane_server + $TI->Arguments ("-ORBInitRef ImplRepoService=file://$ti_imriorfile ". + "shutdown $a_srv_name[$index]"); + test_info("starting TI=" . $TI->CommandLine() . "\n"); + my $TI_status = $TI->SpawnWaitKill ($ti->ProcessStartWaitInterval()); + if ($TI_status != 0) { + print STDERR "ERROR: tao_imr shutdown 2 ($index) returned $TI_status\n"; + $ACT->Kill (); $ACT->TimedWait (1); + $IMR->Kill (); $IMR->TimedWait (1); + return 1; + } + } + + for ($index = 0; $index < $num_srvr; ++$index) { + test_info("killing IMR=" . $IMR->CommandLine() . "\n"); + my $IMR_status = $IMR->TerminateWaitKill ($imr->ProcessStopWaitInterval()); + if ($IMR_status != 0) { + print STDERR "ERROR: ImR returned $IMR_status\n"; + $ACT->Kill (); $ACT->TimedWait (1); + return 1; + } + } - # No need to specify imr_initref or -orbuseimr 1 for servers spawned by activator - $TI->Arguments ("-ORBInitRef ImplRepoService=file://$ti_imriorfile ". - "add airplane_server -c \"\\\"$imr_P_SRV_cmd\\\" $refstyle\""); - $TI_status = $TI->SpawnWaitKill ($ti->ProcessStartWaitInterval()); - if ($TI_status != 0) { - print STDERR "ERROR: tao_imr returned $TI_status\n"; - $p_srv->DeleteFile ($P_SRV_cmd); - $ACT->Kill (); $ACT->TimedWait (1); - $IMR->Kill (); $IMR->TimedWait (1); - return 1; + # Unlink so that we can wait on them again to know the server started. + $imr->DeleteFile ($imriorfile); + $act->DeleteFile ($imriorfile); + $ti->DeleteFile ($imriorfile); + + for ($index = 0; $index < $num_srvr; ++$index) { + $a_srv[$index]->DeleteFile ($imriorfile); } - ## This will write out the imr-ified IOR. Note : If you don't use -orbendpoint - ## when starting the ImR, then this IOR will no longer be valid when the ImR - ## restarts below. You can fix this by creating a new valid IOR, or starting - ## the ImR on a consistent endpoint. - $A_SRV->Arguments ("-o $a_srv_airplaneiorfile -ORBUseIMR 1 $refstyle ". - "-ORBInitRef ImplRepoService=file://$a_srv_imriorfile ". - "-ORBDebugLevel $debug_level"); - $A_SRV_status = $A_SRV->Spawn (); - if ($A_SRV_status != 0) { - print STDERR "ERROR: Airplane Server returned $A_SRV_status\n"; + print "Restarting Implementation Repository.\n"; + $IMR->Arguments ("$imr_arguments "); + test_info("restarting IMR=" . $IMR->CommandLine() . "\n"); + $IMR_status = $IMR->Spawn (); + if ($IMR_status != 0) { + print STDERR "ERROR: ImR Service returned $IMR_status\n"; + $ACT->Kill (); $ACT->TimedWait (1); return 1; } - if ($a_srv->WaitForFileTimed ($airplaneiorfile,$a_srv->ProcessStartWaitInterval()) == -1) { - print STDERR "ERROR: cannot find file <$a_srv_airplaneiorfile>\n"; - $A_SRV->Kill (); $A_SRV->TimedWait (1); + if ($imr->WaitForFileTimed ($imriorfile, + $imr->ProcessStartWaitInterval()) == -1) { + print STDERR "ERROR: cannot find file <$imr_imriorfile>\n"; $ACT->Kill (); $ACT->TimedWait (1); $IMR->Kill (); $IMR->TimedWait (1); return 1; } - if ($a_srv->GetFile ($airplaneiorfile) == -1) { - print STDERR "ERROR: cannot retrieve file <$a_srv_airplaneiorfile>\n"; - $A_SRV->Kill (); $A_SRV->TimedWait (1); + if ($imr->GetFile ($imriorfile) == -1) { + print STDERR "ERROR: cannot retrieve file <$imr_imriorfile>\n"; $ACT->Kill (); $ACT->TimedWait (1); $IMR->Kill (); $IMR->TimedWait (1); return 1; } - if ($a_cli->PutFile ($airplaneiorfile) == -1) { - print STDERR "ERROR: cannot set file <$a_cli_airplaneiorfile>\n"; - $A_SRV->Kill (); $A_SRV->TimedWait (1); + if ($act->PutFile ($imriorfile) == -1) { + print STDERR "ERROR: cannot set file <$act_imriorfile>\n"; $ACT->Kill (); $ACT->TimedWait (1); $IMR->Kill (); $IMR->TimedWait (1); return 1; } - - $A_CLI_status = $A_CLI->SpawnWaitKill ($a_cli->ProcessStartWaitInterval()); - if ($A_CLI_status != 0) { - print STDERR "ERROR: Airplane Client returned $A_CLI_status\n"; - $A_SRV->Kill (); $A_SRV->TimedWait (1); + if ($ti->PutFile ($imriorfile) == -1) { + print STDERR "ERROR: cannot set file <$ti_imriorfile>\n"; $ACT->Kill (); $ACT->TimedWait (1); $IMR->Kill (); $IMR->TimedWait (1); return 1; } - $TI->Arguments ("-ORBInitRef ImplRepoService=file://$ti_imriorfile ". - "shutdown airplane_server"); - $TI_status = $TI->SpawnWaitKill ($ti->ProcessStartWaitInterval()); - if ($TI_status != 0) { - print STDERR "ERROR: tao_imr shutdown returned $TI_status\n"; - $A_SRV->Kill (); $A_SRV->TimedWait (1); - $ACT->Kill (); $ACT->TimedWait (1); - $IMR->Kill (); $IMR->TimedWait (1); + for ($index = 0; $index < $num_srvr; ++$index) { + if ($a_srv[$index]->PutFile ($imriorfile) == -1) { + print STDERR "ERROR: cannot set file <$a_srv_imriorfile[$index]>\n"; + $ACT->Kill (); $ACT->TimedWait (1); + $IMR->Kill (); $IMR->TimedWait (1); + return 1; + } + } + + for ($index = 0; $index < $num_srvr; ++$index) { + test_info("starting client for $a_srv_name[$index]\n"); + # Should cause the activator to spawn another server. + my $A_CLI_status = $A_CLI[$index]->Spawn (); + if ($A_CLI_status != 0) { + print STDERR "ERROR: Airplane Client 3 ($index) failed to spawn returning $A_CLI_status\n"; + $status = 1; + } + } + + for ($index = 0; $index < $num_srvr; ++$index) { + test_info("killing client for $a_srv_name[$index]\n"); + # Should cause the activator to spawn another server. + my $A_CLI_status = $A_CLI[$index]->WaitKill ($a_cli[$index]->ProcessStartWaitInterval()+5); + if ($A_CLI_status != 0) { + print STDERR "ERROR: Airplane Client 3 ($index) returned $A_CLI_status\n"; + $status = 1; + } + } + + for ($index = 0; $index < $num_srvr; ++$index) { + # Shutdown airplane_server + $TI->Arguments ("-ORBInitRef ImplRepoService=file://$ti_imriorfile ". + "shutdown $a_srv_name[$index]"); + test_info("starting TI=" . $TI->CommandLine() . "\n"); + my $TI_status = $TI->SpawnWaitKill ($ti->ProcessStartWaitInterval()); + if ($TI_status != 0) { + print STDERR "ERROR: tao_imr shutdown 3 returned $TI_status\n"; + $status = 1; + } + } + + for ($index = 0; $index < $num_srvr; ++$index) { + test_info("killing ACT\n"); + $ACT_status = $ACT->TerminateWaitKill ($act->ProcessStopWaitInterval()); + if ($ACT_status != 0) { + print STDERR "ERROR: Activator returned $ACT_status\n"; + $status = 1; + } + } + + test_info("killing IMR\n"); + $IMR_status = $IMR->TerminateWaitKill ($imr->ProcessStopWaitInterval()); + if ($IMR_status != 0) { + print STDERR "ERROR: ImR returned $IMR_status\n"; + $status = 1; + } + + if (!defined($backing_store)) { + # startup ImR with "-e" flag to ensure cleanup of registry entries + $IMR->Arguments ("$imr_arguments -e"); + test_info("starting IMR=" . $IMR->CommandLine() . "\n"); + $IMR_status = $IMR->Spawn (); + if ($IMR_status != 0) { + print STDERR "ERROR: ImR Service returned $IMR_status\n"; + return 1; + } + + $IMR->TimedWait ($imr->ProcessStartWaitInterval()); + + test_info("killing IMR\n"); + $IMR_status = $IMR->TerminateWaitKill ($imr->ProcessStopWaitInterval()); + if ($IMR_status != 0) { + print STDERR "ERROR: ImR returned $IMR_status\n"; + $status = 1; + } + } + elsif ($backing_store_flag eq "--directory") { + cleanup_replication($backing_store); + } + else { + $imr->DeleteFile ($backing_store); + } + $imr->DeleteFile ($imriorfile); + $act->DeleteFile ($imriorfile); + $ti->DeleteFile ($imriorfile); + $act->DeleteFile ($actiorfile); + for ($index = 0; $index < $num_srvr; ++$index) { + $imr->DeleteFile ($airplaneiorfile[$index]); + $a_srv[$index]->DeleteFile ($imriorfile); + $a_srv[$index]->DeleteFile ($airplaneiorfile[$index]); + $a_cli[$index]->DeleteFile ($airplaneiorfile[$index]); + $p_srv[$index]->DeleteFile ($P_SRV_cmd[$index]); + } + + return $status; +} + +############################################################################### + +sub failover_test +{ + if (!$replica) { + # The failover test needs the -replica flag + return 0; + } + + my $status = 0; + + my $imr_port = 10001 + $imr->RandomPort (); + my $replica_imr_port = $imr_port + 10; + + my %repo; + setup_repo(\%repo, $imr, $IMR, $imriorfile, $act, $ACT, $actiorfile, $ti, + $TI, $imr_port, "--primary", $backupiorfile); + + my %backup_repo; + setup_repo(\%backup_repo, $replica_imr, $replica_IMR, $replica_imriorfile, + $act, $ACT, $actiorfile, $ti, $TI, + $replica_imr_port, "--backup", $primaryiorfile); + + my @repo_for_srvr; + my @a_srv_imriorfile; + my @imr_airplaneiorfile; + my @a_srv_airplaneiorfile; + for ($index = 0; $index < $num_srvr; ++$index) { + if ($index == ($num_srvr - 1)) { + push(@repo_for_srvr, \%backup_repo); + } else { + push(@repo_for_srvr, \%repo); + } + + push(@a_srv_imriorfile, $a_srv[$index]->LocalFile ($repo_for_srvr[$index]->{imriorfile})); + push(@imr_airplaneiorfile, $repo_for_srvr[$index]->{imr}->LocalFile ($airplaneiorfile[$index])); + push(@a_srv_airplaneiorfile, $a_srv[$index]->LocalFile ($airplaneiorfile[$index])); + $a_srv[$index]->DeleteFile ($repo_for_srvr[$index]->{imriorfile}); + $a_srv[$index]->DeleteFile ($airplaneiorfile[$index]); + $a_cli[$index]->DeleteFile ($airplaneiorfile[$index]); + $repo_for_srvr[$index]->{imr}->DeleteFile ($airplaneiorfile[$index]); + } + $imr->DeleteFile ($imriorfile); + $imr->DeleteFile ($primaryiorfile); + $act->DeleteFile ($imriorfile); + $ti->DeleteFile ($imriorfile); + $act->DeleteFile ($actiorfile); + $replica_imr->DeleteFile ($replica_imriorfile); + $replica_imr->DeleteFile ($backupiorfile); + + print "\n\nstarting primary tao_imr_locator\n"; + $repo{IMR}->Arguments ("-d $test_debug_level -o $repo{imr_imriorfile} " . + "$repo{imr_endpoint_flag} $imr_refstyle $repo{imr_backing_store_flag} "); + my $IMR_status = $repo{IMR}->Spawn (); + if ($IMR_status != 0) { + print STDERR "ERROR: ImR Service returned $IMR_status\n"; return 1; } - $A_SRV_status = $A_SRV->WaitKill ($a_srv->ProcessStartWaitInterval()); - if ($A_SRV_status != 0) { - print STDERR "ERROR: Airplane Server returned $A_SRV_status\n"; - $ACT->Kill (); $ACT->TimedWait (1); - $IMR->Kill (); $IMR->TimedWait (1); + if (wait_for_imr(\%backup_repo, "replicaiorfile")) { return 1; } - # Should cause the activator to spawn another server. - $A_CLI_status = $A_CLI->SpawnWaitKill ($a_cli->ProcessStartWaitInterval()); - if ($A_CLI_status != 0) { - print STDERR "ERROR: Airplane Client 2 returned $A_CLI_status\n"; - $ACT->Kill (); $ACT->TimedWait (1); - $IMR->Kill (); $IMR->TimedWait (1); + print "\n\nstarting backup tao_imr_locator\n"; + $backup_repo{IMR}->Arguments ("-d $test_debug_level -o " . + "$backup_repo{imriorfile} $imr_refstyle " . + "$backup_repo{imr_endpoint_flag} " . + "$backup_repo{imr_backing_store_flag}"); + my $replica_IMR_status = $backup_repo{IMR}->Spawn (); + if ($replica_IMR_status != 0) { + print STDERR "ERROR: ImR Service replica returned $replica_IMR_status\n"; + return 1; + } + if (wait_for_imr(\%repo, "replicaiorfile")) { return 1; } + print "started backup tao_imr_locator\n"; - # Shutdown airplane_server - $TI_status = $TI->SpawnWaitKill ($ti->ProcessStartWaitInterval()); - if ($TI_status != 0) { - print STDERR "ERROR: tao_imr shutdown 2 returned $TI_status\n"; - $ACT->Kill (); $ACT->TimedWait (1); - $IMR->Kill (); $IMR->TimedWait (1); + if (wait_for_imr(\%repo)) { return 1; } + print "started primary tao_imr_locator\n"; - $IMR_status = $IMR->TerminateWaitKill ($imr->ProcessStopWaitInterval()); + for ($index = 0; $index < $num_srvr; ++$index) { + if ($a_srv[$index]->PutFile ($repo_for_srvr[$index]->{imriorfile}) == -1) { + print STDERR "ERROR: cannot set file <$a_srv_imriorfile[$index]>\n"; + kill_imr(); + return 1; + } + } + + print "\n\nstarting tao_imr_activator\n"; + $repo{ACT}->Arguments ("-d $test_debug_level -o $repo{act_actiorfile} " . + "-ORBInitRef ImplRepoService=file://$repo{act_imriorfile} $refstyle " . + $repo{act_explicit_flag}); + my $ACT_status = $repo{ACT}->Spawn (); + if ($ACT_status != 0) { + print STDERR "ERROR: ImR Activator returned $ACT_status\n"; + return 1; + } + + if ($repo{act}->WaitForFileTimed ( + $repo{actiorfile}, + $repo{act}->ProcessStartWaitInterval()) == -1) { + print STDERR "ERROR: cannot find file <" . + $repo{act_actiorfile} . ">\n"; + kill_act(); + kill_imr(); + return 1; + } + print "started tao_imr_activator\n"; + + if (add_servers (\@repo_for_srvr, \@imr_airplaneiorfile) != 0) { + return 1; + } +# for ($index = 0; $index < $num_srvr; ++$index) { +# print "\n\nadding server $index using tao_imr\n"; +# $repo_for_srvr[$index]->{TI}->Arguments ("-ORBInitRef ImplRepoService" . +# "=file://$repo_for_srvr[$index]->{ti_imriorfile} $refstyle " . +# "add $a_srv_name[$index] -c \"$imr_A_SRV_cmd[$index] " . +# "-o $imr_airplaneiorfile[$index] -s $a_srv_name[$index]\" " . +# "$repo_for_srvr[$index]->{server_act_flag} "); +# my $TI_status = $repo_for_srvr[$index]->{TI}->SpawnWaitKill ( +# $repo_for_srvr[$index]->{ti}->ProcessStartWaitInterval()); +# if ($TI_status != 0) { +# print STDERR "ERROR: tao_imr ($index) returned $TI_status\n"; +# kill_act(); +# kill_imr(); +# return 1; +# } +# print "added server $index with the locator using tao_imr\n"; +# } + + if (add_servers_again (\@repo_for_srvr, \@imr_airplaneiorfile) != 0) { + return 1; + } + + for ($index = 0; $index < $num_srvr; ++$index) { + print "\n\nstarting server $index using tao_imr\n"; + $repo_for_srvr[$index]->{TI}->Arguments ("-ORBInitRef ImplRepoService" . + "=file://$repo_for_srvr[$index]->{ti_imriorfile} $refstyle " . + "start $a_srv_name[$index]"); + my $TI_status = $repo_for_srvr[$index]->{TI}->SpawnWaitKill ( + $repo_for_srvr[$index]->{ti}->ProcessStartWaitInterval()); + if ($TI_status != 0) { + print STDERR "ERROR: tao_imr ($index) returned $TI_status\n"; + kill_act(); + kill_imr(); + return 1; + } + print "started server $index using tao_imr\n"; + } + + for ($index = 0; $index < $num_srvr; ++$index) { + if ($a_srv[$index]->WaitForFileTimed ( + $airplaneiorfile[$index], + $a_srv[$index]->ProcessStartWaitInterval()) == -1) { + print STDERR + "ERROR: cannot find file <$a_srv_airplaneiorfile[$index]>\n"; + kill_then_timed_wait(\@A_SRV, 1); + $ACT->Kill (); $ACT->TimedWait (1); + $IMR->Kill (); $IMR->TimedWait (1); + return 1; + } + if ($a_srv[$index]->GetFile ($airplaneiorfile[$index]) == -1) { + print STDERR + "ERROR: cannot retrieve file <$a_srv_airplaneiorfile[$index]>\n"; + kill_then_timed_wait(\@A_SRV, 1); + $ACT->Kill (); $ACT->TimedWait (1); + $IMR->Kill (); $IMR->TimedWait (1); + return 1; + } + if ($a_cli[$index]->PutFile ($airplaneiorfile[$index]) == -1) { + print STDERR "ERROR: cannot set file <$a_cli_airplaneiorfile[$index]>\n"; + kill_then_timed_wait(\@A_SRV, 1); + $ACT->Kill (); $ACT->TimedWait (1); + $IMR->Kill (); $IMR->TimedWait (1); + return 1; + } + } + + if (start_clients() != 0) { + return 1; + } + + if (stop_clients() != 0) { + return 1; + } + + if (shutdown_servers_using_tao_imr(\@repo_for_srvr) != 0) { + return 1; + } + + if (start_clients() != 0) { + return 1; + } + + if (stop_clients() != 0) { + return 1; + } + + print "\n\nkilling the primary tao_imr_locator\n"; + $IMR->Kill(); $IMR->TimedWait(); + print "killed the primary tao_imr_locator\n"; + + if (start_clients() != 0) { + return 1; + } + + if (stop_clients() != 0) { + return 1; + } + + if (shutdown_servers_using_tao_imr(\@repo_for_srvr) != 0) { + return 1; + } + + if (add_servers_again(\@repo_for_srvr, \@imr_airplaneiorfile) != 0) { + return 1; + } + + if (remove_servers(\@repo_for_srvr) != 0) { + return 1; + } + + if (add_servers(\@repo_for_srvr, \@imr_airplaneiorfile) != 0) { + return 1; + } + + print "\n\nstarting primary tao_imr_locator again\n"; + $imr->DeleteFile ($imriorfile); + $repo{IMR}->Arguments ("-d $test_debug_level -o $repo{imr_imriorfile} " . + "$imr_refstyle $repo{imr_endpoint_flag} $repo{imr_backing_store_flag}"); + $IMR_status = $repo{IMR}->Spawn (); if ($IMR_status != 0) { - print STDERR "ERROR: ImR returned $IMR_status\n"; - $ACT->Kill (); $ACT->TimedWait (1); + print STDERR "ERROR: ImR Service returned $IMR_status\n"; return 1; } + if (wait_for_imr(\%repo)) { + return 1; + } + print "started primary tao_imr_locator again\n"; - # Unlink so that we can wait on them again to know the server started. + if (start_clients() != 0) { + return 1; + } + + if (stop_clients() != 0) { + return 1; + } + + if (shutdown_servers_using_tao_imr(\@repo_for_srvr) != 0) { + return 1; + } + + print "\n\nkilling the backup tao_imr_locator\n"; + $replica_IMR->Kill(); $replica_IMR->TimedWait(); + $replica_imr->DeleteFile ($replica_imriorfile); + print "killed the backup tao_imr_locator\n"; + + print "\n\nstarting backup tao_imr_locator\n"; + $backup_repo{IMR}->Arguments ("-d $test_debug_level -o " . + "$backup_repo{imriorfile} $imr_refstyle " . + "$backup_repo{imr_endpoint_flag} " . + "$backup_repo{imr_backing_store_flag}"); + $replica_IMR_status = $backup_repo{IMR}->Spawn (); + if ($replica_IMR_status != 0) { + print STDERR "ERROR: ImR Service replica returned $replica_IMR_status\n"; + return 1; + } + if (wait_for_imr(\%repo, "replicaiorfile")) { + return 1; + } + print "started backup tao_imr_locator again\n"; + + if (start_clients() != 0) { + return 1; + } + + if (stop_clients() != 0) { + return 1; + } + + if (shutdown_servers_using_tao_imr(\@repo_for_srvr) != 0) { + return 1; + } + + $IMR->Kill(); $IMR->TimedWait(); + $replica_IMR->Kill(); $replica_IMR->TimedWait(); + $ACT->Kill(); $ACT->TimedWait(); + + cleanup_replication (); + + # clean up IOR files + for ($index = 0; $index < $num_srvr; ++$index) { + $a_srv[$index]->DeleteFile ($repo_for_srvr[$index]->{imriorfile}); + $a_srv[$index]->DeleteFile ($airplaneiorfile[$index]); + $a_cli[$index]->DeleteFile ($airplaneiorfile[$index]); + $repo_for_srvr[$index]->{imr}->DeleteFile ($airplaneiorfile[$index]); + } $imr->DeleteFile ($imriorfile); + $imr->DeleteFile ($primaryiorfile); $act->DeleteFile ($imriorfile); $ti->DeleteFile ($imriorfile); - $a_srv->DeleteFile ($imriorfile); - print "Restarting Implementation Repository.\n"; - $IMR_status = $IMR->Spawn (); + $act->DeleteFile ($actiorfile); + $replica_imr->DeleteFile ($replica_imriorfile); + $replica_imr->DeleteFile ($backupiorfile); + + return $status; +} + +############################################################################### + +sub persistent_ft_test +{ + my $corrupted = shift; + + if (!$corrupted) { + $corrupted = 0; + } + + if (!$replica) { + # The persistent_ft test needs the -replica flag + return 0; + } + + my $status = 0; + + my $imr_port = 10001 + $imr->RandomPort (); + my $replica_imr_port = $imr_port + 1; + + my %repo; + setup_repo(\%repo, $imr, $IMR, $imriorfile, $act, $ACT, $actiorfile, $ti, + $TI, $imr_port, "--primary", $backupiorfile); + + my %backup_repo; + setup_repo(\%backup_repo, $replica_imr, $replica_IMR, $replica_imriorfile, + $act, $ACT, $actiorfile, $ti, $TI, + $replica_imr_port, "--backup", $primaryiorfile); + + my @repo_for_srvr; + my @a_srv_imriorfile; + my @imr_airplaneiorfile; + my @a_srv_airplaneiorfile; + for ($index = 0; $index < $num_srvr; ++$index) { + if ($index == ($num_srvr - 1)) { + push(@repo_for_srvr, \%backup_repo); + } else { + push(@repo_for_srvr, \%repo); + } + + push(@a_srv_imriorfile, $a_srv[$index]->LocalFile ($repo_for_srvr[$index]->{imriorfile})); + push(@imr_airplaneiorfile, $repo_for_srvr[$index]->{imr}->LocalFile ($airplaneiorfile[$index])); + push(@a_srv_airplaneiorfile, $a_srv[$index]->LocalFile ($airplaneiorfile[$index])); + $a_srv[$index]->DeleteFile ($repo_for_srvr[$index]->{imriorfile}); + $a_srv[$index]->DeleteFile ($airplaneiorfile[$index]); + $a_cli[$index]->DeleteFile ($airplaneiorfile[$index]); + $repo_for_srvr[$index]->{imr}->DeleteFile ($airplaneiorfile[$index]); + } + $imr->DeleteFile ($imriorfile); + $imr->DeleteFile ($primaryiorfile); + $act->DeleteFile ($imriorfile); + $ti->DeleteFile ($imriorfile); + $act->DeleteFile ($actiorfile); + $replica_imr->DeleteFile ($replica_imriorfile); + $replica_imr->DeleteFile ($backupiorfile); + + print "\n\nstarting primary tao_imr_locator\n"; + $repo{IMR}->Arguments ("-d $test_debug_level -o $repo{imr_imriorfile} " . + "$imr_refstyle $repo{imr_endpoint_flag} $repo{imr_backing_store_flag}"); +print "Comment line arguments: -d $test_debug_level -o $repo{imr_imriorfile} " . "$imr_refstyle $repo{imr_endpoint_flag} $repo{imr_backing_store_flag}\n"; + my $IMR_status = $repo{IMR}->Spawn (); if ($IMR_status != 0) { print STDERR "ERROR: ImR Service returned $IMR_status\n"; - $ACT->Kill (); $ACT->TimedWait (1); return 1; } - if ($imr->WaitForFileTimed ($imriorfile,$imr->ProcessStartWaitInterval()) == -1) { - print STDERR "ERROR: cannot find file <$imr_imriorfile>\n"; - $ACT->Kill (); $ACT->TimedWait (1); - $IMR->Kill (); $IMR->TimedWait (1); + + if (wait_for_imr(\%backup_repo, "replicaiorfile")) { return 1; } - if ($imr->GetFile ($imriorfile) == -1) { - print STDERR "ERROR: cannot retrieve file <$imr_imriorfile>\n"; - $ACT->Kill (); $ACT->TimedWait (1); - $IMR->Kill (); $IMR->TimedWait (1); + + print "\n\nstarting backup tao_imr_locator\n"; + $backup_repo{IMR}->Arguments ("-d $test_debug_level -o " . + "$backup_repo{imriorfile} $imr_refstyle " . + "$backup_repo{imr_endpoint_flag} " . + "$backup_repo{imr_backing_store_flag}"); + my $replica_IMR_status = $backup_repo{IMR}->Spawn (); + if ($replica_IMR_status != 0) { + print STDERR "ERROR: ImR Service replica returned $replica_IMR_status\n"; return 1; } - if ($act->PutFile ($imriorfile) == -1) { - print STDERR "ERROR: cannot set file <$act_imriorfile>\n"; - $ACT->Kill (); $ACT->TimedWait (1); - $IMR->Kill (); $IMR->TimedWait (1); + if (wait_for_imr(\%repo, "replicaiorfile")) { return 1; } - if ($ti->PutFile ($imriorfile) == -1) { - print STDERR "ERROR: cannot set file <$ti_imriorfile>\n"; - $ACT->Kill (); $ACT->TimedWait (1); - $IMR->Kill (); $IMR->TimedWait (1); + print "started backup tao_imr_locator\n"; + + if (wait_for_imr(\%repo)) { return 1; } - if ($a_srv->PutFile ($imriorfile) == -1) { - print STDERR "ERROR: cannot set file <$a_srv_imriorfile>\n"; - $ACT->Kill (); $ACT->TimedWait (1); - $IMR->Kill (); $IMR->TimedWait (1); + print "started primary tao_imr_locator\n"; + + for ($index = 0; $index < $num_srvr; ++$index) { + if ($a_srv[$index]->PutFile ($repo_for_srvr[$index]->{imriorfile}) == -1) { + print STDERR "ERROR: cannot set file <$a_srv_imriorfile[$index]>\n"; + kill_imr(); + return 1; + } + } + + print "\n\nstarting tao_imr_activator\n"; + $repo{ACT}->Arguments ("-d $test_debug_level -o $repo{act_actiorfile} " . + "-ORBInitRef ImplRepoService=file://$repo{act_imriorfile} $refstyle " . + $repo{act_explicit_flag}); + my $ACT_status = $repo{ACT}->Spawn (); + if ($ACT_status != 0) { + print STDERR "ERROR: ImR Activator returned $ACT_status\n"; return 1; } - # Should cause the activator to spawn another server. - $A_CLI_status = $A_CLI->SpawnWaitKill ($a_cli->ProcessStartWaitInterval()+5); - if ($A_CLI_status != 0) { - print STDERR "ERROR: Airplane Client 3 returned $A_CLI_status\n"; - $status = 1; + if ($repo{act}->WaitForFileTimed ( + $repo{actiorfile}, + $repo{act}->ProcessStartWaitInterval()) == -1) { + print STDERR "ERROR: cannot find file <" . + $repo{act_actiorfile} . ">\n"; + kill_act(); + kill_imr(); + return 1; + } + print "started tao_imr_activator\n"; + + for ($index = 0; $index < $num_srvr; ++$index) { + print "\n\nupdating server $index using tao_imr\n"; + $repo_for_srvr[$index]->{TI}->Arguments ("-ORBInitRef ImplRepoService" . + "=file://$repo_for_srvr[$index]->{ti_imriorfile} $refstyle " . + "update $a_srv_name[$index] -c \"$imr_A_SRV_cmd[$index] " . + "-o $imr_airplaneiorfile[$index] -s $a_srv_name[$index]\" " . + "$repo_for_srvr[$index]->{server_act_flag} "); + my $TI_status = $repo_for_srvr[$index]->{TI}->SpawnWaitKill ( + $repo_for_srvr[$index]->{ti}->ProcessStartWaitInterval()); + if ($TI_status != 0) { + print STDERR "ERROR: tao_imr ($index) returned $TI_status\n"; + kill_act(); + kill_imr(); + return 1; + } + print "updated server $index with the locator using tao_imr\n"; + } + + for ($index = 0; $index < $num_srvr; ++$index) { + print "\n\nstarting server $index using tao_imr\n"; + $repo_for_srvr[$index]->{TI}->Arguments ("-ORBInitRef ImplRepoService" . + "=file://$repo_for_srvr[$index]->{ti_imriorfile} $refstyle " . + "start $a_srv_name[$index]"); + my $TI_status = $repo_for_srvr[$index]->{TI}->SpawnWaitKill ( + $repo_for_srvr[$index]->{ti}->ProcessStartWaitInterval()); + if ($TI_status != 0) { + print STDERR "ERROR: tao_imr ($index) returned $TI_status\n"; + kill_act(); + kill_imr(); + return 1; + } + print "started server $index using tao_imr\n"; + } + + for ($index = 0; $index < $num_srvr; ++$index) { + if ($a_srv[$index]->WaitForFileTimed ( + $airplaneiorfile[$index], + $a_srv[$index]->ProcessStartWaitInterval()) == -1) { + print STDERR + "ERROR: cannot find file <$a_srv_airplaneiorfile[$index]>\n"; + kill_then_timed_wait(\@A_SRV, 1); + $ACT->Kill (); $ACT->TimedWait (1); + $IMR->Kill (); $IMR->TimedWait (1); + return 1; + } + if ($a_srv[$index]->GetFile ($airplaneiorfile[$index]) == -1) { + print STDERR + "ERROR: cannot retrieve file <$a_srv_airplaneiorfile[$index]>\n"; + kill_then_timed_wait(\@A_SRV, 1); + $ACT->Kill (); $ACT->TimedWait (1); + $IMR->Kill (); $IMR->TimedWait (1); + return 1; + } + if ($a_cli[$index]->PutFile ($airplaneiorfile[$index]) == -1) { + print STDERR "ERROR: cannot set file <$a_cli_airplaneiorfile[$index]>\n"; + kill_then_timed_wait(\@A_SRV, 1); + $ACT->Kill (); $ACT->TimedWait (1); + $IMR->Kill (); $IMR->TimedWait (1); + return 1; + } + } + + if (start_clients() != 0) { + return 1; + } + + if (stop_clients() != 0) { + return 1; + } + + if (shutdown_servers_using_tao_imr(\@repo_for_srvr) != 0) { + return 1; + } + + print "\n\nkilling the primary tao_imr_locator\n"; + $IMR->Kill(); $IMR->TimedWait(); + $imr->DeleteFile ($imriorfile); + $imr->DeleteFile ($primaryiorfile); + print "killed the primary tao_imr_locator\n"; + + print "\n\nkilling the backup tao_imr_locator\n"; + $replica_IMR->Kill(); $replica_IMR->TimedWait(); + $replica_imr->DeleteFile ($replica_imriorfile); + $replica_imr->DeleteFile ($backupiorfile); + print "killed the backup tao_imr_locator\n"; + + if($corrupted == 1){ + my $file= "./imr_listing.xml"; + if (open LIST_FILE, ">$file") { + print LIST_FILE "I'm corrupt!!!"; + } + } elsif ($corrupted > 1) { + my $file = "./1_" .($corrupted -1). ".xml"; + if (open LIST_FILE, ">$file") { + print LIST_FILE "I'm corrupt!!!"; + } + } + + + print "\n\nstarting primary tao_imr_locator again\n"; + $repo{IMR}->Arguments ("-d $test_debug_level -o $repo{imr_imriorfile} " . + "$imr_refstyle $repo{imr_endpoint_flag} $repo{imr_backing_store_flag}"); + + my $test_stdout_file = $imr->LocalFile ($stdout_file); + my $test_stderr_file = $imr->LocalFile ($stderr_file); + + $imr->DeleteFile ($stdout_file); + $imr->DeleteFile ($stderr_file); + +# Rely on return value only, so redirect output + redirect_output($test_stdout_file,$test_stderr_file); + $IMR_status = $repo{IMR}->Spawn (); + restore_output(); + + if ($IMR_status != 0) { + print STDERR "ERROR: ImR Service returned $IMR_status\n"; + return 1; } - # Shutdown airplane_server - $TI_status = $TI->SpawnWaitKill ($ti->ProcessStartWaitInterval()); - if ($TI_status != 0) { - print STDERR "ERROR: tao_imr shutdown 3 returned $TI_status\n"; - $status = 1; + if ($repo{imr}->WaitForFileTimed($primaryiorfile, + $repo{imr}->ProcessStartWaitInterval()) == -1) { + return 1; } - $ACT_status = $ACT->TerminateWaitKill ($act->ProcessStopWaitInterval()); - if ($ACT_status != 0) { - print STDERR "ERROR: Activator returned $ACT_status\n"; - $status = 1; + print "\n\nstarting backup tao_imr_locator again\n"; + $backup_repo{IMR}->Arguments ("-d $test_debug_level -o " . + "$backup_repo{imriorfile} $imr_refstyle " . + "$backup_repo{imr_endpoint_flag} " . + "$backup_repo{imr_backing_store_flag}"); + + redirect_output($test_stdout_file,$test_stderr_file); + $replica_IMR_status = $backup_repo{IMR}->Spawn (); + restore_output(); + + if ($replica_IMR_status != 0) { + print STDERR "ERROR: ImR Service replica returned $replica_IMR_status\n"; + return 1; + } + if ($backup_repo{imr}->WaitForFileTimed($backupiorfile, + $backup_repo{imr}->ProcessStartWaitInterval()) == -1) { + return 1; } + print "started backup tao_imr_locator again\n"; - $IMR_status = $IMR->TerminateWaitKill ($imr->ProcessStopWaitInterval()); - if ($IMR_status != 0) { - print STDERR "ERROR: ImR returned $IMR_status\n"; - $status = 1; + if (start_clients() != 0) { + return 1; + } + + if (stop_clients() != 0) { + return 1; } + if (shutdown_servers_using_tao_imr(\@repo_for_srvr) != 0) { + return 1; + } + + $IMR->Kill(); $IMR->TimedWait(); + $replica_IMR->Kill(); $replica_IMR->TimedWait(); + $ACT->Kill(); $ACT->TimedWait(); + + cleanup_replication (); + + # clean up IOR files + for ($index = 0; $index < $num_srvr; ++$index) { + $a_srv[$index]->DeleteFile ($repo_for_srvr[$index]->{imriorfile}); + $a_srv[$index]->DeleteFile ($airplaneiorfile[$index]); + $a_cli[$index]->DeleteFile ($airplaneiorfile[$index]); + $repo_for_srvr[$index]->{imr}->DeleteFile ($airplaneiorfile[$index]); + } $imr->DeleteFile ($imriorfile); - $imr->DeleteFile ($backing_store); + $imr->DeleteFile ($primaryiorfile); $act->DeleteFile ($imriorfile); $ti->DeleteFile ($imriorfile); - $a_srv->DeleteFile ($imriorfile); $act->DeleteFile ($actiorfile); - $imr->DeleteFile ($airplaneiorfile); - $a_srv->DeleteFile ($airplaneiorfile); - $a_cli->DeleteFile ($airplaneiorfile); - $p_srv->DeleteFile ($P_SRV_cmd); + $replica_imr->DeleteFile ($replica_imriorfile); + $replica_imr->DeleteFile ($backupiorfile); return $status; } @@ -1263,30 +2593,31 @@ sub both_ir_test my $imr_imriorfile = $imr->LocalFile ($imriorfile); my $act_imriorfile = $act->LocalFile ($imriorfile); my $ti_imriorfile = $ti->LocalFile ($imriorfile); - my $a_srv_imriorfile = $a_srv->LocalFile ($imriorfile); + my $a_srv_imriorfile = $a_srv[0]->LocalFile ($imriorfile); my $n_srv_imriorfile = $n_srv->LocalFile ($imriorfile); my $act_actiorfile = $act->LocalFile ($actiorfile); - my $a_srv_airplaneiorfile = $a_srv->LocalFile ($airplaneiorfile); + my $a_srv_airplaneiorfile = $a_srv[0]->LocalFile ($airplaneiorfile[0]); my $n_srv_nesteaiorfile = $n_srv->LocalFile ($nesteaiorfile); my $n_cli_nesteaiorfile = $n_cli->LocalFile ($nesteaiorfile); $imr->DeleteFile ($imriorfile); $act->DeleteFile ($imriorfile); $ti->DeleteFile ($imriorfile); - $a_srv->DeleteFile ($imriorfile); + $a_srv[0]->DeleteFile ($imriorfile); $n_srv->DeleteFile ($imriorfile); $act->DeleteFile ($actiorfile); - $a_srv->DeleteFile ($airplaneiorfile); - $a_cli->DeleteFile ($airplaneiorfile); + $a_srv[0]->DeleteFile ($airplaneiorfile[0]); + $a_cli[0]->DeleteFile ($airplaneiorfile[0]); $n_srv->DeleteFile ($nesteaiorfile); $n_cli->DeleteFile ($nesteaiorfile); - $IMR->Arguments ("-d 2 -t 10 -o $imr_imriorfile $refstyle"); - $IMR_status = $IMR->Spawn (); + $IMR->Arguments ("-d $test_debug_level -t 10 -o $imr_imriorfile $imr_refstyle"); + my $IMR_status = $IMR->Spawn (); if ($IMR_status != 0) { print STDERR "ERROR: ImR Service returned $IMR_status\n"; return 1; } - if ($imr->WaitForFileTimed ($imriorfile,$imr->ProcessStartWaitInterval()) == -1) { + if ($imr->WaitForFileTimed ($imriorfile, + $imr->ProcessStartWaitInterval()) == -1) { print STDERR "ERROR: cannot find file <$imr_imriorfile>\n"; $IMR->Kill (); $IMR->TimedWait (1); return 1; @@ -1306,7 +2637,7 @@ sub both_ir_test $IMR->Kill (); $IMR->TimedWait (1); return 1; } - if ($a_srv->PutFile ($imriorfile) == -1) { + if ($a_srv[0]->PutFile ($imriorfile) == -1) { print STDERR "ERROR: cannot set file <$a_srv_imriorfile>\n"; $IMR->Kill (); $IMR->TimedWait (1); return 1; @@ -1319,8 +2650,8 @@ sub both_ir_test $ACT->Arguments ("-e 16384 -o $act_actiorfile ". "-ORBInitRef ImplRepoService=file://$act_imriorfile ". - "$refstyle -d 2"); - $ACT_status = $ACT->Spawn (); + "$refstyle -d $test_debug_level"); + my $ACT_status = $ACT->Spawn (); if ($ACT_status != 0) { print STDERR "ERROR: ImR Activator returned $ACT_status\n"; return 1; @@ -1339,7 +2670,7 @@ sub both_ir_test # No need to specify imr_initref or -orbuseimr 1 for servers spawned by activator $TI->Arguments ("-ORBInitRef ImplRepoService=file://$ti_imriorfile ". "add nestea_server -c \"$imr_N_SRV_cmd $refstyle\""); - $TI_status = $TI->SpawnWaitKill ($ti->ProcessStartWaitInterval()); + my $TI_status = $TI->SpawnWaitKill ($ti->ProcessStartWaitInterval()); if ($TI_status != 0) { print STDERR "ERROR: tao_imr returned $TI_status\n"; $ACT->Kill (); $ACT->TimedWait (1); @@ -1349,7 +2680,7 @@ sub both_ir_test # No need to specify imr_initref or -orbuseimr 1 for servers spawned by activator $TI->Arguments ("-ORBInitRef ImplRepoService=file://$ti_imriorfile ". - "add airplane_server -c \"$imr_A_SRV_cmd $refstyle\""); + "add $a_srv_name[0] -c \"$imr_A_SRV_cmd[0] $refstyle -s $a_srv_name[0]\""); $TI_status = $TI->SpawnWaitKill ($ti->ProcessStartWaitInterval()); if ($TI_status != 0) { print STDERR "ERROR: tao_imr returned $TI_status\n"; @@ -1361,8 +2692,8 @@ sub both_ir_test $N_SRV->Arguments (" -o $n_srv_nesteaiorfile -ORBUseIMR 1 ". "-ORBInitRef ImplRepoService=file://$n_srv_imriorfile ". "$refstyle ". - "-ORBDebugLevel $debug_level"); - $N_SRV_status = $N_SRV->Spawn (); + "-ORBDebugLevel $srv_debug_level"); + my $N_SRV_status = $N_SRV->Spawn (); if ($N_SRV_status != 0) { print STDERR "ERROR: Nestea Server returned $N_SRV_status\n"; $N_SRV->Kill (); $N_SRV->TimedWait (1); @@ -1392,38 +2723,38 @@ sub both_ir_test return 1; } - $A_SRV->Arguments (" -o $a_srv_airplaneiorfile -ORBUseIMR 1 ". - "-ORBInitRef ImplRepoService=file://$n_srv_imriorfile ". - "$refstyle ". - "-ORBDebugLevel $debug_level"); - $A_SRV_status = $A_SRV->Spawn (); + $A_SRV[0]->Arguments ( + " -o $a_srv_airplaneiorfile -ORBUseIMR 1 ". + "-ORBInitRef ImplRepoService=file://$n_srv_imriorfile ". + "$refstyle -ORBDebugLevel $srv_debug_level -s $a_srv_name[0]"); + my $A_SRV_status = $A_SRV[0]->Spawn (); if ($A_SRV_status != 0) { print STDERR "ERROR: Airplane Server returned $A_SRV_status\n"; - $A_SRV->Kill (); $A_SRV->TimedWait (1); + kill_then_timed_wait(\@A_SRV, 1); $N_SRV->Kill (); $N_SRV->TimedWait (1); $ACT->Kill (); $ACT->TimedWait (1); $IMR->Kill (); $IMR->TimedWait (1); return 1; } - if ($a_srv->WaitForFileTimed ($airplaneiorfile,$a_srv->ProcessStartWaitInterval()) == -1) { + if ($a_srv[0]->WaitForFileTimed ($airplaneiorfile[0],$a_srv[0]->ProcessStartWaitInterval()) == -1) { print STDERR "ERROR: cannot find file <$a_srv_airplaneiorfile>\n"; - $A_SRV->Kill (); $A_SRV->TimedWait (1); + kill_then_timed_wait(\@A_SRV, 1); $N_SRV->Kill (); $N_SRV->TimedWait (1); $ACT->Kill (); $ACT->TimedWait (1); $IMR->Kill (); $IMR->TimedWait (1); return 1; } - if ($a_srv->GetFile ($airplaneiorfile) == -1) { + if ($a_srv[0]->GetFile ($airplaneiorfile[0]) == -1) { print STDERR "ERROR: cannot retrieve file <$a_srv_airplaneiorfile>\n"; - $A_SRV->Kill (); $A_SRV->TimedWait (1); + kill_then_timed_wait(\@A_SRV, 1); $N_SRV->Kill (); $N_SRV->TimedWait (1); $ACT->Kill (); $ACT->TimedWait (1); $IMR->Kill (); $IMR->TimedWait (1); return 1; } - if ($a_cli->PutFile ($airplaneiorfile) == -1) { - print STDERR "ERROR: cannot set file <$a_cli_airplaneiorfile>\n"; - $A_SRV->Kill (); $A_SRV->TimedWait (1); + if ($a_cli[0]->PutFile ($airplaneiorfile[0]) == -1) { + print STDERR "ERROR: cannot set file <$a_cli_airplaneiorfile[$index]>\n"; + kill_then_timed_wait(\@A_SRV, 1); $N_SRV->Kill (); $N_SRV->TimedWait (1); $ACT->Kill (); $ACT->TimedWait (1); $IMR->Kill (); $IMR->TimedWait (1); @@ -1441,7 +2772,7 @@ sub both_ir_test print "\n## Spawning multiple simultaneous clients with both servers running.\n"; map $_->Spawn(), @a_clients; map $_->Spawn(), @n_clients; - map $_->WaitKill($a_cli->ProcessStopWaitInterval()), @a_clients; + map $_->WaitKill($a_cli[0]->ProcessStopWaitInterval()), @a_clients; map $_->WaitKill($n_cli->ProcessStopWaitInterval()), @n_clients; $TI->Arguments ("-ORBInitRef ImplRepoService=file://$n_srv_imriorfile ". @@ -1453,14 +2784,14 @@ sub both_ir_test } $TI->Arguments ("-ORBInitRef ImplRepoService=file://$n_srv_imriorfile ". - "shutdown airplane_server"); + "shutdown $a_srv_name[0]"); $TI_status = $TI->SpawnWaitKill ($ti->ProcessStartWaitInterval()); if ($TI_status != 0) { print STDERR "ERROR: tao_imr returned $TI_status\n"; $status = 1; } - $A_SRV_status = $A_SRV->WaitKill ($a_srv->ProcessStopWaitInterval()); + $A_SRV_status = $A_SRV[0]->WaitKill ($a_srv[0]->ProcessStopWaitInterval()); if ($A_SRV_status != 0) { print STDERR "ERROR: Airplane Server returned $A_SRV_status\n"; $status = 1; @@ -1475,7 +2806,7 @@ sub both_ir_test map $_->Spawn(), @a_clients; map $_->Spawn(), @n_clients; - map $_->WaitKill($a_cli->ProcessStopWaitInterval()), @a_clients; + map $_->WaitKill($a_cli[0]->ProcessStopWaitInterval()), @a_clients; map $_->WaitKill($n_cli->ProcessStopWaitInterval()), @n_clients; $TI->Arguments ("-ORBInitRef ImplRepoService=file://$n_srv_imriorfile ". @@ -1487,7 +2818,7 @@ sub both_ir_test } $TI->Arguments ("-ORBInitRef ImplRepoService=file://$n_srv_imriorfile ". - "shutdown airplane_server"); + "shutdown $a_srv_name[0]"); $TI_status = $TI->SpawnWaitKill ($ti->ProcessStartWaitInterval()); if ($TI_status != 0) { print STDERR "ERROR: tao_imr returned $TI_status\n"; @@ -1509,11 +2840,11 @@ sub both_ir_test $imr->DeleteFile ($imriorfile); $act->DeleteFile ($imriorfile); $ti->DeleteFile ($imriorfile); - $a_srv->DeleteFile ($imriorfile); + $a_srv[0]->DeleteFile ($imriorfile); $n_srv->DeleteFile ($imriorfile); $act->DeleteFile ($actiorfile); - $a_srv->DeleteFile ($airplaneiorfile); - $a_cli->DeleteFile ($airplaneiorfile); + $a_srv[0]->DeleteFile ($airplaneiorfile[0]); + $a_cli[0]->DeleteFile ($airplaneiorfile[0]); $n_srv->DeleteFile ($nesteaiorfile); $n_cli->DeleteFile ($nesteaiorfile); @@ -1526,16 +2857,52 @@ sub both_ir_test # Parse the arguments my $ret = 0; +my $test_num = 0; + +my @tests = ("airplane", "airplane_ir", "nestea", "nestea_ir", + "both_ir", "persistent_ir", "persistent_ir_hash", + "persistent_ir_shared", "persistent_ft", "failover"); +my @nt_tests = ("nt_service_ir", "persistent_ir_registry"); + +my $i; +if ($all_tests) { + push(@ARGV, @tests); +} -if ($#ARGV >= 0) { -for (my $i = 0; $i <= $#ARGV; $i++) { +if ($#ARGV == -1) { + $ret = both_ir_test(); +} + +my $append = ""; +for ($i = 0; $i <= $#ARGV; $i++) { if ($ARGV[$i] eq "-h" || $ARGV[$i] eq "-?") { - print "run_test test\n"; + print "run_test [options] test\n"; print "\n"; + print "options \n"; + print " -debug -- set debug_level to 10\n"; + print " -tdebug -- set the tests debug level to 10\n"; + print " -all -- causes all tests to run (except nt_service_ir and\n"; + print " persistent_ir_registry)\n"; + print " -servers -- run tests with more than 1 server and client\n"; + print " -replica -- run tests with more than 1 server and client interacting\n"; + print " with replicated ImR Locators\n"; print "test -- Runs a specific test:\n"; - print " airplane, airplane_ir, nt_service_ir, ", - "nestea, nestea_ir,\n"; - print " both_ir, persistent_ir\n"; + my $indent = " "; + print "$indent"; + my $count = 0; + my @all_tests = @tests; + push(@all_tests, @nt_tests); + foreach my $test (@all_tests) { + if (++$count > 1) { + print ",$append"; + } + print "$test"; + $append = ""; + if ($count % 3 == 0) { + $append = "\n$indent"; + } + } + print "\n"; exit 1; } elsif ($ARGV[$i] eq "airplane") { @@ -1557,7 +2924,31 @@ for (my $i = 0; $i <= $#ARGV; $i++) { $ret = both_ir_test (); } elsif ($ARGV[$i] eq "persistent_ir") { - $ret = persistent_ir_test (); + $ret = persistent_ir_test ("-x"); + } + elsif ($ARGV[$i] eq "persistent_ir_hash") { + $ret = persistent_ir_test ("-p"); + } + elsif ($ARGV[$i] eq "persistent_ir_registry") { + $ret = persistent_ir_test ("-r"); + } + elsif ($ARGV[$i] eq "persistent_ir_shared") { + $ret = persistent_ir_test ("--directory"); + } + elsif ($ARGV[$i] eq "persistent_ft") { + $ret = persistent_ft_test (); + } + elsif ($ARGV[$i] eq "persistent_listingcorrupt") { + $ret = persistent_ft_test (1); + } + elsif ($ARGV[$i] eq "persistent_activatorcorrupt") { + $ret = persistent_ft_test (2); + } + elsif ($ARGV[$i] eq "persistent_servercorrupt") { + $ret = persistent_ft_test (3); + } + elsif ($ARGV[$i] eq "failover") { + $ret = failover_test (); } elsif ($ARGV[$i] eq "perclient") { $ret = perclient(); @@ -1565,12 +2956,12 @@ for (my $i = 0; $i <= $#ARGV; $i++) { elsif ($ARGV[$i] eq "shutdown") { $ret = shutdown_repo(); } - else { + elsif ($ARGV[$i] !~ /^-/) { print "run_test: Unknown Option: ".$ARGV[$i]."\n"; } -} -} else { - $ret = both_ir_test(); + if ($ret != 0) { + last; + } } exit $ret; |