summaryrefslogtreecommitdiffstats
path: root/config/src/tests
diff options
context:
space:
mode:
Diffstat (limited to 'config/src/tests')
-rw-r--r--config/src/tests/api/api.cpp2
-rw-r--r--config/src/tests/configagent/configagent.cpp33
-rw-r--r--config/src/tests/configfetcher/configfetcher.cpp4
-rw-r--r--config/src/tests/configformat/configformat.cpp1
-rw-r--r--config/src/tests/configgen/configgen.cpp1
-rw-r--r--config/src/tests/configholder/configholder.cpp4
-rw-r--r--config/src/tests/configmanager/configmanager.cpp17
-rw-r--r--config/src/tests/configparser/configparser.cpp8
-rw-r--r--config/src/tests/configretriever/configretriever.cpp16
-rw-r--r--config/src/tests/configuri/configuri_test.cpp5
-rw-r--r--config/src/tests/failover/failover.cpp7
-rw-r--r--config/src/tests/file_subscription/file_subscription.cpp7
-rw-r--r--config/src/tests/frt/frt.cpp10
-rw-r--r--config/src/tests/functiontest/functiontest.cpp11
-rw-r--r--config/src/tests/getconfig/getconfig.cpp2
-rw-r--r--config/src/tests/legacysubscriber/legacysubscriber.cpp2
-rw-r--r--config/src/tests/misc/misc.cpp17
-rw-r--r--config/src/tests/payload_converter/payload_converter.cpp8
-rw-r--r--config/src/tests/print/print.cpp6
-rw-r--r--config/src/tests/raw_subscription/raw_subscription.cpp9
-rw-r--r--config/src/tests/subscriber/subscriber.cpp41
-rw-r--r--config/src/tests/subscription/subscription.cpp8
-rw-r--r--config/src/tests/unittest/unittest.cpp2
23 files changed, 112 insertions, 109 deletions
diff --git a/config/src/tests/api/api.cpp b/config/src/tests/api/api.cpp
index 9cf6ea610bf..3377d256b97 100644
--- a/config/src/tests/api/api.cpp
+++ b/config/src/tests/api/api.cpp
@@ -1,8 +1,8 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#include <vespa/vespalib/testkit/test_kit.h>
-#include <vespa/config/config.h>
#include <vespa/config/common/configcontext.h>
#include <config-my.h>
+#include <vespa/config/subscription/configsubscriber.hpp>
using namespace config;
diff --git a/config/src/tests/configagent/configagent.cpp b/config/src/tests/configagent/configagent.cpp
index 3fbbee8c601..4843b2f0647 100644
--- a/config/src/tests/configagent/configagent.cpp
+++ b/config/src/tests/configagent/configagent.cpp
@@ -1,11 +1,11 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#include <vespa/vespalib/testkit/test_kit.h>
-#include <vespa/config/config.h>
-#include <vespa/config/raw/rawsource.h>
#include <vespa/config/common/misc.h>
#include <vespa/config/common/configrequest.h>
#include <vespa/config/common/timingvalues.h>
#include <vespa/config/common/trace.h>
+#include <vespa/config/common/configkey.h>
+#include <vespa/config/common/configholder.h>
#include <vespa/config/frt/frtconfigagent.h>
#include <config-my.h>
@@ -30,10 +30,10 @@ public:
class MyConfigResponse : public ConfigResponse
{
public:
- MyConfigResponse(const ConfigKey & key, const ConfigValue & value, bool valid, int64_t timestamp,
+ MyConfigResponse(const ConfigKey & key, ConfigValue value, bool valid, int64_t timestamp,
const vespalib::string & xxhash64, const std::string & errorMsg, int errorC0de, bool iserror)
: _key(key),
- _value(value),
+ _value(std::move(value)),
_fillCalled(false),
_valid(valid),
_state(xxhash64, timestamp, false),
@@ -83,10 +83,8 @@ public:
class MyHolder : public IConfigHolder
{
public:
- MyHolder()
- : _update()
- {
- }
+ MyHolder() noexcept = default;
+ ~MyHolder() = default;
std::unique_ptr<ConfigUpdate> provide() override
{
@@ -135,7 +133,7 @@ static TimingValues testTimingValues(
2000); // maxDelayMultiplier
TEST("require that agent returns correct values") {
- FRTConfigAgent handler(IConfigHolder::SP(new MyHolder()), testTimingValues);
+ FRTConfigAgent handler(std::make_shared<MyHolder>(), testTimingValues);
ASSERT_EQUAL(500u, handler.getTimeout());
ASSERT_EQUAL(0u, handler.getWaitTime());
ConfigState cs;
@@ -147,12 +145,12 @@ TEST("require that agent returns correct values") {
TEST("require that successful request is delivered to holder") {
const ConfigKey testKey(ConfigKey::create<MyConfig>("mykey"));
const ConfigValue testValue(createValue("l33t", "a"));
- IConfigHolder::SP latch(new MyHolder());
+ auto latch = std::make_shared<MyHolder>();
FRTConfigAgent handler(latch, testTimingValues);
handler.handleResponse(MyConfigRequest(testKey), MyConfigResponse::createOKResponse(testKey, testValue));
ASSERT_TRUE(latch->poll());
- ConfigUpdate::UP update(latch->provide());
+ std::unique_ptr<ConfigUpdate> update(latch->provide());
ASSERT_TRUE(update);
ASSERT_TRUE(update->hasChanged());
MyConfig cfg(update->getValue());
@@ -163,13 +161,13 @@ TEST("require that important(the change) request is delivered to holder even if
const ConfigKey testKey(ConfigKey::create<MyConfig>("mykey"));
const ConfigValue testValue1(createValue("l33t", "a"));
const ConfigValue testValue2(createValue("l34t", "b"));
- IConfigHolder::SP latch(new MyHolder());
+ auto latch = std::make_shared<MyHolder>();
FRTConfigAgent handler(latch, testTimingValues);
handler.handleResponse(MyConfigRequest(testKey),
MyConfigResponse::createOKResponse(testKey, testValue1, 1, testValue1.getXxhash64()));
ASSERT_TRUE(latch->poll());
- ConfigUpdate::UP update(latch->provide());
+ std::unique_ptr<ConfigUpdate> update(latch->provide());
ASSERT_TRUE(update);
ASSERT_TRUE(update->hasChanged());
MyConfig cfg(update->getValue());
@@ -190,7 +188,7 @@ TEST("require that important(the change) request is delivered to holder even if
TEST("require that successful request sets correct wait time") {
const ConfigKey testKey(ConfigKey::create<MyConfig>("mykey"));
const ConfigValue testValue(createValue("l33t", "a"));
- IConfigHolder::SP latch(new MyHolder());
+ auto latch = std::make_shared<MyHolder>();
FRTConfigAgent handler(latch, testTimingValues);
handler.handleResponse(MyConfigRequest(testKey), MyConfigResponse::createOKResponse(testKey, testValue));
@@ -203,7 +201,7 @@ TEST("require that successful request sets correct wait time") {
TEST("require that bad config response returns false") {
const ConfigKey testKey(ConfigKey::create<MyConfig>("mykey"));
const ConfigValue testValue(createValue("myval", "a"));
- IConfigHolder::SP latch(new MyHolder());
+ auto latch = std::make_shared<MyHolder>();
FRTConfigAgent handler(latch, testTimingValues);
handler.handleResponse(MyConfigRequest(testKey), MyConfigResponse::createConfigErrorResponse(testKey, testValue));
@@ -241,10 +239,9 @@ TEST("require that bad config response returns false") {
TEST("require that bad response returns false") {
const ConfigKey testKey(ConfigKey::create<MyConfig>("mykey"));
- std::vector<vespalib::string> lines;
- const ConfigValue testValue(lines, "a");
+ const ConfigValue testValue(StringVector(), "a");
- IConfigHolder::SP latch(new MyHolder());
+ auto latch = std::make_shared<MyHolder>();
FRTConfigAgent handler(latch, testTimingValues);
handler.handleResponse(MyConfigRequest(testKey), MyConfigResponse::createServerErrorResponse(testKey, testValue));
diff --git a/config/src/tests/configfetcher/configfetcher.cpp b/config/src/tests/configfetcher/configfetcher.cpp
index 4782557338d..6142f9469fc 100644
--- a/config/src/tests/configfetcher/configfetcher.cpp
+++ b/config/src/tests/configfetcher/configfetcher.cpp
@@ -1,6 +1,6 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#include <vespa/vespalib/testkit/test_kit.h>
-#include <vespa/config/helper/configfetcher.h>
+#include <vespa/config/helper/configfetcher.hpp>
#include <vespa/config/common/configcontext.h>
#include <vespa/vespalib/util/exception.h>
#include "config-my.h"
@@ -125,7 +125,7 @@ namespace {
struct ConfigFixture {
MyConfigBuilder builder;
ConfigSet set;
- ConfigContext::SP context;
+ std::shared_ptr<ConfigContext> context;
ConfigFixture() : builder(), set(), context() {
set.addBuilder("cfgid", &builder);
context = std::make_shared<ConfigContext>(set);
diff --git a/config/src/tests/configformat/configformat.cpp b/config/src/tests/configformat/configformat.cpp
index 6623e2ee254..65c40eaea8d 100644
--- a/config/src/tests/configformat/configformat.cpp
+++ b/config/src/tests/configformat/configformat.cpp
@@ -1,6 +1,5 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#include <vespa/vespalib/testkit/test_kit.h>
-#include <vespa/config/config.h>
#include <vespa/config/print/fileconfigformatter.h>
#include <vespa/vespalib/data/slime/slime.h>
diff --git a/config/src/tests/configgen/configgen.cpp b/config/src/tests/configgen/configgen.cpp
index b7113dec972..2d08b526e8d 100644
--- a/config/src/tests/configgen/configgen.cpp
+++ b/config/src/tests/configgen/configgen.cpp
@@ -1,7 +1,6 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#include <vespa/vespalib/testkit/test_kit.h>
-#include <vespa/config/config.h>
#include <vespa/config/helper/configgetter.hpp>
#include "config-motd.h"
diff --git a/config/src/tests/configholder/configholder.cpp b/config/src/tests/configholder/configholder.cpp
index db32cc2e309..b2f6cd83693 100644
--- a/config/src/tests/configholder/configholder.cpp
+++ b/config/src/tests/configholder/configholder.cpp
@@ -14,8 +14,8 @@ constexpr vespalib::duration ONE_MINUTE = 60s;
TEST("Require that element order is correct")
{
- ConfigValue value(std::vector<vespalib::string>(), "foo");
- ConfigValue value2(std::vector<vespalib::string>(), "bar");
+ ConfigValue value(StringVector(), "foo");
+ ConfigValue value2(StringVector(), "bar");
ConfigHolder holder;
holder.handle(std::make_unique<ConfigUpdate>(value, true, 0));
diff --git a/config/src/tests/configmanager/configmanager.cpp b/config/src/tests/configmanager/configmanager.cpp
index 2cc5d4fad4f..9bed974f628 100644
--- a/config/src/tests/configmanager/configmanager.cpp
+++ b/config/src/tests/configmanager/configmanager.cpp
@@ -1,11 +1,12 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#include <vespa/vespalib/testkit/test_kit.h>
-#include <vespa/vespalib/util/noncopyable.hpp>
#include <vespa/config/common/configmanager.h>
#include <vespa/config/common/exceptions.h>
#include <vespa/config/common/timingvalues.h>
#include <vespa/config/subscription/sourcespec.h>
+#include <vespa/config/common/iconfigholder.h>
+
#include <vespa/config/raw/rawsource.h>
#include "config-my.h"
@@ -36,12 +37,12 @@ namespace {
class MySource : public Source
{
public:
- MySource(TestContext * data, const IConfigHolder::SP & holder) : _holder(holder), _data(data) { }
+ MySource(TestContext * data, std::shared_ptr<IConfigHolder> holder) : _holder(std::move(holder)), _data(data) { }
void getConfig() override
{
_data->numGetConfig++;
if (_data->respond) {
- _holder->handle(ConfigUpdate::UP(new ConfigUpdate(ConfigValue(), true, _data->generation)));
+ _holder->handle(std::make_unique<ConfigUpdate>(ConfigValue(), true, _data->generation));
}
}
void reload(int64_t generation) override
@@ -53,7 +54,7 @@ namespace {
{
_data->numClose++;
}
- IConfigHolder::SP _holder;
+ std::shared_ptr<IConfigHolder> _holder;
TestContext * _data;
};
@@ -61,10 +62,10 @@ namespace {
{
public:
MySourceFactory(TestContext * d) : data(d) { }
- Source::UP createSource(const IConfigHolder::SP & holder, const ConfigKey & key) const override
+ std::unique_ptr<Source> createSource(std::shared_ptr<IConfigHolder> holder, const ConfigKey & key) const override
{
(void) key;
- return Source::UP(new MySource(data, holder));
+ return std::make_unique<MySource>(data, std::move(holder));
}
TestContext * data;
};
@@ -78,9 +79,9 @@ namespace {
{
}
SourceSpecKey createKey() const { return SourceSpecKey(_key); }
- SourceFactory::UP createSourceFactory(const TimingValues & timingValues) const override {
+ std::unique_ptr<SourceFactory> createSourceFactory(const TimingValues & timingValues) const override {
(void) timingValues;
- return SourceFactory::UP(new MySourceFactory(_data));
+ return std::make_unique<MySourceFactory>(_data);
}
SourceSpec * clone() const { return new MySpec(*this); }
private:
diff --git a/config/src/tests/configparser/configparser.cpp b/config/src/tests/configparser/configparser.cpp
index 965c2a5a312..3e569a2d3fb 100644
--- a/config/src/tests/configparser/configparser.cpp
+++ b/config/src/tests/configparser/configparser.cpp
@@ -1,8 +1,8 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#include <vespa/vespalib/testkit/test_kit.h>
-#include <vespa/config/config.h>
#include <vespa/config/common/configparser.h>
#include <vespa/config/common/exceptions.h>
+#include <vespa/config/common/configvalue.h>
#include "config-foo.h"
#include <fstream>
#include <vespa/vespalib/stllike/asciistream.h>
@@ -102,14 +102,14 @@ TEST("require that array lengths may be specified")
}
TEST("require that escaped values are properly unescaped") {
- std::vector<vespalib::string> payload;
+ StringVector payload;
payload.push_back("foo \"a\\nb\\rc\\\\d\\\"e\x42g\"");
vespalib::string value(ConfigParser::parse<vespalib::string>("foo", payload));
ASSERT_EQUAL("a\nb\rc\\d\"eBg", value);
}
TEST("verify that locale does not affect double parsing") {
- std::vector<vespalib::string> payload;
+ StringVector payload;
setlocale(LC_NUMERIC, "nb_NO.UTF-8");
payload.push_back("foo 3,14");
ASSERT_EXCEPTION(ConfigParser::parse<double>("foo", payload), InvalidConfigException, "Value 3,14 is not a legal double");
@@ -127,7 +127,7 @@ TEST("require that maps can be parsed")
}
TEST("handles quotes for bool values") {
- std::vector<vespalib::string> payload;
+ StringVector payload;
payload.push_back("foo \"true\"");
payload.push_back("bar \"123\"");
payload.push_back("baz \"1234\"");
diff --git a/config/src/tests/configretriever/configretriever.cpp b/config/src/tests/configretriever/configretriever.cpp
index dbbcd0dec24..fdd106e44f2 100644
--- a/config/src/tests/configretriever/configretriever.cpp
+++ b/config/src/tests/configretriever/configretriever.cpp
@@ -14,6 +14,8 @@
#include <vespa/config/subscription/configsubscription.h>
#include <vespa/config/subscription/sourcespec.h>
#include <vespa/config/common/exceptions.h>
+#include <vespa/config/frt/protocol.h>
+#include <vespa/config/retriever/configsnapshot.hpp>
#include <thread>
#include <atomic>
@@ -34,7 +36,7 @@ struct ConfigTestFixture {
BootstrapConfigBuilder bootstrapBuilder;
map<std::string, ComponentFixture::SP> componentConfig;
ConfigSet set;
- IConfigContext::SP context;
+ std::shared_ptr<IConfigContext> context;
int idcounter;
ConfigTestFixture(const std::string & id)
@@ -115,11 +117,11 @@ struct MySource : public Source
struct SubscriptionFixture
{
- IConfigHolder::SP holder;
- ConfigSubscription::SP sub;
+ std::shared_ptr<IConfigHolder> holder;
+ std::shared_ptr<ConfigSubscription> sub;
SubscriptionFixture(const ConfigKey & key, const ConfigValue value)
- : holder(new ConfigHolder()),
- sub(new ConfigSubscription(0, key, holder, Source::UP(new MySource())))
+ : holder(std::make_shared<ConfigHolder>()),
+ sub(std::make_shared<ConfigSubscription>(0, key, holder, std::make_unique<MySource>()))
{
holder->handle(std::make_unique<ConfigUpdate>(value, 3, 3));
ASSERT_TRUE(sub->nextUpdate(0, 0ms));
@@ -215,7 +217,7 @@ TEST("require that SimpleConfigRetriever usage works") {
barBuilder.barValue = "fooz";
set.addBuilder("id", &fooBuilder);
set.addBuilder("id", &barBuilder);
- IConfigContext::SP ctx(new ConfigContext(set));
+ auto ctx = std::make_shared<ConfigContext>(set);
ConfigKeySet sub;
sub.add<FooConfig>("id");
sub.add<BarConfig>("id");
@@ -281,7 +283,7 @@ TEST_F("require that SimpleConfigurer usage works", ConfigurableFixture()) {
barBuilder.barValue = "fooz";
set.addBuilder("id", &fooBuilder);
set.addBuilder("id", &barBuilder);
- IConfigContext::SP ctx(new ConfigContext(set));
+ auto ctx = std::make_shared<ConfigContext>(set);
ConfigKeySet sub;
sub.add<FooConfig>("id");
sub.add<BarConfig>("id");
diff --git a/config/src/tests/configuri/configuri_test.cpp b/config/src/tests/configuri/configuri_test.cpp
index 1089886cb1d..e4b3ea06195 100644
--- a/config/src/tests/configuri/configuri_test.cpp
+++ b/config/src/tests/configuri/configuri_test.cpp
@@ -1,7 +1,8 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#include <vespa/vespalib/testkit/test_kit.h>
-#include <vespa/config/config.h>
#include <vespa/config/common/configcontext.h>
+#include <vespa/config/subscription/configsubscriber.hpp>
+#include <vespa/config/subscription/configuri.h>
#include "config-my.h"
using namespace config;
@@ -47,7 +48,7 @@ TEST("Require that URI can be created from instance") {
}
-TEST_F("Require that URI can be \"forked\"", IConfigContext::SP(new ConfigContext())) {
+TEST_F("Require that URI can be \"forked\"", std::shared_ptr<IConfigContext>(std::make_shared<ConfigContext>())) {
assertConfigId("baz", ConfigUri("foo/bar").createWithNewId("baz"));
ConfigUri parent("foo", f1);
ConfigUri child = parent.createWithNewId("baz");
diff --git a/config/src/tests/failover/failover.cpp b/config/src/tests/failover/failover.cpp
index 4bac1fb9062..e342a477b13 100644
--- a/config/src/tests/failover/failover.cpp
+++ b/config/src/tests/failover/failover.cpp
@@ -1,10 +1,9 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#include <vespa/vespalib/testkit/test_kit.h>
-#include <vespa/config/common/misc.h>
#include <vespa/config/frt/protocol.h>
-#include <vespa/config/config.h>
#include <vespa/config/common/configcontext.h>
+#include <vespa/config/subscription/configsubscriber.hpp>
#include <vespa/fnet/frt/supervisor.h>
#include <vespa/fnet/frt/rpcrequest.h>
@@ -189,7 +188,7 @@ TimingValues testTimingValues(
1200); // fatalDelay
struct ConfigCheckFixture {
- IConfigContext::SP ctx;
+ std::shared_ptr<IConfigContext> ctx;
NetworkFixture & nf;
ConfigCheckFixture(NetworkFixture & f2)
@@ -221,7 +220,7 @@ struct ConfigCheckFixture {
};
struct ConfigReloadFixture {
- IConfigContext::SP ctx;
+ std::shared_ptr<IConfigContext> ctx;
NetworkFixture & nf;
ConfigSubscriber s;
ConfigHandle<MyConfig>::UP handle;
diff --git a/config/src/tests/file_subscription/file_subscription.cpp b/config/src/tests/file_subscription/file_subscription.cpp
index 1201f72f90e..2d1a8498ba5 100644
--- a/config/src/tests/file_subscription/file_subscription.cpp
+++ b/config/src/tests/file_subscription/file_subscription.cpp
@@ -1,8 +1,7 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#include <vespa/vespalib/testkit/test_kit.h>
-#include <vespa/config/config.h>
+#include <vespa/config/subscription/configsubscriber.hpp>
#include <vespa/config/common/configholder.h>
-#include <vespa/config/file/filesource.h>
#include <vespa/config/common/exceptions.h>
#include <vespa/config/common/sourcefactory.h>
#include <vespa/config/common/configcontext.h>
@@ -63,12 +62,12 @@ TEST("requireThatFileSpecGivesCorrectSource") {
SourceFactory::UP factory(spec.createSourceFactory(TimingValues()));
ASSERT_TRUE(factory);
auto holder = std::make_shared<ConfigHolder>();
- Source::UP src = factory->createSource(holder, ConfigKey("my", "my", "bar", "foo"));
+ std::unique_ptr<Source> src = factory->createSource(holder, ConfigKey("my", "my", "bar", "foo"));
ASSERT_TRUE(src);
src->getConfig();
ASSERT_TRUE(holder->poll());
- ConfigUpdate::UP update(holder->provide());
+ std::unique_ptr<ConfigUpdate> update(holder->provide());
ASSERT_TRUE(update);
const ConfigValue & value(update->getValue());
ASSERT_EQUAL(1u, value.numLines());
diff --git a/config/src/tests/frt/frt.cpp b/config/src/tests/frt/frt.cpp
index 54adbf4d787..0a0c3262b84 100644
--- a/config/src/tests/frt/frt.cpp
+++ b/config/src/tests/frt/frt.cpp
@@ -16,6 +16,8 @@
#include <vespa/fnet/frt/error.h>
#include <vespa/fnet/frt/supervisor.h>
#include <vespa/config/frt/protocol.h>
+#include <vespa/config/common/configvalue.hpp>
+
#include <lz4.h>
#include <thread>
@@ -29,15 +31,15 @@ using namespace config::protocol::v3;
namespace {
struct UpdateFixture : public IConfigHolder {
- ConfigUpdate::UP update;
+ std::unique_ptr<ConfigUpdate> update;
bool notified;
UpdateFixture()
: update(),
notified(false)
{ }
- ConfigUpdate::UP provide() override { return ConfigUpdate::UP(); }
- void handle(ConfigUpdate::UP u) override { update = std::move(u); }
+ std::unique_ptr<ConfigUpdate> provide() override { return std::unique_ptr<ConfigUpdate>(); }
+ void handle(std::unique_ptr<ConfigUpdate> u) override { update = std::move(u); }
bool wait(milliseconds timeoutInMillis) override { (void) timeoutInMillis; return notified; }
bool poll() override { return notified; }
void interrupt() override { }
@@ -75,7 +77,7 @@ namespace {
const vespalib::string & configXxhash64="",
int changed=0,
long generation=0,
- const std::vector<vespalib::string> & payload = std::vector<vespalib::string>(),
+ const StringVector & payload = StringVector(),
const vespalib::string & ns = "")
{
FRT_RPCRequest * req = new FRT_RPCRequest();
diff --git a/config/src/tests/functiontest/functiontest.cpp b/config/src/tests/functiontest/functiontest.cpp
index 80433b0382c..333645176a0 100644
--- a/config/src/tests/functiontest/functiontest.cpp
+++ b/config/src/tests/functiontest/functiontest.cpp
@@ -1,13 +1,14 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-#include <vespa/config/config.h>
-#include <vespa/config/common/exceptions.h>
#include "config-function-test.h"
-
-#include <fstream>
-#include <vespa/log/log.h>
+#include <vespa/config/common/exceptions.h>
+#include <vespa/config/configgen/configpayload.h>
+#include <vespa/config/subscription/configsubscriber.hpp>
#include <vespa/vespalib/data/slime/slime.h>
#include <vespa/vespalib/testkit/test_kit.h>
+#include <fstream>
+
+#include <vespa/log/log.h>
LOG_SETUP("functiontest_test");
diff --git a/config/src/tests/getconfig/getconfig.cpp b/config/src/tests/getconfig/getconfig.cpp
index 4081ce2f1d6..a9598df9be9 100644
--- a/config/src/tests/getconfig/getconfig.cpp
+++ b/config/src/tests/getconfig/getconfig.cpp
@@ -12,7 +12,7 @@ namespace {
struct ConfigFixture {
MyConfigBuilder builder;
ConfigSet set;
- ConfigContext::SP context;
+ std::shared_ptr<IConfigContext> context;
ConfigFixture() : builder(), set(), context() {
set.addBuilder("cfgid", &builder);
context = std::make_shared<ConfigContext>(set);
diff --git a/config/src/tests/legacysubscriber/legacysubscriber.cpp b/config/src/tests/legacysubscriber/legacysubscriber.cpp
index 51a32731b0e..7b5f2e2fc0e 100644
--- a/config/src/tests/legacysubscriber/legacysubscriber.cpp
+++ b/config/src/tests/legacysubscriber/legacysubscriber.cpp
@@ -1,6 +1,6 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#include <vespa/vespalib/testkit/test_kit.h>
-#include <vespa/config/helper/legacysubscriber.h>
+#include <vespa/config/helper/legacysubscriber.hpp>
#include <fstream>
#include <config-my.h>
#include <config-foo.h>
diff --git a/config/src/tests/misc/misc.cpp b/config/src/tests/misc/misc.cpp
index 25b6cf36326..25c6762326d 100644
--- a/config/src/tests/misc/misc.cpp
+++ b/config/src/tests/misc/misc.cpp
@@ -3,6 +3,7 @@
#include <vespa/config/common/configupdate.h>
#include <vespa/config/common/misc.h>
#include <vespa/config/common/configvalue.h>
+#include <vespa/config/common/configkey.h>
#include <vespa/config/common/errorcode.h>
#include <vespa/config/common/vespa_version.h>
#include <vespa/config/subscription/sourcespec.h>
@@ -12,7 +13,7 @@
using namespace config;
TEST("requireThatConfigUpdateWorks") {
- std::vector<vespalib::string> lines;
+ StringVector lines;
lines.push_back("foo");
ConfigUpdate up(ConfigValue(lines, "myxxhash"), true, 1337);
@@ -25,13 +26,13 @@ TEST("requireThatConfigUpdateWorks") {
}
TEST("requireThatConfigValueWorks") {
- std::vector<vespalib::string> lines;
+ StringVector lines;
lines.push_back("myFooField \"bar\"");
- ConfigValue v1(lines, calculateContentXxhash64(lines));
- ConfigValue v2(lines, calculateContentXxhash64(lines));
- ConfigValue v3(lines, calculateContentXxhash64(lines));
+ ConfigValue v1(lines);
+ ConfigValue v2(lines);
+ ConfigValue v3(lines);
lines.push_back("myFooField \"bar2\"");
- ConfigValue v4(lines, calculateContentXxhash64(lines));
+ ConfigValue v4(lines);
ASSERT_TRUE(v1 == v2);
ASSERT_TRUE(v1 == v3);
}
@@ -108,11 +109,11 @@ TEST("requireThatConfigKeyWorks") {
TEST("require that config key initializes schema")
{
- std::vector<vespalib::string> schema;
+ StringVector schema;
schema.push_back("foo");
schema.push_back("bar");
ConfigKey key("id1", "def1", "namespace1", "xxhash1", schema);
- const std::vector<vespalib::string> &vref(key.getDefSchema());
+ const StringVector &vref(key.getDefSchema());
for (size_t i = 0; i < schema.size(); i++) {
ASSERT_EQUAL(schema[i], vref[i]);
}
diff --git a/config/src/tests/payload_converter/payload_converter.cpp b/config/src/tests/payload_converter/payload_converter.cpp
index 2ecb2062944..d5212048b2e 100644
--- a/config/src/tests/payload_converter/payload_converter.cpp
+++ b/config/src/tests/payload_converter/payload_converter.cpp
@@ -19,7 +19,7 @@ TEST("require that v2 payload leaf values can be converted to cfg format") {
root.setDouble("baz", 3.1);
root.setBool("quux", true);
PayloadConverter converter(root);
- std::vector<vespalib::string> lines(converter.convert());
+ StringVector lines(converter.convert());
std::sort(lines.begin(), lines.end());
ASSERT_EQUAL(4u, lines.size());
@@ -36,7 +36,7 @@ TEST("require that v2 payload struct values can be converted to cfg format") {
inner.setString("foo", "bar");
inner.setLong("bar", 8);
PayloadConverter converter(root);
- std::vector<vespalib::string> lines(converter.convert());
+ StringVector lines(converter.convert());
std::sort(lines.begin(), lines.end());
ASSERT_EQUAL(2u, lines.size());
@@ -51,7 +51,7 @@ TEST("require that v2 payload array values can be converted to cfg format") {
inner.addString("foo");
inner.addLong(8);
PayloadConverter converter(root);
- std::vector<vespalib::string> lines(converter.convert());
+ StringVector lines(converter.convert());
ASSERT_EQUAL(2u, lines.size());
EXPECT_EQUAL("arr[0] \"foo\"", lines[0]);
EXPECT_EQUAL("arr[1] 8", lines[1]);
@@ -72,7 +72,7 @@ TEST("require that v2 payload nested structures can be converted to cfg format")
Cursor & innerArr2(innerobj.setArray("arr2"));
innerArr2.addString("muhaha");
PayloadConverter converter(root);
- std::vector<vespalib::string> lines(converter.convert());
+ StringVector lines(converter.convert());
std::sort(lines.begin(), lines.end());
ASSERT_EQUAL(3u, lines.size());
EXPECT_EQUAL("arr[0].foo \"bar\"", lines[0]);
diff --git a/config/src/tests/print/print.cpp b/config/src/tests/print/print.cpp
index 325b8dc28fa..fa20482cf0a 100644
--- a/config/src/tests/print/print.cpp
+++ b/config/src/tests/print/print.cpp
@@ -1,11 +1,11 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#include <vespa/vespalib/testkit/test_kit.h>
-#include <vespa/config/config.h>
#include <vespa/config/print.h>
-#include <vespa/config/print/fileconfigreader.h>
-#include <vespa/config/print/istreamconfigreader.h>
+#include <vespa/config/print/fileconfigreader.hpp>
+#include <vespa/config/print/istreamconfigreader.hpp>
#include <vespa/config/helper/configgetter.hpp>
+#include <vespa/vespalib/util/exceptions.h>
#include "config-my.h"
#include "config-motd.h"
#include <sys/stat.h>
diff --git a/config/src/tests/raw_subscription/raw_subscription.cpp b/config/src/tests/raw_subscription/raw_subscription.cpp
index 7141a21d35d..da35d10da52 100644
--- a/config/src/tests/raw_subscription/raw_subscription.cpp
+++ b/config/src/tests/raw_subscription/raw_subscription.cpp
@@ -1,9 +1,8 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#include <vespa/vespalib/testkit/test_kit.h>
-#include <vespa/config/config.h>
#include <vespa/config/common/configholder.h>
#include <vespa/config/common/sourcefactory.h>
-#include <vespa/config/raw/rawsource.h>
+#include <vespa/config/subscription/configsubscriber.hpp>
#include "config-my.h"
using namespace config;
@@ -13,13 +12,13 @@ TEST("require that raw spec can create source factory")
RawSpec spec("myField \"foo\"\n");
auto raw = spec.createSourceFactory(TimingValues());
ASSERT_TRUE(raw);
- IConfigHolder::SP holder(new ConfigHolder());
- Source::UP src = raw->createSource(holder, ConfigKey("myid", "my", "bar", "foo"));
+ std::shared_ptr<IConfigHolder> holder(new ConfigHolder());
+ std::unique_ptr<Source> src = raw->createSource(holder, ConfigKey("myid", "my", "bar", "foo"));
ASSERT_TRUE(src);
src->getConfig();
ASSERT_TRUE(holder->poll());
- ConfigUpdate::UP update(holder->provide());
+ std::unique_ptr<ConfigUpdate> update(holder->provide());
ASSERT_TRUE(update);
const ConfigValue & value(update->getValue());
ASSERT_EQUAL(1u, value.numLines());
diff --git a/config/src/tests/subscriber/subscriber.cpp b/config/src/tests/subscriber/subscriber.cpp
index 5871add2618..68e211ec3f8 100644
--- a/config/src/tests/subscriber/subscriber.cpp
+++ b/config/src/tests/subscriber/subscriber.cpp
@@ -3,11 +3,12 @@
#include "config-bar.h"
#include "config-baz.h"
#include <vespa/vespalib/testkit/test_kit.h>
-#include <vespa/config/config.h>
#include <vespa/config/common/misc.h>
#include <vespa/config/common/configholder.h>
-#include <vespa/config/subscription/configsubscription.h>
#include <vespa/config/common/exceptions.h>
+#include <vespa/config/common/iconfigmanager.h>
+#include <vespa/config/common/iconfigcontext.h>
+#include <vespa/config/subscription/configsubscriber.hpp>
#include <thread>
using namespace config;
@@ -18,9 +19,9 @@ namespace {
ConfigValue createValue(const std::string & value)
{
- std::vector< vespalib::string > lines;
+ StringVector lines;
lines.push_back(value);
- return ConfigValue(lines, calculateContentXxhash64(lines));
+ return ConfigValue(std::move(lines));
}
ConfigValue createFooValue(const std::string & value)
@@ -40,13 +41,13 @@ namespace {
void verifyConfig(const std::string & expected, std::unique_ptr<FooConfig> cfg)
{
- ASSERT_TRUE(cfg.get() != NULL);
+ ASSERT_TRUE(cfg);
ASSERT_EQUAL(expected, cfg->fooValue);
}
void verifyConfig(const std::string & expected, std::unique_ptr<BarConfig> cfg)
{
- ASSERT_TRUE(cfg.get() != NULL);
+ ASSERT_TRUE(cfg);
ASSERT_EQUAL(expected, cfg->barValue);
}
@@ -72,7 +73,7 @@ namespace {
SubscriptionId idCounter;
- std::vector<IConfigHolder::SP> _holders;
+ std::vector<std::shared_ptr<IConfigHolder>> _holders;
int numCancel;
@@ -80,7 +81,7 @@ namespace {
ConfigSubscription::SP subscribe(const ConfigKey & key, milliseconds timeoutInMillis) override {
(void) timeoutInMillis;
- IConfigHolder::SP holder(new ConfigHolder());
+ auto holder = std::make_shared<ConfigHolder>();
_holders.push_back(holder);
return std::make_shared<ConfigSubscription>(0, key, holder, std::make_unique<MySource>());
@@ -116,16 +117,18 @@ namespace {
{
public:
MyManager & _m;
- APIFixture(MyManager & m)
+ APIFixture(MyManager & m) noexcept
: _m(m)
{
}
- APIFixture(const APIFixture & rhs)
+ APIFixture(const APIFixture & rhs) noexcept
: IConfigContext(rhs),
_m(rhs._m)
{ }
+ ~APIFixture() override = default;
+
IConfigManager & getManagerInstance() override {
return _m;
}
@@ -144,7 +147,7 @@ namespace {
ConfigHandle<FooConfig>::UP h1;
ConfigHandle<BarConfig>::UP h2;
- StandardFixture(MyManager & F1, APIFixture & F2) : f1(F1), s(IConfigContext::SP(new APIFixture(F2)))
+ StandardFixture(MyManager & F1, APIFixture & F2) : f1(F1), s(std::make_shared<APIFixture>(F2))
{
h1 = s.subscribe<FooConfig>("myid");
h2 = s.subscribe<BarConfig>("myid");
@@ -206,7 +209,7 @@ TEST_F("requireThatSubscriptionsCannotBeAddedWhenFrozen", SimpleFixture()) {
}
TEST_FF("requireThatNextConfigReturnsFalseUntilSubscriptionHasSucceeded", MyManager, APIFixture(f1)) {
- ConfigSubscriber s(IConfigContext::SP(new APIFixture(f2)));
+ ConfigSubscriber s(std::make_shared<APIFixture>(f2));
ConfigHandle<FooConfig>::UP h1 = s.subscribe<FooConfig>("myid");
ConfigHandle<BarConfig>::UP h2 = s.subscribe<BarConfig>("myid");
ASSERT_FALSE(s.nextConfigNow());
@@ -335,7 +338,7 @@ TEST_MT_FFF("requireThatNextConfigIsInterruptedOnClose", 2, MyManager, APIFixtur
}
TEST_FF("requireThatHandlesAreMarkedAsChanged", MyManager, APIFixture(f1)) {
- ConfigSubscriber s(IConfigContext::SP(new APIFixture(f2)));
+ ConfigSubscriber s(std::make_shared<APIFixture>(f2));
ConfigHandle<FooConfig>::UP h1 = s.subscribe<FooConfig>("myid2");
ConfigHandle<BarConfig>::UP h2 = s.subscribe<BarConfig>("myid2");
EXPECT_FALSE(s.nextConfigNow());
@@ -357,7 +360,7 @@ TEST_FF("requireThatHandlesAreMarkedAsChanged", MyManager, APIFixture(f1)) {
}
TEST_FF("requireThatNextGenerationMarksChanged", MyManager, APIFixture(f1)) {
- ConfigSubscriber s(IConfigContext::SP(new APIFixture(f2)));
+ ConfigSubscriber s(std::make_shared<APIFixture>(f2));
ConfigHandle<FooConfig>::UP h1 = s.subscribe<FooConfig>("myid2");
ConfigHandle<BarConfig>::UP h2 = s.subscribe<BarConfig>("myid2");
f1.updateValue(0, createFooValue("foo"), 1);
@@ -380,7 +383,7 @@ TEST_FF("requireThatNextGenerationMarksChanged", MyManager, APIFixture(f1)) {
}
TEST_FF("requireThatgetGenerationIsSet", MyManager, APIFixture(f1)) {
- ConfigSubscriber s(IConfigContext::SP(new APIFixture(f2)));
+ ConfigSubscriber s(std::make_shared<APIFixture>(f2));
ConfigHandle<FooConfig>::UP h1 = s.subscribe<FooConfig>("myid2");
ConfigHandle<BarConfig>::UP h2 = s.subscribe<BarConfig>("myid2");
f1.updateValue(0, createFooValue("foo"), 1);
@@ -407,7 +410,7 @@ TEST_FFF("requireThatConfigHandleStillHasConfigOnTimestampUpdate", MyManager, AP
}
TEST_FF("requireThatTimeStamp0Works", MyManager, APIFixture(f1)) {
- ConfigSubscriber s(IConfigContext::SP(new APIFixture(f2)));
+ ConfigSubscriber s(std::make_shared<APIFixture>(f2));
ConfigHandle<BarConfig>::UP h2 = s.subscribe<BarConfig>("myid");
ConfigHandle<FooConfig>::UP h1 = s.subscribe<FooConfig>("myid");
ConfigHandle<BazConfig>::UP h3 = s.subscribe<BazConfig>("myid");
@@ -421,7 +424,7 @@ TEST_FF("requireThatTimeStamp0Works", MyManager, APIFixture(f1)) {
}
TEST_FF("requireThatNextGenerationWorksWithManyConfigs", MyManager, APIFixture(f1)) {
- ConfigSubscriber s(IConfigContext::SP(new APIFixture(f2)));
+ ConfigSubscriber s(std::make_shared<APIFixture>(f2));
ConfigHandle<BarConfig>::UP h2 = s.subscribe<BarConfig>("myid");
ConfigHandle<FooConfig>::UP h1 = s.subscribe<FooConfig>("myid");
ConfigHandle<BazConfig>::UP h3 = s.subscribe<BazConfig>("myid");
@@ -483,7 +486,7 @@ TEST_FF("requireThatNextGenerationWorksWithManyConfigs", MyManager, APIFixture(f
}
TEST_FF("requireThatConfigSubscriberHandlesProxyCache", MyManager, APIFixture(f1)) {
- ConfigSubscriber s(IConfigContext::SP(new APIFixture(f2)));
+ ConfigSubscriber s(std::make_shared<APIFixture>(f2));
ConfigHandle<FooConfig>::UP h1 = s.subscribe<FooConfig>("myid");
f1.updateValue(0, createFooValue("foo"), 1);
f1.updateGeneration(0, 2);
@@ -501,7 +504,7 @@ TEST_FF("requireThatConfigSubscriberHandlesProxyCache", MyManager, APIFixture(f1
TEST_MT_FF("requireThatConfigSubscriberWaitsUntilNextConfigSucceeds", 2, MyManager, APIFixture(f1)) {
if (thread_id == 0) {
- ConfigSubscriber s(IConfigContext::SP(new APIFixture(f2)));
+ ConfigSubscriber s(std::make_shared<APIFixture>(f2));
ConfigHandle<FooConfig>::UP h1 = s.subscribe<FooConfig>("myid");
f1.updateValue(0, createFooValue("foo"), 1);
ASSERT_TRUE(s.nextConfigNow());
diff --git a/config/src/tests/subscription/subscription.cpp b/config/src/tests/subscription/subscription.cpp
index a65528d67ee..f35ea3c6cef 100644
--- a/config/src/tests/subscription/subscription.cpp
+++ b/config/src/tests/subscription/subscription.cpp
@@ -38,12 +38,12 @@ namespace {
struct SubscriptionFixture
{
- IConfigHolder::SP holder;
+ std::shared_ptr<IConfigHolder> holder;
ConfigSubscription sub;
SourceFixture src;
SubscriptionFixture(const ConfigKey & key)
: holder(new ConfigHolder()),
- sub(0, key, holder, Source::UP(new MySource(&src)))
+ sub(0, key, holder, std::make_unique<MySource>(&src))
{
}
};
@@ -100,11 +100,11 @@ TEST_MT_F("requireThatNextUpdateReturnsInterrupted", 2, SubscriptionFixture(Conf
TEST_F("Require that isChanged takes generation into account", SubscriptionFixture(ConfigKey::create<MyConfig>("myid")))
{
- f1.holder->handle(std::make_unique<ConfigUpdate>(ConfigValue(std::vector<vespalib::string>(), "a"), true, 1));
+ f1.holder->handle(std::make_unique<ConfigUpdate>(ConfigValue(StringVector(), "a"), true, 1));
ASSERT_TRUE(f1.sub.nextUpdate(0, 0ms));
f1.sub.flip();
ASSERT_EQUAL(1, f1.sub.getLastGenerationChanged());
- f1.holder->handle(std::make_unique<ConfigUpdate>(ConfigValue(std::vector<vespalib::string>(), "b"), true, 2));
+ f1.holder->handle(std::make_unique<ConfigUpdate>(ConfigValue(StringVector(), "b"), true, 2));
ASSERT_TRUE(f1.sub.nextUpdate(1, 0ms));
f1.sub.flip();
ASSERT_EQUAL(2, f1.sub.getLastGenerationChanged());
diff --git a/config/src/tests/unittest/unittest.cpp b/config/src/tests/unittest/unittest.cpp
index 1ba11db89b9..207a139f31d 100644
--- a/config/src/tests/unittest/unittest.cpp
+++ b/config/src/tests/unittest/unittest.cpp
@@ -1,11 +1,11 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#include <vespa/vespalib/testkit/test_kit.h>
-#include <vespa/config/config.h>
#include <vespa/config/common/configcontext.h>
#include "config-my.h"
#include "config-foo.h"
#include "config-bar.h"
+#include <vespa/config/subscription/configsubscriber.hpp>
#include <vespa/log/log.h>
LOG_SETUP("unittest");