Exemple #1
0
int
run(int, char**, const Ice::CommunicatorPtr& communicator,
    const Ice::InitializationData&)
{
    communicator->getProperties()->setProperty("TestAdapter.Endpoints", "default -p 12010");
    communicator->getProperties()->setProperty("TestAdapter.AdapterId", "test");
    Ice::ObjectAdapterPtr adapter = communicator->createObjectAdapter("TestAdapter");
    Ice::ObjectPrx prx = adapter->add(new MyDerivedClassI, communicator->stringToIdentity("test"));
    //adapter->activate(); // Don't activate OA to ensure collocation is used.

    test(!prx->ice_getConnection());

    Test::MyClassPrx allTests(const Ice::CommunicatorPtr&);
    allTests(communicator);

    return EXIT_SUCCESS;
}
/**
 * \brief Connect the adapter to a connection of a proxy
 *
 * This step is required for the server to be able to send callbacks back
 * over the connection of this proxy
 */
void	CommunicatorSingleton::connect(Ice::ObjectPrx proxy) {
	debug(LOG_DEBUG, DEBUG_LOG, 0, "adding adapter to connection of %s",
		astro::demangle(typeid(*proxy).name()).c_str());
	proxy->ice_getConnection()->setAdapter(getAdapter());
}
Exemple #3
0
TimeoutPrx
allTests(const Ice::CommunicatorPtr& communicator)
{
    string sref = "timeout:default -p 12010";
    Ice::ObjectPrx obj = communicator->stringToProxy(sref);
    test(obj);

    TimeoutPrx timeout = TimeoutPrx::checkedCast(obj);
    test(timeout);

    cout << "testing connect timeout... " << flush;
    {
        //
        // Expect ConnectTimeoutException.
        //
        TimeoutPrx to = TimeoutPrx::uncheckedCast(obj->ice_timeout(100));
        timeout->holdAdapter(500);
        try
        {
            to->op();
            test(false);
        }
        catch(const Ice::ConnectTimeoutException&)
        {
            // Expected.
        }
    }
    {
        //
        // Expect success.
        //
        timeout->op(); // Ensure adapter is active.
        TimeoutPrx to = TimeoutPrx::uncheckedCast(obj->ice_timeout(1000));
        timeout->holdAdapter(500);
        try
        {
            to->op();
        }
        catch(const Ice::ConnectTimeoutException&)
        {
            test(false);
        }
    }
    cout << "ok" << endl;

    // The sequence needs to be large enough to fill the write/recv buffers
    ByteSeq seq(2000000);

    cout << "testing connection timeout... " << flush;
    {
        //
        // Expect TimeoutException.
        //
        TimeoutPrx to = TimeoutPrx::uncheckedCast(obj->ice_timeout(100));
        timeout->holdAdapter(500);
        try
        {
            to->sendData(seq);
            test(false);
        }
        catch(const Ice::TimeoutException&)
        {
            // Expected.
        }
    }
    {
        //
        // Expect success.
        //
        timeout->op(); // Ensure adapter is active.
        TimeoutPrx to = TimeoutPrx::uncheckedCast(obj->ice_timeout(1000));
        timeout->holdAdapter(500);
        try
        {
            ByteSeq seq(1000000);
            to->sendData(seq);
        }
        catch(const Ice::TimeoutException&)
        {
            test(false);
        }
    }
    cout << "ok" << endl;

    cout << "testing invocation timeout... " << flush;
    {
        Ice::ConnectionPtr connection = obj->ice_getConnection();
        TimeoutPrx to = TimeoutPrx::uncheckedCast(obj->ice_invocationTimeout(100));
        test(connection == to->ice_getConnection());
        try
        {
            to->sleep(750);
            test(false);
        }
        catch(const Ice::InvocationTimeoutException&)
        {
        }
        obj->ice_ping();
        to = TimeoutPrx::checkedCast(obj->ice_invocationTimeout(500));
        test(connection == to->ice_getConnection());
        try
        {
            to->sleep(250);
        }
        catch(const Ice::InvocationTimeoutException&)
        {
            test(false);
        }
        test(connection == to->ice_getConnection());
    }
    {
        //
        // Expect InvocationTimeoutException.
        //
        TimeoutPrx to = TimeoutPrx::uncheckedCast(obj->ice_invocationTimeout(100));
        CallbackPtr cb = new Callback();
        to->begin_sleep(750, newCallback_Timeout_sleep(cb, &Callback::responseEx, &Callback::exceptionEx));
        cb->check();
        obj->ice_ping();
    }
    {
        //
        // Expect success.
        //
        TimeoutPrx to = TimeoutPrx::uncheckedCast(obj->ice_invocationTimeout(500));
        CallbackPtr cb = new Callback();
        to->begin_sleep(250, newCallback_Timeout_sleep(cb, &Callback::response, &Callback::exception));
        cb->check();
    }
    {
        //
        // Backward compatible connection timeouts
        //
        TimeoutPrx to = TimeoutPrx::uncheckedCast(obj->ice_invocationTimeout(-2)->ice_timeout(100));
        Ice::ConnectionPtr con;
        try
        {
            con = to->ice_getConnection();
            to->sleep(750);
            test(false);
        }
        catch(const Ice::TimeoutException&)
        {
            try
            {
                con->getInfo();
                test(false);
            }
            catch(const Ice::TimeoutException&)
            {
                // Connection got closed as well.
            }
        }
        obj->ice_ping();

        try
        {
            con = to->ice_getConnection();
            to->end_sleep(to->begin_sleep(750));
            test(false);
        }
        catch(const Ice::TimeoutException&)
        {
            try
            {
                con->getInfo();
                test(false);
            }
            catch(const Ice::TimeoutException&)
            {
                // Connection got closed as well.
            }
        }
        obj->ice_ping();
    }
    cout << "ok" << endl;

    cout << "testing close timeout... " << flush;
    {
        TimeoutPrx to = TimeoutPrx::checkedCast(obj->ice_timeout(100));
        Ice::ConnectionPtr connection = to->ice_getConnection();
        timeout->holdAdapter(500);
        connection->close(false);
        try
        {
            connection->getInfo(); // getInfo() doesn't throw in the closing state.
        }
        catch(const Ice::LocalException&)
        {
            test(false);
        }
        IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(500));
        try
        {
            connection->getInfo();
            test(false);
        }
        catch(const Ice::CloseConnectionException&)
        {
            // Expected.
        }
        timeout->op(); // Ensure adapter is active.
    }
    cout << "ok" << endl;

    cout << "testing timeout overrides... " << flush;
    {
        //
        // Test Ice.Override.Timeout. This property overrides all
        // endpoint timeouts.
        //
        Ice::InitializationData initData;
        initData.properties = communicator->getProperties()->clone();
        initData.properties->setProperty("Ice.Override.Timeout", "100");
        Ice::CommunicatorPtr comm = Ice::initialize(initData);
        TimeoutPrx to = TimeoutPrx::checkedCast(comm->stringToProxy(sref));
        timeout->holdAdapter(500);
        try
        {
            to->sendData(seq);
            test(false);
        }
        catch(const Ice::TimeoutException&)
        {
            // Expected.
        }
        //
        // Calling ice_timeout() should have no effect.
        //
        timeout->op(); // Ensure adapter is active.
        to = TimeoutPrx::checkedCast(to->ice_timeout(1000));
        timeout->holdAdapter(500);
        try
        {
            to->sendData(seq);
            test(false);
        }
        catch(const Ice::TimeoutException&)
        {
            // Expected.
        }
        comm->destroy();
    }
    {
        //
        // Test Ice.Override.ConnectTimeout.
        //
        Ice::InitializationData initData;
        initData.properties = communicator->getProperties()->clone();
        initData.properties->setProperty("Ice.Override.ConnectTimeout", "250");
        Ice::CommunicatorPtr comm = Ice::initialize(initData);
        timeout->holdAdapter(750);
        TimeoutPrx to = TimeoutPrx::uncheckedCast(comm->stringToProxy(sref));
        try
        {
            to->op();
            test(false);
        }
        catch(const Ice::ConnectTimeoutException&)
        {
            // Expected.
        }
        //
        // Calling ice_timeout() should have no effect on the connect timeout.
        //
        timeout->op(); // Ensure adapter is active.
        timeout->holdAdapter(750);
        to = TimeoutPrx::uncheckedCast(to->ice_timeout(1000));
        try
        {
            to->op();
            test(false);
        }
        catch(const Ice::ConnectTimeoutException&)
        {
            // Expected.
        }
        //
        // Verify that timeout set via ice_timeout() is still used for requests.
        //
        timeout->op(); // Ensure adapter is active.
        to = TimeoutPrx::uncheckedCast(to->ice_timeout(100));
        to->ice_getConnection(); // Establish connection
        timeout->holdAdapter(750);
        try
        {
            to->sendData(seq);
            test(false);
        }
        catch(const Ice::TimeoutException&)
        {
            // Expected.
        }
        comm->destroy();
    }
    {
        //
        // Test Ice.Override.CloseTimeout.
        //
        Ice::InitializationData initData;
        initData.properties = communicator->getProperties()->clone();
        initData.properties->setProperty("Ice.Override.CloseTimeout", "100");
        Ice::CommunicatorPtr comm = Ice::initialize(initData);
        Ice::ConnectionPtr connection = comm->stringToProxy(sref)->ice_getConnection();
        timeout->holdAdapter(500);
        IceUtil::Time now = IceUtil::Time::now();
        comm->destroy();
        test(IceUtil::Time::now() - now < IceUtil::Time::milliSeconds(400));
    }
    cout << "ok" << endl;

    cout << "testing invocation timeouts with collocated calls... " << flush;
    {
        communicator->getProperties()->setProperty("TimeoutCollocated.AdapterId", "timeoutAdapter");

        Ice::ObjectAdapterPtr adapter = communicator->createObjectAdapter("TimeoutCollocated");
        adapter->activate();

        TimeoutPrx timeout = TimeoutPrx::uncheckedCast(adapter->addWithUUID(new TimeoutI()));
        timeout = timeout->ice_invocationTimeout(100);
        try
        {
            timeout->sleep(300);
            test(false);
        }
        catch(const Ice::InvocationTimeoutException&)
        {
        }

        try
        {
            timeout->end_sleep(timeout->begin_sleep(300));
            test(false);
        }
        catch(const Ice::InvocationTimeoutException&)
        {
        }

        TimeoutPrx batchTimeout = timeout->ice_batchOneway();
        batchTimeout->ice_ping();
        batchTimeout->ice_ping();
        batchTimeout->ice_ping();

        timeout->ice_invocationTimeout(-1)->begin_sleep(300); // Keep the server thread pool busy.
        try
        {
            batchTimeout->ice_flushBatchRequests();
            test(false);
        }
        catch(const Ice::InvocationTimeoutException&)
        {
        }

        batchTimeout->ice_ping();
        batchTimeout->ice_ping();
        batchTimeout->ice_ping();

        timeout->ice_invocationTimeout(-1)->begin_sleep(300); // Keep the server thread pool busy.
        try
        {
            batchTimeout->end_ice_flushBatchRequests(batchTimeout->begin_ice_flushBatchRequests());
            test(false);
        }
        catch(const Ice::InvocationTimeoutException&)
        {
        }

        adapter->destroy();
    }
    cout << "ok" << endl;

    return timeout;
}
Exemple #4
0
MetricsPrx
allTests(const Ice::CommunicatorPtr& communicator, const CommunicatorObserverIPtr& obsv)
{
    MetricsPrx metrics = MetricsPrx::checkedCast(communicator->stringToProxy("metrics:default -p 12010"));

    cout << "testing metrics admin facet checkedCast... " << flush;
    Ice::ObjectPrx admin = communicator->getAdmin()->ice_collocationOptimized(false);
    Ice::PropertiesAdminPrx clientProps = Ice::PropertiesAdminPrx::checkedCast(admin, "Properties");
    IceMX::MetricsAdminPrx clientMetrics = IceMX::MetricsAdminPrx::checkedCast(admin, "Metrics");
    test(clientProps && clientMetrics);

    admin = metrics->getAdmin();
    Ice::PropertiesAdminPrx serverProps = Ice::PropertiesAdminPrx::checkedCast(admin, "Properties");
    IceMX::MetricsAdminPrx serverMetrics = IceMX::MetricsAdminPrx::checkedCast(admin, "Metrics");
    test(serverProps && serverMetrics);

    UpdateCallbackI* update = new UpdateCallbackI(serverProps);
    Ice::NativePropertiesAdminPtr::dynamicCast(communicator->findAdminFacet("Properties"))->addUpdateCallback(update);

    cout << "ok" << endl;

    Ice::PropertyDict props;

    cout << "testing group by none..." << flush;

    props["IceMX.Metrics.View.GroupBy"] = "none";
    updateProps(clientProps, serverProps, update, props);
    
#ifndef ICE_OS_WINRT
    int threadCount = 4;
#else
    int threadCount = 3; // No endpoint host resolver thread with WinRT.
#endif

    Ice::Long timestamp;
    IceMX::MetricsView view = clientMetrics->getMetricsView("View", timestamp);
    test(view["Connection"].size() == 1 && view["Connection"][0]->current == 1 && view["Connection"][0]->total == 1);
    test(view["Thread"].size() == 1 && view["Thread"][0]->current == threadCount && 
         view["Thread"][0]->total == threadCount);
    cout << "ok" << endl;

    cout << "testing group by id..." << flush;

    props["IceMX.Metrics.View.GroupBy"] = "id";
    updateProps(clientProps, serverProps, update, props);

    metrics->ice_ping();
    metrics->ice_ping();
    metrics->ice_connectionId("Con1")->ice_ping();
    metrics->ice_connectionId("Con1")->ice_ping();
    metrics->ice_connectionId("Con1")->ice_ping();

    view = clientMetrics->getMetricsView("View", timestamp);
    test(static_cast<int>(view["Thread"].size()) == threadCount);
    test(view["Connection"].size() == 2);
    test(view["Invocation"].size() == 1);

    IceMX::InvocationMetricsPtr invoke = IceMX::InvocationMetricsPtr::dynamicCast(view["Invocation"][0]);
    test(invoke->id.find("[ice_ping]") > 0 && invoke->current == 0 && invoke->total == 5);

    test(invoke->remotes.size() == 2);
    test(invoke->remotes[0]->total = 2);
    test(invoke->remotes[1]->total = 3);

    view = serverMetrics->getMetricsView("View", timestamp);
    test(view["Thread"].size() > 4);
    test(view["Connection"].size() == 2);
    test(view["Dispatch"].size() == 1);
    test(view["Dispatch"][0]->current <= 1 && view["Dispatch"][0]->total == 5);
    test(view["Dispatch"][0]->id.find("[ice_ping]") > 0);

    metrics->ice_getConnection()->close(false);
    metrics->ice_connectionId("Con1")->ice_getConnection()->close(false);

    waitForCurrent(clientMetrics, "View", "Connection", 0);
    waitForCurrent(serverMetrics, "View", "Connection", 0);

    clearView(clientProps, serverProps, update);
    
    cout << "ok" << endl;

    cout << "testing connection metrics... " << flush;

    props["IceMX.Metrics.View.Map.Connection.GroupBy"] = "none";
    updateProps(clientProps, serverProps, update, props, "Connection");

    test(clientMetrics->getMetricsView("View", timestamp)["Connection"].empty());
    test(serverMetrics->getMetricsView("View", timestamp)["Connection"].empty());

    metrics->ice_ping();

    IceMX::ConnectionMetricsPtr cm1, sm1, cm2, sm2;
    cm1 = IceMX::ConnectionMetricsPtr::dynamicCast(clientMetrics->getMetricsView("View", timestamp)["Connection"][0]);
    sm1 = IceMX::ConnectionMetricsPtr::dynamicCast(serverMetrics->getMetricsView("View", timestamp)["Connection"][0]);
    sm1 = getServerConnectionMetrics(serverMetrics, 25);
    test(cm1->total == 1 && sm1->total == 1);

    metrics->ice_ping();

    cm2 = IceMX::ConnectionMetricsPtr::dynamicCast(clientMetrics->getMetricsView("View", timestamp)["Connection"][0]);
    sm2 = getServerConnectionMetrics(serverMetrics, 50);

    test(cm2->sentBytes - cm1->sentBytes == 45); // 45 for ice_ping request
    test(cm2->receivedBytes - cm1->receivedBytes == 25); // 25 bytes for ice_ping response
    test(sm2->receivedBytes - sm1->receivedBytes == 45);
    test(sm2->sentBytes - sm1->sentBytes == 25);

    cm1 = cm2;
    sm1 = sm2;

    Test::ByteSeq bs;
    metrics->opByteS(bs);

    cm2 = IceMX::ConnectionMetricsPtr::dynamicCast(clientMetrics->getMetricsView("View", timestamp)["Connection"][0]);
    sm2 = getServerConnectionMetrics(serverMetrics, sm1->sentBytes + cm2->receivedBytes - cm1->receivedBytes);
    Ice::Long requestSz = cm2->sentBytes - cm1->sentBytes;
    Ice::Long replySz = cm2->receivedBytes - cm1->receivedBytes;

    cm1 = cm2;
    sm1 = sm2;

    bs.resize(456);
    metrics->opByteS(bs);

    cm2 = IceMX::ConnectionMetricsPtr::dynamicCast(clientMetrics->getMetricsView("View", timestamp)["Connection"][0]);
    sm2 = getServerConnectionMetrics(serverMetrics, sm1->sentBytes + replySz);

    // 4 is for the seq variable size
    test(cm2->sentBytes - cm1->sentBytes == requestSz + static_cast<int>(bs.size()) + 4);
    test(cm2->receivedBytes - cm1->receivedBytes == replySz);
    test(sm2->receivedBytes - sm1->receivedBytes == requestSz + static_cast<int>(bs.size()) + 4);
    test(sm2->sentBytes - sm1->sentBytes == replySz);

    cm1 = cm2;
    sm1 = sm2;

    bs.resize(1024 * 1024 * 10); // Try with large amount of data which should be sent in several chunks
    metrics->opByteS(bs);

    cm2 = IceMX::ConnectionMetricsPtr::dynamicCast(clientMetrics->getMetricsView("View", timestamp)["Connection"][0]);
    sm2 = getServerConnectionMetrics(serverMetrics, sm1->sentBytes + replySz);

    // 4 is for the seq variable size
    test(cm2->sentBytes - cm1->sentBytes == requestSz + static_cast<int>(bs.size()) + 4);
    test(cm2->receivedBytes - cm1->receivedBytes == replySz);
    test(sm2->receivedBytes - sm1->receivedBytes == requestSz + static_cast<int>(bs.size()) + 4);
    test(sm2->sentBytes - sm1->sentBytes == replySz);
    
    props["IceMX.Metrics.View.Map.Connection.GroupBy"] = "state";
    updateProps(clientProps, serverProps, update, props, "Connection");

    map<string, IceMX::MetricsPtr> map;
    
    map = toMap(serverMetrics->getMetricsView("View", timestamp)["Connection"]);

    test(map["active"]->current == 1);

    ControllerPrx controller = ControllerPrx::checkedCast(communicator->stringToProxy("controller:default -p 12011"));
    controller->hold();

    map = toMap(clientMetrics->getMetricsView("View", timestamp)["Connection"]);
    test(map["active"]->current == 1);
    map = toMap(serverMetrics->getMetricsView("View", timestamp)["Connection"]);
    test(map["holding"]->current == 1);

    metrics->ice_getConnection()->close(false);

    map = toMap(clientMetrics->getMetricsView("View", timestamp)["Connection"]);
    test(map["closing"]->current == 1);
    map = toMap(serverMetrics->getMetricsView("View", timestamp)["Connection"]);
    test(map["holding"]->current == 1);

    controller->resume();

    map = toMap(serverMetrics->getMetricsView("View", timestamp)["Connection"]);
    test(map["holding"]->current == 0);

    props["IceMX.Metrics.View.Map.Connection.GroupBy"] = "none";
    updateProps(clientProps, serverProps, update, props, "Connection");

    metrics->ice_getConnection()->close(false);

    metrics->ice_timeout(500)->ice_ping();
    controller->hold();
    try
    {
        metrics->ice_timeout(500)->ice_ping();
        test(false);
    }
    catch(const Ice::TimeoutException&)
    {
    }
    controller->resume();

    cm1 = IceMX::ConnectionMetricsPtr::dynamicCast(clientMetrics->getMetricsView("View", timestamp)["Connection"][0]);
    while(true)
    {
        sm1 = IceMX::ConnectionMetricsPtr::dynamicCast(
            serverMetrics->getMetricsView("View", timestamp)["Connection"][0]);
        if(sm1-> failures >= 2)
        {
            break;
        }
        IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(10));
    }

    test(cm1->failures == 2 && sm1->failures >= 1);

    checkFailure(clientMetrics, "Connection", cm1->id, "Ice::TimeoutException", 1);
    checkFailure(clientMetrics, "Connection", cm1->id, "Ice::ConnectTimeoutException", 1);
    checkFailure(serverMetrics, "Connection", sm1->id, "Ice::ConnectionLostException");

    MetricsPrx m = metrics->ice_timeout(500)->ice_connectionId("Con1");
    m->ice_ping();

    testAttribute(clientMetrics, clientProps, update, "Connection", "parent", "Communicator");
    //testAttribute(clientMetrics, clientProps, update, "Connection", "id", "");
    testAttribute(clientMetrics, clientProps, update, "Connection", "endpoint", "tcp -h 127.0.0.1 -p 12010 -t 500");

    testAttribute(clientMetrics, clientProps, update, "Connection", "endpointType", "1");
    testAttribute(clientMetrics, clientProps, update, "Connection", "endpointIsDatagram", "false");
    testAttribute(clientMetrics, clientProps, update, "Connection", "endpointIsSecure", "false");
    testAttribute(clientMetrics, clientProps, update, "Connection", "endpointTimeout", "500");
    testAttribute(clientMetrics, clientProps, update, "Connection", "endpointCompress", "false");
    testAttribute(clientMetrics, clientProps, update, "Connection", "endpointHost", "127.0.0.1");
    testAttribute(clientMetrics, clientProps, update, "Connection", "endpointPort", "12010");

    testAttribute(clientMetrics, clientProps, update, "Connection", "incoming", "false");
    testAttribute(clientMetrics, clientProps, update, "Connection", "adapterName", "");
    testAttribute(clientMetrics, clientProps, update, "Connection", "connectionId", "Con1");
    testAttribute(clientMetrics, clientProps, update, "Connection", "localHost", "127.0.0.1");
    //testAttribute(clientMetrics, clientProps, update, "Connection", "localPort", "");
    testAttribute(clientMetrics, clientProps, update, "Connection", "remoteHost", "127.0.0.1");
    testAttribute(clientMetrics, clientProps, update, "Connection", "remotePort", "12010");
    testAttribute(clientMetrics, clientProps, update, "Connection", "mcastHost", "");
    testAttribute(clientMetrics, clientProps, update, "Connection", "mcastPort", "");
    
    m->ice_getConnection()->close(false);

    waitForCurrent(clientMetrics, "View", "Connection", 0);
    waitForCurrent(serverMetrics, "View", "Connection", 0);

    cout << "ok" << endl;

    cout << "testing connection establishment metrics... " << flush;

    props["IceMX.Metrics.View.Map.ConnectionEstablishment.GroupBy"] = "id";
    updateProps(clientProps, serverProps, update, props, "ConnectionEstablishment");
    test(clientMetrics->getMetricsView("View", timestamp)["ConnectionEstablishment"].empty());

    metrics->ice_ping();
    
    test(clientMetrics->getMetricsView("View", timestamp)["ConnectionEstablishment"].size() == 1);
    IceMX::MetricsPtr m1 = clientMetrics->getMetricsView("View", timestamp)["ConnectionEstablishment"][0];
    test(m1->current == 0 && m1->total == 1 && m1->id == "127.0.0.1:12010");

    metrics->ice_getConnection()->close(false);
    controller->hold();
    try
    {
        communicator->stringToProxy("test:tcp -p 12010 -h 127.0.0.1")->ice_timeout(10)->ice_ping();
        test(false);
    }
    catch(const Ice::ConnectTimeoutException&)
    {
    }
    catch(const Ice::LocalException&)
    {
        test(false);
    }
    controller->resume();
    test(clientMetrics->getMetricsView("View", timestamp)["ConnectionEstablishment"].size() == 1);
    m1 = clientMetrics->getMetricsView("View", timestamp)["ConnectionEstablishment"][0];
    test(m1->id == "127.0.0.1:12010" && m1->total == 3 && m1->failures == 2);

    checkFailure(clientMetrics, "ConnectionEstablishment", m1->id, "Ice::ConnectTimeoutException", 2);

    Connect c(metrics);
    testAttribute(clientMetrics, clientProps, update, "ConnectionEstablishment", "parent", "Communicator", c);
    testAttribute(clientMetrics, clientProps, update, "ConnectionEstablishment", "id", "127.0.0.1:12010", c);
    testAttribute(clientMetrics, clientProps, update, "ConnectionEstablishment", "endpoint",  
                  "tcp -h 127.0.0.1 -p 12010", c);

    testAttribute(clientMetrics, clientProps, update, "ConnectionEstablishment", "endpointType", "1", c);
    testAttribute(clientMetrics, clientProps, update, "ConnectionEstablishment", "endpointIsDatagram", "false", c);
    testAttribute(clientMetrics, clientProps, update, "ConnectionEstablishment", "endpointIsSecure", "false", c);
    testAttribute(clientMetrics, clientProps, update, "ConnectionEstablishment", "endpointTimeout", "-1", c);
    testAttribute(clientMetrics, clientProps, update, "ConnectionEstablishment", "endpointCompress", "false", c);
    testAttribute(clientMetrics, clientProps, update, "ConnectionEstablishment", "endpointHost", "127.0.0.1", c);
    testAttribute(clientMetrics, clientProps, update, "ConnectionEstablishment", "endpointPort", "12010", c);

    cout << "ok" << endl;

    //
    // Ice doesn't do any endpoint lookup with WinRT, the WinRT
    // runtime takes care of if.
    //
#ifndef ICE_OS_WINRT
    cout << "testing endpoint lookup metrics... " << flush;

    props["IceMX.Metrics.View.Map.ConnectionEstablishment.GroupBy"] = "id";
    updateProps(clientProps, serverProps, update, props, "EndpointLookup");
    test(clientMetrics->getMetricsView("View", timestamp)["EndpointLookup"].empty());

    Ice::ObjectPrx prx = communicator->stringToProxy("metrics:default -p 12010 -h localhost");
    prx->ice_ping();
    
    test(clientMetrics->getMetricsView("View", timestamp)["EndpointLookup"].size() == 1);
    m1 = clientMetrics->getMetricsView("View", timestamp)["EndpointLookup"][0];

    test(m1->current <= 1 && m1->total == 1 && m1->id == "tcp -h localhost -p 12010");

    prx->ice_getConnection()->close(false);

    bool dnsException = false;
    try
    {
        communicator->stringToProxy("test:tcp -t 500 -p 12010 -h unknownfoo.zeroc.com")->ice_ping();
        test(false);
    }
    catch(const Ice::DNSException&)
    {
        dnsException = true;
    }
    catch(const Ice::LocalException&)
    {
        // Some DNS servers don't fail on unknown DNS names.
    }
    test(clientMetrics->getMetricsView("View", timestamp)["EndpointLookup"].size() == 2);
    m1 = clientMetrics->getMetricsView("View", timestamp)["EndpointLookup"][1];
    test(m1->id == "tcp -h unknownfoo.zeroc.com -p 12010 -t 500" && m1->total == 2 && 
         (!dnsException || m1->failures == 2));
    if(dnsException)
    {
        checkFailure(clientMetrics, "EndpointLookup", m1->id, "Ice::DNSException", 2);
    }

    c = Connect(prx);

    testAttribute(clientMetrics, clientProps, update, "EndpointLookup", "parent", "Communicator", c);
    testAttribute(clientMetrics, clientProps, update, "EndpointLookup", "id", "tcp -h localhost -p 12010", c);
    testAttribute(clientMetrics, clientProps, update, "EndpointLookup", "endpoint", 
                  "tcp -h localhost -p 12010", c);

    testAttribute(clientMetrics, clientProps, update, "EndpointLookup", "endpointType", "1", c);
    testAttribute(clientMetrics, clientProps, update, "EndpointLookup", "endpointIsDatagram", "false", c);
    testAttribute(clientMetrics, clientProps, update, "EndpointLookup", "endpointIsSecure", "false", c);
    testAttribute(clientMetrics, clientProps, update, "EndpointLookup", "endpointTimeout", "-1", c);
    testAttribute(clientMetrics, clientProps, update, "EndpointLookup", "endpointCompress", "false", c);
    testAttribute(clientMetrics, clientProps, update, "EndpointLookup", "endpointHost", "localhost", c);
    testAttribute(clientMetrics, clientProps, update, "EndpointLookup", "endpointPort", "12010", c);

    cout << "ok" << endl;
#endif

    cout << "testing dispatch metrics... " << flush;

    props["IceMX.Metrics.View.Map.Dispatch.GroupBy"] = "operation";
    updateProps(clientProps, serverProps, update, props, "Dispatch");
    test(serverMetrics->getMetricsView("View", timestamp)["Dispatch"].empty());

    metrics->op();
    try
    {
        metrics->opWithUserException();
        test(false);
    }
    catch(const Test::UserEx&)
    {
    }
    try
    {
        metrics->opWithRequestFailedException();
        test(false);
    }
    catch(const Ice::RequestFailedException&)
    {
    }
    try
    {
        metrics->opWithLocalException();
        test(false);
    }
    catch(const Ice::LocalException&)
    {
    }
    try
    {
        metrics->opWithUnknownException();
        test(false);
    }
    catch(const Ice::UnknownException&)
    {
    }
    try
    {
        metrics->fail();
        test(false);
    }
    catch(const Ice::ConnectionLostException&)
    {
    }

    map = toMap(serverMetrics->getMetricsView("View", timestamp)["Dispatch"]);
    test(map.size() == 6);

    IceMX::DispatchMetricsPtr dm1 = IceMX::DispatchMetricsPtr::dynamicCast(map["op"]);
    test(dm1->current <= 1 && dm1->total == 1 && dm1->failures == 0 && dm1->userException == 0);
    test(dm1->size == 21 && dm1->replySize == 7);

    dm1 = IceMX::DispatchMetricsPtr::dynamicCast(map["opWithUserException"]);
    test(dm1->current <= 1 && dm1->total == 1 && dm1->failures == 0 && dm1->userException == 1);
    test(dm1->size == 38 && dm1->replySize == 23);

    dm1 = IceMX::DispatchMetricsPtr::dynamicCast(map["opWithLocalException"]);
    test(dm1->current <= 1 && dm1->total == 1 && dm1->failures == 1 && dm1->userException == 0);
    checkFailure(serverMetrics, "Dispatch", dm1->id, "Ice::SyscallException", 1);
    test(dm1->size == 39 && dm1->replySize > 7); // Reply contains the exception stack depending on the OS.

    dm1 = IceMX::DispatchMetricsPtr::dynamicCast(map["opWithRequestFailedException"]);
    test(dm1->current <= 1 && dm1->total == 1 && dm1->failures == 1 && dm1->userException == 0);
    checkFailure(serverMetrics, "Dispatch", dm1->id, "Ice::ObjectNotExistException", 1);
    test(dm1->size == 47 && dm1->replySize == 40);

    dm1 = IceMX::DispatchMetricsPtr::dynamicCast(map["opWithUnknownException"]);
    test(dm1->current <= 1 && dm1->total == 1 && dm1->failures == 1 && dm1->userException == 0);
    checkFailure(serverMetrics, "Dispatch", dm1->id, "unknown", 1);
    test(dm1->size == 41 && dm1->replySize == 23);

    InvokeOp op(metrics);

    testAttribute(serverMetrics, serverProps, update, "Dispatch", "parent", "TestAdapter", op);
    testAttribute(serverMetrics, serverProps, update, "Dispatch", "id", "metrics [op]", op);
    testAttribute(serverMetrics, serverProps, update, "Dispatch", "endpoint", "tcp -h 127.0.0.1 -p 12010", op);
    //testAttribute(serverMetrics, serverProps, update, "Dispatch", "connection", "", op);

    testAttribute(serverMetrics, serverProps, update, "Dispatch", "endpointType", "1", op);
    testAttribute(serverMetrics, serverProps, update, "Dispatch", "endpointIsDatagram", "false", op);
    testAttribute(serverMetrics, serverProps, update, "Dispatch", "endpointIsSecure", "false", op);
    testAttribute(serverMetrics, serverProps, update, "Dispatch", "endpointTimeout", "-1", op);
    testAttribute(serverMetrics, serverProps, update, "Dispatch", "endpointCompress", "false", op);
    testAttribute(serverMetrics, serverProps, update, "Dispatch", "endpointHost", "127.0.0.1", op);
    testAttribute(serverMetrics, serverProps, update, "Dispatch", "endpointPort", "12010", op);

    testAttribute(serverMetrics, serverProps, update, "Dispatch", "incoming", "true", op);
    testAttribute(serverMetrics, serverProps, update, "Dispatch", "adapterName", "TestAdapter", op);
    testAttribute(serverMetrics, serverProps, update, "Dispatch", "connectionId", "", op);
    testAttribute(serverMetrics, serverProps, update, "Dispatch", "localHost", "127.0.0.1", op);
    testAttribute(serverMetrics, serverProps, update, "Dispatch", "localPort", "12010", op);
    testAttribute(serverMetrics, serverProps, update, "Dispatch", "remoteHost", "127.0.0.1", op);
    //testAttribute(serverMetrics, serverProps, update, "Dispatch", "remotePort", "12010", op);
    testAttribute(serverMetrics, serverProps, update, "Dispatch", "mcastHost", "", op);
    testAttribute(serverMetrics, serverProps, update, "Dispatch", "mcastPort", "", op);

    testAttribute(serverMetrics, serverProps, update, "Dispatch", "operation", "op", op);
    testAttribute(serverMetrics, serverProps, update, "Dispatch", "identity", "metrics", op);
    testAttribute(serverMetrics, serverProps, update, "Dispatch", "facet", "", op);
    testAttribute(serverMetrics, serverProps, update, "Dispatch", "mode", "twoway", op);

    testAttribute(serverMetrics, serverProps, update, "Dispatch", "context.entry1", "test", op);
    testAttribute(serverMetrics, serverProps, update, "Dispatch", "context.entry2", "", op);
    testAttribute(serverMetrics, serverProps, update, "Dispatch", "context.entry3", "", op);

    cout << "ok" << endl;

    cout << "testing invocation metrics... " << flush;

    props["IceMX.Metrics.View.Map.Invocation.GroupBy"] = "operation";
    props["IceMX.Metrics.View.Map.Invocation.Map.Remote.GroupBy"] = "localPort";
    updateProps(clientProps, serverProps, update, props, "Invocation");
    test(serverMetrics->getMetricsView("View", timestamp)["Invocation"].empty());

    CallbackPtr cb = new Callback();
    metrics->op();
    metrics->end_op(metrics->begin_op());
    metrics->begin_op(newCallback_Metrics_op(cb, &Callback::response, &Callback::exception));
    cb->waitForResponse();

    // User exception
    try
    {
        metrics->opWithUserException();
        test(false);
    }
    catch(const Test::UserEx&)
    {
    }
    try
    {
        metrics->end_opWithUserException(metrics->begin_opWithUserException());
        test(false);
    }
    catch(const Test::UserEx&)
    {
    }
    metrics->begin_opWithUserException(newCallback_Metrics_opWithUserException(
                                           cb, &Callback::response, &Callback::exception));
    cb->waitForResponse();

    // Request failed exception
    try
    {
        metrics->opWithRequestFailedException();
        test(false);
    }
    catch(const Ice::RequestFailedException&)
    {
    }
    try
    {
        metrics->end_opWithRequestFailedException(metrics->begin_opWithRequestFailedException());
        test(false);
    }
    catch(const Ice::RequestFailedException&)
    {
    }
    metrics->begin_opWithRequestFailedException(newCallback_Metrics_opWithRequestFailedException(
                                                    cb, &Callback::response, &Callback::exception));
    cb->waitForResponse();

    // Local exception
    try
    {
        metrics->opWithLocalException();
        test(false);
    }
    catch(const Ice::LocalException&)
    {
    }
    try
    {
        metrics->end_opWithLocalException(metrics->begin_opWithLocalException());
        test(false);
    }
    catch(const Ice::LocalException&)
    {
    }
    metrics->begin_opWithLocalException(newCallback_Metrics_opWithLocalException(
                                            cb, &Callback::response, &Callback::exception));
    cb->waitForResponse();

    // Unknown exception
    try
    {
        metrics->opWithUnknownException();
        test(false);
    }
    catch(const Ice::UnknownException&)
    {
    }
    try
    {
        metrics->end_opWithUnknownException(metrics->begin_opWithUnknownException());
        test(false);
    }
    catch(const Ice::UnknownException&)
    {
    }
    metrics->begin_opWithUnknownException(newCallback_Metrics_opWithUnknownException(
                                              cb, &Callback::response, &Callback::exception));
    cb->waitForResponse();

    // Fail
    try
    {
        metrics->fail();
        test(false);
    }
    catch(const Ice::ConnectionLostException&)
    {
    }
    try
    {
        metrics->end_fail(metrics->begin_fail());
        test(false);
    }
    catch(const Ice::ConnectionLostException&)
    {
    }
    metrics->begin_fail(newCallback_Metrics_fail(cb, &Callback::response, &Callback::exception));
    cb->waitForResponse();

    map = toMap(clientMetrics->getMetricsView("View", timestamp)["Invocation"]);
    test(map.size() == 6);

    IceMX::InvocationMetricsPtr im1;
    IceMX::RemoteMetricsPtr rim1;
    im1 = IceMX::InvocationMetricsPtr::dynamicCast(map["op"]);
    test(im1->current <= 1 && im1->total == 3 && im1->failures == 0 && im1->retry == 0 && im1->remotes.size() == 1);
    rim1 = IceMX::RemoteMetricsPtr::dynamicCast(im1->remotes[0]);
    test(rim1->current == 0 && rim1->total == 3 && rim1->failures == 0);
    test(rim1->size == 63 && rim1->replySize == 21);
    
    im1 = IceMX::InvocationMetricsPtr::dynamicCast(map["opWithUserException"]);
    test(im1->current <= 1 && im1->total == 3 && im1->failures == 0 && im1->retry == 0 && im1->remotes.size() == 1);
    rim1 = IceMX::RemoteMetricsPtr::dynamicCast(im1->remotes[0]);
    test(rim1->current == 0 && rim1->total == 3 && rim1->failures == 0);
    test(rim1->size == 114 && rim1->replySize == 69);
    test(im1->userException == 3);

    im1 = IceMX::InvocationMetricsPtr::dynamicCast(map["opWithLocalException"]);
    test(im1->current <= 1 && im1->total == 3 && im1->failures == 3 && im1->retry == 0 && im1->remotes.size() == 1);
    rim1 = IceMX::RemoteMetricsPtr::dynamicCast(im1->remotes[0]);
    test(rim1->current == 0 && rim1->total == 3 && rim1->failures == 0);
    test(rim1->size == 117 && rim1->replySize > 7);
    checkFailure(clientMetrics, "Invocation", im1->id, "Ice::UnknownLocalException", 3);

    im1 = IceMX::InvocationMetricsPtr::dynamicCast(map["opWithRequestFailedException"]);
    test(im1->current <= 1 && im1->total == 3 && im1->failures == 3 && im1->retry == 0 && im1->remotes.size() == 1);
    rim1 = IceMX::RemoteMetricsPtr::dynamicCast(im1->remotes[0]);
    test(rim1->current == 0 && rim1->total == 3 && rim1->failures == 0);
    test(rim1->size == 141 && rim1->replySize == 120);
    checkFailure(clientMetrics, "Invocation", im1->id, "Ice::ObjectNotExistException", 3);

    im1 = IceMX::InvocationMetricsPtr::dynamicCast(map["opWithUnknownException"]);
    test(im1->current <= 1 && im1->total == 3 && im1->failures == 3 && im1->retry == 0 && im1->remotes.size() == 1);
    rim1 = IceMX::RemoteMetricsPtr::dynamicCast(im1->remotes[0]);
    test(rim1->current == 0 && rim1->total == 3 && rim1->failures == 0);
    test(rim1->size == 123 && rim1->replySize == 69);
    checkFailure(clientMetrics, "Invocation", im1->id, "Ice::UnknownException", 3);

    im1 = IceMX::InvocationMetricsPtr::dynamicCast(map["fail"]);
    test(im1->current <= 1 && im1->total == 3 && im1->failures == 3 && im1->retry == 3 && im1->remotes.size() == 6);
    test(im1->remotes[0]->current == 0 && im1->remotes[0]->total == 1 && im1->remotes[0]->failures == 1);
    test(im1->remotes[1]->current == 0 && im1->remotes[1]->total == 1 && im1->remotes[1]->failures == 1);
    test(im1->remotes[2]->current == 0 && im1->remotes[2]->total == 1 && im1->remotes[2]->failures == 1);
    test(im1->remotes[3]->current == 0 && im1->remotes[3]->total == 1 && im1->remotes[3]->failures == 1);
    test(im1->remotes[4]->current == 0 && im1->remotes[4]->total == 1 && im1->remotes[4]->failures == 1);
    test(im1->remotes[5]->current == 0 && im1->remotes[5]->total == 1 && im1->remotes[5]->failures == 1);
    checkFailure(clientMetrics, "Invocation", im1->id, "Ice::ConnectionLostException", 3);

    testAttribute(clientMetrics, clientProps, update, "Invocation", "parent", "Communicator", op);
    testAttribute(clientMetrics, clientProps, update, "Invocation", "id", "metrics -t -e 1.1 [op]", op);

    testAttribute(clientMetrics, clientProps, update, "Invocation", "operation", "op", op);
    testAttribute(clientMetrics, clientProps, update, "Invocation", "identity", "metrics", op);
    testAttribute(clientMetrics, clientProps, update, "Invocation", "facet", "", op);
    testAttribute(clientMetrics, clientProps, update, "Invocation", "encoding", "1.1", op);
    testAttribute(clientMetrics, clientProps, update, "Invocation", "mode", "twoway", op);
    testAttribute(clientMetrics, clientProps, update, "Invocation", "proxy", 
                  "metrics -t -e 1.1:tcp -h 127.0.0.1 -p 12010", op);

    testAttribute(clientMetrics, clientProps, update, "Invocation", "context.entry1", "test", op);
    testAttribute(clientMetrics, clientProps, update, "Invocation", "context.entry2", "", op);
    testAttribute(clientMetrics, clientProps, update, "Invocation", "context.entry3", "", op);

    cout << "ok" << endl;

    cout << "testing metrics view enable/disable..." << flush;

    Ice::StringSeq disabledViews;
    props["IceMX.Metrics.View.GroupBy"] = "none";
    props["IceMX.Metrics.View.Disabled"] = "0";
    updateProps(clientProps, serverProps, update, props, "Thread");
    test(!clientMetrics->getMetricsView("View", timestamp)["Thread"].empty());
    test(clientMetrics->getMetricsViewNames(disabledViews).size() == 1 && disabledViews.empty());

    props["IceMX.Metrics.View.Disabled"] = "1";
    updateProps(clientProps, serverProps, update, props, "Thread");
    test(clientMetrics->getMetricsView("View", timestamp)["Thread"].empty());
    test(clientMetrics->getMetricsViewNames(disabledViews).empty() && disabledViews.size() == 1);

    clientMetrics->enableMetricsView("View");
    test(!clientMetrics->getMetricsView("View", timestamp)["Thread"].empty());
    test(clientMetrics->getMetricsViewNames(disabledViews).size() == 1 && disabledViews.empty());

    clientMetrics->disableMetricsView("View");
    test(clientMetrics->getMetricsView("View", timestamp)["Thread"].empty());
    test(clientMetrics->getMetricsViewNames(disabledViews).empty() && disabledViews.size() == 1);

    try
    {
        clientMetrics->enableMetricsView("UnknownView");
    }
    catch(const IceMX::UnknownMetricsView&)
    {
    }

    cout << "ok" << endl;

    cout << "testing instrumentation observer delegate... " << flush;

    test(obsv->threadObserver->getTotal() > 0);
    test(obsv->connectionObserver->getTotal() > 0);
    test(obsv->connectionEstablishmentObserver->getTotal() > 0);
#ifndef ICE_OS_WINRT
    test(obsv->endpointLookupObserver->getTotal() > 0);
#endif
    test(obsv->dispatchObserver->getTotal() > 0);
    test(obsv->invocationObserver->getTotal() > 0);
    test(obsv->invocationObserver->remoteObserver->getTotal() > 0);

    test(obsv->threadObserver->getCurrent() > 0);
    test(obsv->connectionObserver->getCurrent() > 0);
    test(obsv->connectionEstablishmentObserver->getCurrent() == 0);
#ifndef ICE_OS_WINRT
    test(obsv->endpointLookupObserver->getCurrent() == 0);
#endif
    test(obsv->dispatchObserver->getCurrent() == 0);
    test(obsv->invocationObserver->getCurrent() == 0);
    test(obsv->invocationObserver->remoteObserver->getCurrent() == 0);

    test(obsv->threadObserver->getFailedCount() == 0);
    test(obsv->connectionObserver->getFailedCount() > 0);
    test(obsv->connectionEstablishmentObserver->getFailedCount() > 0);
#ifndef ICE_OS_WINRT
    test(obsv->endpointLookupObserver->getFailedCount() > 0);
#endif
    //test(obsv->dispatchObserver->getFailedCount() > 0);
    test(obsv->invocationObserver->getFailedCount() > 0);
    test(obsv->invocationObserver->remoteObserver->getFailedCount() > 0);

    test(obsv->threadObserver->states > 0);
    test(obsv->connectionObserver->received > 0 && obsv->connectionObserver->sent > 0);
    //test(obsv->dispatchObserver->userExceptionCount > 0);
    test(obsv->invocationObserver->userExceptionCount > 0 && obsv->invocationObserver->retriedCount > 0);
    test(obsv->invocationObserver->remoteObserver->replySize > 0);

    cout << "ok" << endl;

    return metrics;
}
Exemple #5
0
void
allTests(const Ice::CommunicatorPtr& communicator)
{
    cout << "testing proxy endpoint information... " << flush;
    {
        Ice::ObjectPrx p1 =
            communicator->stringToProxy("test -t:default -h tcphost -p 10000 -t 1200 -z --sourceAddress 10.10.10.10:"
                                        "udp -h udphost -p 10001 --interface eth0 --ttl 5 --sourceAddress 10.10.10.10:"
                                        "opaque -e 1.8 -t 100 -v ABCD");

        Ice::EndpointSeq endps = p1->ice_getEndpoints();

        Ice::IPEndpointInfoPtr ipEndpoint = Ice::IPEndpointInfoPtr::dynamicCast(endps[0]->getInfo());
        test(ipEndpoint);
        test(ipEndpoint->host == "tcphost");
        test(ipEndpoint->port == 10000);
        test(ipEndpoint->timeout == 1200);
#if !defined(ICE_OS_WINRT)
        test(ipEndpoint->sourceAddress == "10.10.10.10");
#endif
        test(ipEndpoint->compress);
        test(!ipEndpoint->datagram());
        test((ipEndpoint->type() == Ice::TCPEndpointType && !ipEndpoint->secure()) ||
             (ipEndpoint->type() == IceSSL::EndpointType && ipEndpoint->secure()) ||
             (ipEndpoint->type() == Ice::WSEndpointType && !ipEndpoint->secure()) ||
             (ipEndpoint->type() == Ice::WSSEndpointType && ipEndpoint->secure()));
        test((ipEndpoint->type() == Ice::TCPEndpointType && Ice::TCPEndpointInfoPtr::dynamicCast(ipEndpoint)) ||
             (ipEndpoint->type() == IceSSL::EndpointType && IceSSL::EndpointInfoPtr::dynamicCast(ipEndpoint)) ||
             (ipEndpoint->type() == Ice::WSEndpointType && Ice::EndpointInfoPtr::dynamicCast(ipEndpoint)) ||
             (ipEndpoint->type() == Ice::WSSEndpointType && Ice::EndpointInfoPtr::dynamicCast(ipEndpoint)));

        Ice::UDPEndpointInfoPtr udpEndpoint = Ice::UDPEndpointInfoPtr::dynamicCast(endps[1]->getInfo());
        test(udpEndpoint);
        test(udpEndpoint->host == "udphost");
        test(udpEndpoint->port == 10001);
#if !defined(ICE_OS_WINRT)
        test(udpEndpoint->sourceAddress == "10.10.10.10");
#endif
        test(udpEndpoint->mcastInterface == "eth0");
        test(udpEndpoint->mcastTtl == 5);
        test(udpEndpoint->timeout == -1);
        test(!udpEndpoint->compress);
        test(!udpEndpoint->secure());
        test(udpEndpoint->datagram());
        test(udpEndpoint->type() == Ice::UDPEndpointType);

        Ice::OpaqueEndpointInfoPtr opaqueEndpoint = Ice::OpaqueEndpointInfoPtr::dynamicCast(endps[2]->getInfo());
        test(opaqueEndpoint);
        Ice::EncodingVersion rev;
        rev.major = 1;
        rev.minor = 8;
        test(opaqueEndpoint->rawEncoding == rev);
    }
    cout << "ok" << endl;

    string defaultHost = communicator->getProperties()->getProperty("Ice.Default.Host");
    cout << "test object adapter endpoint information... " << flush;
    {
        communicator->getProperties()->setProperty("TestAdapter.Endpoints", "default -t 15000:udp");
        Ice::ObjectAdapterPtr adapter = communicator->createObjectAdapter("TestAdapter");

        Ice::EndpointSeq endpoints = adapter->getEndpoints();
        test(endpoints.size() == 2);
        Ice::EndpointSeq publishedEndpoints = adapter->getPublishedEndpoints();
        test(endpoints == publishedEndpoints);

        Ice::IPEndpointInfoPtr ipEndpoint = Ice::IPEndpointInfoPtr::dynamicCast(endpoints[0]->getInfo());
        test(ipEndpoint);
        test(ipEndpoint->type() == Ice::TCPEndpointType || ipEndpoint->type() == IceSSL::EndpointType ||
             ipEndpoint->type() == Ice::WSEndpointType || ipEndpoint->type() == Ice::WSSEndpointType);
        test(ipEndpoint->host == defaultHost);
        test(ipEndpoint->port > 0);
        test(ipEndpoint->timeout == 15000);

        Ice::UDPEndpointInfoPtr udpEndpoint = Ice::UDPEndpointInfoPtr::dynamicCast(endpoints[1]->getInfo());
        test(udpEndpoint);
        test(udpEndpoint->host == defaultHost);
        test(udpEndpoint->datagram());
        test(udpEndpoint->port > 0);

        adapter->destroy();

        communicator->getProperties()->setProperty("TestAdapter.Endpoints", "default -h * -p 12020");
        communicator->getProperties()->setProperty("TestAdapter.PublishedEndpoints", "default -h 127.0.0.1 -p 12020");
        adapter = communicator->createObjectAdapter("TestAdapter");

        endpoints = adapter->getEndpoints();
        test(endpoints.size() >= 1);
        publishedEndpoints = adapter->getPublishedEndpoints();
        test(publishedEndpoints.size() == 1);

        for(Ice::EndpointSeq::const_iterator p = endpoints.begin(); p != endpoints.end(); ++p)
        {
            ipEndpoint = Ice::IPEndpointInfoPtr::dynamicCast((*p)->getInfo());
            test(ipEndpoint->port == 12020);
        }

        ipEndpoint = Ice::IPEndpointInfoPtr::dynamicCast(publishedEndpoints[0]->getInfo());
        test(ipEndpoint->host == "127.0.0.1");
        test(ipEndpoint->port == 12020);

        adapter->destroy();
    }
    cout << "ok" << endl;

    Ice::ObjectPrx base = communicator->stringToProxy("test:default -p 12010:udp -p 12010 -c");
    TestIntfPrx testIntf = TestIntfPrx::checkedCast(base);

    cout << "test connection endpoint information... " << flush;
    {
        Ice::EndpointInfoPtr info = base->ice_getConnection()->getEndpoint()->getInfo();
        Ice::IPEndpointInfoPtr ipinfo = Ice::IPEndpointInfoPtr::dynamicCast(info);
        test(ipinfo->port == 12010);
        test(!ipinfo->compress);
        test(ipinfo->host == defaultHost);

        ostringstream os;

        Ice::Context ctx = testIntf->getEndpointInfoAsContext();
        test(ctx["host"] == ipinfo->host);
        test(ctx["compress"] == "false");
        istringstream is(ctx["port"]);
        int port;
        is >> port;
        test(port > 0);

        info = base->ice_datagram()->ice_getConnection()->getEndpoint()->getInfo();
        Ice::UDPEndpointInfoPtr udp = Ice::UDPEndpointInfoPtr::dynamicCast(info);
        test(udp);
        test(udp->port == 12010);
        test(udp->host == defaultHost);
    }
    cout << "ok" << endl;

    cout << "testing connection information... " << flush;
    {
        Ice::IPConnectionInfoPtr info = Ice::IPConnectionInfoPtr::dynamicCast(base->ice_getConnection()->getInfo());
        test(info);
        test(!info->incoming);
        test(info->adapterName.empty());
        test(info->localPort > 0);
        test(info->remotePort == 12010);
        if(defaultHost == "127.0.0.1")
        {
            test(info->remoteAddress == defaultHost);
            test(info->localAddress == defaultHost);
        }

        ostringstream os;

        Ice::Context ctx = testIntf->getConnectionInfoAsContext();
        test(ctx["incoming"] == "true");
        test(ctx["adapterName"] == "TestAdapter");
        test(ctx["remoteAddress"] == info->localAddress);
        test(ctx["localAddress"] == info->remoteAddress);
        os.str("");
        os << info->localPort;
        test(ctx["remotePort"] == os.str());
        os.str("");
        os << info->remotePort;
        test(ctx["localPort"] == os.str());

        info = Ice::IPConnectionInfoPtr::dynamicCast(base->ice_datagram()->ice_getConnection()->getInfo());
        test(!info->incoming);
        test(info->adapterName.empty());
        test(info->localPort > 0);
        test(info->remotePort == 12010);
        if(defaultHost == "127.0.0.1")
        {
            test(info->remoteAddress == defaultHost);
            test(info->localAddress == defaultHost);
        }

    }
    cout << "ok" << endl;

    testIntf->shutdown();

    communicator->shutdown();
    communicator->waitForShutdown();
}