From: prascle Date: Tue, 11 Oct 2005 07:00:18 +0000 (+0000) Subject: PR: more test on LifeCycleCORBA X-Git-Tag: BR_UnitTests_20051010 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=e18dc345872d09dd899df279a0a4699e49c8ea8e;p=modules%2Fkernel.git PR: more test on LifeCycleCORBA --- diff --git a/src/LifeCycleCORBA/Test/LifeCycleCORBATest.cxx b/src/LifeCycleCORBA/Test/LifeCycleCORBATest.cxx index d8b20edf7..dc30adfed 100644 --- a/src/LifeCycleCORBA/Test/LifeCycleCORBATest.cxx +++ b/src/LifeCycleCORBA/Test/LifeCycleCORBATest.cxx @@ -49,6 +49,7 @@ LifeCycleCORBATest::setUp() string s = "file:"; s += theFileName; //s="local"; + //s="with_logger"; CPPUNIT_ASSERT(! setenv("SALOME_trace",s.c_str(),1)); // 1: overwrite ofstream traceFile; @@ -431,7 +432,7 @@ LifeCycleCORBATest::testFindOrLoad_Component_ParamsLocalContainer() Engines::TestComponent_var m1; m1 = Engines::TestComponent::_narrow(mycompo); - // --- check container is on local computer + // --- check that container is on local computer CPPUNIT_ASSERT(!CORBA::is_nil(m1)); Engines::Container_var c1 = m1->GetContainerRef(); @@ -465,7 +466,7 @@ LifeCycleCORBATest::testFindOrLoad_Component_ParamsContainerName() Engines::TestComponent_var m1; m1 = Engines::TestComponent::_narrow(mycompo); - // --- check container has good name + // --- check that container has good name CPPUNIT_ASSERT(!CORBA::is_nil(m1)); Engines::Container_var c1 = m1->GetContainerRef(); @@ -476,6 +477,114 @@ LifeCycleCORBATest::testFindOrLoad_Component_ParamsContainerName() CPPUNIT_ASSERT(cname1.find(containerName) != string::npos); } +// ============================================================================ +/*! + * Check FindOrLoad_Component on remote computer + */ +// ============================================================================ + +void +LifeCycleCORBATest::testFindOrLoad_Component_RemoteComputer() +{ + SALOME_LifeCycleCORBA _LCC(&_NS); + + string remoteHost = GetRemoteHost(); + + string containerName = remoteHost; + containerName += "/aContainer"; + DEVTRACE("containerName = " << containerName); + Engines::Component_var mycompo1 = + _LCC.FindOrLoad_Component(containerName.c_str(),"SalomeTestComponent"); + CPPUNIT_ASSERT(!CORBA::is_nil(mycompo1)); + + // --- check narrow + + Engines::TestComponent_var m1; + m1 = Engines::TestComponent::_narrow(mycompo1); + + // --- check that container is on good computer + + CPPUNIT_ASSERT(!CORBA::is_nil(m1)); + Engines::Container_var c1 = m1->GetContainerRef(); + CPPUNIT_ASSERT(!CORBA::is_nil(c1)); + string hostname1 = c1->getHostName(); + CPPUNIT_ASSERT_EQUAL(hostname1, remoteHost); +} + +// ============================================================================ +/*! + * Check FindOrLoad_Component with params on remote computer + * params empty except hostname + */ +// ============================================================================ + +void +LifeCycleCORBATest::testFindOrLoad_Component_ParamsRemoteComputer() +{ + SALOME_LifeCycleCORBA _LCC(&_NS); + + string remoteHost = GetRemoteHost(); + + Engines::MachineParameters params; + _LCC.preSet(params); + params.hostname = remoteHost.c_str(); + + Engines::Component_var mycompo1 = + _LCC.FindOrLoad_Component(params,"SalomeTestComponent"); + CPPUNIT_ASSERT(!CORBA::is_nil(mycompo1)); + + // --- check narrow + + Engines::TestComponent_var m1; + m1 = Engines::TestComponent::_narrow(mycompo1); + + // --- check that container is on good computer + + CPPUNIT_ASSERT(!CORBA::is_nil(m1)); + Engines::Container_var c1 = m1->GetContainerRef(); + CPPUNIT_ASSERT(!CORBA::is_nil(c1)); + string hostname1 = c1->getHostName(); + CPPUNIT_ASSERT_EQUAL(hostname1, remoteHost); +} + +// ============================================================================ +/*! + * Check FindOrLoad_Component with params on remote computer + * params empty except hostname and container_name + */ +// ============================================================================ + +void +LifeCycleCORBATest::testFindOrLoad_Component_ParamsRemoteComputer2() +{ + SALOME_LifeCycleCORBA _LCC(&_NS); + + string remoteHost = GetRemoteHost(); + + Engines::MachineParameters params; + _LCC.preSet(params); + params.hostname = remoteHost.c_str(); + params.container_name = "anotherContainer"; + + Engines::Component_var mycompo1 = + _LCC.FindOrLoad_Component(params,"SalomeTestComponent"); + CPPUNIT_ASSERT(!CORBA::is_nil(mycompo1)); + + // --- check narrow + + Engines::TestComponent_var m1; + m1 = Engines::TestComponent::_narrow(mycompo1); + + // --- check that container is on good computer + + CPPUNIT_ASSERT(!CORBA::is_nil(m1)); + Engines::Container_var c1 = m1->GetContainerRef(); + CPPUNIT_ASSERT(!CORBA::is_nil(c1)); + string hostname1 = c1->getHostName(); + CPPUNIT_ASSERT_EQUAL(hostname1, remoteHost); +} + + // ============================================================================ /*! @@ -488,3 +597,48 @@ LifeCycleCORBATest::testFindOrLoad_Component_ParamsContainerName() // { // } + + + + + + + +// ============================================================================ +/*! + * Get a remote HostName in the Resource Catalog + */ +// ============================================================================ + +string LifeCycleCORBATest::GetRemoteHost() +{ + SALOME_LifeCycleCORBA _LCC(&_NS); + + CORBA::Object_var obj = _NS.Resolve("/ContainerManager"); + CPPUNIT_ASSERT(!CORBA::is_nil(obj)); + Engines::ContainerManager_var containerManager = + Engines::ContainerManager::_narrow(obj); + CPPUNIT_ASSERT(!CORBA::is_nil(containerManager)); + + Engines::MachineParameters params; + _LCC.preSet(params); // empty params to get all the machines + + Engines::MachineList_var hostList = + containerManager->GetFittingResources(params,"SalomeTestComponent"); + CPPUNIT_ASSERT(hostList->length() > 1); + + string localHost = GetHostname(); + string remoteHost; + for (unsigned int i=0; i < hostList->length(); i++) + { + const char* aMachine = hostList[i]; + string machine(aMachine); + if (machine != localHost) + { + remoteHost = machine; + break; + } + } + CPPUNIT_ASSERT(remoteHost != ""); + return remoteHost; +} diff --git a/src/LifeCycleCORBA/Test/LifeCycleCORBATest.hxx b/src/LifeCycleCORBA/Test/LifeCycleCORBATest.hxx index 56858599c..2f457f09d 100644 --- a/src/LifeCycleCORBA/Test/LifeCycleCORBATest.hxx +++ b/src/LifeCycleCORBA/Test/LifeCycleCORBATest.hxx @@ -23,6 +23,10 @@ class LifeCycleCORBATest : public CppUnit::TestFixture CPPUNIT_TEST( testFindOrLoad_Component_ParamsEmpty ); CPPUNIT_TEST( testFindOrLoad_Component_ParamsLocalContainer ); CPPUNIT_TEST( testFindOrLoad_Component_ParamsContainerName ); + CPPUNIT_TEST( testFindOrLoad_Component_RemoteComputer ); + CPPUNIT_TEST( testFindOrLoad_Component_ParamsRemoteComputer ); + CPPUNIT_TEST( testFindOrLoad_Component_ParamsRemoteComputer2 ); +// CPPUNIT_TEST( testFindOrLoad_Component_ ); // CPPUNIT_TEST( testFindOrLoad_Component_ ); // CPPUNIT_TEST( ); // CPPUNIT_TEST( ); @@ -44,9 +48,14 @@ public: void testFindOrLoad_Component_ParamsEmpty(); void testFindOrLoad_Component_ParamsLocalContainer(); void testFindOrLoad_Component_ParamsContainerName(); + void testFindOrLoad_Component_RemoteComputer(); + void testFindOrLoad_Component_ParamsRemoteComputer(); + void testFindOrLoad_Component_ParamsRemoteComputer2(); +// void testFindOrLoad_Component_(); // void testFindOrLoad_Component_(); protected: + std::string GetRemoteHost(); CORBA::ORB_var _orb; SALOME_NamingService _NS; };