summaryrefslogtreecommitdiffstats
path: root/searchcore/src/tests
diff options
context:
space:
mode:
Diffstat (limited to 'searchcore/src/tests')
-rw-r--r--searchcore/src/tests/proton/attribute/document_field_extractor/document_field_extractor_test.cpp8
-rw-r--r--searchcore/src/tests/proton/document_iterator/document_iterator_test.cpp90
-rw-r--r--searchcore/src/tests/proton/documentdb/executor_threading_service/executor_threading_service_test.cpp1
-rw-r--r--searchcore/src/tests/proton/index/fusionrunner_test.cpp1
-rw-r--r--searchcore/src/tests/proton/index/indexcollection_test.cpp5
-rw-r--r--searchcore/src/tests/proton/server/documentretriever_test.cpp23
-rw-r--r--searchcore/src/tests/proton/verify_ranksetup/verify_ranksetup_test.cpp14
7 files changed, 74 insertions, 68 deletions
diff --git a/searchcore/src/tests/proton/attribute/document_field_extractor/document_field_extractor_test.cpp b/searchcore/src/tests/proton/attribute/document_field_extractor/document_field_extractor_test.cpp
index 65d17d207ec..903b4d89696 100644
--- a/searchcore/src/tests/proton/attribute/document_field_extractor/document_field_extractor_test.cpp
+++ b/searchcore/src/tests/proton/attribute/document_field_extractor/document_field_extractor_test.cpp
@@ -50,7 +50,7 @@ makeIntArray(const std::vector<int32_t> &array)
{
auto result = std::make_unique<ArrayFieldValue>(arrayTypeInt);
for (const auto &elem : array) {
- result->append(std::make_unique<IntFieldValue>(elem));
+ result->append(IntFieldValue::make(elem));
}
return result;
}
@@ -60,7 +60,7 @@ makeStringArray(const std::vector<vespalib::string> &array)
{
auto result = std::make_unique<ArrayFieldValue>(arrayTypeString);
for (const auto &elem : array) {
- result->append(std::make_unique<StringFieldValue>(elem));
+ result->append(StringFieldValue::make(elem));
}
return result;
}
@@ -160,8 +160,8 @@ TEST_F("require that simple fields give simple values", SimpleFixture)
auto doc = f.makeDoc();
doc->setValue(f.weightField, IntFieldValue(200));
doc->setValue(f.nameField, StringFieldValue("name200b"));
- TEST_DO(f.assertExtracted("weight", std::make_unique<IntFieldValue>(200)));
- TEST_DO(f.assertExtracted("name", std::make_unique<StringFieldValue>("name200b")));
+ TEST_DO(f.assertExtracted("weight", IntFieldValue::make(200)));
+ TEST_DO(f.assertExtracted("name", StringFieldValue::make("name200b")));
}
struct ArrayFixture : public FixtureBase
diff --git a/searchcore/src/tests/proton/document_iterator/document_iterator_test.cpp b/searchcore/src/tests/proton/document_iterator/document_iterator_test.cpp
index 82eac88a53e..a460c65fbb2 100644
--- a/searchcore/src/tests/proton/document_iterator/document_iterator_test.cpp
+++ b/searchcore/src/tests/proton/document_iterator/document_iterator_test.cpp
@@ -338,8 +338,8 @@ const DocumentType &getAttrDocType() {
IDocumentRetriever::SP doc_with_fields(const std::string &id, Timestamp t, Bucket b) {
auto d = std::make_unique<Document>(getDocType(), DocumentId(id));
- d->set("header", "foo");
- d->set("body", "bar");
+ d->setValue("header", StringFieldValue::make("foo"));
+ d->setValue("body", StringFieldValue::make("bar"));
return std::make_shared<UnitDR>(getDocType(), std::move(d), t, b, false);
}
@@ -355,12 +355,12 @@ IDocumentRetriever::SP doc_with_attr_fields(const vespalib::string &id,
const vespalib::string &attr_ss)
{
auto d = std::make_unique<Document>(getAttrDocType(), DocumentId(id));
- d->set("header", "foo");
- d->set("body", "bar");
- d->set("aa", aa);
- d->set("ab", ab);
- d->set("dd", dd);
- d->set("ss", ss);
+ d->setValue("header", StringFieldValue::make("foo"));
+ d->setValue("body", StringFieldValue::make("bar"));
+ d->setValue("aa", IntFieldValue::make(aa));
+ d->setValue("ab", IntFieldValue::make(ab));
+ d->setValue("dd", DoubleFieldValue::make(dd));
+ d->setValue("ss", StringFieldValue::make(ss));
return std::make_shared<AttrUnitDR>(std::move(d), t, b, false, attr_aa, attr_dd, attr_ss);
}
@@ -782,7 +782,7 @@ TEST("require that fieldset limits fields returned") {
EXPECT_TRUE(res.isCompleted());
EXPECT_EQUAL(1u, res.getEntries().size());
Document expected(getDocType(), DocumentId("id:ns:foo::xxx1"));
- expected.set("header", "foo");
+ expected.setValue("header", StringFieldValue::make("foo"));
TEST_DO(checkEntry(res, 0, expected, Timestamp(1)));
}
@@ -838,19 +838,19 @@ TEST("require that attributes are used")
EXPECT_TRUE(res.isCompleted());
EXPECT_EQUAL(2u, res.getEntries().size());
Document expected1(getAttrDocType(), DocumentId("id:ns:foo::xx2"));
- expected1.set("header", "foo");
- expected1.set("body", "bar");
- expected1.set("aa", 27);
- expected1.set("ab", 28);
- expected1.set("dd", 2.7);
- expected1.set("ss", "x27");
+ expected1.setValue("header", StringFieldValue::make("foo"));
+ expected1.setValue("body", StringFieldValue::make("bar"));
+ expected1.setValue("aa", IntFieldValue::make(27));
+ expected1.setValue("ab", IntFieldValue::make(28));
+ expected1.setValue("dd", DoubleFieldValue::make(2.7));
+ expected1.setValue("ss", StringFieldValue::make("x27"));
Document expected2(getAttrDocType(), DocumentId("id:ns:foo::xx4"));
- expected2.set("header", "foo");
- expected2.set("body", "bar");
- expected2.set("aa", 45);
- expected2.set("ab", 46);
- expected2.set("dd", 4.5);
- expected2.set("ss", "x45");
+ expected2.setValue("header", StringFieldValue::make("foo"));
+ expected2.setValue("body", StringFieldValue::make("bar"));
+ expected2.setValue("aa", IntFieldValue::make(45));
+ expected2.setValue("ab", IntFieldValue::make(46));
+ expected2.setValue("dd", DoubleFieldValue::make(4.5));
+ expected2.setValue("ss", StringFieldValue::make("x45"));
TEST_DO(checkEntry(res, 0, expected1, Timestamp(2)));
TEST_DO(checkEntry(res, 1, expected2, Timestamp(4)));
@@ -868,19 +868,19 @@ TEST("require that attributes are used")
EXPECT_TRUE(res2.isCompleted());
EXPECT_EQUAL(2u, res2.getEntries().size());
Document expected3(getAttrDocType(), DocumentId("id:ns:foo::xx6"));
- expected3.set("header", "foo");
- expected3.set("body", "bar");
- expected3.set("aa", 27);
- expected3.set("ab", 28);
- expected3.set("dd", 2.7);
- expected3.set("ss", "x27");
+ expected3.setValue("header", StringFieldValue::make("foo"));
+ expected3.setValue("body", StringFieldValue::make("bar"));
+ expected3.setValue("aa", IntFieldValue::make(27));
+ expected3.setValue("ab", IntFieldValue::make(28));
+ expected3.setValue("dd", DoubleFieldValue::make(2.7));
+ expected3.setValue("ss", StringFieldValue::make("x27"));
Document expected4(getAttrDocType(), DocumentId("id:ns:foo::xx8"));
- expected4.set("header", "foo");
- expected4.set("body", "bar");
- expected4.set("aa", 45);
- expected4.set("ab", 46);
- expected4.set("dd", 4.5);
- expected4.set("ss", "x45");
+ expected4.setValue("header", StringFieldValue::make("foo"));
+ expected4.setValue("body", StringFieldValue::make("bar"));
+ expected4.setValue("aa", IntFieldValue::make(45));
+ expected4.setValue("ab", IntFieldValue::make(46));
+ expected4.setValue("dd", DoubleFieldValue::make(4.5));
+ expected4.setValue("ss", StringFieldValue::make("x45"));
TEST_DO(checkEntry(res2, 0, expected3, Timestamp(6)));
TEST_DO(checkEntry(res2, 1, expected4, Timestamp(8)));
@@ -898,19 +898,19 @@ TEST("require that attributes are used")
EXPECT_TRUE(res3.isCompleted());
EXPECT_EQUAL(2u, res3.getEntries().size());
Document expected5(getAttrDocType(), DocumentId("id:ns:foo::xx10"));
- expected5.set("header", "foo");
- expected5.set("body", "bar");
- expected5.set("aa", 27);
- expected5.set("ab", 28);
- expected5.set("dd", 2.7);
- expected5.set("ss", "x27");
+ expected5.setValue("header", StringFieldValue::make("foo"));
+ expected5.setValue("body", StringFieldValue::make("bar"));
+ expected5.setValue("aa", IntFieldValue::make(27));
+ expected5.setValue("ab", IntFieldValue::make(28));
+ expected5.setValue("dd", DoubleFieldValue::make(2.7));
+ expected5.setValue("ss", StringFieldValue::make("x27"));
Document expected6(getAttrDocType(), DocumentId("id:ns:foo::xx12"));
- expected6.set("header", "foo");
- expected6.set("body", "bar");
- expected6.set("aa", 45);
- expected6.set("ab", 46);
- expected6.set("dd", 4.5);
- expected6.set("ss", "x45");
+ expected6.setValue("header", StringFieldValue::make("foo"));
+ expected6.setValue("body", StringFieldValue::make("bar"));
+ expected6.setValue("aa", IntFieldValue::make(45));
+ expected6.setValue("ab", IntFieldValue::make(46));
+ expected6.setValue("dd", DoubleFieldValue::make(4.5));
+ expected6.setValue("ss", StringFieldValue::make("x45"));
TEST_DO(checkEntry(res3, 0, expected5, Timestamp(10)));
TEST_DO(checkEntry(res3, 1, expected6, Timestamp(12)));
}
diff --git a/searchcore/src/tests/proton/documentdb/executor_threading_service/executor_threading_service_test.cpp b/searchcore/src/tests/proton/documentdb/executor_threading_service/executor_threading_service_test.cpp
index 934dcdb36e3..46a6419e924 100644
--- a/searchcore/src/tests/proton/documentdb/executor_threading_service/executor_threading_service_test.cpp
+++ b/searchcore/src/tests/proton/documentdb/executor_threading_service/executor_threading_service_test.cpp
@@ -33,6 +33,7 @@ public:
void setup(uint32_t indexing_threads, SharedFieldWriterExecutor shared_field_writer) {
service = std::make_unique<ExecutorThreadingService>(_transport.shared(),
_transport.transport(),
+ _transport.clock(),
field_writer_executor.get(),
nullptr,
ThreadingServiceConfig::make(indexing_threads, shared_field_writer));
diff --git a/searchcore/src/tests/proton/index/fusionrunner_test.cpp b/searchcore/src/tests/proton/index/fusionrunner_test.cpp
index 38314abd7e5..1b04415b78f 100644
--- a/searchcore/src/tests/proton/index/fusionrunner_test.cpp
+++ b/searchcore/src/tests/proton/index/fusionrunner_test.cpp
@@ -18,6 +18,7 @@
#include <vespa/vespalib/util/destructor_callbacks.h>
#include <vespa/vespalib/testkit/testapp.h>
#include <vespa/vespalib/util/size_literals.h>
+#include <vespa/searchlib/queryeval/fake_requestcontext.h>
#include <set>
using document::Document;
diff --git a/searchcore/src/tests/proton/index/indexcollection_test.cpp b/searchcore/src/tests/proton/index/indexcollection_test.cpp
index 70141f057bf..6f6fe3d4e41 100644
--- a/searchcore/src/tests/proton/index/indexcollection_test.cpp
+++ b/searchcore/src/tests/proton/index/indexcollection_test.cpp
@@ -5,7 +5,7 @@
#include <vespa/vespalib/gtest/gtest.h>
#include <vespa/vespalib/util/size_literals.h>
#include <vespa/vespalib/util/threadstackexecutor.h>
-
+#include <vespa/vespalib/util/testclock.h>
#include <vespa/log/log.h>
LOG_SETUP("indexcollection_test");
@@ -43,6 +43,7 @@ public:
std::shared_ptr<IndexSearchable> _source2;
std::shared_ptr<IndexSearchable> _fusion_source;
vespalib::ThreadStackExecutor _executor;
+ vespalib::TestClock _clock;
std::shared_ptr<IndexSearchable> _warmup;
void expect_searchable_can_be_appended(IndexCollection::UP collection) {
@@ -76,7 +77,7 @@ public:
}
IndexCollection::UP create_warmup(const IndexCollection::SP& prev, const IndexCollection::SP& next) {
- return std::make_unique<WarmupIndexCollection>(WarmupConfig(1s, false), prev, next, *_warmup, _executor, *this);
+ return std::make_unique<WarmupIndexCollection>(WarmupConfig(1s, false), prev, next, *_warmup, _executor, _clock.clock(), *this);
}
void warmupDone(std::shared_ptr<WarmupIndexCollection> current) override {
diff --git a/searchcore/src/tests/proton/server/documentretriever_test.cpp b/searchcore/src/tests/proton/server/documentretriever_test.cpp
index e631388c9b8..b4236ba4e3e 100644
--- a/searchcore/src/tests/proton/server/documentretriever_test.cpp
+++ b/searchcore/src/tests/proton/server/documentretriever_test.cpp
@@ -20,6 +20,7 @@
#include <vespa/document/fieldset/fieldsets.h>
#include <vespa/document/repo/configbuilder.h>
#include <vespa/document/repo/documenttyperepo.h>
+#include <vespa/document/test/fieldvalue_helpers.h>
#include <vespa/eval/eval/simple_value.h>
#include <vespa/eval/eval/tensor_spec.h>
#include <vespa/eval/eval/value.h>
@@ -66,6 +67,7 @@ using document::StructFieldValue;
using document::TensorDataType;
using document::TensorFieldValue;
using document::WeightedSetFieldValue;
+using document::WSetHelper;
using search::AttributeFactory;
using search::AttributeGuard;
using search::AttributeVector;
@@ -160,12 +162,12 @@ struct MyDocumentStore : proton::test::DummyDocumentStore {
const DocumentType *doc_type = r.getDocumentType(doc_type_name);
auto doc = std::make_unique<Document>(*doc_type, doc_id);
ASSERT_TRUE(doc);
- doc->set(static_field, static_value);
- doc->set(dyn_field_i, static_value);
- doc->set(dyn_field_s, static_value_s);
- doc->set(dyn_field_nai, static_value);
- doc->set(dyn_field_nas, static_value_s);
- doc->set(zcurve_field, static_zcurve_value);
+ doc->setValue(static_field, IntFieldValue::make(static_value));
+ doc->setValue(dyn_field_i, IntFieldValue::make(static_value));
+ doc->setValue(dyn_field_s, StringFieldValue::make(static_value_s));
+ doc->setValue(dyn_field_nai, IntFieldValue::make(static_value));
+ doc->setValue(dyn_field_nas, StringFieldValue::make(static_value_s));
+ doc->setValue(zcurve_field, LongFieldValue::make(static_zcurve_value));
doc->setValue(dyn_field_p, static_value_p);
TensorFieldValue tensorFieldValue(tensorDataType);
tensorFieldValue = SimpleValue::from_value(*static_tensor);
@@ -173,8 +175,8 @@ struct MyDocumentStore : proton::test::DummyDocumentStore {
if (_set_position_struct_field) {
FieldValue::UP fv = PositionDataType::getInstance().createFieldValue();
auto &pos = dynamic_cast<StructFieldValue &>(*fv);
- pos.set(PositionDataType::FIELD_X, 42);
- pos.set(PositionDataType::FIELD_Y, 21);
+ pos.setValue(PositionDataType::FIELD_X, IntFieldValue::make(42));
+ pos.setValue(PositionDataType::FIELD_Y, IntFieldValue::make(21));
doc->setValue(doc->getField(position_field), *fv);
}
@@ -430,10 +432,11 @@ template <typename T>
void checkWset(FieldValue::UP wset, T v) {
ASSERT_TRUE(wset);
auto *wset_val = dynamic_cast<WeightedSetFieldValue *>(wset.get());
+ WSetHelper val(*wset_val);
ASSERT_TRUE(wset_val);
ASSERT_EQUAL(2u, wset_val->size());
- EXPECT_EQUAL(dyn_weight, wset_val->get(v));
- EXPECT_EQUAL(dyn_weight, wset_val->get(v + 1));
+ EXPECT_EQUAL(dyn_weight, val.get(v));
+ EXPECT_EQUAL(dyn_weight, val.get(v + 1));
}
TEST_F("require that attributes are patched into stored document", Fixture) {
diff --git a/searchcore/src/tests/proton/verify_ranksetup/verify_ranksetup_test.cpp b/searchcore/src/tests/proton/verify_ranksetup/verify_ranksetup_test.cpp
index c6c65f45e4b..1feb46cfdb7 100644
--- a/searchcore/src/tests/proton/verify_ranksetup/verify_ranksetup_test.cpp
+++ b/searchcore/src/tests/proton/verify_ranksetup/verify_ranksetup_test.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/vespalib/util/child_process.h>
+#include <vespa/vespalib/process/process.h>
#include <vespa/vespalib/util/stringfmt.h>
#include <vespa/searchcommon/common/schema.h>
#include <vespa/searchlib/fef/indexproperties.h>
@@ -220,7 +220,7 @@ struct Setup {
}
bool verify() {
generate();
- return vespalib::ChildProcess::run(fmt("%s dir:%s", prog, gen_dir.c_str()).c_str());
+ return vespalib::Process::run(fmt("%s dir:%s", prog, gen_dir.c_str()));
}
void verify_valid(std::initializer_list<std::string> features) {
for (const std::string &f: features) {
@@ -288,12 +288,12 @@ struct ShadowSetup : Setup {
};
TEST_F("print usage", Setup()) {
- EXPECT_TRUE(!vespalib::ChildProcess::run(fmt("%s", prog).c_str()));
+ EXPECT_TRUE(!vespalib::Process::run(fmt("%s", prog)));
}
TEST_F("setup output directory", Setup()) {
- ASSERT_TRUE(vespalib::ChildProcess::run(fmt("rm -rf %s", gen_dir.c_str()).c_str()));
- ASSERT_TRUE(vespalib::ChildProcess::run(fmt("mkdir %s", gen_dir.c_str()).c_str()));
+ ASSERT_TRUE(vespalib::Process::run(fmt("rm -rf %s", gen_dir.c_str())));
+ ASSERT_TRUE(vespalib::Process::run(fmt("mkdir %s", gen_dir.c_str())));
}
//-----------------------------------------------------------------------------
@@ -458,7 +458,7 @@ TEST_F("require that broken fragile model without dry-run passes verification",
//-----------------------------------------------------------------------------
TEST_F("cleanup files", Setup()) {
- ASSERT_TRUE(vespalib::ChildProcess::run(fmt("rm -rf %s", gen_dir.c_str()).c_str()));
+ ASSERT_TRUE(vespalib::Process::run(fmt("rm -rf %s", gen_dir.c_str())));
}
-TEST_MAIN_WITH_PROCESS_PROXY() { TEST_RUN_ALL(); }
+TEST_MAIN() { TEST_RUN_ALL(); }