Skip to content

Commit 6c2e4f9

Browse files
authored
Deflake hashexpire tests (#2473)
1. Better separation of test steps in `Chain Replication (Primary -> R1 -> R2) preserves TTL` This can help prevent or provide better understanding of a flakey fail: https://github.com/valkey-io/valkey/actions/runs/16867976482/job/47777607814 2. increase the millisecond short timeout to 1 second since some tests are failing because of it. It also better matches the second timeout. example fail: https://github.com/valkey-io/valkey/actions/runs/16867976482/job/47777607746 Signed-off-by: Ran Shidlansik <[email protected]>
1 parent 7a9ef29 commit 6c2e4f9

File tree

1 file changed

+20
-7
lines changed

1 file changed

+20
-7
lines changed

tests/unit/hashexpire.tcl

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,9 @@ proc check_myhash_and_expired_subkeys {r myhash expected_len initial_expired exp
3939
proc get_short_expire_value {command} {
4040
expr {
4141
($command eq "HEXPIRE" || $command eq "EX") ? 1 :
42-
($command eq "HPEXPIRE" || $command eq "PX") ? 10 :
42+
($command eq "HPEXPIRE" || $command eq "PX") ? 1000 :
4343
($command eq "HEXPIREAT" || $command eq "EXAT") ? [clock seconds] + 1 :
44-
[clock milliseconds] + 10
44+
[clock milliseconds] + 1000
4545
}
4646
}
4747

@@ -2385,13 +2385,29 @@ start_server {tags {"hashexpire external:skip"}} {
23852385
assert_equal {1} [psubscribe $rd_replica_2 __keyevent@*]
23862386

23872387
# Create hash and timing - f1 < f2 < f3 expiry times
2388-
set f1_exp [expr {[clock seconds] + 10000}]
2388+
set f1_exp [expr {[clock seconds] + 1000000}]
2389+
2390+
wait_for_ofs_sync $primary $replica_1
2391+
wait_for_ofs_sync $replica_1 $replica_2
23892392

23902393
############################################# STEUP HASH #############################################
2391-
$primary HSET myhash f1 v1 f2 v2 ;# Should trigger 3 hset
2394+
$primary HSETEX myhash FIELDS 2 f1 v1 f2 v2 ;# Should trigger 3 hset
2395+
wait_for_ofs_sync $primary $replica_1
2396+
wait_for_ofs_sync $replica_1 $replica_2
2397+
2398+
# Verify hset event was generated on all 3 nodes
2399+
foreach rd [list $rd_primary $rd_replica_1 $rd_replica_2] {
2400+
assert_keyevent_patterns $rd myhash hset
2401+
}
2402+
23922403
$primary HEXPIREAT myhash $f1_exp FIELDS 1 f1 ;# Should trigger 3 hexpire
23932404
wait_for_ofs_sync $primary $replica_1
23942405
wait_for_ofs_sync $replica_1 $replica_2
2406+
2407+
# Verify hexpire event was generated on all 3 nodes
2408+
foreach rd [list $rd_primary $rd_replica_1 $rd_replica_2] {
2409+
assert_keyevent_patterns $rd myhash hexpire
2410+
}
23952411

23962412
$primary HPEXPIRE myhash 0 FIELDS 1 f1 ;# Should trigger 1 hexpired (for primary) and 2 hdel (for replicas)
23972413
wait_for_ofs_sync $primary $replica_1
@@ -2408,9 +2424,6 @@ start_server {tags {"hashexpire external:skip"}} {
24082424
}
24092425

24102426
# primary gets hexpired and replicas get hdel
2411-
foreach rd [list $rd_primary $rd_replica_1 $rd_replica_2] {
2412-
assert_keyevent_patterns $rd myhash hset hexpire
2413-
}
24142427
assert_keyevent_patterns $rd_primary myhash hexpired
24152428
assert_keyevent_patterns $rd_replica_1 myhash hdel
24162429
assert_keyevent_patterns $rd_replica_2 myhash hdel

0 commit comments

Comments
 (0)