summaryrefslogtreecommitdiffstats
path: root/storage/src/tests/distributor/throttlingoperationstartertest.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'storage/src/tests/distributor/throttlingoperationstartertest.cpp')
-rw-r--r--storage/src/tests/distributor/throttlingoperationstartertest.cpp51
1 files changed, 26 insertions, 25 deletions
diff --git a/storage/src/tests/distributor/throttlingoperationstartertest.cpp b/storage/src/tests/distributor/throttlingoperationstartertest.cpp
index eac345a243f..4e99388327b 100644
--- a/storage/src/tests/distributor/throttlingoperationstartertest.cpp
+++ b/storage/src/tests/distributor/throttlingoperationstartertest.cpp
@@ -21,7 +21,7 @@ const MockOperation& as_mock_operation(const Operation& operation) {
struct ThrottlingOperationStarterTest : Test {
std::shared_ptr<Operation> createMockOperation() {
- return std::shared_ptr<Operation>(new MockOperation(makeDocumentBucket(BucketId(16, 1))));
+ return std::make_shared<MockOperation>(makeDocumentBucket(BucketId(16, 1)));
}
std::unique_ptr<MockOperationStarter> _starterImpl;
@@ -48,14 +48,12 @@ ThrottlingOperationStarterTest::TearDown()
TEST_F(ThrottlingOperationStarterTest, operation_not_throttled_when_slot_available) {
auto operation = createMockOperation();
- EXPECT_TRUE(_operationStarter->start(operation,
- OperationStarter::Priority(0)));
+ EXPECT_TRUE(_operationStarter->start(operation, OperationStarter::Priority(0)));
EXPECT_FALSE(as_mock_operation(*operation).get_was_throttled());
}
TEST_F(ThrottlingOperationStarterTest, operation_starting_is_forwarded_to_implementation) {
- ASSERT_TRUE(_operationStarter->start(createMockOperation(),
- OperationStarter::Priority(0)));
+ ASSERT_TRUE(_operationStarter->start(createMockOperation(), OperationStarter::Priority(0)));
EXPECT_EQ("Bucket(BucketSpace(0x0000000000000001), BucketId(0x4000000000000001)), pri 0\n",
_starterImpl->toString());
}
@@ -63,8 +61,8 @@ TEST_F(ThrottlingOperationStarterTest, operation_starting_is_forwarded_to_implem
TEST_F(ThrottlingOperationStarterTest, operation_throttled_when_no_available_slots) {
_operationStarter->setMaxPendingRange(0, 0);
auto operation = createMockOperation();
- EXPECT_FALSE(_operationStarter->start(operation,
- OperationStarter::Priority(0)));
+ EXPECT_FALSE(_operationStarter->may_allow_operation_with_priority(OperationStarter::Priority(0)));
+ EXPECT_FALSE(_operationStarter->start(operation, OperationStarter::Priority(0)));
EXPECT_TRUE(as_mock_operation(*operation).get_was_throttled());
}
@@ -88,32 +86,35 @@ TEST_F(ThrottlingOperationStarterTest, throttling_with_max_pending_range) {
TEST_F(ThrottlingOperationStarterTest, starting_operations_fills_up_pending_window) {
_operationStarter->setMaxPendingRange(1, 3);
- EXPECT_TRUE(_operationStarter->start(createMockOperation(),
- OperationStarter::Priority(255)));
- EXPECT_FALSE(_operationStarter->start(createMockOperation(),
- OperationStarter::Priority(255)));
- EXPECT_TRUE(_operationStarter->start(createMockOperation(),
- OperationStarter::Priority(100)));
- EXPECT_FALSE(_operationStarter->start(createMockOperation(),
- OperationStarter::Priority(100)));
- EXPECT_TRUE(_operationStarter->start(createMockOperation(),
- OperationStarter::Priority(0)));
- EXPECT_FALSE(_operationStarter->start(createMockOperation(),
- OperationStarter::Priority(0)));
+ EXPECT_TRUE(_operationStarter->may_allow_operation_with_priority(OperationStarter::Priority(255)));
+ EXPECT_TRUE(_operationStarter->start(createMockOperation(), OperationStarter::Priority(255)));
+
+ EXPECT_FALSE(_operationStarter->may_allow_operation_with_priority(OperationStarter::Priority(255)));
+ EXPECT_FALSE(_operationStarter->start(createMockOperation(), OperationStarter::Priority(255)));
+
+ EXPECT_TRUE(_operationStarter->may_allow_operation_with_priority(OperationStarter::Priority(100)));
+ EXPECT_TRUE(_operationStarter->start(createMockOperation(), OperationStarter::Priority(100)));
+
+ EXPECT_FALSE(_operationStarter->may_allow_operation_with_priority(OperationStarter::Priority(255)));
+ EXPECT_FALSE(_operationStarter->start(createMockOperation(), OperationStarter::Priority(100)));
+
+ EXPECT_TRUE(_operationStarter->may_allow_operation_with_priority(OperationStarter::Priority(0)));
+ EXPECT_TRUE(_operationStarter->start(createMockOperation(), OperationStarter::Priority(0)));
+
+ EXPECT_FALSE(_operationStarter->may_allow_operation_with_priority(OperationStarter::Priority(0)));
+ EXPECT_FALSE(_operationStarter->start(createMockOperation(), OperationStarter::Priority(0)));
}
TEST_F(ThrottlingOperationStarterTest, finishing_operations_allows_more_to_start) {
_operationStarter->setMaxPendingRange(1, 1);
- EXPECT_TRUE(_operationStarter->start(createMockOperation(),
- OperationStarter::Priority(255)));
- EXPECT_FALSE(_operationStarter->start(createMockOperation(),
- OperationStarter::Priority(255)));
+ EXPECT_TRUE(_operationStarter->start(createMockOperation(), OperationStarter::Priority(255)));
+ EXPECT_FALSE(_operationStarter->start(createMockOperation(), OperationStarter::Priority(255)));
EXPECT_FALSE(_starterImpl->getOperations().empty());
_starterImpl->getOperations().pop_back();
- EXPECT_TRUE(_operationStarter->start(createMockOperation(),
- OperationStarter::Priority(255)));
+ EXPECT_TRUE(_operationStarter->may_allow_operation_with_priority(OperationStarter::Priority(255)));
+ EXPECT_TRUE(_operationStarter->start(createMockOperation(), OperationStarter::Priority(255)));
EXPECT_FALSE(_starterImpl->getOperations().empty());
}