diff options
author | Henning Baldersheim <balder@yahoo-inc.com> | 2022-02-22 15:31:49 +0000 |
---|---|---|
committer | Henning Baldersheim <balder@yahoo-inc.com> | 2022-02-22 15:31:49 +0000 |
commit | 8053e9f74e61a1a5e6b557c7d4d4388bc67f5d72 (patch) | |
tree | a87d693d6afbbe246816cb89cb17cff183b4016d /config/src/tests | |
parent | f859f58e988c61b0c16f4ed4eb9aaa5daca1661d (diff) |
Add support for creating ConfigContext with externally provided FNET_Transport object
Diffstat (limited to 'config/src/tests')
-rw-r--r-- | config/src/tests/file_subscription/file_subscription.cpp | 2 | ||||
-rw-r--r-- | config/src/tests/frtconnectionpool/frtconnectionpool.cpp | 37 | ||||
-rw-r--r-- | config/src/tests/subscriber/subscriber.cpp | 2 |
3 files changed, 30 insertions, 11 deletions
diff --git a/config/src/tests/file_subscription/file_subscription.cpp b/config/src/tests/file_subscription/file_subscription.cpp index b4a2b890bb5..6b900876bda 100644 --- a/config/src/tests/file_subscription/file_subscription.cpp +++ b/config/src/tests/file_subscription/file_subscription.cpp @@ -58,7 +58,7 @@ TEST("requireThatFileSpecGivesCorrectSource") { writeFile("my.cfg", "foobar"); FileSpec spec("my.cfg"); - SourceFactory::UP factory(spec.createSourceFactory(TimingValues())); + auto factory = spec.createSourceFactory(TimingValues()); ASSERT_TRUE(factory); auto holder = std::make_shared<ConfigHolder>(); std::unique_ptr<Source> src = factory->createSource(holder, ConfigKey("my", "my", "bar", "foo")); diff --git a/config/src/tests/frtconnectionpool/frtconnectionpool.cpp b/config/src/tests/frtconnectionpool/frtconnectionpool.cpp index c2ed60370e0..46e1f698091 100644 --- a/config/src/tests/frtconnectionpool/frtconnectionpool.cpp +++ b/config/src/tests/frtconnectionpool/frtconnectionpool.cpp @@ -3,6 +3,9 @@ #include <vespa/vespalib/testkit/testapp.h> #include <vespa/config/frt/frtconnectionpool.h> #include <vespa/fnet/frt/error.h> +#include <vespa/fnet/transport.h> +#include <vespa/fastos/thread.h> +#include <vespa/vespalib/util/size_literals.h> #include <sstream> #include <set> #include <unistd.h> @@ -12,8 +15,12 @@ using namespace config; class Test : public vespalib::TestApp { private: static ServerSpec::HostSpecList _sources; + FastOS_ThreadPool _threadPool; + FNET_Transport _transport; void verifyAllSourcesInRotation(FRTConnectionPool& sourcePool); public: + Test(); + ~Test() override; int Main() override; void testBasicRoundRobin(); void testBasicHashBasedSelection(); @@ -25,6 +32,18 @@ public: void testManySources(); }; +Test::Test() + : vespalib::TestApp(), + _threadPool(64_Ki), + _transport() +{ + _transport.Start(&_threadPool); +} + +Test::~Test() { + _transport.ShutDown(true); +} + TEST_APPHOOK(Test); ServerSpec::HostSpecList Test::_sources; @@ -79,7 +98,7 @@ void Test::verifyAllSourcesInRotation(FRTConnectionPool& sourcePool) { */ void Test::testBasicRoundRobin() { const ServerSpec spec(_sources); - FRTConnectionPool sourcePool(spec, timingValues); + FRTConnectionPool sourcePool(_transport, spec, timingValues); for (int i = 0; i < 9; i++) { int j = i % _sources.size(); std::stringstream s; @@ -93,7 +112,7 @@ void Test::testBasicRoundRobin() { */ void Test::testBasicHashBasedSelection() { const ServerSpec spec(_sources); - FRTConnectionPool sourcePool(spec, timingValues); + FRTConnectionPool sourcePool(_transport, spec, timingValues); sourcePool.setHostname("a.b.com"); for (int i = 0; i < 9; i++) { EXPECT_EQUAL("host1", sourcePool.getNextHashBased()->getAddress()); @@ -108,7 +127,7 @@ void Test::testBasicHashBasedSelection() { hostnames.push_back("stroustrup-02.example.yahoo.com"); hostnames.push_back("alexandrescu-03.example.yahoo.com"); const ServerSpec spec2(hostnames); - FRTConnectionPool sourcePool2(spec2, timingValues); + FRTConnectionPool sourcePool2(_transport, spec2, timingValues); sourcePool2.setHostname("sutter-01.example.yahoo.com"); EXPECT_EQUAL("stroustrup-02.example.yahoo.com", sourcePool2.getNextHashBased()->getAddress()); sourcePool2.setHostname("stroustrup-02.example.yahoo.com"); @@ -123,7 +142,7 @@ void Test::testBasicHashBasedSelection() { */ void Test::testSetErrorRoundRobin() { const ServerSpec spec(_sources); - FRTConnectionPool sourcePool(spec, timingValues); + FRTConnectionPool sourcePool(_transport, spec, timingValues); FRTConnection* source = sourcePool.getNextRoundRobin(); source->setError(FRTE_RPC_CONNECTION); for (int i = 0; i < 9; i++) { @@ -138,7 +157,7 @@ void Test::testSetErrorRoundRobin() { */ void Test::testSetErrorAllRoundRobin() { const ServerSpec spec(_sources); - FRTConnectionPool sourcePool(spec, timingValues); + FRTConnectionPool sourcePool(_transport, spec, timingValues); for (int i = 0; i < (int)_sources.size(); i++) { FRTConnection* source = sourcePool.getNextRoundRobin(); source->setError(FRTE_RPC_CONNECTION); @@ -152,7 +171,7 @@ void Test::testSetErrorAllRoundRobin() { */ void Test::testSetErrorHashBased() { const ServerSpec spec(_sources); - FRTConnectionPool sourcePool(spec, timingValues); + FRTConnectionPool sourcePool(_transport, spec, timingValues); FRTConnection* source = sourcePool.getNextHashBased(); source->setError(FRTE_RPC_CONNECTION); for (int i = 0; i < (int)_sources.size(); i++) { @@ -167,7 +186,7 @@ void Test::testSetErrorHashBased() { */ void Test::testSetErrorAllHashBased() { const ServerSpec spec(_sources); - FRTConnectionPool sourcePool(spec, timingValues); + FRTConnectionPool sourcePool(_transport, spec, timingValues); FRTConnection* firstSource = sourcePool.getNextHashBased(); auto readySources = sourcePool.getReadySources(); for (int i = 0; i < (int)readySources.size(); i++) { @@ -199,7 +218,7 @@ void Test::testSetErrorAllHashBased() { */ void Test::testSuspensionTimeout() { const ServerSpec spec(_sources); - FRTConnectionPool sourcePool(spec, timingValues); + FRTConnectionPool sourcePool(_transport, spec, timingValues); Connection* source = sourcePool.getCurrent(); source->setTransientDelay(1s); source->setError(FRTE_RPC_CONNECTION); @@ -227,7 +246,7 @@ void Test::testManySources() { twoSources.push_back("host1"); const ServerSpec spec(twoSources); - FRTConnectionPool sourcePool(spec, timingValues); + FRTConnectionPool sourcePool(_transport, spec, timingValues); for (int i = 0; i < (int)hostnames.size(); i++) { sourcePool.setHostname(hostnames[i]); diff --git a/config/src/tests/subscriber/subscriber.cpp b/config/src/tests/subscriber/subscriber.cpp index 548e54e1d18..d7320bb6a2f 100644 --- a/config/src/tests/subscriber/subscriber.cpp +++ b/config/src/tests/subscriber/subscriber.cpp @@ -85,7 +85,7 @@ namespace { return std::make_shared<ConfigSubscription>(0, key, holder, std::make_unique<MySource>()); } - void unsubscribe(const ConfigSubscription::SP & subscription) override { + void unsubscribe(const ConfigSubscription & subscription) override { (void) subscription; numCancel++; } |