summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--config/src/tests/frtconnectionpool/CMakeLists.txt1
-rw-r--r--config/src/tests/frtconnectionpool/frtconnectionpool.cpp136
-rw-r--r--dependency-versions/pom.xml6
-rw-r--r--document/src/tests/serialization/CMakeLists.txt1
-rw-r--r--document/src/tests/serialization/annotationserializer_test.cpp137
-rw-r--r--documentapi/src/tests/messagebus/CMakeLists.txt1
-rw-r--r--documentapi/src/tests/messagebus/messagebus_test.cpp70
-rw-r--r--vespalib/src/tests/datastore/unique_store/unique_store_test.cpp6
8 files changed, 155 insertions, 203 deletions
diff --git a/config/src/tests/frtconnectionpool/CMakeLists.txt b/config/src/tests/frtconnectionpool/CMakeLists.txt
index b39a5bdf6f5..003d3151fc7 100644
--- a/config/src/tests/frtconnectionpool/CMakeLists.txt
+++ b/config/src/tests/frtconnectionpool/CMakeLists.txt
@@ -4,5 +4,6 @@ vespa_add_executable(config_frtconnectionpool_test_app TEST
frtconnectionpool.cpp
DEPENDS
config_cloudconfig
+ GTest::gtest
)
vespa_add_test(NAME config_frtconnectionpool_test_app COMMAND config_frtconnectionpool_test_app)
diff --git a/config/src/tests/frtconnectionpool/frtconnectionpool.cpp b/config/src/tests/frtconnectionpool/frtconnectionpool.cpp
index 9d1501962a1..a27dffa6fc5 100644
--- a/config/src/tests/frtconnectionpool/frtconnectionpool.cpp
+++ b/config/src/tests/frtconnectionpool/frtconnectionpool.cpp
@@ -1,121 +1,79 @@
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-#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/vespalib/gtest/gtest.h>
#include <sstream>
#include <set>
#include <unistd.h>
using namespace config;
-class Test : public vespalib::TestApp {
-private:
- static ServerSpec::HostSpecList _sources;
+class FRTConnectionPoolTest : public testing::Test {
+protected:
+ ServerSpec::HostSpecList _sources;
FNET_Transport _transport;
void verifyAllSourcesInRotation(FRTConnectionPool& sourcePool);
-public:
- Test();
- ~Test() override;
- int Main() override;
- void testBasicRoundRobin();
- void testBasicHashBasedSelection();
- void testSetErrorRoundRobin();
- void testSetErrorAllRoundRobin();
- void testSetErrorHashBased();
- void testSetErrorAllHashBased();
- void testSuspensionTimeout();
- void testManySources();
+ FRTConnectionPoolTest();
+ ~FRTConnectionPoolTest() override;
};
-Test::Test()
- : vespalib::TestApp(),
+FRTConnectionPoolTest::FRTConnectionPoolTest()
+ : testing::Test(),
+ _sources(),
_transport()
{
+ _sources.push_back("host0");
+ _sources.push_back("host1");
+ _sources.push_back("host2");
_transport.Start();
}
-Test::~Test() {
+FRTConnectionPoolTest::~FRTConnectionPoolTest() {
_transport.ShutDown(true);
}
-TEST_APPHOOK(Test);
-
-ServerSpec::HostSpecList Test::_sources;
TimingValues timingValues;
-int Test::Main() {
- TEST_INIT("frtconnectionpool_test");
-
- _sources.push_back("host0");
- _sources.push_back("host1");
- _sources.push_back("host2");
-
- testBasicRoundRobin();
- TEST_FLUSH();
-
- testBasicHashBasedSelection();
- TEST_FLUSH();
-
- testSetErrorRoundRobin();
- TEST_FLUSH();
-
- testSetErrorAllRoundRobin();
- TEST_FLUSH();
-
- testSetErrorHashBased();
- TEST_FLUSH();
-
- testSetErrorAllHashBased();
- TEST_FLUSH();
-
- testSuspensionTimeout();
- TEST_FLUSH();
-
- testManySources();
- TEST_FLUSH();
-
- TEST_DONE();
- return 0;
-}
-
-void Test::verifyAllSourcesInRotation(FRTConnectionPool& sourcePool) {
+void FRTConnectionPoolTest::verifyAllSourcesInRotation(FRTConnectionPool& sourcePool) {
std::set<std::string> completeSet(_sources.begin(), _sources.end());
std::set<std::string> foundSet;
for (int i = 0; i < (int)_sources.size(); i++) {
foundSet.insert(sourcePool.getNextRoundRobin()->getAddress());
}
- EXPECT_EQUAL(true, completeSet == foundSet);
+ EXPECT_EQ(true, completeSet == foundSet);
}
/**
* Tests that basic round robin selection through the list works.
*/
-void Test::testBasicRoundRobin() {
+TEST_F(FRTConnectionPoolTest, test_basic_round_robin)
+{
const ServerSpec spec(_sources);
FRTConnectionPool sourcePool(_transport, spec, timingValues);
for (int i = 0; i < 9; i++) {
int j = i % _sources.size();
std::stringstream s;
s << "host" << j;
- EXPECT_EQUAL(s.str(), sourcePool.getNextRoundRobin()->getAddress());
+ EXPECT_EQ(s.str(), sourcePool.getNextRoundRobin()->getAddress());
}
}
/**
* Tests that hash-based selection through the list works.
*/
-void Test::testBasicHashBasedSelection() {
+TEST_F(FRTConnectionPoolTest, test_basic_hash_based_selection)
+{
const ServerSpec spec(_sources);
FRTConnectionPool sourcePool(_transport, spec, timingValues);
sourcePool.setHostname("a.b.com");
for (int i = 0; i < 9; i++) {
- EXPECT_EQUAL("host1", sourcePool.getNextHashBased()->getAddress());
+ EXPECT_EQ("host1", sourcePool.getNextHashBased()->getAddress());
}
sourcePool.setHostname("host98");
for (int i = 0; i < 9; i++) {
- EXPECT_EQUAL("host0", sourcePool.getNextHashBased()->getAddress());
+ EXPECT_EQ("host0", sourcePool.getNextHashBased()->getAddress());
}
ServerSpec::HostSpecList hostnames;
@@ -125,24 +83,25 @@ void Test::testBasicHashBasedSelection() {
const ServerSpec spec2(hostnames);
FRTConnectionPool sourcePool2(_transport, spec2, timingValues);
sourcePool2.setHostname("sutter-01.example.yahoo.com");
- EXPECT_EQUAL("stroustrup-02.example.yahoo.com", sourcePool2.getNextHashBased()->getAddress());
+ EXPECT_EQ("stroustrup-02.example.yahoo.com", sourcePool2.getNextHashBased()->getAddress());
sourcePool2.setHostname("stroustrup-02.example.yahoo.com");
- EXPECT_EQUAL("sutter-01.example.yahoo.com", sourcePool2.getNextHashBased()->getAddress());
+ EXPECT_EQ("sutter-01.example.yahoo.com", sourcePool2.getNextHashBased()->getAddress());
sourcePool2.setHostname("alexandrescu-03.example.yahoo.com");
- EXPECT_EQUAL("alexandrescu-03.example.yahoo.com", sourcePool2.getNextHashBased()->getAddress());
+ EXPECT_EQ("alexandrescu-03.example.yahoo.com", sourcePool2.getNextHashBased()->getAddress());
}
/**
* Tests that a source is taken out of rotation when an error is reported,
* and that it is taken back in when a success is reported.
*/
-void Test::testSetErrorRoundRobin() {
+TEST_F(FRTConnectionPoolTest, test_set_error_round_robin)
+{
const ServerSpec spec(_sources);
FRTConnectionPool sourcePool(_transport, spec, timingValues);
FRTConnection* source = sourcePool.getNextRoundRobin();
source->setError(FRTE_RPC_CONNECTION);
for (int i = 0; i < 9; i++) {
- EXPECT_NOT_EQUAL(source->getAddress(), sourcePool.getCurrent()->getAddress());
+ EXPECT_NE(source->getAddress(), sourcePool.getCurrent()->getAddress());
}
source->setSuccess();
verifyAllSourcesInRotation(sourcePool);
@@ -151,7 +110,8 @@ void Test::testSetErrorRoundRobin() {
/**
* Tests that all sources are in rotation when all sources have errors set.
*/
-void Test::testSetErrorAllRoundRobin() {
+TEST_F(FRTConnectionPoolTest, test_set_error_all_round_robin)
+{
const ServerSpec spec(_sources);
FRTConnectionPool sourcePool(_transport, spec, timingValues);
for (int i = 0; i < (int)_sources.size(); i++) {
@@ -165,22 +125,24 @@ void Test::testSetErrorAllRoundRobin() {
* Tests that a source is not used when an error is reported,
* and that the same source is used when a success is reported.
*/
-void Test::testSetErrorHashBased() {
+TEST_F(FRTConnectionPoolTest, test_set_error_hash_based)
+{
const ServerSpec spec(_sources);
FRTConnectionPool sourcePool(_transport, spec, timingValues);
FRTConnection* source = sourcePool.getNextHashBased();
source->setError(FRTE_RPC_CONNECTION);
for (int i = 0; i < (int)_sources.size(); i++) {
- EXPECT_NOT_EQUAL(source->getAddress(), sourcePool.getNextHashBased()->getAddress());
+ EXPECT_NE(source->getAddress(), sourcePool.getNextHashBased()->getAddress());
}
source->setSuccess();
- EXPECT_EQUAL(source->getAddress(), sourcePool.getNextHashBased()->getAddress());
+ EXPECT_EQ(source->getAddress(), sourcePool.getNextHashBased()->getAddress());
}
/**
* Tests that the same source is used when all sources have errors set.
*/
-void Test::testSetErrorAllHashBased() {
+TEST_F(FRTConnectionPoolTest, test_set_error_all_hash_based)
+{
const ServerSpec spec(_sources);
FRTConnectionPool sourcePool(_transport, spec, timingValues);
FRTConnection* firstSource = sourcePool.getNextHashBased();
@@ -188,11 +150,11 @@ void Test::testSetErrorAllHashBased() {
for (int i = 0; i < (int)readySources.size(); i++) {
readySources[i]->setError(FRTE_RPC_CONNECTION);
}
- EXPECT_EQUAL(sourcePool.getReadySources().size(), 0u);
- EXPECT_EQUAL(sourcePool.getSuspendedSources().size(), 3u);
+ EXPECT_EQ(sourcePool.getReadySources().size(), 0u);
+ EXPECT_EQ(sourcePool.getSuspendedSources().size(), 3u);
// should get the same source now, since all are suspended
- EXPECT_EQUAL(firstSource->getAddress(), sourcePool.getNextHashBased()->getAddress());
+ EXPECT_EQ(firstSource->getAddress(), sourcePool.getNextHashBased()->getAddress());
// set all except firstSource to OK
for (int i = 0; i < (int)readySources.size(); i++) {
@@ -201,18 +163,19 @@ void Test::testSetErrorAllHashBased() {
}
}
- EXPECT_EQUAL(sourcePool.getReadySources().size(), 2u);
- EXPECT_EQUAL(sourcePool.getSuspendedSources().size(), 1u);
+ EXPECT_EQ(sourcePool.getReadySources().size(), 2u);
+ EXPECT_EQ(sourcePool.getSuspendedSources().size(), 1u);
// should not get the same source now, since original source is
// suspended, while the rest are OK
- EXPECT_NOT_EQUAL(firstSource->getAddress(), sourcePool.getNextHashBased()->getAddress());
+ EXPECT_NE(firstSource->getAddress(), sourcePool.getNextHashBased()->getAddress());
}
/**
* Tests that the source is put back into rotation when the suspension times out.
*/
-void Test::testSuspensionTimeout() {
+TEST_F(FRTConnectionPoolTest, test_suspension_timeout)
+{
const ServerSpec spec(_sources);
TimingValues short_transient_delay;
short_transient_delay.transientDelay = 1s;
@@ -220,7 +183,7 @@ void Test::testSuspensionTimeout() {
FRTConnection* source = dynamic_cast<FRTConnection *>(sourcePool.getCurrent());
source->setError(FRTE_RPC_CONNECTION);
for (int i = 0; i < 9; i++) {
- EXPECT_NOT_EQUAL(source->getAddress(), sourcePool.getCurrent()->getAddress());
+ EXPECT_NE(source->getAddress(), sourcePool.getCurrent()->getAddress());
}
sleep(2);
verifyAllSourcesInRotation(sourcePool);
@@ -230,7 +193,8 @@ void Test::testSuspensionTimeout() {
* Tests that when there are two sources and several clients
* the sources will be chosen with equal probability.
*/
-void Test::testManySources() {
+TEST_F(FRTConnectionPoolTest, test_many_sources)
+{
std::vector<std::string> hostnames;
for (int i = 0; i < 20; ++i) {
hostnames.push_back("host-" + std::to_string(i) + ".example.yahoo.com");
@@ -255,6 +219,8 @@ void Test::testManySources() {
timesUsed[address] = 1;
}
}
- EXPECT_EQUAL(timesUsed["host0"], (int)hostnames.size() / 2);
- EXPECT_EQUAL(timesUsed["host1"], (int)hostnames.size() / 2);
+ EXPECT_EQ(timesUsed["host0"], (int)hostnames.size() / 2);
+ EXPECT_EQ(timesUsed["host1"], (int)hostnames.size() / 2);
}
+
+GTEST_MAIN_RUN_ALL_TESTS()
diff --git a/dependency-versions/pom.xml b/dependency-versions/pom.xml
index a9e17bbb45c..b796fdbc1a5 100644
--- a/dependency-versions/pom.xml
+++ b/dependency-versions/pom.xml
@@ -36,7 +36,7 @@
<error-prone-annotations.vespa.version>2.25.0</error-prone-annotations.vespa.version>
<guava.vespa.version>33.0.0-jre</guava.vespa.version>
<guice.vespa.version>6.0.0</guice.vespa.version>
- <jackson2.vespa.version>2.16.1</jackson2.vespa.version>
+ <jackson2.vespa.version>2.16.2</jackson2.vespa.version>
<jackson-databind.vespa.version>${jackson2.vespa.version}</jackson-databind.vespa.version>
<jakarta.inject.vespa.version>2.0.1</jakarta.inject.vespa.version>
<javax.inject.vespa.version>1</javax.inject.vespa.version>
@@ -65,7 +65,7 @@
<assertj.vespa.version>3.25.3</assertj.vespa.version>
<!-- Athenz dependencies. Make sure these dependencies match those in Vespa's internal repositories -->
- <aws-sdk.vespa.version>1.12.675</aws-sdk.vespa.version>
+ <aws-sdk.vespa.version>1.12.676</aws-sdk.vespa.version>
<athenz.vespa.version>1.11.53</athenz.vespa.version>
<!-- Athenz END -->
@@ -158,7 +158,7 @@
<!-- Maven plugins -->
<clover-maven-plugin.vespa.version>4.5.2</clover-maven-plugin.vespa.version>
<maven-antrun-plugin.vespa.version>3.1.0</maven-antrun-plugin.vespa.version>
- <maven-assembly-plugin.vespa.version>3.6.0</maven-assembly-plugin.vespa.version>
+ <maven-assembly-plugin.vespa.version>3.7.0</maven-assembly-plugin.vespa.version>
<maven-bundle-plugin.vespa.version>5.1.9</maven-bundle-plugin.vespa.version>
<maven-compiler-plugin.vespa.version>3.12.1</maven-compiler-plugin.vespa.version>
<maven-core.vespa.version>3.9.6</maven-core.vespa.version>
diff --git a/document/src/tests/serialization/CMakeLists.txt b/document/src/tests/serialization/CMakeLists.txt
index e5bf91f401d..8a997299e38 100644
--- a/document/src/tests/serialization/CMakeLists.txt
+++ b/document/src/tests/serialization/CMakeLists.txt
@@ -11,5 +11,6 @@ vespa_add_executable(document_annotationserializer_test_app TEST
annotationserializer_test.cpp
DEPENDS
document
+ GTest::gtest
)
vespa_add_test(NAME document_annotationserializer_test_app COMMAND document_annotationserializer_test_app)
diff --git a/document/src/tests/serialization/annotationserializer_test.cpp b/document/src/tests/serialization/annotationserializer_test.cpp
index 14edd38d0b0..3499f9d8012 100644
--- a/document/src/tests/serialization/annotationserializer_test.cpp
+++ b/document/src/tests/serialization/annotationserializer_test.cpp
@@ -11,11 +11,13 @@
#include <vespa/document/serialization/vespadocumentdeserializer.h>
#include <vespa/document/serialization/vespadocumentserializer.h>
#include <vespa/document/repo/documenttyperepo.h>
+#include <vespa/vespalib/gtest/gtest.h>
#include <vespa/vespalib/objects/nbostream.h>
-#include <vespa/vespalib/testkit/testapp.h>
+#include <vespa/vespalib/testkit/test_path.h>
#include <vespa/fastos/file.h>
-#include <fstream>
#include <algorithm>
+#include <fstream>
+#include <optional>
using std::fstream;
@@ -27,35 +29,11 @@ using namespace document;
namespace {
-class Test : public vespalib::TestApp {
- StringFieldValue::SpanTrees readSpanTree(const string &file_name, const FixedTypeRepo &repo);
-
- void requireThatSimpleSpanTreeIsDeserialized();
- void requireThatAdvancedSpanTreeIsDeserialized();
- void requireThatSpanTreeCanBeSerialized();
- void requireThatUnknownAnnotationIsSkipped();
-
-public:
- int Main() override;
-};
-
-int
-Test::Main()
-{
- if (getenv("TEST_SUBSET") != 0) { return 0; }
- TEST_INIT("annotationserializer_test");
- TEST_DO(requireThatSimpleSpanTreeIsDeserialized());
- TEST_DO(requireThatAdvancedSpanTreeIsDeserialized());
- TEST_DO(requireThatSpanTreeCanBeSerialized());
- TEST_DO(requireThatUnknownAnnotationIsSkipped());
-
- TEST_DONE();
-}
-
template <typename T, int N> int arraysize(const T (&)[N]) { return N; }
-StringFieldValue::SpanTrees
-Test::readSpanTree(const string &file_name, const FixedTypeRepo &repo) {
+void
+read_span_trees(const string &file_name, const FixedTypeRepo &repo, std::optional<StringFieldValue::SpanTrees>& span_trees)
+{
FastOS_File file(file_name.c_str());
ASSERT_TRUE(file.OpenReadOnlyExisting());
char buffer[1024];
@@ -67,26 +45,31 @@ Test::readSpanTree(const string &file_name, const FixedTypeRepo &repo) {
StringFieldValue value;
deserializer.read(value);
- EXPECT_EQUAL(0u, stream.size());
+ EXPECT_EQ(0u, stream.size());
ASSERT_TRUE(value.hasSpanTrees());
- return value.getSpanTrees();
+ span_trees = value.getSpanTrees();
}
-void Test::requireThatSimpleSpanTreeIsDeserialized() {
+}
+
+TEST(AnnotationSerializerTest, require_that_simple_span_tree_is_deserialized)
+{
DocumentTypeRepo type_repo(readDocumenttypesConfig(TEST_PATH("annotation.serialize.test.repo.cfg")));
FixedTypeRepo repo(type_repo);
- SpanTree::UP span_tree = std::move(readSpanTree(TEST_PATH("test_data_serialized_simple"), repo).front());
+ std::optional<StringFieldValue::SpanTrees> span_trees;
+ ASSERT_NO_FATAL_FAILURE(read_span_trees(TEST_PATH("test_data_serialized_simple"), repo, span_trees));
+ auto span_tree = std::move(span_trees.value().front());
- EXPECT_EQUAL("html", span_tree->getName());
+ EXPECT_EQ("html", span_tree->getName());
const SimpleSpanList *root = dynamic_cast<const SimpleSpanList *>(&span_tree->getRoot());
ASSERT_TRUE(root);
- EXPECT_EQUAL(5u, root->size());
+ EXPECT_EQ(5u, root->size());
SimpleSpanList::const_iterator it = root->begin();
- EXPECT_EQUAL(Span(0, 19), (*it++));
- EXPECT_EQUAL(Span(19, 5), (*it++));
- EXPECT_EQUAL(Span(24, 21), (*it++));
- EXPECT_EQUAL(Span(45, 23), (*it++));
- EXPECT_EQUAL(Span(68, 14), (*it++));
+ EXPECT_EQ(Span(0, 19), (*it++));
+ EXPECT_EQ(Span(19, 5), (*it++));
+ EXPECT_EQ(Span(24, 21), (*it++));
+ EXPECT_EQ(Span(45, 23), (*it++));
+ EXPECT_EQ(Span(68, 14), (*it++));
EXPECT_TRUE(it == root->end());
}
@@ -107,49 +90,51 @@ struct AnnotationComparator {
void compare() {
std::sort(expect.begin(), expect.end());
std::sort(actual.begin(), actual.end());
- EXPECT_EQUAL(expect.size(), actual.size());
+ EXPECT_EQ(expect.size(), actual.size());
for (size_t i = 0; i < expect.size() && i < actual.size(); ++i) {
- EXPECT_EQUAL(expect[i].size(), actual[i].size());
- EXPECT_EQUAL(expect[i], actual[i]);
+ EXPECT_EQ(expect[i].size(), actual[i].size());
+ EXPECT_EQ(expect[i], actual[i]);
}
}
};
-void Test::requireThatAdvancedSpanTreeIsDeserialized() {
+TEST(AnnotationSerializerTest, require_that_advanced_span_tree_is_deserialized)
+{
DocumentTypeRepo type_repo(readDocumenttypesConfig(TEST_PATH("annotation.serialize.test.repo.cfg")));
FixedTypeRepo repo(type_repo, "my_document");
- SpanTree::UP span_tree = std::move(readSpanTree(TEST_PATH("test_data_serialized_advanced"),
- repo).front());
+ std::optional<StringFieldValue::SpanTrees> span_trees;
+ ASSERT_NO_FATAL_FAILURE(read_span_trees(TEST_PATH("test_data_serialized_advanced"), repo, span_trees));
+ auto span_tree = std::move(span_trees.value().front());
- EXPECT_EQUAL("html", span_tree->getName());
+ EXPECT_EQ("html", span_tree->getName());
const SpanList *root = dynamic_cast<const SpanList *>(&span_tree->getRoot());
ASSERT_TRUE(root);
- EXPECT_EQUAL(4u, root->size());
+ EXPECT_EQ(4u, root->size());
SpanList::const_iterator it = root->begin();
- EXPECT_EQUAL(Span(0, 6), *(static_cast<Span *>(*it++)));
+ EXPECT_EQ(Span(0, 6), *(static_cast<Span *>(*it++)));
AlternateSpanList *alt_list = dynamic_cast<AlternateSpanList *>(*it++);
- EXPECT_EQUAL(Span(27, 9), *(static_cast<Span *>(*it++)));
- EXPECT_EQUAL(Span(36, 8), *(static_cast<Span *>(*it++)));
+ EXPECT_EQ(Span(27, 9), *(static_cast<Span *>(*it++)));
+ EXPECT_EQ(Span(36, 8), *(static_cast<Span *>(*it++)));
EXPECT_TRUE(it == root->end());
ASSERT_TRUE(alt_list);
- EXPECT_EQUAL(2u, alt_list->getNumSubtrees());
- EXPECT_EQUAL(0.9, alt_list->getProbability(0));
- EXPECT_EQUAL(0.1, alt_list->getProbability(1));
- EXPECT_EQUAL(4u, alt_list->getSubtree(0).size());
+ EXPECT_EQ(2u, alt_list->getNumSubtrees());
+ EXPECT_EQ(0.9, alt_list->getProbability(0));
+ EXPECT_EQ(0.1, alt_list->getProbability(1));
+ EXPECT_EQ(4u, alt_list->getSubtree(0).size());
it = alt_list->getSubtree(0).begin();
- EXPECT_EQUAL(Span(6, 3), *(static_cast<Span *>(*it++)));
- EXPECT_EQUAL(Span(9, 10), *(static_cast<Span *>(*it++)));
- EXPECT_EQUAL(Span(19, 4), *(static_cast<Span *>(*it++)));
- EXPECT_EQUAL(Span(23, 4), *(static_cast<Span *>(*it++)));
+ EXPECT_EQ(Span(6, 3), *(static_cast<Span *>(*it++)));
+ EXPECT_EQ(Span(9, 10), *(static_cast<Span *>(*it++)));
+ EXPECT_EQ(Span(19, 4), *(static_cast<Span *>(*it++)));
+ EXPECT_EQ(Span(23, 4), *(static_cast<Span *>(*it++)));
EXPECT_TRUE(it == alt_list->getSubtree(0).end());
- EXPECT_EQUAL(2u, alt_list->getSubtree(1).size());
+ EXPECT_EQ(2u, alt_list->getSubtree(1).size());
it = alt_list->getSubtree(1).begin();
- EXPECT_EQUAL(Span(6, 13), *(static_cast<Span *>(*it++)));
- EXPECT_EQUAL(Span(19, 8), *(static_cast<Span *>(*it++)));
+ EXPECT_EQ(Span(6, 13), *(static_cast<Span *>(*it++)));
+ EXPECT_EQ(Span(19, 8), *(static_cast<Span *>(*it++)));
EXPECT_TRUE(it == alt_list->getSubtree(1).end());
- EXPECT_EQUAL(12u, span_tree->numAnnotations());
+ EXPECT_EQ(12u, span_tree->numAnnotations());
AnnotationComparator comparator;
comparator.addActual(span_tree->begin(), span_tree->end())
@@ -213,10 +198,11 @@ void Test::requireThatAdvancedSpanTreeIsDeserialized() {
" AnnotationReferenceFieldValue(n)\n"
" )\n"
"))");
- TEST_DO(comparator.compare());
+ comparator.compare();
}
-void Test::requireThatSpanTreeCanBeSerialized() {
+TEST(AnnotationSerializerTest, require_that_span_tree_can_be_serialized)
+{
DocumentTypeRepo type_repo(
readDocumenttypesConfig(TEST_PATH("annotation.serialize.test.repo.cfg")));
FixedTypeRepo repo(type_repo, "my_document");
@@ -233,25 +219,26 @@ void Test::requireThatSpanTreeCanBeSerialized() {
StringFieldValue value;
deserializer.read(value);
- SpanTree::UP span_tree = std::move(value.getSpanTrees().front());
- EXPECT_EQUAL("html", span_tree->getName());
- EXPECT_EQUAL(0u, stream.size());
+ auto span_tree = std::move(value.getSpanTrees().front());
+ EXPECT_EQ("html", span_tree->getName());
+ EXPECT_EQ(0u, stream.size());
stream.clear();
VespaDocumentSerializer serializer(stream);
serializer.write(value);
- EXPECT_EQUAL(size, static_cast<ssize_t>(stream.size()));
+ EXPECT_EQ(size, static_cast<ssize_t>(stream.size()));
int diff_count = 0;
for (size_t i = 0; i < stream.size(); ++i) {
if (buffer[i] != stream.peek()[i]) {
++diff_count;
}
- EXPECT_EQUAL((int) buffer[i], (int) stream.peek()[i]);
+ EXPECT_EQ((int) buffer[i], (int) stream.peek()[i]);
}
- EXPECT_EQUAL(0, diff_count);
+ EXPECT_EQ(0, diff_count);
}
-void Test::requireThatUnknownAnnotationIsSkipped() {
+TEST(AnnotationSerializerTest, require_that_unknown_annotation_is_skipped)
+{
AnnotationType type(42, "my type");
Annotation annotation(type, FieldValue::UP(new StringFieldValue("foo")));
nbostream stream;
@@ -264,9 +251,7 @@ void Test::requireThatUnknownAnnotationIsSkipped() {
Annotation a;
deserializer.readAnnotation(a);
EXPECT_FALSE(a.valid());
- EXPECT_EQUAL(0u, stream.size());
+ EXPECT_EQ(0u, stream.size());
}
-} // namespace
-
-TEST_APPHOOK(Test);
+GTEST_MAIN_RUN_ALL_TESTS()
diff --git a/documentapi/src/tests/messagebus/CMakeLists.txt b/documentapi/src/tests/messagebus/CMakeLists.txt
index 22e213f29d8..ef597fbee10 100644
--- a/documentapi/src/tests/messagebus/CMakeLists.txt
+++ b/documentapi/src/tests/messagebus/CMakeLists.txt
@@ -4,5 +4,6 @@ vespa_add_executable(documentapi_messagebus_test_app TEST
messagebus_test.cpp
DEPENDS
documentapi
+ GTest::gtest
)
vespa_add_test(NAME documentapi_messagebus_test_app COMMAND documentapi_messagebus_test_app)
diff --git a/documentapi/src/tests/messagebus/messagebus_test.cpp b/documentapi/src/tests/messagebus/messagebus_test.cpp
index 6ce76fc753f..39f9cedb38f 100644
--- a/documentapi/src/tests/messagebus/messagebus_test.cpp
+++ b/documentapi/src/tests/messagebus/messagebus_test.cpp
@@ -6,7 +6,8 @@
#include <vespa/document/repo/documenttyperepo.h>
#include <vespa/document/update/documentupdate.h>
#include <vespa/documentapi/documentapi.h>
-#include <vespa/vespalib/testkit/testapp.h>
+#include <vespa/vespalib/gtest/gtest.h>
+#include <vespa/vespalib/testkit/test_path.h>
using document::DocumentTypeRepo;
using document::readDocumenttypesConfig;
@@ -15,44 +16,35 @@ using mbus::Blob;
using mbus::Routable;
using mbus::IRoutingPolicy;
-class Test : public vespalib::TestApp {
- std::shared_ptr<const DocumentTypeRepo> _repo;
-
-public:
- Test();
- ~Test();
- int Main() override;
-
-private:
- void testMessage();
- void testProtocol();
- void get_document_message_is_not_sequenced();
- void stat_bucket_message_is_not_sequenced();
- void get_bucket_list_message_is_not_sequenced();
+class MessageBusTest : public testing::Test {
+protected:
+ static std::shared_ptr<const DocumentTypeRepo> _repo;
+ MessageBusTest();
+ ~MessageBusTest() override;
+ static void SetUpTestSuite();
+ static void TearDownTestSuite();
};
-TEST_APPHOOK(Test);
-
-int
-Test::Main()
-{
- TEST_INIT(_argv[0]);
- _repo.reset(new DocumentTypeRepo(readDocumenttypesConfig(
- TEST_PATH("../../../test/cfg/testdoctypes.cfg"))));
+MessageBusTest::MessageBusTest() = default;
+MessageBusTest::~MessageBusTest() = default;
- testMessage(); TEST_FLUSH();
- testProtocol(); TEST_FLUSH();
- get_document_message_is_not_sequenced(); TEST_FLUSH();
- stat_bucket_message_is_not_sequenced(); TEST_FLUSH();
- get_bucket_list_message_is_not_sequenced(); TEST_FLUSH();
+std::shared_ptr<const DocumentTypeRepo> MessageBusTest::_repo;
- TEST_DONE();
+void
+MessageBusTest::SetUpTestSuite()
+{
+ auto path = TEST_PATH("../../../test/cfg/testdoctypes.cfg");
+ _repo = std::make_shared<const DocumentTypeRepo>(readDocumenttypesConfig(path));
}
-Test::Test() = default;
-Test::~Test() = default;
+void
+MessageBusTest::TearDownTestSuite()
+{
+ _repo.reset();
+}
-void Test::testMessage() {
+TEST_F(MessageBusTest, test_message)
+{
const document::DataType *testdoc_type = _repo->getDocumentType("testdoc");
// Test one update.
@@ -85,7 +77,8 @@ void Test::testMessage() {
EXPECT_TRUE(msg2.getType() == DocumentProtocol::MESSAGE_UPDATEDOCUMENT);
}
-void Test::testProtocol() {
+TEST_F(MessageBusTest, test_protocol)
+{
DocumentProtocol protocol(_repo);
EXPECT_TRUE(protocol.getName() == "document");
@@ -99,17 +92,22 @@ void Test::testProtocol() {
EXPECT_TRUE(policy.get() == NULL);
}
-void Test::get_document_message_is_not_sequenced() {
+TEST_F(MessageBusTest, get_document_message_is_not_sequenced)
+{
GetDocumentMessage message(document::DocumentId("id:foo:bar::baz"));
EXPECT_FALSE(message.hasSequenceId());
}
-void Test::stat_bucket_message_is_not_sequenced() {
+TEST_F(MessageBusTest, stat_bucket_message_is_not_sequenced)
+{
StatBucketMessage message(document::BucketId(16, 1), "");
EXPECT_FALSE(message.hasSequenceId());
}
-void Test::get_bucket_list_message_is_not_sequenced() {
+TEST_F(MessageBusTest, get_bucket_list_message_is_not_sequenced)
+{
GetBucketListMessage message(document::BucketId(16, 1));
EXPECT_FALSE(message.hasSequenceId());
}
+
+GTEST_MAIN_RUN_ALL_TESTS()
diff --git a/vespalib/src/tests/datastore/unique_store/unique_store_test.cpp b/vespalib/src/tests/datastore/unique_store/unique_store_test.cpp
index 7e96ab7b7a2..2c359db59b1 100644
--- a/vespalib/src/tests/datastore/unique_store/unique_store_test.cpp
+++ b/vespalib/src/tests/datastore/unique_store/unique_store_test.cpp
@@ -352,14 +352,14 @@ TYPED_TEST(TestBase, store_can_be_compacted)
{
EntryRef val0Ref = this->add(this->values()[0]);
EntryRef val1Ref = this->add(this->values()[1]);
- this->remove(this->add(this->values()[2]));
+ ASSERT_NO_FATAL_FAILURE(this->remove(this->add(this->values()[2])));
this->reclaim_memory();
size_t reserved = this->get_reserved(val0Ref);
this->assertBufferState(val0Ref, TestBufferStats().used(reserved + 3).dead(reserved + 1));
uint32_t val1BufferId = this->getBufferId(val0Ref);
EXPECT_EQ(2u, this->refStore.size());
- this->compactWorst();
+ ASSERT_NO_FATAL_FAILURE(this->compactWorst());
EXPECT_EQ(2u, this->refStore.size());
this->assertStoreContent();
@@ -401,7 +401,7 @@ TYPED_TEST(TestBase, store_can_be_enumerated)
{
EntryRef val0Ref = this->add(this->values()[0]);
EntryRef val1Ref = this->add(this->values()[1]);
- this->remove(this->add(this->values()[2]));
+ ASSERT_NO_FATAL_FAILURE(this->remove(this->add(this->values()[2])));
this->reclaim_memory();
auto enumerator = this->getEnumerator(true);