From 4d9ceeda71fa91f30da720a8c87f4ceb85aaf8e9 Mon Sep 17 00:00:00 2001 From: coryan Date: Mon, 23 Apr 2001 18:53:19 +0000 Subject: ChangeLogTag:Mon Apr 23 11:47:07 2001 Carlos O'Ryan --- TAO/ChangeLogs/ChangeLog-02a | 15 ++++++ TAO/tests/AMI_Buffering/Client_Task.cpp | 23 +++++++-- TAO/tests/AMI_Buffering/Client_Task.h | 10 ++++ TAO/tests/AMI_Buffering/client.cpp | 66 +++++++++++++++++-------- TAO/tests/AMI_Buffering/run_timeout_reactive.pl | 65 ++++++++++++++++++++++++ TAO/tests/Oneway_Buffering/client.cpp | 36 +++++++------- 6 files changed, 174 insertions(+), 41 deletions(-) create mode 100755 TAO/tests/AMI_Buffering/run_timeout_reactive.pl diff --git a/TAO/ChangeLogs/ChangeLog-02a b/TAO/ChangeLogs/ChangeLog-02a index 1781a15b697..64502346ea8 100644 --- a/TAO/ChangeLogs/ChangeLog-02a +++ b/TAO/ChangeLogs/ChangeLog-02a @@ -1,3 +1,18 @@ +Mon Apr 23 11:47:07 2001 Carlos O'Ryan + + * tests/AMI_Buffering/Client_Task.h: + * tests/AMI_Buffering/Client_Task.cpp: + * tests/AMI_Buffering/client.cpp: + The client event loop can be explicitly terminated now. + + * tests/AMI_Buffering/run_timeout_reactive.pl: + Add new driver script for timeout based flushing, but initiated + via the Reactor. + + * tests/Oneway_Buffering/client.cpp: + Renamed the second part of the test, 'liveness' is a more + descriptive term. + Mon Apr 23 10:38:28 2001 Carlos O'Ryan * tests/AMI_Buffering/svc.conf: diff --git a/TAO/tests/AMI_Buffering/Client_Task.cpp b/TAO/tests/AMI_Buffering/Client_Task.cpp index bd620fae7a8..3c74d4aa262 100644 --- a/TAO/tests/AMI_Buffering/Client_Task.cpp +++ b/TAO/tests/AMI_Buffering/Client_Task.cpp @@ -8,9 +8,17 @@ ACE_RCSID(AMI_Buffering, Client_Task, "$Id$") Client_Task::Client_Task (CORBA::ORB_ptr orb) : orb_ (CORBA::ORB::_duplicate (orb)) + , terminate_loop_ (0) { } +void +Client_Task::terminate_loop (void) +{ + ACE_GUARD (TAO_SYNCH_MUTEX, ace_mon, this->mutex_); + this->terminate_loop_ = 1; +} + int Client_Task::svc (void) { @@ -18,10 +26,17 @@ Client_Task::svc (void) ACE_DECLARE_NEW_CORBA_ENV; ACE_TRY { - // run the test for at most 240 seconds... - ACE_Time_Value tv (240, 0); - this->orb_->run (tv, ACE_TRY_ENV); - ACE_TRY_CHECK; + while (1) + { + // run the even loop for 1 second... + ACE_Time_Value tv (1, 0); + this->orb_->run (tv, ACE_TRY_ENV); + ACE_TRY_CHECK; + + ACE_GUARD_RETURN (TAO_SYNCH_MUTEX, ace_mon, this->mutex_, -1); + if (this->terminate_loop_ != 0) + break; + } } ACE_CATCHANY { diff --git a/TAO/tests/AMI_Buffering/Client_Task.h b/TAO/tests/AMI_Buffering/Client_Task.h index 372fbc96cfb..1e41e68bdc9 100644 --- a/TAO/tests/AMI_Buffering/Client_Task.h +++ b/TAO/tests/AMI_Buffering/Client_Task.h @@ -20,12 +20,22 @@ public: /// Constructor Client_Task (CORBA::ORB_ptr orb); + /// Terminate the loop + void terminate_loop (void); + /// Thread entry point int svc (void); private: /// Reference to the ORB CORBA::ORB_var orb_; + + /// A mutex, synchronize access to the termination flag + TAO_SYNCH_MUTEX mutex_; + + /// Termination flag, set to 1 when the client wants this task to + /// exit + int terminate_loop_; }; #include "ace/post.h" diff --git a/TAO/tests/AMI_Buffering/client.cpp b/TAO/tests/AMI_Buffering/client.cpp index 2a34690bdff..462a70e860f 100644 --- a/TAO/tests/AMI_Buffering/client.cpp +++ b/TAO/tests/AMI_Buffering/client.cpp @@ -23,7 +23,7 @@ const int TIMEOUT_MILLISECONDS = 50; const int BUFFER_SIZE = 64 * PAYLOAD_LENGTH; /// Check that no more than 10% of the messages are not sent. -const double PROGRESS_TOLERANCE = 0.9; +const double LIVENESS_TOLERANCE = 0.9; /// Factor in GIOP overhead in the buffer size test const double GIOP_OVERHEAD = 0.9; @@ -114,6 +114,26 @@ main (int argc, char *argv[]) CORBA::ORB_init (argc, argv, "", ACE_TRY_ENV); ACE_TRY_CHECK; + CORBA::Object_var poa_object = + orb->resolve_initial_references("RootPOA", ACE_TRY_ENV); + ACE_TRY_CHECK; + + PortableServer::POA_var root_poa = + PortableServer::POA::_narrow (poa_object.in (), ACE_TRY_ENV); + ACE_TRY_CHECK; + + 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 (ACE_TRY_ENV); + ACE_TRY_CHECK; + + poa_manager->activate (ACE_TRY_ENV); + ACE_TRY_CHECK; + if (parse_args (argc, argv) != 0) return 1; @@ -205,14 +225,19 @@ main (int argc, char *argv[]) "ERROR: No test was configured\n")); } + client_task.terminate_loop (); + client_task.thr_mgr ()->wait (); - + ami_buffering->shutdown (ACE_TRY_ENV); ACE_TRY_CHECK; ami_buffering_admin->shutdown (ACE_TRY_ENV); ACE_TRY_CHECK; + root_poa->destroy (1, 1, ACE_TRY_ENV); + ACE_TRY_CHECK; + orb->destroy (ACE_TRY_ENV); ACE_TRY_CHECK; } @@ -305,14 +330,13 @@ configure_policies (CORBA::ORB_ptr orb, } int -run_progress_test (Test::AMI_AMI_BufferingHandler_ptr reply_handler, +run_liveness_test (Test::AMI_AMI_BufferingHandler_ptr reply_handler, Test::AMI_Buffering_ptr ami_buffering, Test::AMI_Buffering_ptr flusher, Test::AMI_Buffering_Admin_ptr ami_buffering_admin, CORBA::Environment &ACE_TRY_ENV) { - ACE_DEBUG ((LM_DEBUG, "Liveness test\n")); - + ACE_DEBUG ((LM_DEBUG, ".... checking for liveness\n")); int test_failed = 0; // Get back in sync with the server... @@ -325,14 +349,14 @@ run_progress_test (Test::AMI_AMI_BufferingHandler_ptr reply_handler, ami_buffering_admin->request_count (ACE_TRY_ENV); ACE_CHECK_RETURN (-1); - int progress_test_iterations = int(send_count); + int liveness_test_iterations = int(send_count); Test::Payload payload (PAYLOAD_LENGTH); payload.length (PAYLOAD_LENGTH); for (int j = 0; j != PAYLOAD_LENGTH; ++j) payload[j] = CORBA::Octet(j % 256); - for (int i = 0; i != progress_test_iterations; ++i) + for (int i = 0; i != liveness_test_iterations; ++i) { ami_buffering->sendc_receive_data (reply_handler, payload, @@ -348,7 +372,7 @@ run_progress_test (Test::AMI_AMI_BufferingHandler_ptr reply_handler, // expect it to fall too far behind, i.e. at least 90% of the // messages should be delivered.... CORBA::ULong expected = - CORBA::ULong (PROGRESS_TOLERANCE * send_count); + CORBA::ULong (LIVENESS_TOLERANCE * send_count); if (receive_count < expected) { @@ -465,15 +489,15 @@ run_message_count (CORBA::ORB_ptr orb, } } - int progress_test_failed = - run_progress_test (reply_handler.in (), + int liveness_test_failed = + run_liveness_test (reply_handler.in (), ami_buffering, flusher.in (), ami_buffering_admin, ACE_TRY_ENV); ACE_CHECK_RETURN (-1); - if (progress_test_failed) + if (liveness_test_failed) test_failed = 1; return test_failed; @@ -581,15 +605,15 @@ run_timeout (CORBA::ORB_ptr orb, } } - int progress_test_failed = - run_progress_test (reply_handler.in (), + int liveness_test_failed = + run_liveness_test (reply_handler.in (), ami_buffering, flusher.in (), ami_buffering_admin, ACE_TRY_ENV); ACE_CHECK_RETURN (-1); - if (progress_test_failed) + if (liveness_test_failed) test_failed = 1; return test_failed; @@ -703,16 +727,18 @@ run_timeout_reactive (CORBA::ORB_ptr orb, } } - int progress_test_failed = - run_progress_test (reply_handler.in (), +#if 0 + int liveness_test_failed = + run_liveness_test (reply_handler.in (), ami_buffering, flusher.in (), ami_buffering_admin, ACE_TRY_ENV); ACE_CHECK_RETURN (-1); - if (progress_test_failed) + if (liveness_test_failed) test_failed = 1; +#endif /* 0 */ return test_failed; @@ -822,15 +848,15 @@ run_buffer_size (CORBA::ORB_ptr orb, } } - int progress_test_failed = - run_progress_test (reply_handler.in (), + int liveness_test_failed = + run_liveness_test (reply_handler.in (), ami_buffering, flusher.in (), ami_buffering_admin, ACE_TRY_ENV); ACE_CHECK_RETURN (-1); - if (progress_test_failed) + if (liveness_test_failed) test_failed = 1; return test_failed; diff --git a/TAO/tests/AMI_Buffering/run_timeout_reactive.pl b/TAO/tests/AMI_Buffering/run_timeout_reactive.pl new file mode 100755 index 00000000000..31f09190b88 --- /dev/null +++ b/TAO/tests/AMI_Buffering/run_timeout_reactive.pl @@ -0,0 +1,65 @@ +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; + +$admin_iorfile = PerlACE::LocalFile ("admin.ior"); +$server_iorfile = PerlACE::LocalFile ("server.ior"); + +unlink $admin_iorfile; +unlink $server_iorfile; + +my $AD = new PerlACE::Process ("admin", "-o $admin_iorfile"); +my $SV = new PerlACE::Process ("server", "-o $server_iorfile"); +my $CL = new PerlACE::Process ("client", + " -k file://$server_iorfile " + ."-a file://$admin_iorfile " + ."-r "); + +$AD->Spawn (); + +if (PerlACE::waitforfile_timed ($admin_iorfile, 10) == -1) { + print STDERR "ERROR: cannot find file <$admin_iorfile>\n"; + $AD->Kill (); $AD->TimedWait (1); + exit 1; +} + +$SV->Spawn (); + +if (PerlACE::waitforfile_timed ($server_iorfile, 10) == -1) { + print STDERR "ERROR: cannot find file <$server_iorfile>\n"; + $AD->Kill (); $AD->TimedWait (1); + $SV->Kill (); $SV->TimedWait (1); + exit 1; +} + +$client = $CL->SpawnWaitKill (300); + +if ($client != 0) { + print STDERR "ERROR: client returned $client\n"; + $status = 1; +} + +$server = $SV->WaitKill (10); + +if ($server != 0) { + print STDERR "ERROR: server returned $server\n"; + $status = 1; +} + +$admin = $AD->WaitKill (10); + +if ($admin != 0) { + print STDERR "ERROR: admin returned $admin\n"; + $status = 1; +} + +unlink $server_iorfile; +unlink $admin_iorfile; + +exit $status; diff --git a/TAO/tests/Oneway_Buffering/client.cpp b/TAO/tests/Oneway_Buffering/client.cpp index 38b154f4ad7..7c10393f717 100644 --- a/TAO/tests/Oneway_Buffering/client.cpp +++ b/TAO/tests/Oneway_Buffering/client.cpp @@ -22,7 +22,7 @@ const int TIMEOUT_MILLISECONDS = 50; const int BUFFER_SIZE = 64 * PAYLOAD_LENGTH; /// Check that no more than 10% of the messages are not sent. -const double PROGRESS_TOLERANCE = 0.9; +const double LIVENESS_TOLERANCE = 0.9; /// Factor in GIOP overhead in the buffer size test const double GIOP_OVERHEAD = 0.9; @@ -85,6 +85,7 @@ run_message_count (CORBA::ORB_ptr orb, Test::Oneway_Buffering_ptr oneway_buffering, Test::Oneway_Buffering_Admin_ptr oneway_buffering_admin, CORBA::Environment &ACE_TRY_ENV); + int run_timeout (CORBA::ORB_ptr orb, Test::Oneway_Buffering_ptr oneway_buffering, @@ -296,11 +297,12 @@ configure_policies (CORBA::ORB_ptr orb, } int -run_progress_test (Test::Oneway_Buffering_ptr oneway_buffering, +run_liveness_test (Test::Oneway_Buffering_ptr oneway_buffering, Test::Oneway_Buffering_ptr flusher, Test::Oneway_Buffering_Admin_ptr oneway_buffering_admin, CORBA::Environment &ACE_TRY_ENV) { + ACE_DEBUG ((LM_DEBUG, ".... checking for liveness\n")); int test_failed = 0; // Get back in sync with the server... @@ -313,14 +315,14 @@ run_progress_test (Test::Oneway_Buffering_ptr oneway_buffering, oneway_buffering_admin->request_count (ACE_TRY_ENV); ACE_CHECK_RETURN (-1); - int progress_test_iterations = int(send_count); + int liveness_test_iterations = int(send_count); Test::Payload payload (PAYLOAD_LENGTH); payload.length (PAYLOAD_LENGTH); for (int j = 0; j != PAYLOAD_LENGTH; ++j) payload[j] = CORBA::Octet(j % 256); - for (int i = 0; i != progress_test_iterations; ++i) + for (int i = 0; i != liveness_test_iterations; ++i) { oneway_buffering->receive_data (payload, ACE_TRY_ENV); ACE_CHECK_RETURN (-1); @@ -334,7 +336,7 @@ run_progress_test (Test::Oneway_Buffering_ptr oneway_buffering, // expect it to fall too far behind, i.e. at least 90% of the // messages should be delivered.... CORBA::ULong expected = - CORBA::ULong (PROGRESS_TOLERANCE * send_count); + CORBA::ULong (LIVENESS_TOLERANCE * send_count); if (receive_count < expected) { @@ -439,14 +441,14 @@ run_message_count (CORBA::ORB_ptr orb, } } - int progress_test_failed = - run_progress_test (oneway_buffering, + int liveness_test_failed = + run_liveness_test (oneway_buffering, flusher.in (), oneway_buffering_admin, ACE_TRY_ENV); ACE_CHECK_RETURN (-1); - if (progress_test_failed) + if (liveness_test_failed) test_failed = 1; return test_failed; @@ -542,14 +544,14 @@ run_timeout (CORBA::ORB_ptr orb, } } - int progress_test_failed = - run_progress_test (oneway_buffering, + int liveness_test_failed = + run_liveness_test (oneway_buffering, flusher.in (), oneway_buffering_admin, ACE_TRY_ENV); ACE_CHECK_RETURN (-1); - if (progress_test_failed) + if (liveness_test_failed) test_failed = 1; @@ -652,14 +654,14 @@ run_timeout_reactive (CORBA::ORB_ptr orb, } } - int progress_test_failed = - run_progress_test (oneway_buffering, + int liveness_test_failed = + run_liveness_test (oneway_buffering, flusher.in (), oneway_buffering_admin, ACE_TRY_ENV); ACE_CHECK_RETURN (-1); - if (progress_test_failed) + if (liveness_test_failed) test_failed = 1; @@ -760,14 +762,14 @@ run_buffer_size (CORBA::ORB_ptr orb, } } - int progress_test_failed = - run_progress_test (oneway_buffering, + int liveness_test_failed = + run_liveness_test (oneway_buffering, flusher.in (), oneway_buffering_admin, ACE_TRY_ENV); ACE_CHECK_RETURN (-1); - if (progress_test_failed) + if (liveness_test_failed) test_failed = 1; return test_failed; -- cgit v1.2.1