diff options
author | Tor Brede Vekterli <vekterli@verizonmedia.com> | 2020-02-24 12:19:14 +0000 |
---|---|---|
committer | Tor Brede Vekterli <vekterli@verizonmedia.com> | 2020-02-24 12:19:14 +0000 |
commit | eac171f29717ffbf383c8d3a55239ff81dc79373 (patch) | |
tree | 2081dcae2a5d3093cd3b4c5a20a3cf7d883ddf68 /storage/src/tests/persistence/processalltest.cpp | |
parent | 6c122d41cb1d890c285ffd1786eb7cc16f8eba55 (diff) |
Add count metric for number of documents garbage collected
New distributor metric available as:
```
vds.idealstate.garbage_collection.documents_removed
```
Add documents removed statistics to `RemoveLocation` responses,
which is what GC is currently built around. Could technically have
been implemented as a diff of before/after BucketInfo, but GC is
very low priority so many other mutating ops may have changed the
bucket document set in the time span between sending the GC ops
and receiving the replies.
This relates to issue #12139
Diffstat (limited to 'storage/src/tests/persistence/processalltest.cpp')
-rw-r--r-- | storage/src/tests/persistence/processalltest.cpp | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/storage/src/tests/persistence/processalltest.cpp b/storage/src/tests/persistence/processalltest.cpp index 8c0f8853d2d..83f243ed1b2 100644 --- a/storage/src/tests/persistence/processalltest.cpp +++ b/storage/src/tests/persistence/processalltest.cpp @@ -23,11 +23,15 @@ TEST_F(ProcessAllHandlerTest, remove_location) { api::RemoveLocationCommand removeLocation("id.user == 4", makeDocumentBucket(bucketId)); ProcessAllHandler handler(getEnv(), getPersistenceProvider()); spi::Context context(documentapi::LoadType::DEFAULT, 0, 0); - handler.handleRemoveLocation(removeLocation, context); + auto tracker = handler.handleRemoveLocation(removeLocation, context); EXPECT_EQ("DocEntry(1234, 1, id:mail:testdoctype1:n=4:3619.html)\n" "DocEntry(2345, 1, id:mail:testdoctype1:n=4:4008.html)\n", dumpBucket(bucketId)); + + auto reply = std::dynamic_pointer_cast<api::RemoveLocationReply>(tracker->getReply()); + ASSERT_TRUE(reply.get() != nullptr); + EXPECT_EQ(2u, reply->documents_removed()); } TEST_F(ProcessAllHandlerTest, remove_location_document_subset) { @@ -44,7 +48,7 @@ TEST_F(ProcessAllHandlerTest, remove_location_document_subset) { api::RemoveLocationCommand removeLocation("testdoctype1.headerval % 2 == 0", makeDocumentBucket(bucketId)); spi::Context context(documentapi::LoadType::DEFAULT, 0, 0); - handler.handleRemoveLocation(removeLocation, context); + auto tracker = handler.handleRemoveLocation(removeLocation, context); EXPECT_EQ("DocEntry(100, 1, id:mail:testdoctype1:n=4:3619.html)\n" "DocEntry(101, 0, Doc(id:mail:testdoctype1:n=4:33113.html))\n" @@ -57,6 +61,10 @@ TEST_F(ProcessAllHandlerTest, remove_location_document_subset) { "DocEntry(108, 1, id:mail:testdoctype1:n=4:42967.html)\n" "DocEntry(109, 0, Doc(id:mail:testdoctype1:n=4:6925.html))\n", dumpBucket(bucketId)); + + auto reply = std::dynamic_pointer_cast<api::RemoveLocationReply>(tracker->getReply()); + ASSERT_TRUE(reply.get() != nullptr); + EXPECT_EQ(5u, reply->documents_removed()); } TEST_F(ProcessAllHandlerTest, remove_location_throws_exception_on_unknown_doc_type) { |