|
33 | 33 |
|
34 | 34 | import javax.inject.Inject; |
35 | 35 |
|
36 | | -import org.junit.Ignore; |
37 | 36 | import org.junit.jupiter.api.*; |
38 | 37 | import org.junit.jupiter.api.extension.ExtendWith; |
39 | 38 |
|
|
52 | 51 | import io.lettuce.test.LettuceExtension; |
53 | 52 | import io.lettuce.test.ListStreamingAdapter; |
54 | 53 | import io.lettuce.test.condition.EnabledOnCommand; |
55 | | -import io.lettuce.test.condition.RedisConditions; |
56 | 54 |
|
57 | 55 | /** |
58 | 56 | * Integration tests for {@link io.lettuce.core.api.sync.RedisKeyCommands}. |
@@ -307,11 +305,14 @@ void pexpireWithArgs() { |
307 | 305 |
|
308 | 306 | @Test |
309 | 307 | void pexpireat() { |
310 | | - Date expiration = new Date(System.currentTimeMillis() + 5000); |
| 308 | + long expiryMillis = System.currentTimeMillis() + 5000; |
| 309 | + Date expiration = new Date(expiryMillis); |
311 | 310 | assertThat(redis.pexpireat(key, expiration)).isFalse(); |
312 | 311 | redis.set(key, value); |
313 | 312 | assertThat(redis.pexpireat(key, expiration)).isTrue(); |
314 | | - assertThat(redis.pttl(key)).isGreaterThan(0).isLessThanOrEqualTo(5000); |
| 313 | + long clockSkewToleranceMs = 50; |
| 314 | + long upperBound = expiryMillis - System.currentTimeMillis() + clockSkewToleranceMs; |
| 315 | + assertThat(redis.pttl(key)).isGreaterThan(0).isLessThanOrEqualTo(upperBound); |
315 | 316 |
|
316 | 317 | assertThat(redis.pexpireat(key, Instant.now().plusSeconds(15))).isTrue(); |
317 | 318 | assertThat(redis.ttl(key)).isBetween(10L, 20L); |
@@ -404,10 +405,12 @@ void restoreReplace() { |
404 | 405 | assertThat(redis.pttl(key)).isGreaterThan(0).isLessThanOrEqualTo(1000); |
405 | 406 |
|
406 | 407 | redis.del(key); |
407 | | - assertThat(redis.restore(key, bytes, RestoreArgs.Builder.ttl(System.currentTimeMillis() + 3000).replace().absttl())) |
408 | | - .isEqualTo("OK"); |
| 408 | + long expiryMillis = System.currentTimeMillis() + 5000; |
| 409 | + assertThat(redis.restore(key, bytes, RestoreArgs.Builder.ttl(expiryMillis).replace().absttl())).isEqualTo("OK"); |
409 | 410 | assertThat(redis.get(key)).isEqualTo(value); |
410 | | - assertThat(redis.pttl(key)).isGreaterThan(0).isLessThanOrEqualTo(3000); |
| 411 | + long clockSkewToleranceMs = 50; |
| 412 | + long upperBound = expiryMillis - System.currentTimeMillis() + clockSkewToleranceMs; |
| 413 | + assertThat(redis.pttl(key)).isGreaterThan(0).isLessThanOrEqualTo(upperBound); |
411 | 414 | } |
412 | 415 |
|
413 | 416 | @Test |
|
0 commit comments