aboutsummaryrefslogtreecommitdiffstats
path: root/staging_vespalib
diff options
context:
space:
mode:
Diffstat (limited to 'staging_vespalib')
-rw-r--r--staging_vespalib/src/tests/singleexecutor/singleexecutor_test.cpp28
1 files changed, 15 insertions, 13 deletions
diff --git a/staging_vespalib/src/tests/singleexecutor/singleexecutor_test.cpp b/staging_vespalib/src/tests/singleexecutor/singleexecutor_test.cpp
index 732ab122546..fae57b6532f 100644
--- a/staging_vespalib/src/tests/singleexecutor/singleexecutor_test.cpp
+++ b/staging_vespalib/src/tests/singleexecutor/singleexecutor_test.cpp
@@ -35,13 +35,15 @@ void verifyResizeTaskLimit(bool up) {
std::condition_variable cond;
std::atomic<uint64_t> started(0);
std::atomic<uint64_t> allowed(0);
- SingleExecutor executor(sequenced_executor, 10);
+ constexpr uint32_t INITIAL = 20;
+ const uint32_t INITIAL_2inN = roundUp2inN(INITIAL);
+ SingleExecutor executor(sequenced_executor, INITIAL, INITIAL/2, 10ms);
- uint32_t targetTaskLimit = up ? 20 : 5;
+ uint32_t targetTaskLimit = up ? 40 : 5;
uint32_t roundedTaskLimit = roundUp2inN(targetTaskLimit);
- EXPECT_NOT_EQUAL(16u, roundedTaskLimit);
+ EXPECT_NOT_EQUAL(INITIAL_2inN, roundedTaskLimit);
- for (uint64_t i(0); i < 10; i++) {
+ for (uint64_t i(0); i < INITIAL; i++) {
executor.execute(makeLambdaTask([&lock, &cond, &started, &allowed] {
started++;
std::unique_lock guard(lock);
@@ -53,15 +55,15 @@ void verifyResizeTaskLimit(bool up) {
while (started < 1);
EXPECT_EQUAL(1u, started);
executor.setTaskLimit(targetTaskLimit);
- EXPECT_EQUAL(16u, executor.getTaskLimit());
+ EXPECT_EQUAL(INITIAL_2inN, executor.getTaskLimit());
allowed = 5;
while (started < 6);
EXPECT_EQUAL(6u, started);
- EXPECT_EQUAL(16u, executor.getTaskLimit());
- allowed = 10;
- while (started < 10);
- EXPECT_EQUAL(10u, started);
- EXPECT_EQUAL(16u, executor.getTaskLimit());
+ EXPECT_EQUAL(INITIAL_2inN, executor.getTaskLimit());
+ allowed = INITIAL;
+ while (started < INITIAL);
+ EXPECT_EQUAL(INITIAL, started);
+ EXPECT_EQUAL(INITIAL_2inN, executor.getTaskLimit());
executor.execute(makeLambdaTask([&lock, &cond, &started, &allowed] {
started++;
std::unique_lock guard(lock);
@@ -69,10 +71,10 @@ void verifyResizeTaskLimit(bool up) {
cond.wait_for(guard, 1ms);
}
}));
- while (started < 11);
- EXPECT_EQUAL(11u, started);
+ while (started < INITIAL + 1);
+ EXPECT_EQUAL(INITIAL + 1, started);
EXPECT_EQUAL(roundedTaskLimit, executor.getTaskLimit());
- allowed = 11;
+ allowed = INITIAL + 1;
}
TEST("test that resizing up and down works") {
TEST_DO(verifyResizeTaskLimit(true));