[asterisk-scf-commits] asterisk-scf/integration/mediatransportudptl.git branch "master" updated.
Commits to the Asterisk SCF project code repositories
asterisk-scf-commits at lists.digium.com
Wed Sep 28 13:50:10 CDT 2011
branch "master" has been updated
via 3b1dd8ecd661bcab230acfd7e6ae3a7e2e759d7a (commit)
from 35178480df903a5e326aaade1c8f0c11a1ff7b81 (commit)
Summary of changes:
.../{test_component.config => test_udptl_ice.conf} | 4 +-
test/CMakeLists.txt | 10 +
test/TestUDPTLICE.cpp | 270 ++++++++++++++++++++
3 files changed, 283 insertions(+), 1 deletions(-)
copy config/{test_component.config => test_udptl_ice.conf} (94%)
create mode 100644 test/TestUDPTLICE.cpp
- Log -----------------------------------------------------------------
commit 3b1dd8ecd661bcab230acfd7e6ae3a7e2e759d7a
Author: Joshua Colp <jcolp at digium.com>
Date: Wed Sep 28 15:56:48 2011 -0300
Add test for STUN/ICE support. Working on extending it.
diff --git a/config/test_udptl_ice.conf b/config/test_udptl_ice.conf
new file mode 100644
index 0000000..0d24c2f
--- /dev/null
+++ b/config/test_udptl_ice.conf
@@ -0,0 +1,67 @@
+# This is a configuration file used in conjunction with the MediaTransportUDPTL test driver
+
+#
+# Icebox Configuration
+#
+
+UdptlConfiguration.Name=UdptlStateReplicator
+
+IceBox.InheritProperties=1
+IceBox.LoadOrder=ServiceDiscovery,UdptlStateReplicator,MediaTransportUDPTL,TestMediaTransportUDPTL
+
+Ice.Override.Timeout=5000
+
+# RtpStateReplicator Configuration
+IceBox.Service.UdptlStateReplicator=UdptlStateReplicator:create
+
+# Adapter parameters for this component
+UdptlStateReplicator.Adapter.Endpoints=tcp:udp
+
+# A proxy to the service locator management service
+LocatorServiceManagement.Proxy=LocatorServiceManagement:tcp -p 4412
+
+# A proxy to the service locator service
+LocatorService.Proxy=LocatorService:tcp -p 4411
+
+#
+# MediaTransportUDPTL Configuration
+#
+
+IceBox.Service.MediaTransportUDPTL=MediaTransportUDPTL:create
+
+# Adapter parameters for this component
+MediaTransportUDPTLAdapter.Endpoints=default
+MediaTransportUDPTLAdapterLocal.Endpoints=default
+MediaTransportUDPTLAdapterLogger.Endpoints=default
+
+#
+# TestMediaTransportUDPTL Configuration
+#
+
+IceBox.Service.TestMediaTransportUDPTL=MediaTransportUDPTL_ice_test:create
+
+#
+# Service Locator Configuration
+#
+
+IceBox.Service.ServiceDiscovery=service_locator:create
+
+ServiceDiscovery.IceStorm.InstanceName=ServiceDiscovery
+ServiceDiscovery.IceStorm.TopicManager.Endpoints=default -p 10000
+ServiceDiscovery.IceStorm.Publish.Endpoints=tcp -p 10001:udp -p 10001
+ServiceDiscovery.IceStorm.Trace.TopicManager=2
+ServiceDiscovery.IceStorm.Transient=1
+ServiceDiscovery.IceStorm.Flush.Timeout=2000
+
+UdptlStateReplicator.IceStorm.InstanceName=UdptlStateReplicator
+UdptlStateReplicator.IceStorm.TopicManager.Endpoints=default -p 10005
+UdptlStateReplicator.IceStorm.Publish.Endpoints=default -p 10006
+UdptlStateReplicator.IceStorm.Trace.TopicManager=2
+UdptlStateReplicator.IceStorm.Transient=1
+UdptlStateReplicator.IceStorm.Flush.Timeout=2000
+
+ServiceDiscovery.Management.ServiceAdapter.Endpoints=tcp -p 4412
+ServiceDiscovery.Locator.ServiceAdapter.Endpoints=tcp -p 4411
+ServiceDiscovery.BackplaneAdapter.Endpoints=default
+
+LoggerAdapter.Endpoints=default
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
index ac980f6..e12c557 100644
--- a/test/CMakeLists.txt
+++ b/test/CMakeLists.txt
@@ -14,5 +14,15 @@ astscf_component_add_slice_collection_libraries(MediaTransportUDPTL_test_v6 ASTS
astscf_component_build_icebox(MediaTransportUDPTL_test_v6)
set_property(TARGET MediaTransportUDPTL_test_v6 PROPERTY COMPILE_DEFINITIONS IPV6_TEST)
+astscf_component_init(MediaTransportUDPTL_ice_test)
+astscf_component_add_files(MediaTransportUDPTL_ice_test TestUDPTLICE.cpp)
+astscf_component_add_slices(MediaTransportUDPTL_ice_test PROJECT AsteriskSCF/Replication/UDPTL/UdptlStateReplicationIf.ice)
+astscf_component_add_slices(MediaTransportUDPTL_ice_test PROJECT AsteriskSCF/Configuration/UDPTL/UdptlConfigurationIf.ice)
+astscf_component_add_boost_libraries(MediaTransportUDPTL_ice_test unit_test_framework thread date_time)
+astscf_component_add_slice_collection_libraries(MediaTransportUDPTL_ice_test ASTSCF)
+astscf_component_build_icebox(MediaTransportUDPTL_ice_test)
+pjproject_link(MediaTransportUDPTL_ice_test pjlib)
+
astscf_test_icebox(MediaTransportUDPTL_test config/test_component.config)
astscf_test_icebox(MediaTransportUDPTL_test_v6 config/test_component_v6.config)
+astscf_test_icebox(MediaTransportUDPTL_ice_test config/test_udptl_ice.conf)
diff --git a/test/TestUDPTLICE.cpp b/test/TestUDPTLICE.cpp
new file mode 100644
index 0000000..402a55a
--- /dev/null
+++ b/test/TestUDPTLICE.cpp
@@ -0,0 +1,270 @@
+/*
+ * Asterisk SCF -- An open-source communications framework.
+ *
+ * Copyright (C) 2011, Digium, Inc.
+ *
+ * See http://www.asterisk.org for more information about
+ * the Asterisk SCF project. Please do not directly contact
+ * any of the maintainers of this project for assistance;
+ * the project provides a web site, mailing lists and IRC
+ * channels for your use.
+ *
+ * This program is free software, distributed under the terms of
+ * the GNU General Public License Version 2. See the LICENSE.txt file
+ * at the top of the source tree.
+ */
+
+
+#define BOOST_TEST_MODULE UdptlICETestModule
+#define BOOST_TEST_NO_MAIN
+
+#include <AsteriskSCF/Testing/IceBoxBoostTest.h>
+
+#include "UdptlConfigurationIf.h"
+#include "UdptlStateReplicationIf.h"
+
+#include <boost/test/debug.hpp>
+#include <boost/thread/thread.hpp>
+#include <boost/thread/mutex.hpp>
+#include <boost/thread/condition.hpp>
+#include <Ice/Ice.h>
+#include <Ice/BuiltinSequences.h>
+
+#include <AsteriskSCF/Core/Discovery/ServiceLocatorIf.h>
+#include <AsteriskSCF/Media/MediaIf.h>
+#include <AsteriskSCF/Media/UDPTL/MediaUDPTLIf.h>
+
+//
+// An attempt to get some reasonable code coverage and verify that the basic *premise* of the functionality works as
+// expected. HOWEVER, nothing beats live testing. Due the the dependency on external agencies (STUN server, TURN server,
+// NAT firewall, etc) there isn't much in the way of real functional testing that we can drive from a single icebox
+// instance. A HOW_TO_TEST document would be a good idea and is a major TODO.
+//
+
+using namespace std;
+using namespace AsteriskSCF::Core::Discovery::V1;
+using namespace AsteriskSCF::Media::V1;
+using namespace AsteriskSCF::Media::UDPTL::V1;
+using namespace AsteriskSCF::System::Configuration::V1;
+using namespace AsteriskSCF::Replication::UDPTL::V1;
+using namespace AsteriskSCF::Configuration::UDPTL::V1;
+
+namespace
+{
+
+class TestReplicatorListener : public UdptlStateReplicatorListener
+{
+public:
+ void stateRemoved(const Ice::StringSeq&, const Ice::Current&)
+ {
+ }
+
+ void stateSet(const UdptlStateItemSeq&, const Ice::Current&)
+ {
+ }
+
+private:
+
+};
+
+class IceEnvironment
+{
+public:
+ IceEnvironment()
+ {
+ Ice::InitializationData data;
+ data.properties = IceBoxTestEnv.communicator->getProperties();
+ mCommunicator = Ice::initialize(IceBoxTestEnv.argc, IceBoxTestEnv.argv, data);
+ mAdapter = mCommunicator->createObjectAdapterWithEndpoints("TestAdapter", "default");
+
+ //
+ // We will be making calls on proxies instantiated on this adapter, so we should activated here.
+ //
+ mAdapter->activate();
+ }
+
+ ~IceEnvironment()
+ {
+ if (mCommunicator)
+ {
+ mCommunicator->shutdown();
+ }
+ }
+
+ Ice::CommunicatorPtr getCommunicator()
+ {
+ return mCommunicator;
+ }
+
+ Ice::ObjectAdapterPtr getObjectAdapter()
+ {
+ return mAdapter;
+ }
+
+private:
+ Ice::CommunicatorPtr mCommunicator;
+ Ice::ObjectAdapterPtr mAdapter;
+};
+
+class TestFixture
+{
+public:
+ TestFixture()
+ {
+ BOOST_TEST_MESSAGE("Creating test fixture");
+ ::boost::debug::detect_memory_leaks(false);
+ ::boost::unit_test::unit_test_log.set_stream(cout);
+ }
+
+ ~TestFixture()
+ {
+ BOOST_TEST_MESSAGE("Destroying test fixture");
+ }
+};
+
+BOOST_GLOBAL_FIXTURE(TestFixture);
+
+UDPTLMediaServicePrx locateMediaService(const ServiceLocatorPrx& locator)
+{
+ UDPTLOverICEServiceLocatorParamsPtr query = new UDPTLOverICEServiceLocatorParams;
+ query->category = "udptl";
+ query->enableICE = true;
+ query->enableTURN = false;
+ return UDPTLMediaServicePrx::checkedCast(locator->locate(query));
+}
+
+ConfigurationServicePrx locateConfigurationService(const ServiceLocatorPrx& locator)
+{
+ ServiceLocatorParamsPtr query = new ServiceLocatorParams;
+ query->category = ConfigurationDiscoveryCategory;
+ return ConfigurationServicePrx::uncheckedCast(locator->locate(query));
+}
+
+ServiceLocatorPrx getLocator(const Ice::CommunicatorPtr& comm)
+{
+ return ServiceLocatorPrx::checkedCast(comm->propertyToProxy("LocatorService.Proxy"));
+}
+
+BOOST_AUTO_TEST_CASE(UdptlSessionWithICEEnabled)
+{
+ IceEnvironment iceEnv;
+ bool testResult = false;
+ try
+ {
+ ServiceLocatorPrx locator;
+ BOOST_REQUIRE_NO_THROW(locator = getLocator(iceEnv.getCommunicator()));
+ BOOST_REQUIRE(locator != 0);
+
+ //
+ // It's actually pretty handy that this icebox test suite probably
+ // shares the configuration file that hosts the media service!
+ //
+ ConfigurationServicePrx configPrx;
+ BOOST_REQUIRE_NO_THROW(
+ configPrx = locateConfigurationService(locator));
+ BOOST_REQUIRE(configPrx != 0);
+ UDPTLICEConfigurationGroupPtr iceGroup = new UDPTLICEConfigurationGroup;
+
+ STUNServerItemPtr stunServerCfg = new STUNServerItem;
+ stunServerCfg->address = "stun.xten.com";
+ stunServerCfg->port = 3478;
+ iceGroup->configurationItems[STUNServerItemName] = stunServerCfg;
+
+ UDPTLICETransportFlagsItemPtr iceFlags = new UDPTLICETransportFlagsItem;
+ iceFlags->enableICE = true;
+ iceFlags->enableTURN = false;
+ iceGroup->configurationItems[UDPTLICETransportFlagsItemName] = iceFlags;
+
+ ConfigurationGroupSeq s;
+ s.push_back(iceGroup);
+ configPrx->setConfiguration(s);
+
+ UDPTLMediaServicePrx servicePrx;
+ {
+ UDPTLOverICEServiceLocatorParamsPtr query = new UDPTLOverICEServiceLocatorParams;
+ query->category = "udptl";
+ query->enableICE = true;
+ query->enableTURN = false;
+ servicePrx = UDPTLMediaServicePrx::checkedCast(locator->locate(query));
+ }
+ BOOST_REQUIRE(servicePrx);
+ try
+ {
+ UDPTLOverICEServiceLocatorParamsPtr query = new UDPTLOverICEServiceLocatorParams;
+ query->category = "udptl";
+ query->enableICE = true;
+ query->enableTURN = false;
+ UDPTLSessionPrx sessionPrx;
+ BOOST_REQUIRE_NO_THROW(sessionPrx = servicePrx->allocate(query));
+ BOOST_REQUIRE(sessionPrx != 0);
+ sessionPrx->ice_ping(); // To silence unused arg warning.
+ sessionPrx->release();
+ testResult = true;
+ }
+ catch (const SessionAllocationFailure& ex)
+ {
+ BOOST_TEST_MESSAGE(ex.what());
+ }
+ }
+ catch (const Ice::Exception& ex)
+ {
+ BOOST_FAIL(ex.what());
+ }
+ BOOST_CHECK(testResult);
+}
+
+BOOST_AUTO_TEST_CASE(UdptlSessionAllocationFailure)
+{
+ IceEnvironment iceEnv;
+ bool testResult = false;
+ try
+ {
+ ServiceLocatorPrx locator;
+ BOOST_REQUIRE_NO_THROW(locator = getLocator(iceEnv.getCommunicator()));
+ BOOST_REQUIRE(locator != 0);
+ UDPTLMediaServicePrx servicePrx;
+ BOOST_REQUIRE_NO_THROW(servicePrx = locateMediaService(locator));
+ BOOST_REQUIRE(servicePrx);
+
+ //
+ // It's actually pretty handy that this icebox test suite probably
+ // shares the configuration file that hosts the media service!
+ //
+ ConfigurationServicePrx configPrx;
+ BOOST_REQUIRE_NO_THROW(
+ configPrx = locateConfigurationService(locator));
+ UDPTLICEConfigurationGroupPtr iceGroup = new UDPTLICEConfigurationGroup;
+ UDPTLICETransportFlagsItemPtr iceFlags = new UDPTLICETransportFlagsItem;
+ iceFlags->enableICE = false;
+ iceFlags->enableTURN = false;
+ iceGroup->configurationItems[UDPTLICETransportFlagsItemName] = iceFlags;
+ ConfigurationGroupSeq s;
+ s.push_back(iceGroup);
+ BOOST_REQUIRE_NO_THROW(configPrx->setConfiguration(s));
+ try
+ {
+ UDPTLOverICEServiceLocatorParamsPtr query = new UDPTLOverICEServiceLocatorParams;
+ query->category = "udptl";
+ query->enableICE = true;
+ query->enableTURN = true;
+ UDPTLSessionPrx sessionPrx = servicePrx->allocate(query);
+ sessionPrx->ice_ping();
+ }
+ catch (const SessionAllocationFailure& ex)
+ {
+ testResult = true;
+ BOOST_TEST_MESSAGE(ex.what());
+ }
+ }
+ catch (const Ice::Exception& ex)
+ {
+ BOOST_TEST_MESSAGE(ex.what());
+ }
+ BOOST_CHECK(testResult);
+}
+
+}
+
+
+
+
-----------------------------------------------------------------------
--
asterisk-scf/integration/mediatransportudptl.git
More information about the asterisk-scf-commits
mailing list