diff options
author | Phil Mesnier <mesnier_p@ociweb.com> | 2014-09-12 14:23:55 +0000 |
---|---|---|
committer | Phil Mesnier <mesnier_p@ociweb.com> | 2014-09-12 14:23:55 +0000 |
commit | 4603fb929cff102ff3cbbca760b8483d1a329ee2 (patch) | |
tree | 33f836f03d2313e48415444667ab2fa1cfb6ef7b /TAO/orbsvcs/tests/ImplRepo | |
parent | d46afcea703c6a5cd70118d25fa6a1d8157a6e56 (diff) | |
download | ATCD-4603fb929cff102ff3cbbca760b8483d1a329ee2.tar.gz |
Fri Sep 12 14:10:47 UTC 2014 Phil Mesnier <mesnier_p@ociweb.com>
* orbsvcs/ImplRepo_Service/Activator_Options.cpp:
* orbsvcs/ImplRepo_Service/Locator_Options.cpp:
Set the default debug level to be 0 rather than 1.
Services should be quiet by default.
* orbsvcs/ImplRepo_Service/ImR_Activator.idl:
* orbsvcs/ImplRepo_Service/ImR_Activator_i.h:
* orbsvcs/ImplRepo_Service/ImR_Activator_i.cpp:
* orbsvcs/ImplRepo_Service/ImR_Locator_i.cpp:
* orbsvcs/ImplRepo_Service/Locator_Repository.h:
* orbsvcs/ImplRepo_Service/Locator_Repository.cpp:
* orbsvcs/ImplRepo_Service/Shared_Backing_Store.h:
Add an enhancement to allow a restarted IMR Locator verify that
servers
* orbsvcs/tests/ImplRepo/RestartIMR:
* bin/tao_other_tests.lst:
Add new test to verify the feature.
* orbsvcs/tests/ImplRepo/servers_list/run_test.pl:
Fix a typo.
Diffstat (limited to 'TAO/orbsvcs/tests/ImplRepo')
-rwxr-xr-x | TAO/orbsvcs/tests/ImplRepo/RestartIMR/RestartIMR.mpc | 26 | ||||
-rwxr-xr-x | TAO/orbsvcs/tests/ImplRepo/RestartIMR/run_test.pl | 301 | ||||
-rwxr-xr-x | TAO/orbsvcs/tests/ImplRepo/RestartIMR/server.cpp | 130 | ||||
-rwxr-xr-x | TAO/orbsvcs/tests/ImplRepo/RestartIMR/test.idl | 15 | ||||
-rwxr-xr-x | TAO/orbsvcs/tests/ImplRepo/RestartIMR/test_i.cpp | 51 | ||||
-rwxr-xr-x | TAO/orbsvcs/tests/ImplRepo/RestartIMR/test_i.h | 48 | ||||
-rwxr-xr-x | TAO/orbsvcs/tests/ImplRepo/servers_list/run_test.pl | 2 |
7 files changed, 572 insertions, 1 deletions
diff --git a/TAO/orbsvcs/tests/ImplRepo/RestartIMR/RestartIMR.mpc b/TAO/orbsvcs/tests/ImplRepo/RestartIMR/RestartIMR.mpc new file mode 100755 index 00000000000..366986b9076 --- /dev/null +++ b/TAO/orbsvcs/tests/ImplRepo/RestartIMR/RestartIMR.mpc @@ -0,0 +1,26 @@ +// $Id$ +// +// Really the server is the only one that needs to avoid minimum_corba and +// the lot. But there's no sense in building anything if you can't build +// the server. + +project(*idl): taoidldefaults, avoids_minimum_corba, avoids_corba_e_compact, avoids_corba_e_micro { + custom_only = 1 + IDL_Files { + test.idl + } +} + +project(*server): taoserver, imr_client, avoids_minimum_corba, avoids_corba_e_compact, avoids_corba_e_micro { + exename = server + after += *idl + IDL_Files { + } + Source_Files { + testC.cpp + testS.cpp + server.cpp + test_i.cpp + } +} + diff --git a/TAO/orbsvcs/tests/ImplRepo/RestartIMR/run_test.pl b/TAO/orbsvcs/tests/ImplRepo/RestartIMR/run_test.pl new file mode 100755 index 00000000000..aa104160af4 --- /dev/null +++ b/TAO/orbsvcs/tests/ImplRepo/RestartIMR/run_test.pl @@ -0,0 +1,301 @@ +eval '(exit $?0)' && eval 'exec perl -S $0 ${1+"$@"}' + & eval 'exec perl -S $0 $argv:q' + if 0; + +# $Id$ +# -*- perl -*- + +############################################################################### + +use lib "$ENV{ACE_ROOT}/bin"; +use PerlACE::TestTarget; + +$status = 0; + +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 $srv = PerlACE::TestTarget::create_target (++$tgt_num) || die "Create target $tgt_num failed\n"; + +my $port = $imr->RandomPort (); +my $srv_id = "AAA"; +my $srv_id_cmd = "-ORBServerId AAA "; +my $ping_ext = "-v 0 "; +my $server_pid = 0; + +my $kill_svr = 0; +my $kill_act = 0; + +my $imr_debug = "-d 1 "; +my $act_debug = ""; +my $srv_debug = ""; +my $clt_debug = ""; + +foreach my $i (@ARGV) { + if ($i eq '-debug') { + $imr_debug = "-ORBDebugLevel 10 -ORBVerboseLogging 1 -ORBLogFile imr.log -d 5 "; + $act_debug = "-ORBDebugLevel 10 -ORBVerboseLogging 1 -ORBLogFile act.log -d 5 "; + $srv_debug = "-ORBDebugLevel 10 -ORBVerboseLogging 1 -ORBLogFile srv.log "; + } + elsif ($i eq '-kill_act') { + $kill_act = 1; + $kill_svr = 1; + } + elsif ($i eq '-kill_server') { + $kill_svr = 1; + } + elsif ($i eq '-noid') { + $srv_id = ""; + $srv_id_cmd = ""; + } + elsif ($i eq '-pingexternal') { + $ping_ext = "-i "; + } + else { + print STDERR "unrecognized argument $i\n"; + exit 1; + } +} + +my $imriorfile = "imr_locator.ior"; +my $imrlogfile = "imr.log"; +my $actiorfile = "imr_activator.ior"; +my $actlogfile = "act.log"; +my $srvlogfile = "srv.log"; +my $srvpidfile = "server.pid"; +my $persist_dir = "persist"; + +my $imr_imriorfile = $imr->LocalFile ($imriorfile); +my $act_imriorfile = $act->LocalFile ($imriorfile); +my $act_actiorfile = $act->LocalFile ($actiorfile); +my $srv_imriorfile = $srv->LocalFile ($imriorfile); +my $srv_srvpidfile = $srv->LocalFile ($srvpidfile); +my $ti_imriorfile = $ti->LocalFile ($imriorfile); + + +sub get_server_pid +{ + my $pid = 0; + open (FILE, $srv_srvpidfile) or die "Can't open server.pid: $!"; + while (<FILE>) { + chomp; + $pid = $_; + $server_pid = $pid if ($server_pid == 0); + } + close FILE; + return $pid; +} + +sub signal_server +{ + my $sig = shift; + print "signal $sig to server $server_pid\n"; + kill ($sig, $server_pid); +} + + +sub delete_files +{ + my $logs_too = shift; + if ($logs_too == 1) { + $imr->DeleteFile ($imrlogfile); + $act->DeleteFile ($actlogfile); + $srv->DeleteFile ($srvlogfile); + } + $imr->DeleteFile ($imriorfile); + $act->DeleteFile ($imriorfile); + $act->DeleteFile ($actiorfile); + $ti->DeleteFile ($imriorfile); + $srv->DeleteFile ($imriorfile); + $srv->DeleteFile ($srvpidfile); + + unlink <persist/*>; + rmdir $persist_dir; +} + +# Clean up after exit call +END +{ + delete_files (0); +} + +delete_files (1); + +mkdir $persist_dir; + +$IMR = $imr->CreateProcess ("../../../ImplRepo_Service/tao_imr_locator", + "-ORBEndpoint iiop://:$port ". + "-UnregisterIfAddressReused $imr_debug". + "--directory $persist_dir " . + $ping_ext . + "-o $imr_imriorfile "); + +$ACT = $act->CreateProcess ("../../../ImplRepo_Service/tao_imr_activator", + "-l $act_debug -o $act_actiorfile " . + "-ORBInitRef ImplRepoService=file://$act_imriorfile"); + +my $srv_args = "-ORBInitRef ImplRepoService=file://$srv_imriorfile -ORBUseIMR 1 ". + $srv_id_cmd . $srv_debug; + +$SRV = $srv->CreateProcess ("server", $srv_args); + +my $poaA = "$srv_id:poaA"; +my $poaC = "$srv_id:poaC"; + +my $srv_cmd = $act->LocalFile ($SRV->Executable()); + +$TI = $ti->CreateProcess ("../../../ImplRepo_Service/tao_imr", + "-ORBInitRef ImplRepoService=file://$ti_imriorfile ". + "add $poaA -c \"$srv_cmd $srv_args\""); + +print STDERR "=== start Locator\n"; +print STDERR $IMR->CommandLine () . "\n"; +$IMR_status = $IMR->Spawn (); +if ($IMR_status != 0) { + print STDERR "ERROR: ImplRepo Service returned $IMR_status\n"; + exit 1; +} +if ($imr->WaitForFileTimed ($imriorfile,$imr->ProcessStartWaitInterval()) == -1) { + print STDERR "ERROR: cannot find file <$imr_imriorfile>\n"; + $IMR->Kill (); $IMR->TimedWait (1); + exit 1; +} + +if ($imr->GetFile ($imriorfile) == -1) { + print STDERR "ERROR: cannot retrieve file <$imr_imriorfile>\n"; + $IMR->Kill (); $IMR->TimedWait (1); + exit 1; +} +if ($srv->PutFile ($imriorfile) == -1) { + print STDERR "ERROR: cannot set file <$srv_imriorfile>\n"; + $IMR->Kill (); $IMR->TimedWait (1); + exit 1; +} +if ($act->PutFile ($imriorfile) == -1) { + print STDERR "ERROR: cannot set file <$act_imriorfile>\n"; + $IMR->Kill (); $IMR->TimedWait (1); + exit 1; +} +if ($ti->PutFile ($imriorfile) == -1) { + print STDERR "ERROR: cannot set file <$ti_imriorfile>\n"; + $IMR->Kill (); $IMR->TimedWait (1); + exit 1; +} + +print STDERR "=== start Activator\n"; +$ACT_status = $ACT->Spawn (); +if ($ACT_status != 0) { + print STDERR "ERROR: ImR Activator returned $ACT_status\n"; + exit 1; +} +if ($act->WaitForFileTimed ($actiorfile,$act->ProcessStartWaitInterval()) == -1) { + print STDERR "ERROR: cannot find file <$act_imriorfile>\n"; + $ACT->Kill (); $ACT->TimedWait (1); + $IMR->Kill (); $IMR->TimedWait (1); + exit 1; +} + +print STDERR "=== Registering POAs\n"; +$TI_status = $TI->SpawnWaitKill ($ti->ProcessStartWaitInterval()); +if ($TI_status != 0) { + print STDERR "tao_imr register poaA returned $TI_status\n"; +} +$TI->Arguments ("-ORBInitRef ImplRepoService=file://$ti_imriorfile ". + "link $poaA -p poaC"); +$TI_status = $TI->SpawnWaitKill ($ti->ProcessStartWaitInterval()); +if ($TI_status != 0) { + print STDERR "tao_imr link poaC to poaA returned $TI_status\n"; +} + +print STDERR "=== start server\n"; +$TI->Arguments ("-ORBInitRef ImplRepoService=file://$ti_imriorfile ". + "start $poaA"); +$TI_status = $TI->SpawnWaitKill ($ti->ProcessStartWaitInterval()); +if ($TI_status != 0) { + print STDERR "tao_imr list returned $TI_status\n"; +} +if ($srv->GetFile ($srvpidfile) == -1) { + print STDERR "ERROR: cannot retrieve file <$srvpidfile>\n"; +} + +print STDERR "=== list pre-kill\n"; +$TI->Arguments ("-ORBInitRef ImplRepoService=file://$ti_imriorfile ". + "list -v"); +$TI_status = $TI->SpawnWaitKill ($ti->ProcessStartWaitInterval()); +if ($TI_status != 0) { + print STDERR "tao_imr list poaC to poaA returned $TI_status\n"; +} + +print STDERR "=== kill ImR Locator\n"; +$IMR_status = $IMR->TerminateWaitKill ($imr->ProcessStopWaitInterval()); +$imr->DeleteFile ($imriorfile); + +if ($kill_act == 1) { + print STDERR "=== kill ImR Activator\n"; + $ACT_status = $ACT->TerminateWaitKill ($act->ProcessStopWaitInterval()); + $act->DeleteFile ($actiorfile); +} + +if ($kill_svr == 1) { + print STDERR "=== kill server\n"; + get_server_pid (); + signal_server ("KILL"); + $srv->DeleteFile ($srvpidfile); +} + +print STDERR "=== restart ImR Locator\n"; +$IMR_status = $IMR->Spawn (); +if ($IMR_status != 0) { + print STDERR "ERROR: ImplRepo Service returned $IMR_status\n"; + exit 1; +} +if ($imr->WaitForFileTimed ($imriorfile,$imr->ProcessStartWaitInterval()) == -1) { + print STDERR "ERROR: cannot find file <$imr_imriorfile>\n"; + $IMR->Kill (); $IMR->TimedWait (1); + exit 1; +} + +if ($kill_act == 1) { + print STDERR "=== restart ImR Activator\n"; + $ACT_status = $ACT->Spawn (); + if ($ACT_status != 0) { + print STDERR "ERROR: ImplRepo Service returned $ACT_status\n"; + $IMR->Kill (); $IMR->TimedWait (1); + $ACT->Kill (); $ACT->TimedWait (1); + exit 1; + } + if ($act->WaitForFileTimed ($actiorfile,$act->ProcessStartWaitInterval()) == -1) { + print STDERR "ERROR: cannot find file <$act_actiorfile>\n"; + $IMR->Kill (); $IMR->TimedWait (1); + $ACT->Kill (); $ACT->TimedWait (1); + exit 1; + } +} + +print STDERR "=== restart server via ImR\n"; +$TI->Arguments ("-ORBInitRef ImplRepoService=file://$ti_imriorfile ". + "start $poaA "); +$TI_status = $TI->SpawnWaitKill ($ti->ProcessStartWaitInterval()); +if ($TI_status != 0) { + print STDERR "tao_imr start $poaA returned $TI_status\n"; +} +$TI->Arguments ("-ORBInitRef ImplRepoService=file://$ti_imriorfile ". + "list -v"); +$TI_status = $TI->SpawnWaitKill ($ti->ProcessStartWaitInterval()); +if ($TI_status != 0) { + print STDERR "tao_imr list returned $TI_status\n"; +} + +$TI->Arguments ("-ORBInitRef ImplRepoService=file://$ti_imriorfile ". + "shutdown $poaA "); +$TI_status = $TI->SpawnWaitKill ($ti->ProcessStartWaitInterval()); +if ($TI_status != 0) { + print STDERR "tao_imr shutdown $poaA returned $TI_status\n"; +} + +$ACT_status = $ACT->TerminateWaitKill ($act->ProcessStopWaitInterval()); + +$IMR_status = $IMR->TerminateWaitKill ($imr->ProcessStopWaitInterval()); + +exit $status; diff --git a/TAO/orbsvcs/tests/ImplRepo/RestartIMR/server.cpp b/TAO/orbsvcs/tests/ImplRepo/RestartIMR/server.cpp new file mode 100755 index 00000000000..107828cff59 --- /dev/null +++ b/TAO/orbsvcs/tests/ImplRepo/RestartIMR/server.cpp @@ -0,0 +1,130 @@ +// $Id$ +#include "test_i.h" +#include "tao/ImR_Client/ImR_Client.h" +#include <ace/Task.h> +#include <ace/Get_Opt.h> + +const ACE_TCHAR * pid_file = ACE_TEXT ("server.pid"); + +int +parse_args (int argc, ACE_TCHAR *argv[]) +{ + ACE_Get_Opt get_opts (argc, argv, ACE_TEXT("p:")); + int c; + + + while ((c = get_opts ()) != -1) + { + switch (c) + { + case 'p': + pid_file = get_opts.opt_arg (); + break; + case '?': + default: + ACE_ERROR_RETURN ((LM_ERROR, + ACE_TEXT ("usage: %s ") + ACE_TEXT ("-p <iorfile>") + ACE_TEXT ("\n"), + argv [0]), + -1); + } + } + + return 0; +} + +int +ACE_TMAIN(int argc, ACE_TCHAR *argv[]) +{ + try + { + CORBA::ORB_var orb = CORBA::ORB_init (argc, argv); + if (parse_args (argc, argv) != 0) + { + return 1; + } + + 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 (); + + CORBA::PolicyList policies (5); + policies.length (5); + + // Lifespan policy + policies[0] = + rootPOA->create_lifespan_policy (PortableServer::PERSISTENT); + + // Servant Retention Policy + policies[1] = + rootPOA->create_servant_retention_policy (PortableServer::RETAIN ); + + // ID Assignment Policy + policies[2] = + rootPOA->create_id_assignment_policy (PortableServer::USER_ID ); + + // Request Processing Policy + policies[3] = + rootPOA->create_request_processing_policy (PortableServer::USE_ACTIVE_OBJECT_MAP_ONLY ); + + // Threading policy + policies[4] = + rootPOA->create_thread_policy (PortableServer::ORB_CTRL_MODEL); + + PortableServer::POA_var poa_a = rootPOA->create_POA ("poaA", + poa_manager.in (), + policies + ); + PortableServer::POA_var poa_c = rootPOA->create_POA ("poaC", + poa_manager.in (), + policies + ); + + for (CORBA::ULong i = 0; + i < policies.length (); + ++i) + { + CORBA::Policy_ptr policy = policies[i]; + policy->destroy (); + } + + Test_Time_i* time = new Test_Time_i(); + + PortableServer::ObjectId_var oid = + PortableServer::string_to_ObjectId ("Server_A"); + poa_a->activate_object_with_id (oid.in (), time); + CORBA::Object_var time_obj = poa_a->id_to_reference(oid.in()); + CORBA::String_var ior = + orb->object_to_string (time_obj.in ()); + + poa_manager->activate (); + + FILE *output_file = ACE_OS::fopen (pid_file, ACE_TEXT ("w")); + if (output_file == 0) + ACE_ERROR_RETURN ((LM_ERROR, + ACE_TEXT ("Cannot open output file for writing IOR: %s\n"), + pid_file), + 1); + + ACE_OS::fprintf (output_file, "%d\n", ACE_OS::getpid ()); + ACE_OS::fclose (output_file); + + orb->run (); + + rootPOA->destroy (1, 1); + orb->destroy (); + } + catch (const CORBA::Exception &ex) + { + ex._tao_print_exception (ACE_TEXT ("server:")); + return 1; + } + + return 0; +} + + diff --git a/TAO/orbsvcs/tests/ImplRepo/RestartIMR/test.idl b/TAO/orbsvcs/tests/ImplRepo/RestartIMR/test.idl new file mode 100755 index 00000000000..3e16ed854f5 --- /dev/null +++ b/TAO/orbsvcs/tests/ImplRepo/RestartIMR/test.idl @@ -0,0 +1,15 @@ +// $Id$ +module Test +{ + interface Dummy + { + string getMessage(); + }; + + interface Time + { + long current_time (); + oneway void shutdown (); + }; + +}; diff --git a/TAO/orbsvcs/tests/ImplRepo/RestartIMR/test_i.cpp b/TAO/orbsvcs/tests/ImplRepo/RestartIMR/test_i.cpp new file mode 100755 index 00000000000..0487df28e12 --- /dev/null +++ b/TAO/orbsvcs/tests/ImplRepo/RestartIMR/test_i.cpp @@ -0,0 +1,51 @@ +// $Id$ +#include "test_i.h" +#include "ace/OS_NS_time.h" + + +// Implementation skeleton constructor +Test_Dummy_i::Test_Dummy_i (void) +{ +} + +// Implementation skeleton destructor +Test_Dummy_i::~Test_Dummy_i (void) +{ +} + +char * Test_Dummy_i::getMessage ( + void + ) +{ + // Add your implementation here + return CORBA::string_dup("Test::Dummy---->Hello World"); +} + +Test_Time_i::Test_Time_i (void) +{ +} + +// Implementation skeleton destructor +Test_Time_i::~Test_Time_i (void) +{ +} + +::CORBA::Long Test_Time_i::current_time ( + void + ) +{ + ACE_DEBUG ((LM_DEBUG, "(%P|%t)Test_Time_i::current_time called\n")); + return CORBA::Long (ACE_OS::time (0)); +} + +void Test_Time_i::shutdown ( + void + ) +{ + ACE_DEBUG ((LM_DEBUG, + "%s\n", + "Time_i is shutting down")); + +} + + diff --git a/TAO/orbsvcs/tests/ImplRepo/RestartIMR/test_i.h b/TAO/orbsvcs/tests/ImplRepo/RestartIMR/test_i.h new file mode 100755 index 00000000000..4c0e0ef2ceb --- /dev/null +++ b/TAO/orbsvcs/tests/ImplRepo/RestartIMR/test_i.h @@ -0,0 +1,48 @@ +// $Id$ +#ifndef IMR_RECONNECTSERVER_H +#define IMR_RECONNECTSERVER_H + +#include "testS.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +#pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + + +class Test_Dummy_i + : public virtual POA_Test::Dummy +{ +public: + // Constructor + Test_Dummy_i (void); + + // Destructor + virtual ~Test_Dummy_i (void); + + virtual char * getMessage (void); +}; + +class Test_Time_i + : public virtual POA_Test::Time +{ +public: + // Constructor + Test_Time_i (void); + + // Destructor + virtual ~Test_Time_i (void); + + virtual + ::CORBA::Long current_time ( + void + ); + + virtual + void shutdown ( + void + ); +}; + + +#endif /* IMR_RECONNECTSERVER_H */ + diff --git a/TAO/orbsvcs/tests/ImplRepo/servers_list/run_test.pl b/TAO/orbsvcs/tests/ImplRepo/servers_list/run_test.pl index ab1d15ac633..5393ca5f3c0 100755 --- a/TAO/orbsvcs/tests/ImplRepo/servers_list/run_test.pl +++ b/TAO/orbsvcs/tests/ImplRepo/servers_list/run_test.pl @@ -178,7 +178,7 @@ sub servers_setup () $TI->Arguments ("-ORBInitRef ImplRepoService=file://$ti_imriorfile ". "add $objprefix" . '_' . $i . " -c \"". $srv_server_cmd[i]. - " -ORBUseIMR 1d -n $i -d $server_init_delay ". + " -ORBUseIMR 1 -n $i -d $server_init_delay ". "-ORBInitRef ImplRepoService=file://$imr_imriorfile\""); $TI_status = $TI->SpawnWaitKill ($ti->ProcessStartWaitInterval()); |