diff options
Diffstat (limited to 'TAO/orbsvcs/tests/Transport_Current/IIOP')
12 files changed, 876 insertions, 0 deletions
diff --git a/TAO/orbsvcs/tests/Transport_Current/IIOP/Current_Test_Impl.cpp b/TAO/orbsvcs/tests/Transport_Current/IIOP/Current_Test_Impl.cpp index 84be62c3e9d..6141fb1b9c7 100644 --- a/TAO/orbsvcs/tests/Transport_Current/IIOP/Current_Test_Impl.cpp +++ b/TAO/orbsvcs/tests/Transport_Current/IIOP/Current_Test_Impl.cpp @@ -229,6 +229,145 @@ Current_Test_Impl::invoked_by_client (ACE_ENV_SINGLE_ARG_DECL) ACE_ENV_SINGLE_ARG_DECL); ACE_TRY_CHECK; + TAO::Transport::CurrentTest_var self = + TAO::Transport::CurrentTest::_narrow (selfobject.in () + ACE_ENV_SINGLE_ARG_DECL); + ACE_TRY_CHECK; + + if (TAO_debug_level >= 1) { + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("(%P|%t) server - Making a collocated invocation to invoked_during_upcall().\n"))); + } + self->invoked_during_upcall (ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + } + else + { + if (TAO_debug_level >= 1) + { + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("(%P|%t) server - skipping collocated calls\n"))); + } + + } + +} + +void +Current_Test_Impl::invoked_during_upcall (ACE_ENV_SINGLE_ARG_DECL_NOT_USED) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + if (TAO_debug_level > 2) { + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("(%P|%t) server - Test method invoked ") + ACE_TEXT ("by the server during upcall.\n"))); + } +} + +void +Current_Test_Impl::shutdown (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + if (TAO_debug_level > 2) { + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("(%P|%t) server - shutting down.\n"))); + } + + this->orb_->shutdown (0 + ACE_ENV_ARG_PARAMETER); +} +// -*- C++ -*- + +#include "Current_Test_Impl.h" + +#include "orbsvcs/Transport_Current/TC_IIOPC.h" +#include "orbsvcs/Transport_Current/TCC.h" + +ACE_RCSID (Transport_Current, + Current_Test_Impl, + "$Id$") + + +Current_Test_Impl::Current_Test_Impl (CORBA::ORB_ptr orb, + PortableServer::POA_ptr poa, + int do_collocated_calls) + : orb_ (CORBA::ORB::_duplicate (orb)) + , poa_ (PortableServer::POA::_duplicate (poa)) + , do_collocated_calls_ (do_collocated_calls) +{ +} + +Current_Test_Impl::~Current_Test_Impl (void) +{ +} + +::CORBA::Long +Current_Test_Impl::self_test (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((::CORBA::SystemException)) +{ + return 0; +} + +void +Current_Test_Impl::test_transport_current (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + if (TAO_debug_level > 2) { + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("(%P|%t) server - Testing access to IIOP Transport Current ...\n"))); + } + + CORBA::Object_var tcobject = + this->orb_->resolve_initial_references ("TAO::Transport::IIOP::Current" + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + TAO::Transport::IIOP::Current_var tc = + TAO::Transport::IIOP::Current::_narrow (tcobject.in () + ACE_ENV_SINGLE_ARG_DECL); + ACE_TRY_CHECK; + + if (CORBA::is_nil (tc.in())) + { + ACE_ERROR ((LM_ERROR, + ACE_TEXT ("Unable to narrow down to TAO::Transport::IIOP::Current\n"))); + ACE_THROW (CORBA::INTERNAL ()); + } + + CORBA::String_var rhost (tc->remote_host ()); + CORBA::String_var lhost (tc->local_host ()); + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("(%P|%t) server - [%s:%d] -> [%s:%d]\n"), + rhost.in (), tc->remote_port (), + lhost.in (), tc->local_port ())); + + if (TAO_debug_level > 2) { + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("(%P|%t) server - Successfully accessed IIOP Transport Current\n"))); + } +} + + + +void +Current_Test_Impl::invoked_by_client (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + if (TAO_debug_level >= 1) { + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("(%P|%t) server - Test method invoked by client.\n"))); + } + + this->test_transport_current (ACE_ENV_SINGLE_ARG_DECL); + ACE_TRY_CHECK; + + if (this->do_collocated_calls_) + { + CORBA::Object_var selfobject = + poa_->servant_to_reference (this + ACE_ENV_SINGLE_ARG_DECL); + ACE_TRY_CHECK; + TAO::Transport::Current_Test_var self = TAO::Transport::Current_Test::_narrow (selfobject.in () ACE_ENV_SINGLE_ARG_DECL); diff --git a/TAO/orbsvcs/tests/Transport_Current/IIOP/IIOP.mpc b/TAO/orbsvcs/tests/Transport_Current/IIOP/IIOP.mpc index 271c07bfdaf..e8dc8e713f3 100644 --- a/TAO/orbsvcs/tests/Transport_Current/IIOP/IIOP.mpc +++ b/TAO/orbsvcs/tests/Transport_Current/IIOP/IIOP.mpc @@ -82,3 +82,45 @@ project(*Client): taoclient, tc, pi, dynamicinterface { ../Framework/Current_Test.idl } } +// -*- MPC -*- +// $Id$ + +project(*Server): taoserver, tc, pi_server { + + idlflags += -o ../Framework + + libs += TAO_TC_IIOP + includes += ../Framework + + Source_Files { + ../Framework/server.cpp + ../Framework/Server_Request_Interceptor.cpp + Current_Test_Impl.cpp + IIOP_Server_Request_Interceptor.cpp + IIOP_Server_Main.cpp + IIOP_Tester.cpp + } + + IDL_Files { + ../Framework/Current_Test.idl + } +} + +project(*Client): taoclient, tc, pi, dynamicinterface { + + after += *Server* + + includes += ../Framework + libs += TAO_TC_IIOP + + idlflags += -o ../Framework + + Source_Files { + ../Framework/Client_Request_Interceptor.cpp + ../Framework/client.cpp + IIOP_Tester.cpp + } + IDL_Files { + ../Framework/Current_Test.idl + } +} diff --git a/TAO/orbsvcs/tests/Transport_Current/IIOP/IIOP_Server_Main.cpp b/TAO/orbsvcs/tests/Transport_Current/IIOP/IIOP_Server_Main.cpp index cce444d8662..3bd1b2bb12e 100644 --- a/TAO/orbsvcs/tests/Transport_Current/IIOP/IIOP_Server_Main.cpp +++ b/TAO/orbsvcs/tests/Transport_Current/IIOP/IIOP_Server_Main.cpp @@ -21,3 +21,26 @@ ACE_TMAIN (int argc, Test::IIOP_Server_Request_Interceptor cri ("test_orb", test_transport_current); return server_main (argc, argv, &cri); } +// -*- C++ -*- + +// $Id$ + +#include "IIOP_Server_Request_Interceptor.h" + +/// Prototype +int server_main (int argc, + ACE_TCHAR *argv[], + Test::Server_Request_Interceptor *cri); + +int +test_transport_current (CORBA::ORB_ptr orb + ACE_ENV_ARG_DECL) ACE_THROW_SPEC ((CORBA::SystemException, + CORBA::UserException)); + +int +ACE_TMAIN (int argc, + ACE_TCHAR *argv[]) +{ + Test::IIOP_Server_Request_Interceptor cri ("test_orb", test_transport_current); + return server_main (argc, argv, &cri); +} diff --git a/TAO/orbsvcs/tests/Transport_Current/IIOP/IIOP_Server_Request_Interceptor.cpp b/TAO/orbsvcs/tests/Transport_Current/IIOP/IIOP_Server_Request_Interceptor.cpp index 92950ce0b7f..bbc77e6b8f0 100644 --- a/TAO/orbsvcs/tests/Transport_Current/IIOP/IIOP_Server_Request_Interceptor.cpp +++ b/TAO/orbsvcs/tests/Transport_Current/IIOP/IIOP_Server_Request_Interceptor.cpp @@ -321,3 +321,326 @@ namespace Test { } } +// -*- C++ -*- + +#include "ace/Log_Msg.h" +#include "tao/ORB_Constants.h" +#include "orbsvcs/Transport_Current/TC_IIOPC.h" + +ACE_RCSID (ForwardRequest, + Server_Request_Interceptor, + "$Id$") + +#include "IIOP_Server_Request_Interceptor.h" + +namespace Test { + + using namespace TAO; + + IIOP_Server_Request_Interceptor::IIOP_Server_Request_Interceptor (const char* orbid, TEST test) + : Server_Request_Interceptor (orbid, test) + , iiop_test_successful_ (true) + , mult_thr_test_successful_ (true) + { + } + + IIOP_Server_Request_Interceptor::~IIOP_Server_Request_Interceptor (void) + { + } + + char * + IIOP_Server_Request_Interceptor::name (ACE_ENV_SINGLE_ARG_DECL_NOT_USED) + ACE_THROW_SPEC ((CORBA::SystemException)) + { + return CORBA::string_dup ("II SRI"); + } + + /// + TAO::Transport::IIOP::Current_ptr + IIOP_Server_Request_Interceptor::resolve_iiop_transport_current (const char* orbid + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)) + { + CORBA::String_var name (this->name ()); + + int tmpargc = 0; + CORBA::ORB_var orb = CORBA::ORB_init (tmpargc, + 0, + orbid + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + CORBA::Object_var tcobject = + orb->resolve_initial_references (ACE_TEXT_ALWAYS_CHAR ("TAO::Transport::IIOP::Current") + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + return TAO::Transport::IIOP::Current::_narrow (tcobject.in () + ACE_ENV_ARG_PARAMETER); + } + + /// On every request, a client-supplied (via the context) id is used + /// as index in an array, where we store the endpoint + void + IIOP_Server_Request_Interceptor::push_request_info (size_t requestID + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)) + { + CORBA::String_var name (this->name ()); + + TAO::Transport::IIOP::Current_var tc = + resolve_iiop_transport_current (this->orb_id_.in () + ACE_ENV_ARG_PARAMETER); + + CORBA::String_var host (tc->remote_host()); + EndPoint ep (tc->remote_port(), host.in ()); + + if (requestID < sizeof (endPoints_)) + endPoints_[requestID] = ep; + else + ACE_ERROR ((LM_ERROR, + ACE_TEXT ("%s (%P|%t) ") + ACE_TEXT ("push_request_info: Can't track that many requests %d\n"), + name.in (), + requestID)); + + } + + void + IIOP_Server_Request_Interceptor::pop_request_info (size_t requestID) + { + static EndPoint dummy; + CORBA::String_var name (this->name ()); + + if (requestID >= sizeof (endPoints_)) + { + ACE_ERROR ((LM_ERROR, + ACE_TEXT ("%s (%P|%t) ") + ACE_TEXT ("pop_request_info: Can't track that many requests %d\n"), + name.in (), + requestID)); + return; + } + + TAO::Transport::IIOP::Current_var tc = + resolve_iiop_transport_current (this->orb_id_.in () + ACE_ENV_ARG_PARAMETER); + + CORBA::String_var host (tc->remote_host()); + EndPoint ep (tc->remote_port(), host.in ()); + + if (ep != endPoints_[requestID]) + { + ACE_ERROR ((LM_ERROR, + ACE_TEXT ("%s (%P|%t) ") + ACE_TEXT ("pop_request_info: The expected host and port don't match for request %d\n"), + name.in (), + requestID)); + return; + } + + endPoints_[requestID] = dummy; + } + + + /// Checks if all the endpoints, encountered on the way in have been + /// cleaned on the way out of the interception point + bool + IIOP_Server_Request_Interceptor::self_test (void) + { + CORBA::String_var name (this->name ()); + bool has_remaining_endpoints = false; + for (size_t count = 0; + count < sizeof (endPoints_); + count ++) + { + if (endPoints_[count].port_ != 0) + { + has_remaining_endpoints = true; + ACE_ERROR ((LM_ERROR, + ACE_TEXT ("%s (%S|%t) Endpoint at ") + ACE_TEXT ("index=%d is not been removed yet\n"), + name.in ())); + } + } + + return Server_Request_Interceptor::self_test () + && iiop_test_successful_ + && !has_remaining_endpoints; + } + + + + void + IIOP_Server_Request_Interceptor::inbound_process_context (PortableInterceptor::ServerRequestInfo_ptr ri + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)) + { + CORBA::String_var name (this->name ()); + CORBA::String_var op (ri->operation(ACE_ENV_ARG_PARAMETER)); + ACE_CHECK; + + if (TAO_debug_level >=1) + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT("%s (%P|%t) Intercepted operation %s ()\n"), + name.in (), + op.in ())); + + ACE_TRY + { + IOP::ServiceId id = Transport::CurrentTest::ContextTag; + IOP::ServiceContext_var sc = + ri->get_request_service_context (id + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + const char *buf = + ACE_reinterpret_cast (const char *, sc->context_data.get_buffer ()); + + long requestID = ACE_OS::atoi (buf); + + this->push_request_info (requestID); + } + ACE_CATCHANY + { + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("%s (%P|%t) Service context") + ACE_TEXT (" is unavailable when invoking %s (). ") + ACE_TEXT ("A colocated invocation would have ") + ACE_TEXT ("no service context.\n"), + name.in (), + op.in ())); + } + ACE_ENDTRY; + + } + + void + IIOP_Server_Request_Interceptor::outbound_process_context (PortableInterceptor::ServerRequestInfo_ptr ri + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)) + { + IOP::ServiceId id = Transport::CurrentTest::ContextTag; + + IOP::ServiceContext_var sc = + ri->get_request_service_context (id ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + const char *buf = + ACE_reinterpret_cast (const char *, sc->context_data.get_buffer ()); + + this->pop_request_info (ACE_OS::atoi (buf)); + } + + + + + + + void + IIOP_Server_Request_Interceptor::receive_request_service_contexts (PortableInterceptor::ServerRequestInfo_ptr ri + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException, + PortableInterceptor::ForwardRequest)) + { + ACE_TRY + { + inbound_process_context (ri ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + } + ACE_CATCHANY + { + CORBA::String_var name (this->name ()); + ACE_ERROR ((LM_ERROR, + ACE_TEXT("%s (%P|%t) Inbound_process_context failed in ") + ACE_TEXT(" receive_request_service_contexts.\n"), + name.in ())); + } + ACE_ENDTRY; + + Server_Request_Interceptor::receive_request_service_contexts (ri ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + } + + + void + IIOP_Server_Request_Interceptor::send_reply (PortableInterceptor::ServerRequestInfo_ptr ri + ACE_ENV_ARG_DECL_NOT_USED) + ACE_THROW_SPEC ((CORBA::SystemException)) + { + ACE_TRY + { + outbound_process_context (ri ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + } + ACE_CATCHANY + { + CORBA::String_var name (this->name ()); + ACE_ERROR ((LM_ERROR, + ACE_TEXT("%s (%P|%t) Outbound_process_context failed in ") + ACE_TEXT("send_reply.\n"), + name.in ())); + } + ACE_ENDTRY; + + Server_Request_Interceptor::send_reply (ri ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + } + + void + IIOP_Server_Request_Interceptor::send_exception (PortableInterceptor::ServerRequestInfo_ptr ri + ACE_ENV_ARG_DECL_NOT_USED) + ACE_THROW_SPEC ((CORBA::SystemException, + PortableInterceptor::ForwardRequest)) + { + ACE_TRY + { + outbound_process_context (ri ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + + } + ACE_CATCHANY + { + CORBA::String_var name (this->name ()); + ACE_ERROR ((LM_ERROR, + ACE_TEXT("%s (%P|%t) Outbound_process_context failed in ") + ACE_TEXT("send_exception.\n"), + name.in ())); + + } + ACE_ENDTRY; + + Server_Request_Interceptor::send_exception (ri ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + } + + void + IIOP_Server_Request_Interceptor::send_other (PortableInterceptor::ServerRequestInfo_ptr ri + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException, + PortableInterceptor::ForwardRequest)) + { + ACE_TRY + { + outbound_process_context (ri ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + } + ACE_CATCHANY + { + CORBA::String_var name (this->name ()); + ACE_ERROR ((LM_ERROR, + ACE_TEXT("%s (%P|%t) Outbound_process_context failed in ") + ACE_TEXT("send_other.\n"), + name.in ())); + } + ACE_ENDTRY; + + Server_Request_Interceptor::send_other (ri ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + } + +} diff --git a/TAO/orbsvcs/tests/Transport_Current/IIOP/IIOP_Server_Request_Interceptor.h b/TAO/orbsvcs/tests/Transport_Current/IIOP/IIOP_Server_Request_Interceptor.h index 00b45f19ee6..4184e4bbc7a 100644 --- a/TAO/orbsvcs/tests/Transport_Current/IIOP/IIOP_Server_Request_Interceptor.h +++ b/TAO/orbsvcs/tests/Transport_Current/IIOP/IIOP_Server_Request_Interceptor.h @@ -322,3 +322,165 @@ namespace Test #endif /* _MSC_VER */ #endif /* ISERVER_REQUEST_INTERCEPTOR_H */ +// -*- C++ -*- + +//============================================================================= +/** + * @file IIOP_Server_Request_Interceptor.h + * + * $Id$ + * + * Implementation header for the server request interceptor for the + * IIOP_Threading test. + * + * @author Iliyan Jeliazkov <iliyan@ociweb.com> + * @author Ciju John <johnc@ociweb.com> + */ +//============================================================================= + +#ifndef ISERVER_REQUEST_INTERCEPTOR_H +#define ISERVER_REQUEST_INTERCEPTOR_H + +#include "ace/config-all.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "Server_Request_Interceptor.h" +#include "orbsvcs/Transport_Current/IIOP_Transport_Current.h" + +#if defined(_MSC_VER) +#pragma warning(push) +#pragma warning(disable:4250) +#endif /* _MSC_VER */ + +namespace Test +{ + + class IIOP_Server_Request_Interceptor + : public virtual Test::Server_Request_Interceptor + , public virtual TAO_Local_RefCounted_Object + { + public: + + /// Constructor. + IIOP_Server_Request_Interceptor (const char* orbid, TEST test); + + /// Destructor. + virtual ~IIOP_Server_Request_Interceptor (); + + /// queries the status of the test + bool self_test (); + + /** + * @name Methods Required by the Server Request Interceptor + * Interface + * + * These are methods that must be implemented since they are pure + * virtual in the abstract base class. They are the canonical + * methods required for all server request interceptors. + */ + //@{ + /// Return the name of this ServerRequestinterceptor. + virtual char * name (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException)); + + /// incomming interception point + virtual void receive_request_service_contexts (PortableInterceptor::ServerRequestInfo_ptr + ACE_ENV_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException, + PortableInterceptor::ForwardRequest)); + + /// outgoing interception point + virtual void send_reply (PortableInterceptor::ServerRequestInfo_ptr ri + ACE_ENV_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException)); + + /// outgoing interception point + virtual void send_exception (PortableInterceptor::ServerRequestInfo_ptr ri + ACE_ENV_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException, + PortableInterceptor::ForwardRequest)); + + /// outgoing interception point + virtual void send_other (PortableInterceptor::ServerRequestInfo_ptr ri + ACE_ENV_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException, + PortableInterceptor::ForwardRequest)); + //@} + + protected: + + /// process incomming requests context + void inbound_process_context + (PortableInterceptor::ServerRequestInfo_ptr ri + ACE_ENV_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException)); + + /// process outgoing requests context + void outbound_process_context + (PortableInterceptor::ServerRequestInfo_ptr ri + ACE_ENV_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException)); + + /// saves the incomming request info + void push_request_info (size_t requestID + ACE_ENV_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException)); + + /// clears the outgoing request info + void pop_request_info (size_t requestID); + + TAO::Transport::IIOP::Current_ptr resolve_iiop_transport_current (const char* orbid + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)); + + private: + + /// transport ID dtata structure + typedef struct EP { + CORBA::UShort port_; + CORBA::String_var host_; + + EP () + : port_(0) + , host_ () + {}; + + EP (CORBA::UShort port, const char* host) + : port_(port) + , host_ (host) + {}; + + bool operator== (const struct EP &ep) const + { + return (this->port_ == ep.port_) && + (strcmp (this->host_.in (), ep.host_.in ()) == 0); + }; + bool operator!= (const struct EP &ep) const + { + return !(this->operator== (ep)); + }; + + } EndPoint; + + private: + + /// IIOPTraits test status + bool iiop_test_successful_; + + /// Multi-threaded test status + bool mult_thr_test_successful_; + + /// Endpoints hash table + EndPoint endPoints_[1001]; + }; + +}; /* namespace Test */ + +#if defined(_MSC_VER) +#pragma warning(pop) +#endif /* _MSC_VER */ + +#endif /* ISERVER_REQUEST_INTERCEPTOR_H */ diff --git a/TAO/orbsvcs/tests/Transport_Current/IIOP/IIOP_Tester.cpp b/TAO/orbsvcs/tests/Transport_Current/IIOP/IIOP_Tester.cpp index 2b87ba0e285..ec76e46eee5 100644 --- a/TAO/orbsvcs/tests/Transport_Current/IIOP/IIOP_Tester.cpp +++ b/TAO/orbsvcs/tests/Transport_Current/IIOP/IIOP_Tester.cpp @@ -79,3 +79,84 @@ test_transport_current (CORBA::ORB_ptr orb return 0; } +// -*- C++ -*- + +// $Id$ + +#include "orbsvcs/Transport_Current/IIOP_Transport_Current.h" + +using namespace TAO; + + +/// Test referencing the TC data outside of the context of an upcall, +/// or a client-side interceptor + +int +test_transport_current (CORBA::ORB_ptr orb + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException, + CORBA::UserException)) +{ + // Get the Current object. + CORBA::Object_var tcobject = + orb->resolve_initial_references (ACE_TEXT_ALWAYS_CHAR ("TAO::Transport::IIOP::Current") + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + + if (TAO_debug_level >= 1) + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("Tester (%P|%t) Resolved initial reference for IIOP::Current\n"))); + + Transport::IIOP::Current_var tc = + Transport::IIOP::Current::_narrow (tcobject.in () + ACE_ENV_SINGLE_ARG_DECL); + ACE_TRY_CHECK; + + if (TAO_debug_level >= 1) + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("Tester (%P|%t) Narowed the IIOP Transport Current\n"))); + + if (CORBA::is_nil (tc.in ())) + { + ACE_ERROR ((LM_ERROR, + ACE_TEXT ("Tester (%P|%t) ERROR: Could not resolve ") + ACE_TEXT ("TAO::Transport::IIOP::Current object.\n"))); + + ACE_TRY_THROW (CORBA::INTERNAL ()); + } + + ::CORBA::String_var rhost (tc->remote_host (ACE_ENV_SINGLE_ARG_PARAMETER)); + ACE_TRY_CHECK; + + ::CORBA::String_var lhost (tc->local_host (ACE_ENV_SINGLE_ARG_PARAMETER)); + ACE_TRY_CHECK; + + ::CORBA::Long id = tc->id (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_TRY_CHECK; + + ::TAO::CounterT bs = tc->bytes_sent (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_TRY_CHECK; + + ::TAO::CounterT br = tc->bytes_received (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_TRY_CHECK; + + ::TAO::CounterT rs = tc->messages_sent (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_TRY_CHECK; + + ::TAO::CounterT rr = tc->messages_received (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_TRY_CHECK; + + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("Tester (%P|%t) Transport [%q] [%s:%d -> %s:%d] ") + ACE_TEXT ("Sent/Received [bytes=%q/%q, messages=%q/%q]\n"), + (ACE_UINT64)id, + rhost.in (), tc->remote_port (ACE_ENV_SINGLE_ARG_PARAMETER), + lhost.in (), tc->local_port (ACE_ENV_SINGLE_ARG_PARAMETER), + (ACE_UINT64)bs, + (ACE_UINT64)br, + (ACE_UINT64)rs, + (ACE_UINT64)rr)); + return 0; +} + diff --git a/TAO/orbsvcs/tests/Transport_Current/IIOP/README b/TAO/orbsvcs/tests/Transport_Current/IIOP/README index 0d1ea8db316..d83d071a53a 100644 --- a/TAO/orbsvcs/tests/Transport_Current/IIOP/README +++ b/TAO/orbsvcs/tests/Transport_Current/IIOP/README @@ -48,3 +48,28 @@ creation (as it did in lab conditions). See ../Framework/README for more detail on how and what contexts are tested. +This test has two parts, which run automatically: + +Part 1: + +IIOP_Transport_Current test: Demonstrates how in the application the +user can resolve the IIOP_Transport_Current and use it to obtain +IIOP-related transport properties for the current Transport. + +Part 2: + +Multi threading test: In this test the server has a Thread Pool. Using +Interceptors, the test tracks the transports that are used in the +individual invocations at various stage of the up-call. This validates +that the TC framework accurately tracks the correct transport for an +invocation, no matter what stage of the up-call in a multi-threaded +environment. + +We force creation of multiple transport by using the: static +Client_Strategy_Factory "-ORBTransportMuxStrategy exclusive" +directive. While this isn't 100% guaranteed, having multiple client +threads and making simultaneous invocations should trigger new transport +creation (as it did in lab conditions). + +See ../Framework/README for more detail on how and what contexts are +tested. diff --git a/TAO/orbsvcs/tests/Transport_Current/IIOP/client_dynamic.conf b/TAO/orbsvcs/tests/Transport_Current/IIOP/client_dynamic.conf index 21ba9549422..84beeafa7bf 100644 --- a/TAO/orbsvcs/tests/Transport_Current/IIOP/client_dynamic.conf +++ b/TAO/orbsvcs/tests/Transport_Current/IIOP/client_dynamic.conf @@ -4,3 +4,6 @@ dynamic TAO_Transport_IIOP_Current_Loader Service_Object * TAO_TC_IIOP:_make_TAO static Client_Strategy_Factory "-ORBTransportMuxStrategy exclusive" dynamic TAO_Transport_Current_Loader Service_Object * TAO_TC:_make_TAO_Transport_Current_Loader() "" dynamic TAO_Transport_IIOP_Current_Loader Service_Object * TAO_TC_IIOP:_make_TAO_Transport_IIOP_Current_Loader() "" +static Client_Strategy_Factory "-ORBTransportMuxStrategy exclusive" +dynamic TAO_Transport_Current_Loader Service_Object * TAO_TC:_make_TAO_Transport_Current_Loader() "" +dynamic TAO_Transport_IIOP_Current_Loader Service_Object * TAO_TC_IIOP:_make_TAO_Transport_IIOP_Current_Loader() "" diff --git a/TAO/orbsvcs/tests/Transport_Current/IIOP/client_static.conf b/TAO/orbsvcs/tests/Transport_Current/IIOP/client_static.conf index 0a2ca3b3151..ba19c06e24f 100644 --- a/TAO/orbsvcs/tests/Transport_Current/IIOP/client_static.conf +++ b/TAO/orbsvcs/tests/Transport_Current/IIOP/client_static.conf @@ -4,3 +4,6 @@ static Client_Strategy_Factory "-ORBTransportMuxStrategy exclusive" #static TAO_Transport_Current_Loader "" #static TAO_Transport_IIOP_Current_Loader "" static Client_Strategy_Factory "-ORBTransportMuxStrategy exclusive" +#static TAO_Transport_Current_Loader "" +#static TAO_Transport_IIOP_Current_Loader "" +static Client_Strategy_Factory "-ORBTransportMuxStrategy exclusive" diff --git a/TAO/orbsvcs/tests/Transport_Current/IIOP/run_test.pl b/TAO/orbsvcs/tests/Transport_Current/IIOP/run_test.pl index cbb4b0a6e7d..4eedc12459b 100755 --- a/TAO/orbsvcs/tests/Transport_Current/IIOP/run_test.pl +++ b/TAO/orbsvcs/tests/Transport_Current/IIOP/run_test.pl @@ -140,3 +140,74 @@ if ($server != 0) { unlink $iorfile; exit $status; +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::Run_Test; + +$status = 0; + +$client = PerlACE::LocalFile ("client"); + +$mode = shift (@ARGV); +if ( $mode =~ /-dynamic/) { + $client_conf_file = PerlACE::LocalFile ("client_dynamic.conf"); + $server_conf_file = PerlACE::LocalFile ("server_dynamic.conf"); +} +elsif ( $mode =~ /-static/) { + $client_conf_file = PerlACE::LocalFile ("client_static.conf"); + $server_conf_file = PerlACE::LocalFile ("server_static.conf"); +} +else { + print STDERR "Unknown $mode. Specify -static or -dynamic\n"; + exit 1; +} + +$iorfile = PerlACE::LocalFile ("server.ior"); +unlink $iorfile; + +if (PerlACE::is_vxworks_test()) { + $SV = new PerlACE::ProcessVX ("server", + "@ARGV -c 0 -ORBSvcConf $server_conf_file -o server.ior"); +} +else { + $SV = new PerlACE::Process ("server", + "@ARGV -c 0 -ORBSvcConf $server_conf_file -o $iorfile"); +} + +$CL = new PerlACE::Process ($client, + "@ARGV -n 1 -ORBSvcConf $client_conf_file -k file://$iorfile"); + +print STDERR $SV->CommandLine()."\n"; +$SV->Spawn (); + +if (PerlACE::waitforfile_timed ($iorfile, + $PerlACE::wait_interval_for_process_creation) == -1) { + print STDERR "$0: ERROR: cannot find file <$iorfile>\n"; + $SV->Kill (); $SV->TimedWait (1); + exit 1; +} + +print STDERR $CL->CommandLine()."\n"; +$client = $CL->SpawnWaitKill (300); + +if ($client != 0) { + print STDERR "$0: ERROR: client returned $client\n"; + $status = 1; +} + +$server = $SV->WaitKill (10); + +if ($server != 0) { + print STDERR "$0: ERROR: server returned $server\n"; + $status = 1; +} + +unlink $iorfile; + +exit $status; diff --git a/TAO/orbsvcs/tests/Transport_Current/IIOP/server_dynamic.conf b/TAO/orbsvcs/tests/Transport_Current/IIOP/server_dynamic.conf index ac6f857d827..cfc55520f9d 100644 --- a/TAO/orbsvcs/tests/Transport_Current/IIOP/server_dynamic.conf +++ b/TAO/orbsvcs/tests/Transport_Current/IIOP/server_dynamic.conf @@ -2,3 +2,5 @@ dynamic TAO_Transport_Current_Loader Service_Object * TAO_TC:_make_TAO_Transport dynamic TAO_Transport_IIOP_Current_Loader Service_Object * TAO_TC_IIOP:_make_TAO_Transport_IIOP_Current_Loader() "" dynamic TAO_Transport_Current_Loader Service_Object * TAO_TC:_make_TAO_Transport_Current_Loader() "" dynamic TAO_Transport_IIOP_Current_Loader Service_Object * TAO_TC_IIOP:_make_TAO_Transport_IIOP_Current_Loader() "" +dynamic TAO_Transport_Current_Loader Service_Object * TAO_TC:_make_TAO_Transport_Current_Loader() "" +dynamic TAO_Transport_IIOP_Current_Loader Service_Object * TAO_TC_IIOP:_make_TAO_Transport_IIOP_Current_Loader() "" diff --git a/TAO/orbsvcs/tests/Transport_Current/IIOP/server_static.conf b/TAO/orbsvcs/tests/Transport_Current/IIOP/server_static.conf index 2649683408d..18bc6c22fe6 100644 --- a/TAO/orbsvcs/tests/Transport_Current/IIOP/server_static.conf +++ b/TAO/orbsvcs/tests/Transport_Current/IIOP/server_static.conf @@ -2,3 +2,5 @@ static TAO_Transport_Current_Loader "" static TAO_Transport_IIOP_Current_Loader "" static TAO_Transport_Current_Loader "" static TAO_Transport_IIOP_Current_Loader "" +static TAO_Transport_Current_Loader "" +static TAO_Transport_IIOP_Current_Loader "" |