MCPcopy Create free account
hub / github.com/apache/arrow / TEST_F

Function TEST_F

cpp/src/parquet/encryption/two_level_cache_with_expiration_test.cc:71–97  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

69};
70
71TEST_F(TwoLevelCacheWithExpirationTest, RemoveExpiration) {
72 auto lifetime1_before_expiration = cache_.GetOrCreateInternalCache("lifetime1", 1);
73 ASSERT_EQ(lifetime1_before_expiration->size(), 2);
74
75 // wait for 0.3s, we expect:
76 // lifetime1 will be expired
77 // lifetime2 will not be expired
78 SleepFor(0.3);
79 // now clear expired items from the cache
80 cache_.CheckCacheForExpiredTokens();
81
82 // lifetime1 (with 2 items) is expired and has been removed from the cache.
83 // Now the cache create a new object which has no item.
84 auto lifetime1 = cache_.GetOrCreateInternalCache("lifetime1", 1);
85 ASSERT_EQ(lifetime1->size(), 0);
86
87 // However, lifetime1_before_expiration can still access normally and independently
88 // from the one in cache
89 lifetime1_before_expiration->Insert("item3", 3);
90 ASSERT_EQ(lifetime1_before_expiration->size(), 3);
91 ASSERT_EQ(lifetime1->size(), 0);
92
93 // lifetime2 is not expired and still contains 2 items.
94 std::shared_ptr<ConcurrentMap<std::string, int>> lifetime2 =
95 cache_.GetOrCreateInternalCache("lifetime2", 3);
96 ASSERT_EQ(lifetime2->size(), 2);
97}
98
99TEST_F(TwoLevelCacheWithExpirationTest, CleanupPeriodOk) {
100 // wait for 0.3s, now:

Callers

nothing calls this directly

Calls 11

SleepForFunction · 0.85
RemoveMethod · 0.80
emplace_backMethod · 0.80
TaskInsertMethod · 0.80
TaskCleanMethod · 0.80
sizeMethod · 0.45
InsertMethod · 0.45
ClearMethod · 0.45
joinMethod · 0.45

Tested by

no test coverage detected