summaryrefslogtreecommitdiffstats
path: root/searchcore/src/tests/proton/server/shared_threading_service/shared_threading_service_test.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'searchcore/src/tests/proton/server/shared_threading_service/shared_threading_service_test.cpp')
-rw-r--r--searchcore/src/tests/proton/server/shared_threading_service/shared_threading_service_test.cpp38
1 files changed, 38 insertions, 0 deletions
diff --git a/searchcore/src/tests/proton/server/shared_threading_service/shared_threading_service_test.cpp b/searchcore/src/tests/proton/server/shared_threading_service/shared_threading_service_test.cpp
index faf64af17e1..e90bfc8ae57 100644
--- a/searchcore/src/tests/proton/server/shared_threading_service/shared_threading_service_test.cpp
+++ b/searchcore/src/tests/proton/server/shared_threading_service/shared_threading_service_test.cpp
@@ -1,10 +1,15 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#include <vespa/searchcore/config/config-proton.h>
+#include <vespa/searchcore/proton/server/shared_threading_service.h>
#include <vespa/searchcore/proton/server/shared_threading_service_config.h>
+#include <vespa/vespalib/util/isequencedtaskexecutor.h>
+#include <vespa/vespalib/util/sequencedtaskexecutor.h>
#include <vespa/vespalib/gtest/gtest.h>
using namespace proton;
+using vespalib::ISequencedTaskExecutor;
+using vespalib::SequencedTaskExecutor;
using ProtonConfig = vespa::config::search::core::ProtonConfig;
using ProtonConfigBuilder = vespa::config::search::core::ProtonConfigBuilder;
@@ -18,6 +23,8 @@ make_proton_config(double concurrency)
builder.flush.maxconcurrent = 1;
builder.feeding.concurrency = concurrency;
+ builder.feeding.sharedFieldWriterExecutor = ProtonConfig::Feeding::SharedFieldWriterExecutor::DOCUMENT_DB;
+ builder.indexing.tasklimit = 300;
return builder;
}
@@ -38,4 +45,35 @@ TEST(SharedThreadingServiceConfigTest, shared_threads_are_derived_from_cpu_cores
expect_shared_threads(5, 10);
}
+class SharedThreadingServiceTest : public ::testing::Test {
+public:
+ std::unique_ptr<SharedThreadingService> service;
+ SharedThreadingServiceTest()
+ : service()
+ {
+ }
+ void setup(double concurrency, uint32_t cpu_cores) {
+ service = std::make_unique<SharedThreadingService>(
+ SharedThreadingServiceConfig::make(make_proton_config(concurrency), HwInfo::Cpu(cpu_cores)));
+ }
+ SequencedTaskExecutor* field_writer() {
+ return dynamic_cast<SequencedTaskExecutor*>(service->field_writer());
+ }
+};
+
+void
+assert_executor(SequencedTaskExecutor* exec, uint32_t exp_executors, uint32_t exp_task_limit)
+{
+ EXPECT_EQ(exp_executors, exec->getNumExecutors());
+ EXPECT_EQ(exp_task_limit, exec->first_executor()->getTaskLimit());
+}
+
+TEST_F(SharedThreadingServiceTest, field_writer_can_be_shared_across_all_document_dbs)
+{
+ setup(0.75, 8);
+ EXPECT_TRUE(field_writer());
+ EXPECT_EQ(6, field_writer()->getNumExecutors());
+ EXPECT_EQ(300, field_writer()->first_executor()->getTaskLimit());
+}
+
GTEST_MAIN_RUN_ALL_TESTS()