summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Corino <mcorino@remedy.nl>2020-01-29 10:44:17 +0100
committerMartin Corino <mcorino@remedy.nl>2020-01-29 10:44:17 +0100
commit0f723d9f5e8a77fa0b80198cc0523295c730ca01 (patch)
tree80a619af6364f9639d763ea94657bf9db1ba04f9
parent3384df595ff0b98f167f2015045eb8ad0bb9ae2a (diff)
downloadATCD-0f723d9f5e8a77fa0b80198cc0523295c730ca01.tar.gz
Added regression test for transient error handling with deferred DII requests.
* TAO/tests/DII_Deferred_Transient/DII_Deferred_Transient.mpc: * TAO/tests/DII_Deferred_Transient/Hello.cpp: * TAO/tests/DII_Deferred_Transient/Hello.h: * TAO/tests/DII_Deferred_Transient/README: * TAO/tests/DII_Deferred_Transient/Test.idl: * TAO/tests/DII_Deferred_Transient/client.cpp: * TAO/tests/DII_Deferred_Transient/run_test.pl: * TAO/tests/DII_Deferred_Transient/server.cpp: Added. * TAO/bin/tao_orb_tests.lst:
-rw-r--r--TAO/bin/tao_orb_tests.lst1
-rw-r--r--TAO/tests/DII_Deferred_Transient/DII_Deferred_Transient.mpc34
-rw-r--r--TAO/tests/DII_Deferred_Transient/Hello.cpp20
-rw-r--r--TAO/tests/DII_Deferred_Transient/Hello.h23
-rw-r--r--TAO/tests/DII_Deferred_Transient/README17
-rw-r--r--TAO/tests/DII_Deferred_Transient/Test.idl14
-rw-r--r--TAO/tests/DII_Deferred_Transient/client.cpp113
-rwxr-xr-xTAO/tests/DII_Deferred_Transient/run_test.pl75
-rw-r--r--TAO/tests/DII_Deferred_Transient/server.cpp100
9 files changed, 397 insertions, 0 deletions
diff --git a/TAO/bin/tao_orb_tests.lst b/TAO/bin/tao_orb_tests.lst
index 22ba2f6be7a..303c079e515 100644
--- a/TAO/bin/tao_orb_tests.lst
+++ b/TAO/bin/tao_orb_tests.lst
@@ -476,6 +476,7 @@ TAO/tests/Parallel_Connect_Strategy/run_test.pl -quick : QUICK55
TAO/tests/DII_Collocation_Tests/oneway/run_test.pl: !ST !MINIMUM !CORBA_E_COMPACT !CORBA_E_MICRO
TAO/tests/DII_Collocation_Tests/twoway/run_test.pl: !ST !MINIMUM !CORBA_E_COMPACT !CORBA_E_MICRO
TAO/tests/DII_Discard_Deferred/run_test.pl: !MINIMUM !CORBA_E_COMPACT !CORBA_E_MICRO
+TAO/tests/DII_Deferred_Transient/run_test.pl: !MINIMUM !CORBA_E_COMPACT !CORBA_E_MICRO
TAO/tests/Compression/run_test.pl
TAO/tests/Collocated_Forwarding/run_test.pl: !MINIMUM !CORBA_E_COMPACT !CORBA_E_MICRO !DISABLE_INTERCEPTORS !ACE_FOR_TAO
TAO/tests/ZIOP/run_test.pl: ZLIB BZIP2
diff --git a/TAO/tests/DII_Deferred_Transient/DII_Deferred_Transient.mpc b/TAO/tests/DII_Deferred_Transient/DII_Deferred_Transient.mpc
new file mode 100644
index 00000000000..de4381c7b1e
--- /dev/null
+++ b/TAO/tests/DII_Deferred_Transient/DII_Deferred_Transient.mpc
@@ -0,0 +1,34 @@
+// -*- MPC -*-
+project(*idl): taoidldefaults, dynamicinterface, avoids_minimum_corba {
+ IDL_Files {
+ Test.idl
+ }
+ custom_only = 1
+}
+
+project(*Server): taoserver, dynamicinterface, avoids_minimum_corba {
+ after += *idl
+ Source_Files {
+ Hello.cpp
+ server.cpp
+ }
+ Source_Files {
+ TestC.cpp
+ TestS.cpp
+ }
+ IDL_Files {
+ }
+}
+
+project(*Client): taoclient, dynamicinterface, avoids_minimum_corba {
+ after += *idl
+ Source_Files {
+ client.cpp
+ }
+ Source_Files {
+ TestC.cpp
+ }
+ IDL_Files {
+ }
+}
+
diff --git a/TAO/tests/DII_Deferred_Transient/Hello.cpp b/TAO/tests/DII_Deferred_Transient/Hello.cpp
new file mode 100644
index 00000000000..6d8aab734a4
--- /dev/null
+++ b/TAO/tests/DII_Deferred_Transient/Hello.cpp
@@ -0,0 +1,20 @@
+// -*- C++ -*-
+#include "Hello.h"
+#include "ace/OS_NS_unistd.h"
+
+Hello::Hello ()
+{
+}
+
+void
+Hello::crash ()
+{
+ ACE::terminate_process (ACE_OS::getpid ());
+}
+
+char *
+Hello::get_string ()
+{
+// ACE_DEBUG ((LM_DEBUG, "(%P|%t) - Hello::get_string called\n"));
+ return CORBA::string_dup ("Hello there!");
+}
diff --git a/TAO/tests/DII_Deferred_Transient/Hello.h b/TAO/tests/DII_Deferred_Transient/Hello.h
new file mode 100644
index 00000000000..1f26f2bfe55
--- /dev/null
+++ b/TAO/tests/DII_Deferred_Transient/Hello.h
@@ -0,0 +1,23 @@
+
+#ifndef HELLO_H
+#define HELLO_H
+#include /**/ "ace/pre.h"
+
+#include "TestS.h"
+
+/// Implement the Test::Hello interface
+class Hello
+ : public virtual POA_Test::Hello
+{
+public:
+ /// Constructor
+ Hello ();
+
+ // = The skeleton methods
+ virtual void crash ();
+
+ virtual char * get_string ();
+};
+
+#include /**/ "ace/post.h"
+#endif /* HELLO_H */
diff --git a/TAO/tests/DII_Deferred_Transient/README b/TAO/tests/DII_Deferred_Transient/README
new file mode 100644
index 00000000000..d986907ed1b
--- /dev/null
+++ b/TAO/tests/DII_Deferred_Transient/README
@@ -0,0 +1,17 @@
+/**
+
+@page DII Discarded Deferred Request Test README File
+
+ The goals of writing this test are:
+
+- Test transient error management (in case of disappearing/unreachable clients)
+ with the deferred DII calling scheme.
+
+ To run the test use the run_test.pl script:
+
+$ ./run_test.pl
+
+ the script returns 0 if the test was successful.
+
+ In case of a regression the test might segfault.
+*/
diff --git a/TAO/tests/DII_Deferred_Transient/Test.idl b/TAO/tests/DII_Deferred_Transient/Test.idl
new file mode 100644
index 00000000000..78382dcbcec
--- /dev/null
+++ b/TAO/tests/DII_Deferred_Transient/Test.idl
@@ -0,0 +1,14 @@
+
+/// Put the interfaces in a module, to avoid global namespace pollution
+module Test
+{
+ /// A very simple interface
+ interface Hello
+ {
+ /// signal server to terminate
+ oneway void crash ();
+
+ /// Return a simple string
+ string get_string ();
+ };
+};
diff --git a/TAO/tests/DII_Deferred_Transient/client.cpp b/TAO/tests/DII_Deferred_Transient/client.cpp
new file mode 100644
index 00000000000..98baad26c9f
--- /dev/null
+++ b/TAO/tests/DII_Deferred_Transient/client.cpp
@@ -0,0 +1,113 @@
+// -*- C++ -*-
+#include "tao/DynamicInterface/Request.h"
+#include "tao/DynamicInterface/DII_CORBA_methods.h"
+#include "TestC.h"
+#include "ace/Get_Opt.h"
+#include "ace/OS_NS_unistd.h"
+
+const ACE_TCHAR *ior = ACE_TEXT("file://test.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
+ {
+ CORBA::ORB_var orb = CORBA::ORB_init (argc, argv);
+
+ if (parse_args (argc, argv) != 0)
+ return 1;
+
+ CORBA::Object_var obj = orb->string_to_object(ior);
+
+ const char* the_string = 0;
+
+ ACE_DEBUG ((LM_INFO, "(%P|%t) - #### Deferred twoway DII (using get_response())\n"));
+
+ CORBA::Request_var req = obj->_request ("get_string");
+ req->set_return_type (CORBA::_tc_string);
+
+ req->send_deferred ();
+ ACE_DEBUG ((LM_INFO, "(%P|%t) - Get response...\n"));
+ req->get_response ();
+ req->return_value () >>= the_string;
+
+ ACE_DEBUG ((LM_DEBUG, "(%P|%t) - string returned <%C>\n",
+ the_string));
+
+ ACE_DEBUG ((LM_INFO, "(%P|%t) - #### Oneway DII to initiate crash\n"));
+
+ req = obj->_request ("crash");
+
+ req->send_oneway ();
+
+ ACE_OS::sleep(1); // give it some time
+
+ ACE_DEBUG ((LM_INFO, "(%P|%t) - #### Multiple deferred twoway DII (with discarded replies)\n"));
+
+ int iterations = 10;
+ int exceptions = 0;
+ for (int i=0; i<iterations ;++i)
+ {
+ try
+ {
+ ACE_DEBUG ((LM_INFO, "(%P|%t) - get_string iteration #%d\n", i));
+
+ req = obj->_request ("get_string");
+ req->set_return_type (CORBA::_tc_string);
+
+ req->send_deferred ();
+ // discard reply
+
+ ACE_DEBUG ((LM_INFO, "(%P|%t) - sent deferred\n"));
+ }
+ catch (const CORBA::Exception&)
+ {
+ ++exceptions;
+ }
+ }
+
+ if (exceptions == 0)
+ {
+ ACE_DEBUG ((LM_ERROR, "(%P|%t) - All requests unexpectedly succeeded\n"));
+ }
+ else
+ {
+ ACE_DEBUG ((LM_INFO, "(%P|%t) - Caught exceptions from requests as expected (%d)\n", exceptions));
+ }
+
+ orb->destroy ();
+ }
+ catch (const CORBA::Exception& ex)
+ {
+ ex._tao_print_exception ("Exception caught:");
+ return 1;
+ }
+
+ return 0;
+}
diff --git a/TAO/tests/DII_Deferred_Transient/run_test.pl b/TAO/tests/DII_Deferred_Transient/run_test.pl
new file mode 100755
index 00000000000..80bc1ae58b1
--- /dev/null
+++ b/TAO/tests/DII_Deferred_Transient/run_test.pl
@@ -0,0 +1,75 @@
+eval '(exit $?0)' && eval 'exec perl -S $0 ${1+"$@"}'
+ & eval 'exec perl -S $0 $argv:q'
+ if 0;
+
+# -*- perl -*-
+
+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 $server = PerlACE::TestTarget::create_target (1) || die "Create target 1 failed\n";
+my $client = PerlACE::TestTarget::create_target (2) || die "Create target 2 failed\n";
+
+my $iorbase = "server.ior";
+my $server_iorfile = $server->LocalFile ($iorbase);
+my $client_iorfile = $client->LocalFile ($iorbase);
+$server->DeleteFile($iorbase);
+$client->DeleteFile($iorbase);
+
+$SV = $server->CreateProcess ("server", "-ORBdebuglevel $debug_level -o $server_iorfile");
+$CL = $client->CreateProcess ("client", "-ORBdebuglevel $debug_level -k file://$client_iorfile");
+$server_status = $SV->Spawn ();
+
+if ($server_status != 0) {
+ print STDERR "ERROR: server returned $server_status\n";
+ exit 1;
+}
+
+if ($server->WaitForFileTimed ($iorbase,
+ $server->ProcessStartWaitInterval()) == -1) {
+ print STDERR "ERROR: cannot find file <$server_iorfile>\n";
+ $SV->Kill (); $SV->TimedWait (1);
+ exit 1;
+}
+
+if ($server->GetFile ($iorbase) == -1) {
+ print STDERR "ERROR: cannot retrieve file <$server_iorfile>\n";
+ $SV->Kill (); $SV->TimedWait (1);
+ exit 1;
+}
+if ($client->PutFile ($iorbase) == -1) {
+ print STDERR "ERROR: cannot set file <$client_iorfile>\n";
+ $SV->Kill (); $SV->TimedWait (1);
+ exit 1;
+}
+
+$client_status = $CL->SpawnWaitKill ($client->ProcessStartWaitInterval());
+
+if ($client_status != 0) {
+ print STDERR "ERROR: client returned $client_status\n";
+ $status = 1;
+}
+
+$server_status = $SV->WaitKill ($server->ProcessStopWaitInterval());
+
+if ($server_status != 0) {
+ print STDERR "ERROR: server returned $server_status\n";
+ $status = 1;
+}
+
+$server->GetStderrLog();
+$client->GetStderrLog();
+
+$server->DeleteFile($iorbase);
+$client->DeleteFile($iorbase);
+
+exit $status;
diff --git a/TAO/tests/DII_Deferred_Transient/server.cpp b/TAO/tests/DII_Deferred_Transient/server.cpp
new file mode 100644
index 00000000000..74558b8e9fe
--- /dev/null
+++ b/TAO/tests/DII_Deferred_Transient/server.cpp
@@ -0,0 +1,100 @@
+// -*- C++ -*-
+#include "Hello.h"
+#include "ace/Get_Opt.h"
+#include "ace/OS_NS_stdio.h"
+
+const ACE_TCHAR *ior_output_file = ACE_TEXT("test.ior");
+
+int
+parse_args (int argc, ACE_TCHAR *argv[])
+{
+ ACE_Get_Opt get_opts (argc, argv, ACE_TEXT("o:"));
+ int c;
+
+ while ((c = get_opts ()) != -1)
+ switch (c)
+ {
+ case 'o':
+ ior_output_file = get_opts.opt_arg ();
+ break;
+
+ case '?':
+ default:
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "usage: %s "
+ "-o <iorfile>"
+ "\n",
+ argv [0]),
+ -1);
+ }
+ // Indicates successful parsing of the command line
+ return 0;
+}
+
+int
+ACE_TMAIN(int argc, ACE_TCHAR *argv[])
+{
+ try
+ {
+ CORBA::ORB_var orb =
+ CORBA::ORB_init (argc, argv);
+
+ CORBA::Object_var poa_object =
+ orb->resolve_initial_references("RootPOA");
+
+ PortableServer::POA_var root_poa =
+ PortableServer::POA::_narrow (poa_object.in ());
+
+ if (CORBA::is_nil (root_poa.in ()))
+ ACE_ERROR_RETURN ((LM_ERROR,
+ " (%P|%t) Panic: nil RootPOA\n"),
+ 1);
+
+ PortableServer::POAManager_var poa_manager = root_poa->the_POAManager ();
+
+ if (parse_args (argc, argv) != 0)
+ return 1;
+
+ Hello *hello_impl = 0;
+ ACE_NEW_RETURN (hello_impl,
+ Hello (),
+ 1);
+ PortableServer::ServantBase_var owner_transfer(hello_impl);
+
+ PortableServer::ObjectId_var id =
+ root_poa->activate_object (hello_impl);
+
+ CORBA::Object_var object = root_poa->id_to_reference (id.in ());
+
+ Test::Hello_var hello = Test::Hello::_narrow (object.in ());
+
+ CORBA::String_var ior = orb->object_to_string (hello.in ());
+
+ // Output the IOR to the <ior_output_file>
+ 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\n",
+ ior_output_file),
+ 1);
+ ACE_OS::fprintf (output_file, "%s", ior.in ());
+ ACE_OS::fclose (output_file);
+
+ poa_manager->activate ();
+
+ orb->run ();
+
+ ACE_DEBUG ((LM_DEBUG, "(%P|%t) server - event loop finished\n"));
+
+ root_poa->destroy (1, 1);
+
+ orb->destroy ();
+ }
+ catch (const CORBA::Exception& ex)
+ {
+ ex._tao_print_exception ("Exception caught:");
+ return 1;
+ }
+
+ return 0;
+}