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.xml2
-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/btree/frozenbtree_test.cpp37
-rw-r--r--vespalib/src/tests/datastore/array_store/array_store_test.cpp24
-rw-r--r--vespalib/src/tests/datastore/sharded_hash_map/sharded_hash_map_test.cpp6
10 files changed, 176 insertions, 239 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 8dddaddf7a2..c0dcfde9f10 100644
--- a/dependency-versions/pom.xml
+++ b/dependency-versions/pom.xml
@@ -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/btree/frozenbtree_test.cpp b/vespalib/src/tests/btree/frozenbtree_test.cpp
index ffe8b4516aa..bc8230e2ded 100644
--- a/vespalib/src/tests/btree/frozenbtree_test.cpp
+++ b/vespalib/src/tests/btree/frozenbtree_test.cpp
@@ -416,37 +416,22 @@ TEST_F(FrozenBTreeTest, test_frozen_btree)
sortRandomValues();
allocTree();
- insertRandomValues(*_tree, *_allocator, _randomValues);
- lookupRandomValues(*_tree, *_allocator, _randomValues);
+ ASSERT_NO_FATAL_FAILURE(insertRandomValues(*_tree, *_allocator, _randomValues));
+ ASSERT_NO_FATAL_FAILURE(lookupRandomValues(*_tree, *_allocator, _randomValues));
EXPECT_TRUE(_tree->getFrozenView(*_allocator).empty());
_allocator->freeze();
EXPECT_FALSE(_tree->getFrozenView(*_allocator).empty());
_allocator->assign_generation(_generationHandler->getCurrentGeneration());
lookupFrozenRandomValues(*_tree, *_allocator, _randomValues);
- traverseTreeIterator(*_tree,
- *_allocator,
- _sortedRandomValues,
- false);
- traverseTreeIterator(*_tree,
- *_allocator,
- _sortedRandomValues,
- true);
- traverseTreeIterator(*_tree,
- *_allocator,
- _sortedRandomValues,
- false);
- traverseTreeIterator(*_tree,
- *_allocator,
- _sortedRandomValues,
- true);
- removeRandomValues(*_tree, *_allocator, _randomValues);
- lookupGoneRandomValues(*_tree, *_allocator, _randomValues);
- lookupFrozenRandomValues(*_tree, *_allocator,_randomValues);
- traverseTreeIterator(*_tree,
- *_allocator,
- _sortedRandomValues,
- true);
- insertRandomValues(*_tree, *_allocator, _randomValues);
+ ASSERT_NO_FATAL_FAILURE(traverseTreeIterator(*_tree, *_allocator, _sortedRandomValues, false));
+ ASSERT_NO_FATAL_FAILURE(traverseTreeIterator(*_tree, *_allocator, _sortedRandomValues, true));
+ ASSERT_NO_FATAL_FAILURE(traverseTreeIterator(*_tree, *_allocator, _sortedRandomValues, false));
+ ASSERT_NO_FATAL_FAILURE(traverseTreeIterator(*_tree, *_allocator, _sortedRandomValues, true));
+ ASSERT_NO_FATAL_FAILURE(removeRandomValues(*_tree, *_allocator, _randomValues));
+ ASSERT_NO_FATAL_FAILURE(lookupGoneRandomValues(*_tree, *_allocator, _randomValues));
+ ASSERT_NO_FATAL_FAILURE(lookupFrozenRandomValues(*_tree, *_allocator,_randomValues));
+ ASSERT_NO_FATAL_FAILURE(traverseTreeIterator(*_tree, *_allocator, _sortedRandomValues, true));
+ ASSERT_NO_FATAL_FAILURE(insertRandomValues(*_tree, *_allocator, _randomValues));
freeTree(true);
}
diff --git a/vespalib/src/tests/datastore/array_store/array_store_test.cpp b/vespalib/src/tests/datastore/array_store/array_store_test.cpp
index 583f6590e87..dc248ec2fed 100644
--- a/vespalib/src/tests/datastore/array_store/array_store_test.cpp
+++ b/vespalib/src/tests/datastore/array_store/array_store_test.cpp
@@ -145,7 +145,7 @@ struct ArrayStoreTest : public TestT
}
void assert_ref_reused(const ElemVector& first, const ElemVector& second, bool should_reuse) {
EntryRef ref1 = add(first);
- remove(ref1);
+ ASSERT_NO_FATAL_FAILURE(remove(ref1));
reclaim_memory();
EntryRef ref2 = add(second);
EXPECT_EQ(should_reuse, (ref2 == ref1));
@@ -372,7 +372,7 @@ TYPED_TEST(NumberStoreFreeListsDisabledTest, large_arrays_are_NOT_allocated_from
TYPED_TEST(NumberStoreTest, track_size_of_large_array_allocations_with_free_lists_enabled) {
EntryRef ref = this->add({1,2,3,4,5});
this->assert_buffer_stats(ref, TestBufferStats().used(2).hold(0).dead(1).extra_used(20));
- this->remove({1,2,3,4,5});
+ ASSERT_NO_FATAL_FAILURE(this->remove({1,2,3,4,5}));
this->assert_buffer_stats(ref, TestBufferStats().used(2).hold(1).dead(1).extra_hold(20).extra_used(20));
this->reclaim_memory();
this->assert_buffer_stats(ref, TestBufferStats().used(2).hold(0).dead(2).extra_used(0));
@@ -406,7 +406,7 @@ test_compaction(NumberStoreBasicTest &f)
EntryRef size1Ref = f.add({1});
EntryRef size2Ref = f.add({2,2});
EntryRef size3Ref = f.add({3,3,3});
- f.remove(f.add({5,5}));
+ ASSERT_NO_FATAL_FAILURE(f.remove(f.add({5,5})));
f.reclaim_memory();
f.assertBufferState(size1Ref, MemStats().used(1).dead(0));
f.assertBufferState(size2Ref, MemStats().used(2).dead(1));
@@ -416,7 +416,7 @@ test_compaction(NumberStoreBasicTest &f)
uint32_t size3BufferId = f.getBufferId(size3Ref);
EXPECT_EQ(3u, f.refStore.size());
- f.compactWorst(true, false);
+ ASSERT_NO_FATAL_FAILURE(f.compactWorst(true, false));
EXPECT_EQ(3u, f.refStore.size());
f.assertStoreContent();
@@ -449,9 +449,9 @@ void testCompaction(Fixture &f, bool compactMemory, bool compactAddressSpace)
EntryRef size1Ref = f.add({1});
EntryRef size2Ref = f.add({2,2});
EntryRef size3Ref = f.add({3,3,3});
- f.remove(f.add({5,5,5}));
- f.remove(f.add({6}));
- f.remove(f.add({7}));
+ ASSERT_NO_FATAL_FAILURE(f.remove(f.add({5,5,5})));
+ ASSERT_NO_FATAL_FAILURE(f.remove(f.add({6})));
+ ASSERT_NO_FATAL_FAILURE(f.remove(f.add({7})));
f.reclaim_memory();
f.assertBufferState(size1Ref, MemStats().used(3).dead(2));
f.assertBufferState(size2Ref, MemStats().used(1).dead(0));
@@ -461,7 +461,7 @@ void testCompaction(Fixture &f, bool compactMemory, bool compactAddressSpace)
uint32_t size3BufferId = f.getBufferId(size3Ref);
EXPECT_EQ(3u, f.refStore.size());
- f.compactWorst(compactMemory, compactAddressSpace);
+ ASSERT_NO_FATAL_FAILURE(f.compactWorst(compactMemory, compactAddressSpace));
EXPECT_EQ(3u, f.refStore.size());
f.assertStoreContent();
@@ -527,7 +527,7 @@ TYPED_TEST(NumberStoreTest, used_onHold_and_dead_memory_usage_is_tracked_for_sma
this->add({1,2,3});
uint32_t exp_entry_size = this->simple_buffers() ? (this->elem_size() * 3) : (this->elem_size() * 4 + 4);
this->assertMemoryUsage(exp.used(exp_entry_size));
- this->remove({1,2,3});
+ ASSERT_NO_FATAL_FAILURE(this->remove({1,2,3}));
this->assertMemoryUsage(exp.hold(exp_entry_size));
this->reclaim_memory();
this->assertMemoryUsage(exp.holdToDead(exp_entry_size));
@@ -538,7 +538,7 @@ TYPED_TEST(NumberStoreTest, used_onHold_and_dead_memory_usage_is_tracked_for_lar
MemStats exp(this->store.getMemoryUsage());
this->add({1,2,3,4,5});
this->assertMemoryUsage(exp.used(this->largeArraySize() + this->elem_size() * 5));
- this->remove({1,2,3,4,5});
+ ASSERT_NO_FATAL_FAILURE(this->remove({1,2,3,4,5}));
this->assertMemoryUsage(exp.hold(this->largeArraySize() + this->elem_size() * 5));
this->reclaim_memory();
this->assertMemoryUsage(exp.decUsed(this->elem_size() * 5).decHold(this->largeArraySize() + this->elem_size() * 5).
@@ -599,8 +599,8 @@ TYPED_TEST(NumberStoreTest, provided_memory_allocator_is_used)
EXPECT_EQ(AllocStats(5, 0), this->stats);
this->assertAdd({2,3,4,5,6,7});
EXPECT_EQ(AllocStats(6, 0), this->stats);
- this->remove({1,2,3,4,5});
- this->remove({2,3,4,5,6,7});
+ ASSERT_NO_FATAL_FAILURE(this->remove({1,2,3,4,5}));
+ ASSERT_NO_FATAL_FAILURE(this->remove({2,3,4,5,6,7}));
this->reclaim_memory();
EXPECT_EQ(AllocStats(6, 2), this->stats);
this->assertAdd({1,2,3,4,5});
diff --git a/vespalib/src/tests/datastore/sharded_hash_map/sharded_hash_map_test.cpp b/vespalib/src/tests/datastore/sharded_hash_map/sharded_hash_map_test.cpp
index 08b9b96e202..6b4aa51a481 100644
--- a/vespalib/src/tests/datastore/sharded_hash_map/sharded_hash_map_test.cpp
+++ b/vespalib/src/tests/datastore/sharded_hash_map/sharded_hash_map_test.cpp
@@ -306,7 +306,7 @@ void
DataStoreShardedHashTest::test_normalize_values(bool use_filter, bool one_filter)
{
populate_sample_data(large_population);
- populate_sample_values(large_population);
+ ASSERT_NO_FATAL_FAILURE(populate_sample_values(large_population));
if (use_filter) {
auto filter = make_entry_ref_filter<RefT>(one_filter);
EXPECT_TRUE(_hash_map.normalize_values([](std::vector<EntryRef> &refs) noexcept { for (auto &ref : refs) { RefT iref(ref); ref = RefT(iref.offset() + 300, iref.bufferId()); } }, filter));
@@ -332,7 +332,7 @@ void
DataStoreShardedHashTest::test_foreach_value(bool one_filter)
{
populate_sample_data(large_population);
- populate_sample_values(large_population);
+ ASSERT_NO_FATAL_FAILURE(populate_sample_values(large_population));
auto filter = make_entry_ref_filter<RefT>(one_filter);
std::vector<EntryRef> exp_refs;
@@ -340,7 +340,7 @@ DataStoreShardedHashTest::test_foreach_value(bool one_filter)
std::vector<EntryRef> act_refs;
_hash_map.foreach_value([&act_refs](const std::vector<EntryRef> &refs) { act_refs.insert(act_refs.end(), refs.begin(), refs.end()); }, filter);
EXPECT_EQ(exp_refs, act_refs);
- clear_sample_values(large_population);
+ ASSERT_NO_FATAL_FAILURE(clear_sample_values(large_population));
}
TEST_F(DataStoreShardedHashTest, single_threaded_reader_without_updates)