Skip to content

Commit 2aa16dd

Browse files
authored
Disable ttl based tests in ClientMapTest suite for near cache client [HZ-5308] [HZ-5310] (#1388)
Disabled ttl based tests for near cache based test cases due to an issue at server side hazelcast/hazelcast#10975 Fixed ClientMapTest.testPutIfAbsentTtl so that it is in sync with Java test https://github.com/hazelcast/hazelcast-mono/blob/aad45696a4bb784c6a538e22d26f183973ace9c4/hazelcast/hazelcast/src/test/java/com/hazelcast/client/map/ClientMapTest.java#L542. The problem was that we dependent on timing on the entry expiry and 1 second may not be enough in busy times. Hence, it is changed to 10 seconds. We also re-put the entry with 10 seconds ttl in the send put also to avoid expiry when we checked the value in the next step. opened #1390 so that we do not forget to re-open these tests. fixes #1145 fixes #1181
1 parent cbca3fe commit 2aa16dd

File tree

1 file changed

+45
-6
lines changed

1 file changed

+45
-6
lines changed

hazelcast/test/src/HazelcastTests5.cpp

Lines changed: 45 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1172,6 +1172,13 @@ TEST_P(ClientMapTest, testTryPutRemove)
11721172

11731173
TEST_P(ClientMapTest, testPutTtl)
11741174
{
1175+
if (client_.get_client_config().get_near_cache_config(imap_->get_name()) !=
1176+
nullptr) {
1177+
GTEST_SKIP_(
1178+
"Server side expiry does not send near cache invalidations. "
1179+
"See https://github.com/hazelcast/hazelcast/issues/10975");
1180+
}
1181+
11751182
validate_expiry_invalidations(imap_, [=]() {
11761183
imap_
11771184
->put<std::string, std::string>(
@@ -1182,6 +1189,13 @@ TEST_P(ClientMapTest, testPutTtl)
11821189

11831190
TEST_P(ClientMapTest, testPutConfigTtl)
11841191
{
1192+
if (client_.get_client_config().get_near_cache_config(
1193+
ONE_SECOND_MAP_NAME) != nullptr) {
1194+
GTEST_SKIP_(
1195+
"Server side expiry does not send near cache invalidations. "
1196+
"See https://github.com/hazelcast/hazelcast/issues/10975");
1197+
}
1198+
11851199
std::shared_ptr<imap> map = client_.get_map(ONE_SECOND_MAP_NAME).get();
11861200
validate_expiry_invalidations(map, [=]() {
11871201
map->put<std::string, std::string>("key1", "value1").get();
@@ -1201,9 +1215,16 @@ TEST_P(ClientMapTest, testPutIfAbsent)
12011215

12021216
TEST_P(ClientMapTest, testPutIfAbsentTtl)
12031217
{
1218+
if (client_.get_client_config().get_near_cache_config(imap_->get_name()) !=
1219+
nullptr) {
1220+
GTEST_SKIP_(
1221+
"Server side expiry does not send near cache invalidations. "
1222+
"See https://github.com/hazelcast/hazelcast/issues/10975");
1223+
}
1224+
12041225
ASSERT_FALSE((imap_
12051226
->put_if_absent<std::string, std::string>(
1206-
"key1", "value1", std::chrono::seconds(1))
1227+
"key1", "value1", std::chrono::seconds(10))
12071228
.get()
12081229
.has_value()));
12091230
ASSERT_EQ("value1",
@@ -1213,11 +1234,15 @@ TEST_P(ClientMapTest, testPutIfAbsentTtl)
12131234
.get()
12141235
.value()));
12151236

1216-
ASSERT_FALSE_EVENTUALLY((imap_
1217-
->put_if_absent<std::string, std::string>(
1218-
"key1", "value3", std::chrono::seconds(1))
1219-
.get()
1220-
.has_value()));
1237+
ASSERT_FALSE_EVENTUALLY(
1238+
(imap_->get<std::string, std::string>("key1").get().has_value()));
1239+
1240+
ASSERT_FALSE((imap_
1241+
->put_if_absent<std::string, std::string>(
1242+
"key1", "value3", std::chrono::seconds(10))
1243+
.get()
1244+
.has_value()));
1245+
12211246
ASSERT_EQ("value3",
12221247
(imap_
12231248
->put_if_absent<std::string, std::string>(
@@ -1239,13 +1264,27 @@ TEST_P(ClientMapTest, testSet)
12391264

12401265
TEST_P(ClientMapTest, testSetTtl)
12411266
{
1267+
if (client_.get_client_config().get_near_cache_config(imap_->get_name()) !=
1268+
nullptr) {
1269+
GTEST_SKIP_(
1270+
"Server side expiry does not send near cache invalidations. "
1271+
"See https://github.com/hazelcast/hazelcast/issues/10975");
1272+
}
1273+
12421274
validate_expiry_invalidations(imap_, [=]() {
12431275
imap_->set("key1", "value1", std::chrono::seconds(1)).get();
12441276
});
12451277
}
12461278

12471279
TEST_P(ClientMapTest, testSetConfigTtl)
12481280
{
1281+
if (client_.get_client_config().get_near_cache_config(
1282+
ONE_SECOND_MAP_NAME) != nullptr) {
1283+
GTEST_SKIP_(
1284+
"Server side expiry does not send near cache invalidations. "
1285+
"See https://github.com/hazelcast/hazelcast/issues/10975");
1286+
}
1287+
12491288
std::shared_ptr<imap> map = client_.get_map(ONE_SECOND_MAP_NAME).get();
12501289
validate_expiry_invalidations(map,
12511290
[=]() { map->set("key1", "value1").get(); });

0 commit comments

Comments
 (0)