diff options
-rw-r--r-- | TAO/ChangeLog | 15 | ||||
-rwxr-xr-x | TAO/orbsvcs/tests/Bug_2247_Regression/Bug_2247_Regression.mpc | 17 | ||||
-rwxr-xr-x | TAO/orbsvcs/tests/Bug_2247_Regression/Client_i.h | 29 | ||||
-rwxr-xr-x | TAO/orbsvcs/tests/Bug_2247_Regression/Manager.cpp | 629 | ||||
-rwxr-xr-x | TAO/orbsvcs/tests/Bug_2247_Regression/Manager.h | 50 | ||||
-rwxr-xr-x | TAO/orbsvcs/tests/Bug_2247_Regression/README | 31 | ||||
-rwxr-xr-x | TAO/orbsvcs/tests/Bug_2247_Regression/run_test.pl | 142 | ||||
-rwxr-xr-x | TAO/orbsvcs/tests/Bug_2247_Regression/server.cpp | 136 | ||||
-rwxr-xr-x | TAO/orbsvcs/tests/Bug_2247_Regression/test.idl | 10 | ||||
-rwxr-xr-x | TAO/orbsvcs/tests/Bug_2247_Regression/test_i.cpp | 71 | ||||
-rwxr-xr-x | TAO/orbsvcs/tests/Bug_2247_Regression/test_i.h | 38 |
11 files changed, 1168 insertions, 0 deletions
diff --git a/TAO/ChangeLog b/TAO/ChangeLog index 13eb6dd4fa2..936e9406be2 100644 --- a/TAO/ChangeLog +++ b/TAO/ChangeLog @@ -1,3 +1,18 @@ +Thu Sep 29 14:29:17 2005 Simon McQueen <sm@prismtech.com> + + * orbsvcs/tests/Bug_2247_Regression/Bug_2247_Regression.mpc: + * orbsvcs/tests/Bug_2247_Regression/Client_i.h: + * orbsvcs/tests/Bug_2247_Regression/Manager.cpp: + * orbsvcs/tests/Bug_2247_Regression/Manager.h: + * orbsvcs/tests/Bug_2247_Regression/README: + * orbsvcs/tests/Bug_2247_Regression/run_test.pl: + * orbsvcs/tests/Bug_2247_Regression/server.cpp: + * orbsvcs/tests/Bug_2247_Regression/test.idl: + * orbsvcs/tests/Bug_2247_Regression/test_i.cpp: + * orbsvcs/tests/Bug_2247_Regression/test_i.h: + + Regression test added. + Thu Sep 29 07:38:32 2005 Chad Elliott <elliott_c@ociweb.com> * tests/Smart_Proxies/dtor/client.cpp: diff --git a/TAO/orbsvcs/tests/Bug_2247_Regression/Bug_2247_Regression.mpc b/TAO/orbsvcs/tests/Bug_2247_Regression/Bug_2247_Regression.mpc new file mode 100755 index 00000000000..83c4e7e38d0 --- /dev/null +++ b/TAO/orbsvcs/tests/Bug_2247_Regression/Bug_2247_Regression.mpc @@ -0,0 +1,17 @@ +// -*- MPC -*- +// $Id$ + +project(*server): portableserver, orbsvcsexe, iormanip, messaging { + Source_Files { + test_i.cpp + server.cpp + } +} + +project(*Manager): portableserver, orbsvcsexe, iormanip, ftorb { + Source_Files { + testC.cpp + Manager.cpp + } +} + diff --git a/TAO/orbsvcs/tests/Bug_2247_Regression/Client_i.h b/TAO/orbsvcs/tests/Bug_2247_Regression/Client_i.h new file mode 100755 index 00000000000..50efe0c1099 --- /dev/null +++ b/TAO/orbsvcs/tests/Bug_2247_Regression/Client_i.h @@ -0,0 +1,29 @@ +// -*- C++ -*- +// $Id$ + +#ifndef BUG_2247_REGRESSION_CLIENT_I_H +#define BUG_2247_REGRESSION_CLIENT_I_H + +#include /**/ "ace/pre.h" +#include "tao/ORB.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +class Client_i +{ +public: + Client_i (CORBA::ORB_ptr orb); + // Our constructor + + int init (ACE_ENV_SINGLE_ARG_DECL); + // Initialize the ORB etc. + +private: + CORBA::ORB_var orb_; + +}; + +#include /**/ "ace/post.h" +#endif /* BUG_2247_REGRESSION_CLIENT_I_H */ diff --git a/TAO/orbsvcs/tests/Bug_2247_Regression/Manager.cpp b/TAO/orbsvcs/tests/Bug_2247_Regression/Manager.cpp new file mode 100755 index 00000000000..08e2def7121 --- /dev/null +++ b/TAO/orbsvcs/tests/Bug_2247_Regression/Manager.cpp @@ -0,0 +1,629 @@ +// $Id$ +#include "Manager.h" +#include "Client_i.h" +#include "testC.h" +#include "ace/Get_Opt.h" +#include "ace/Read_Buffer.h" +#include "ace/OS_NS_fcntl.h" +#include "ace/OS_NS_unistd.h" +#include "tao/IORManipulation/IORManip_Loader.h" +#include "tao/PortableServer/PortableServer.h" +#include "orbsvcs/orbsvcs/FaultTolerance/FT_Service_Activate.h" +#include "orbsvcs/orbsvcs/FaultTolerance/FT_IOGR_Property.h" +#include "ace/OS_NS_stdio.h" + +// Files which have the IOR +const char *first_ior = 0; +const char *first_key = 0; +const char *second_ior = 0; +const char *second_key = 0; +const char *ior_output_file = 0; +int shutdown_test = 0; +int merged_test = 0; + +// Objects +CORBA::Object_var object_primary = 0; +CORBA::Object_var object_secondary = 0; + +// Reference to the IOR manipulator +TAO_IOP::TAO_IOR_Manipulation_var iorm = 0; + +int +parse_args (int argc, char *argv[]) +{ + ACE_Get_Opt get_opts (argc, argv, "a:k:b:l:c:sm"); + int c; + + while ((c = get_opts ()) != -1) + switch (c) + { + case 'a': + first_ior = get_opts.opt_arg (); + break; + case 'k': + first_key = get_opts.opt_arg (); + break; + case 'b': + second_ior = get_opts.opt_arg (); + break; + case 'l': + second_key = get_opts.opt_arg (); + break; + case 'c': + ior_output_file = get_opts.opt_arg (); + break; + case 's': + shutdown_test = 1; + break; + case 'm': + merged_test = 1; + break; + case '?': + default: + ACE_ERROR_RETURN ((LM_ERROR, + "usage: %s " + "-a <iorfile1> -k <key1> " + "-b <iorfile2> -l <key2> " + "-c <output ior file>" + "\n", + argv [0]), + -1); + } + // Indicates sucessful parsing of the command line + return 0; +} + + +int +main (int argc, + char *argv[]) +{ + ACE_DECLARE_NEW_CORBA_ENV; + + Manager manager; + + ACE_TRY + { + // Initilaize the ORB, POA etc. + manager.init (argc, + argv + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + // the command line arguments + if (parse_args (argc, argv) == -1) + return -1; + + // Merge the different IORS + manager.make_merged_iors (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_TRY_CHECK; + + if (merged_test) + { + // Set properties. This is the most important portion of the + // test + manager.set_properties (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_TRY_CHECK; + } + + // Write IOR to file + manager.write_to_file (); + + // Client, who is going to use the merged IOR + // Construct that with the managers ORB + Client_i client_imp (manager.orb ()); + return client_imp.init (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_TRY_CHECK; + } + ACE_CATCHANY + { + ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, + "Caught"); + return -1; + } + ACE_ENDTRY; + + return 0; +} + +Manager::Manager (void) + :orb_ (0), + merged_set_ (0) +{ + //no-op +} + +void +Manager::init (int argc, + char *argv[] + ACE_ENV_ARG_DECL) +{ + this->orb_ = CORBA::ORB_init (argc, + argv, + 0 + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + // Obtain the RootPOA. + CORBA::Object_var obj_var = + this->orb_->resolve_initial_references ("RootPOA" + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + // Get the POA_var object from Object_var. + PortableServer::POA_var root_poa_var = + PortableServer::POA::_narrow (obj_var.in () ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + // Get the POAManager of the RootPOA. + PortableServer::POAManager_var poa_manager_var = + root_poa_var->the_POAManager (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + + poa_manager_var->activate (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; +} + +int +Manager::make_merged_iors (ACE_ENV_SINGLE_ARG_DECL) +{ + // First server + object_primary = + this->orb_->string_to_object (first_ior + ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (-1); + + if (merged_test) + { + //Second server + object_secondary = + this->orb_->string_to_object (second_ior + ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (-1); + + // Get an object reference for the ORBs IORManipultion object! + CORBA::Object_var IORM = + this->orb_->resolve_initial_references (TAO_OBJID_IORMANIPULATION, + 0 + ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (-1); + + iorm = + TAO_IOP::TAO_IOR_Manipulation::_narrow (IORM.in() ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (-1); + + + // Create the list + TAO_IOP::TAO_IOR_Manipulation::IORList iors (2); + iors.length(2); + iors [0] = CORBA::Object::_duplicate (object_primary.in ()); + iors [1] = CORBA::Object::_duplicate (object_secondary.in ()); + + // Create a merged set 1; + merged_set_ = + iorm->merge_iors (iors ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (-1); + } + else + { + merged_set_ = object_primary; + } + + return 0; +} + +int +Manager::set_properties (ACE_ENV_SINGLE_ARG_DECL) +{ + FT::TagFTGroupTaggedComponent ft_tag_component; + + // Property values + + // Major and Minor revision numbers + ft_tag_component.component_version.major = (CORBA::Octet) 1; + ft_tag_component.component_version.minor = (CORBA::Octet) 0; + + // Domain id + const char *id = "iogr_testing"; + ft_tag_component.group_domain_id = id; + + // Object group id + ft_tag_component.object_group_id = + (CORBA::ULongLong) 10; + + // Version + ft_tag_component.object_group_ref_version = + (CORBA::ULong) 5; + + // Construct the IOGR Property class + TAO_FT_IOGR_Property iogr_prop (ft_tag_component); + + // Set the property + CORBA::Boolean retval = iorm->set_primary (&iogr_prop, + object_secondary.in (), + this->merged_set_.in () + ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (-1); + + // Set the primary + // See we are setting the second ior as the primary + if (retval != 0) + { + retval = iorm->set_property (&iogr_prop, + this->merged_set_.in () + ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (-1); + } + + return 0; +} + +int +Manager::run (ACE_ENV_SINGLE_ARG_DECL) +{ + ACE_TRY + { + this->orb_->run (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_TRY_CHECK; + } + ACE_CATCHANY + { + ACE_ERROR_RETURN ((LM_DEBUG, + "Error in run \n"), + -1); + } + ACE_ENDTRY; + + return 0; +} + +int +Manager::write_to_file (void) +{ + // + CORBA::String_var iorref = + this->orb_->object_to_string (this->merged_set_.in ()); + + if (ior_output_file != 0) + { + FILE *output_file= ACE_OS::fopen (ior_output_file, "w"); + if (output_file == 0) + ACE_ERROR_RETURN ((LM_ERROR, + "Cannot open output file for writing IOR: %s", + ior_output_file), + 1); + ACE_OS::fprintf (output_file, "%s", iorref.in ()); + ACE_OS::fclose (output_file); + } + + return 0; +} + +CORBA::ORB_ptr +Manager::orb (void) +{ + return this->orb_.in (); +} + +Client_i::Client_i (CORBA::ORB_ptr orb) + :orb_ (CORBA::ORB::_duplicate (orb)) +{ +} + +int run_remote_test (Simple_Server_ptr server, const char* execute_key) +{ + char expected[1024], received[1024]; + if (execute_key) + { + ACE_OS::sprintf (expected, + "remote_call() completed by %s", execute_key); + } + else if (shutdown_test && !merged_test) + { + ACE_OS::strcpy (expected, "CORBA::COMM_FAILURE"); + } + else + { + ACE_OS::strcpy (expected, "CORBA::TRANSIENT"); + } + + ACE_TRY_NEW_ENV + { + // Make a remote call + CORBA::String_var s = + server->remote_call (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_TRY_CHECK; + + if (!s.in()) + { + ACE_OS::strcpy (received, "(null)"); + } + else + { + ACE_OS::strcpy (received, s.in()); + } + } + ACE_CATCH (CORBA::TRANSIENT, et) + { + ACE_OS::strcpy (received, "CORBA::TRANSIENT"); + } + ACE_CATCH (CORBA::COMM_FAILURE, ec) + { + ACE_OS::strcpy (received, "CORBA::COMM_FAILURE"); + } + ACE_ENDTRY; + + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT("CLIENT> REMOTE expected: '%s'"), + expected)); + + if (ACE_OS::strcmp (expected, received)) + { + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("... FAIL\n" + "CLIENT> received: '%s'\n"), + received)); + return -1; + } + + ACE_DEBUG ((LM_DEBUG, ACE_TEXT("... OK\n"))); + return 0; +} + +int run_abort_test (Simple_Server_ptr server, + const char* request_key, const char* execute_key) +{ + char expected[1024], received[1024]; + if (execute_key) + { + ACE_OS::sprintf (expected, + "abort() completed by %s, still_alive=1", + execute_key); + } + else if (merged_test) + { + ACE_OS::strcpy (expected, "CORBA::TRANSIENT"); + } + else + { + ACE_OS::strcpy (expected, "CORBA::COMM_FAILURE"); + } + + ACE_TRY_NEW_ENV + { + CORBA::String_var s = server->abort (request_key); + ACE_TRY_CHECK; + + if (!s.in()) + { + ACE_OS::strcpy (received, "(null)"); + } + else + { + ACE_OS::strcpy (received, s.in()); + } + } + ACE_CATCH (CORBA::TRANSIENT, et) + { + ACE_OS::strcpy (received, "CORBA::TRANSIENT"); + } + ACE_CATCH (CORBA::COMM_FAILURE, ec) + { + ACE_OS::strcpy (received, "CORBA::COMM_FAILURE"); + } + ACE_ENDTRY; + + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT("CLIENT> ABORT expected: '%s'"), + expected)); + if (ACE_OS::strcmp (expected, received)) + { + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("... FAIL\n" + "CLIENT> received: '%s'\n"), + received)); + return -1; + } + + ACE_DEBUG ((LM_DEBUG, ACE_TEXT("... OK\n"))); + return 0; +} + +int run_shutdown_test (Simple_Server_ptr server, + const char* request_key, const char* execute_key) +{ + char expected[1024], received[1024]; + if (execute_key) + { + ACE_OS::sprintf (expected, + "shutdown() completed by %s, still_alive=0", + execute_key); + } + else + { + ACE_OS::strcpy (expected, "CORBA::TRANSIENT"); + } + + ACE_TRY_NEW_ENV + { + CORBA::String_var s = server->shutdown (request_key); + ACE_TRY_CHECK; + + if (!s.in()) + { + ACE_OS::strcpy (received, "(null)"); + } + else + { + ACE_OS::strcpy (received, s.in()); + } + } + ACE_CATCH (CORBA::TRANSIENT, ex) + { + ACE_OS::strcpy (received, "CORBA::TRANSIENT"); + } + ACE_ENDTRY; + + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT("CLIENT> SHUTDOWN expected: '%s'"), + expected)); + if (ACE_OS::strcmp (expected, received)) + { + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("... FAIL\n" + "CLIENT> received: '%s'\n"), + received)); + return -1; + } + + ACE_DEBUG ((LM_DEBUG, ACE_TEXT("... OK\n"))); + return 0; +} + +int run_full_abort_test (Simple_Server_ptr server) +{ + int rv = run_remote_test (server, second_key); + if (rv) + { + return rv; + } + + rv = run_abort_test (server, second_key, first_key); + if (rv) + { + return rv; + } + + rv = run_remote_test (server, first_key); + if (rv) + { + return rv; + } + + rv = run_abort_test (server, first_key, 0); + if (rv) + { + return rv; + } + + rv = run_remote_test (server, 0); + if (rv) + { + return rv; + } + + return 0; +} + +int run_full_shutdown_test (Simple_Server_ptr server) +{ + int rv = run_remote_test (server, second_key); + if (rv) + { + return rv; + } + + rv = run_shutdown_test (server, second_key, second_key); + if (rv) + { + return rv; + } + + rv = run_remote_test (server, first_key); + if (rv) + { + return rv; + } + + rv = run_shutdown_test (server, first_key, first_key); + if (rv) + { + return rv; + } + + rv = run_remote_test (server, 0); + if (rv) + { + return rv; + } + + return 0; +} + +int +Client_i::init (ACE_ENV_SINGLE_ARG_DECL) +{ + // Open the file for reading. + ACE_HANDLE f_handle = ACE_OS::open (ior_output_file, + 0); + + if (f_handle == ACE_INVALID_HANDLE) + ACE_ERROR ((LM_ERROR, + "Unable to open %s for writing: %p\n", + ior_output_file)); + + ACE_Read_Buffer ior_buffer (f_handle); + + char *data = ior_buffer.read (); + + if (data == 0) + ACE_ERROR ((LM_ERROR, + "Unable to read ior: %p\n")); + + + int argc = 0; + char **argv = 0; + this->orb_ = CORBA::ORB_init (argc, + argv, + 0 + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + CORBA::Object_var object = + this->orb_->string_to_object (data + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + // Combined IOR stuff + Simple_Server_var server = + Simple_Server::_narrow (object.in () + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + if (CORBA::is_nil (server.in ())) + { + ACE_ERROR ((LM_ERROR, + "Object reference <%s> is nil\n", + data)); + } + + int rv; + if (!merged_test) + { + if (shutdown_test) + { + rv = run_shutdown_test (server.in(), first_key, first_key); + } + else + { + rv = run_abort_test (server.in(), first_key, 0); + } + + if (!rv) + { + rv = run_remote_test (server.in(), 0); + } + } + else if (shutdown_test) + { + rv = run_full_shutdown_test (server.in ()); + } + else + { + rv = run_full_abort_test (server.in ()); + } + + ior_buffer.alloc ()->free (data); + ACE_OS::close (f_handle); + return rv; +} diff --git a/TAO/orbsvcs/tests/Bug_2247_Regression/Manager.h b/TAO/orbsvcs/tests/Bug_2247_Regression/Manager.h new file mode 100755 index 00000000000..81760e158f4 --- /dev/null +++ b/TAO/orbsvcs/tests/Bug_2247_Regression/Manager.h @@ -0,0 +1,50 @@ +// -*- C++ -*- +// $Id$ + +#ifndef BUG_2247_REGRESSION_MANAGER_H +#define BUG_2247_REGRESSION_MANAGER_H + +#include "tao/ORB.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "tao/Object.h" + +class Manager +{ +public: + + Manager (void); + // Ctor + + void init (int argc, + char *argv[] + ACE_ENV_ARG_DECL); + + // Initialize the ORB, POA etc. + + int make_merged_iors (ACE_ENV_SINGLE_ARG_DECL_NOT_USED); + // Merges the different IORS + + int set_properties (ACE_ENV_SINGLE_ARG_DECL_NOT_USED); + // Sets the properties for the profiles + + int run (ACE_ENV_SINGLE_ARG_DECL); + // Run the ORB event loop.. + + int write_to_file (void); + // Write the merged IOR to a file + + CORBA::ORB_ptr orb (void); + // Return the pointer to the copy of our ORB +private: + CORBA::ORB_var orb_; + // Our ORB + + CORBA::Object_var merged_set_; + // The merged IOR set +}; + +#endif /* BUG_2247_REGRESSION_MANAGER_H */ diff --git a/TAO/orbsvcs/tests/Bug_2247_Regression/README b/TAO/orbsvcs/tests/Bug_2247_Regression/README new file mode 100755 index 00000000000..b2cda70e18d --- /dev/null +++ b/TAO/orbsvcs/tests/Bug_2247_Regression/README @@ -0,0 +1,31 @@ +// $Id$ + +This program tests the behavior of FT aware client when there +is a fault in the server. + +First, you can test the behavior of client when it works with +a simple single profile IOR (not IOGR). + +To test server crashing down (aborting) in the middle of the RPC: +$./server -o file1.ior -k KEY1 +$./Manager -a file://file1.ior -k KEY1 -c g.ior + +To test server gracefully shutting down in the middle of the RPC: +$./server -o file1.ior -k KEY1 +$./Manager -a file://file1.ior -k KEY1 -c g.ior -s + +You can also test behavior of client when using IOGR with two servers +by supplying -g as the option to Manager. + +To test servers crashing down (aborting) in the middle of the RPC: +$./server -o file1.ior -k KEY1 +$./server -o file2.ior -k KEY2 +$./Manager -a file://file1.ior -k KEY1 -b file://file2.ior -l KEY2 -c g.ior -g + +To test one of two serversshutting down in the middle of the RPC: +$./server -o file1.ior -k KEY1 +$./server -o file2.ior -k KEY2 +$./Manager -a file://file1.ior -k KEY1 -b file://file2.ior -l KEY2 -c g.ior -g -s + +The complete test can be run by run_test.pl. +The script exits with error code != 0 in case of error. diff --git a/TAO/orbsvcs/tests/Bug_2247_Regression/run_test.pl b/TAO/orbsvcs/tests/Bug_2247_Regression/run_test.pl new file mode 100755 index 00000000000..64addd90090 --- /dev/null +++ b/TAO/orbsvcs/tests/Bug_2247_Regression/run_test.pl @@ -0,0 +1,142 @@ +eval '(exit $?0)' && eval 'exec perl -S $0 ${1+"$@"}' + & eval 'exec perl -S $0 $argv:q' + if 0; + +# $Id$ +# -*- perl -*- + +use lib '../../../../bin'; +use PerlACE::Run_Test; + +$status = 0; + +$file1ior = PerlACE::LocalFile ("file1.ior"); +$file2ior = PerlACE::LocalFile ("file2.ior"); +$outputior = PerlACE::LocalFile ("output.ior"); + +unlink $file1ior, $file2ior, $outputior; + +$SERV1 = new PerlACE::Process ("server", "-o $file1ior -k KEY1"); +$SERV2 = new PerlACE::Process ("server", "-o $file2ior -k KEY2"); +$MANAGER_00 = new PerlACE::Process ("Manager", "-a file://$file1ior -k KEY1 -b file://$file2ior -l KEY2 -c $outputior"); +$MANAGER_01 = new PerlACE::Process ("Manager", "-a file://$file1ior -k KEY1 -b file://$file2ior -l KEY2 -c $outputior -s"); +$MANAGER_10 = new PerlACE::Process ("Manager", "-a file://$file1ior -k KEY1 -b file://$file2ior -l KEY2 -c $outputior -m"); +$MANAGER_11 = new PerlACE::Process ("Manager", "-a file://$file1ior -k KEY1 -b file://$file2ior -l KEY2 -c $outputior -m -s"); + +# --------------- +print STDERR "Starting ABORT test\n"; + +print STDERR "Starting Server 1\n"; +$SERV1->Spawn (); +if (PerlACE::waitforfile_timed ($file1ior, 20) == -1) { + print STDERR "ERROR: cannot find file <$file1ior>\n"; + $SERV1->Kill (); + exit 1; +} + +print STDERR "Starting ABORT Manager\n"; +$MANAGER_00->Spawn (); +$manager = $MANAGER_00->WaitKill (30); + +$SERV1->WaitKill(5); + +if ($manager != 0) { + print STDERR "ERROR: Manager returned $manager\n"; + ++ $status; +} + +unlink $file1ior, $outputior; + +# --------------- +print STDERR "Starting SHUTDOWN test\n"; + +print STDERR "Starting Server 1\n"; +$SERV1->Spawn (); +if (PerlACE::waitforfile_timed ($file1ior, 20) == -1) { + print STDERR "ERROR: cannot find file <$file1ior>\n"; + $SERV1->Kill (); + exit 1; +} + +print STDERR "Starting SHUTDOWN Manager\n"; +$MANAGER_01->Spawn (); +$manager = $MANAGER_01->WaitKill (30); + +$SERV1->WaitKill(5); + +if ($manager != 0) { + print STDERR "ERROR: Manager returned $manager\n"; + ++ $status; +} + +unlink $file1ior, $outputior; + +# --------------- +print STDERR "Starting MERGED ABORT test\n"; + +print STDERR "Starting Server 1\n"; +$SERV1->Spawn (); +if (PerlACE::waitforfile_timed ($file1ior, 20) == -1) { + print STDERR "ERROR: cannot find file <$file1ior>\n"; + $SERV1->Kill (); + exit 1; +} + +print STDERR "Starting Server 2\n"; +$SERV2->Spawn (); +if (PerlACE::waitforfile_timed ($file2ior, 20) == -1) { + print STDERR "ERROR: cannot find file <$file2ior>\n"; + $SERV1->Kill (); + $SERV2->Kill (); + exit 1; +} + +print STDERR "Starting ABORT Manager\n"; +$MANAGER_10->Spawn (); +$manager = $MANAGER_10->WaitKill (30); + +$SERV1->WaitKill(5); +$SERV2->WaitKill(5); + +if ($manager != 0) { + print STDERR "ERROR: Manager returned $manager\n"; + ++ $status; +} + +unlink $file1ior, $file2ior, $outputior; + +# --------------- +print STDERR "Starting MERGED SHUTDOWN test\n"; + +print STDERR "Starting Server 1\n"; +$SERV1->Spawn (); +if (PerlACE::waitforfile_timed ($file1ior, 20) == -1) { + print STDERR "ERROR: cannot find file <$file1ior>\n"; + $SERV1->Kill (); + exit 1; +} + +print STDERR "Starting Server 2\n"; +$SERV2->Spawn (); +if (PerlACE::waitforfile_timed ($file2ior, 20) == -1) { + print STDERR "ERROR: cannot find file <$file2ior>\n"; + $SERV1->Kill (); + $SERV2->Kill (); + exit 1; +} + +print STDERR "Starting SHUTDOWN Manager\n"; +$MANAGER_11->Spawn (); +$manager = $MANAGER_11->WaitKill (30); + +$SERV1->WaitKill(5); +$SERV2->WaitKill(5); + +if ($manager != 0) { + print STDERR "ERROR: Manager returned $manager\n"; + ++ $status; +} + +unlink $file1ior, $file2ior, $outputior; + +exit $status diff --git a/TAO/orbsvcs/tests/Bug_2247_Regression/server.cpp b/TAO/orbsvcs/tests/Bug_2247_Regression/server.cpp new file mode 100755 index 00000000000..d597ec0d27d --- /dev/null +++ b/TAO/orbsvcs/tests/Bug_2247_Regression/server.cpp @@ -0,0 +1,136 @@ +// $Id$ + +#include "test_i.h" +#include "ace/Get_Opt.h" +#include "ace/OS_NS_stdio.h" +const char *ior_output_file = 0; +const char *key = 0; + +int +parse_args (int argc, char *argv[]) +{ + ACE_Get_Opt get_opts (argc, argv, "o:k:"); + int c; + + while ((c = get_opts ()) != -1) + switch (c) + { + case 'o': + ior_output_file = get_opts.opt_arg (); + break; + case 'k': + key = get_opts.opt_arg (); + break; + + case '?': + default: + ACE_ERROR_RETURN ((LM_ERROR, + "usage: %s " + "-o <iorfile>" + "-k <key>" + "\n", + argv [0]), + -1); + } + // Indicates sucessful parsing of the command line + return 0; +} + +int +main (int argc, char *argv[]) +{ + ACE_DECLARE_NEW_CORBA_ENV; + ACE_TRY + { + CORBA::ORB_var orb = + CORBA::ORB_init (argc, argv, "" ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + // We do the command line parsing first + if (parse_args (argc, argv) != 0) + return 1; + CORBA::Object_var poa_object = + orb->resolve_initial_references("RootPOA" ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + if (CORBA::is_nil (poa_object.in ())) + ACE_ERROR_RETURN ((LM_ERROR, + " (%P|%t) Unable to initialize the POA.\n"), + 1); + + PortableServer::POA_var root_poa = + PortableServer::POA::_narrow (poa_object.in () ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + PortableServer::POAManager_var poa_manager = + root_poa->the_POAManager (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_TRY_CHECK; + + CORBA::PolicyList policies; + policies.length (3); + policies[0] = root_poa->create_id_assignment_policy ( + PortableServer::USER_ID ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + policies[1] = root_poa->create_implicit_activation_policy ( + PortableServer::NO_IMPLICIT_ACTIVATION ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + policies[2] = root_poa->create_lifespan_policy ( + PortableServer::PERSISTENT ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + PortableServer::POA_var poa = root_poa->create_POA ( + "PERS_POA", poa_manager.in (), policies ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + for (CORBA::ULong i = 0; i < policies.length (); ++i) + { + policies[i]->destroy (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_TRY_CHECK; + } + + // Instantiate the LCD_Display implementation class + Simple_Server_i display_impl (orb.in (), key); + PortableServer::ObjectId_var id = + PortableServer::string_to_ObjectId ("IOGR_OID"); + + poa->activate_object_with_id (id.in(), &display_impl ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + CORBA::Object_var server = + poa->id_to_reference (id.in () ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + CORBA::String_var ior = + orb->object_to_string (server.in () ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + ACE_DEBUG ((LM_DEBUG, "Activated as <%s>\n", ior.in ())); + + // If the ior_output_file exists, output the ior to it + if (ior_output_file != 0) + { + FILE *output_file= ACE_OS::fopen (ior_output_file, "w"); + if (output_file == 0) + ACE_ERROR_RETURN ((LM_ERROR, + "Cannot open output file for writing IOR: %s", + ior_output_file), + 1); + ACE_OS::fprintf (output_file, "%s", ior.in ()); + ACE_OS::fclose (output_file); + } + + poa_manager->activate (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_TRY_CHECK; + + orb->run (); + + } + ACE_CATCHANY + { + ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, + "Caught exception:"); + return 1; + } + ACE_ENDTRY; + return 0; +} diff --git a/TAO/orbsvcs/tests/Bug_2247_Regression/test.idl b/TAO/orbsvcs/tests/Bug_2247_Regression/test.idl new file mode 100755 index 00000000000..ecca7fffd42 --- /dev/null +++ b/TAO/orbsvcs/tests/Bug_2247_Regression/test.idl @@ -0,0 +1,10 @@ +/* + * $Id$ + */ + +interface Simple_Server +{ + string remote_call (); + string shutdown (in string ior_file); + string abort (in string ior_file); +}; diff --git a/TAO/orbsvcs/tests/Bug_2247_Regression/test_i.cpp b/TAO/orbsvcs/tests/Bug_2247_Regression/test_i.cpp new file mode 100755 index 00000000000..e76f93f11ab --- /dev/null +++ b/TAO/orbsvcs/tests/Bug_2247_Regression/test_i.cpp @@ -0,0 +1,71 @@ +// $Id$ + +#include "test_i.h" + +#include "ace/OS_NS_stdio.h" +#include "ace/OS_NS_string.h" + +Simple_Server_i::Simple_Server_i (CORBA::ORB_ptr orb, const char* key) + : orb_ (CORBA::ORB::_duplicate (orb)) + , _key (CORBA::string_dup (key)) +{ +} + +Simple_Server_i::Simple_Server_i (void) + : orb_ (0) +{ + // no-op +} + +char* +Simple_Server_i::remote_call (ACE_ENV_SINGLE_ARG_DECL_NOT_USED /*ACE_ENV_SINGLE_ARG_PARAMETER*/) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + ACE_DEBUG ((LM_DEBUG, "SERVER(%s)> executing remote_call()\n", _key.in())); + + char buf[256]; + ACE_OS::sprintf (buf, "remote_call() completed by %s", _key.in()); + + ACE_DEBUG ((LM_DEBUG, "SERVER(%s)> returning '%s'\n", _key.in(), buf)); + return CORBA::string_dup (buf); +} + + +char* +Simple_Server_i::shutdown (const char* key ACE_ENV_SINGLE_ARG_DECL_NOT_USED) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + ACE_DEBUG ((LM_DEBUG, "SERVER(%s)> executing shutdown()\n", _key.in())); + + int still_alive = 1; + if (!ACE_OS::strcmp (_key.in(), key)) + { + this->orb_->shutdown (0); + still_alive = 0; + } + + char buf[256]; + ACE_OS::sprintf (buf, "shutdown() completed by %s, still_alive=%d", + _key.in(), still_alive); + ACE_DEBUG ((LM_DEBUG, "SERVER(%s)> returning '%s'\n", _key.in(), buf)); + return CORBA::string_dup (buf); +} + +char* +Simple_Server_i::abort (const char* key ACE_ENV_SINGLE_ARG_DECL_NOT_USED) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + ACE_DEBUG ((LM_DEBUG, "SERVER(%s)> executing abort()\n", _key.in())); + int still_alive = 1; + if (!ACE_OS::strcmp (_key.in(), key)) + { + ACE_OS::abort(); + still_alive = 0; + } + + char buf[256]; + ACE_OS::sprintf (buf, "abort() completed by %s, still_alive=%d", + _key.in(), still_alive); + ACE_DEBUG ((LM_DEBUG, "SERVER(%s)> returning '%s'\n", _key.in(), buf)); + return CORBA::string_dup (buf); +} diff --git a/TAO/orbsvcs/tests/Bug_2247_Regression/test_i.h b/TAO/orbsvcs/tests/Bug_2247_Regression/test_i.h new file mode 100755 index 00000000000..110555b959c --- /dev/null +++ b/TAO/orbsvcs/tests/Bug_2247_Regression/test_i.h @@ -0,0 +1,38 @@ +// $Id$ + +#ifndef BUG_2247_REGRESSION_TEST_I_H +#define BUG_2247_REGRESSION_TEST_I_H + +#include "testS.h" + +class Simple_Server_i : public POA_Simple_Server +{ + // = TITLE + // Simpler Server implementation + // + // = DESCRIPTION + // Implements the Simple_Server interface in test.idl + // +public: + Simple_Server_i (CORBA::ORB_ptr orb, const char* key); + // ctor + + Simple_Server_i (void); + // ctor + + // = The Simple_Server methods. + char* remote_call (ACE_ENV_SINGLE_ARG_DECL_NOT_USED) + ACE_THROW_SPEC ((CORBA::SystemException)); + + char* shutdown (const char* key ACE_ENV_SINGLE_ARG_DECL_NOT_USED) + ACE_THROW_SPEC ((CORBA::SystemException)); + + char* abort (const char* key ACE_ENV_SINGLE_ARG_DECL_NOT_USED) + ACE_THROW_SPEC ((CORBA::SystemException)); + +private: + CORBA::ORB_var orb_; + CORBA::String_var _key; +}; + +#endif /* BUG_2247_REGRESSION_TEST_I_H */ |