chenBright commented on code in PR #3776:
URL: https://github.com/apache/brpc/pull/3776#discussion_r4694377319
##########
test/abalist_unittest.cc:
##########
@@ -42,5 +44,38 @@ TEST(AbaListTest, TestGc) {
size_t cnts[1];
aba_list.get_sizes(cnts, 1);
EXPECT_EQ(cnts[0], (size_t)96);
+ TestIdTraits::id_set.clear();
+}
+
+void VerifyGcPreservesAddedIds(bool churn) {
+ TestIdTraits::id_set.clear();
+ ListOfABAFreeId<int, TestIdTraits> aba_list;
+ std::vector<int> accepted;
+ unsigned int seed = 12345;
+ for (int id = 1000; id < 2000; ++id) {
+ TestIdTraits::id_set.insert(id);
+ int rc = aba_list.add(id);
+ if (rc != 0) {
+ TestIdTraits::id_set.erase(id);
+ continue;
Review Comment:
This skips all insertion errors. In the all-live scenario, there are only
`112` slots when GC is first triggered, below the `1000` limit. If this
insertion returns `EAGAIN`, the ID being added is removed from the expected
set, and the test can still pass. Consider recording the capacity before
`add()` and skipping the check only if it already exceeds `MAX_ENTRIES` before
the call and the call returns `EAGAIN`.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]