From a5054de6e37e9cd34bc141e53d61b175a90885d6 Mon Sep 17 00:00:00 2001 From: "viktoriya.kutsarova" Date: Fri, 24 Oct 2025 14:40:19 +0300 Subject: [PATCH 1/2] Fix HGETDEL, HGETEX and HSETEX pipeline and transaction integration tests. Signed-off-by: viktoriya.kutsarova --- .../AbstractConnectionIntegrationTests.java | 63 +++++++++---------- 1 file changed, 29 insertions(+), 34 deletions(-) diff --git a/src/test/java/org/springframework/data/redis/connection/AbstractConnectionIntegrationTests.java b/src/test/java/org/springframework/data/redis/connection/AbstractConnectionIntegrationTests.java index d6720d9cea..66a939d5ea 100644 --- a/src/test/java/org/springframework/data/redis/connection/AbstractConnectionIntegrationTests.java +++ b/src/test/java/org/springframework/data/redis/connection/AbstractConnectionIntegrationTests.java @@ -3729,62 +3729,57 @@ public void hTtlReturnsMinusTwoWhenFieldOrKeyMissing() { @EnabledOnCommand("HGETDEL") public void hGetDelWorksAsExpected() { - connection.hSet("hash-hgetdel", "field-1", "value-1"); - connection.hSet("hash-hgetdel", "field-2", "value-2"); - connection.hSet("hash-hgetdel", "field-3", "value-3"); + actual.add(connection.hSet("hash-hgetdel", "field-1", "value-1")); + actual.add(connection.hSet("hash-hgetdel", "field-2", "value-2")); + actual.add(connection.hSet("hash-hgetdel", "field-3", "value-3")); - // hgetdel first 2 fields - assertThat(connection.hGetDel("hash-hgetdel", "field-1", "field-2")).containsExactly("value-1", "value-2"); - assertThat(connection.hExists("hash-hgetdel", "field-1")).isFalse(); - assertThat(connection.hExists("hash-hgetdel", "field-2")).isFalse(); + actual.add(connection.hGetDel("hash-hgetdel", "field-1", "field-2")); + actual.add(connection.hExists("hash-hgetdel", "field-1")); + actual.add(connection.hExists("hash-hgetdel", "field-2")); - // hgetdel non-existent field returns null - assertThat(connection.hGetDel("hash-hgetdel", "field-1")).containsExactly(null); + actual.add(connection.hGetDel("hash-hgetdel", "field-1")); - // hgetdel last field - assertThat(connection.hGetDel("hash-hgetdel", "field-3")).containsExactly("value-3"); - assertThat(connection.hExists("hash-hgetdel", "field-3")).isFalse(); - assertThat(connection.exists("hash-hgetdel")).isFalse(); + actual.add(connection.hGetDel("hash-hgetdel", "field-3")); + actual.add(connection.hExists("hash-hgetdel", "field-3")); + actual.add(connection.exists("hash-hgetdel")); - // hgetdel non-existent hash returns null - assertThat(connection.hGetDel("hash-hgetdel", "field-1")).containsExactly(null); + actual.add(connection.hGetDel("hash-hgetdel", "field-1")); + + verifyResults(Arrays.asList(Boolean.TRUE, Boolean.TRUE, Boolean.TRUE, + Arrays.asList("value-1", "value-2"), Boolean.FALSE, Boolean.FALSE, + Collections.singletonList(null), Arrays.asList("value-3"), Boolean.FALSE, Boolean.FALSE, + Collections.singletonList(null))); } @Test // GH-3211 @EnabledOnCommand("HGETEX") - @LongRunningTest public void hGetExWorksAsExpected() { - connection.hSet("hash-hgetex", "field-1", "value-1"); - connection.hSet("hash-hgetex", "field-2", "value-2"); - connection.hSet("hash-hgetex", "field-3", "value-3"); + actual.add(connection.hSet("hash-hgetex", "field-1", "value-1")); + actual.add(connection.hSet("hash-hgetex", "field-2", "value-2")); + actual.add(connection.hSet("hash-hgetex", "field-3", "value-3")); - assertThat(connection.hGetEx("hash-hgetex", Expiration.seconds(2), "field-1", "field-2")).containsExactly("value-1", - "value-2"); + actual.add(connection.hGetEx("hash-hgetex", Expiration.seconds(2), "field-1", "field-2")); - // non-existent field returns null - assertThat(connection.hGetEx("hash-hgetex", null, "no-such-field")).containsExactly(null); + actual.add(connection.hGetEx("hash-hgetex", null, "no-such-field")); - // non-existent hash returns null - assertThat(connection.hGetEx("no-such-key", null, "field-1")).containsExactly(null); + actual.add(connection.hGetEx("no-such-key", null, "field-1")); - await().atMost(Duration.ofMillis(3000L)) - .until(() -> !connection.hExists("hash-getex", "field-1") && !connection.hExists("hash-getex", "field-2")); + verifyResults(Arrays.asList(Boolean.TRUE, "value-1", "value-2")); } @Test // GH-3211 @EnabledOnCommand("HSETEX") - @LongRunningTest public void hSetExWorksAsExpected() { Map fieldMap = Map.of("field-1", "value-1", "field-2", "value-2"); - assertThat(connection.hSetEx("hash-hsetex", fieldMap, RedisHashCommands.HashFieldSetOption.upsert(), - Expiration.seconds(2))).isTrue(); - assertThat(connection.hGet("hash-hsetex", "field-1")).isEqualTo("value-1"); - assertThat(connection.hGet("hash-hsetex", "field-2")).isEqualTo("value-2"); + actual.add(connection.hSetEx("hash-hsetex", fieldMap, RedisHashCommands.HashFieldSetOption.upsert(), + Expiration.seconds(2))); + actual.add(connection.hGet("hash-hsetex", "field-1")); + actual.add(connection.hGet("hash-hsetex", "field-2")); - await().atMost(Duration.ofMillis(3000L)) - .until(() -> !connection.hExists("hash-getex", "field-1") && !connection.hExists("hash-getex", "field-2")); + verifyResults(Arrays.asList(Boolean.TRUE, Boolean.TRUE, Boolean.TRUE, + Arrays.asList("value-1", "value-2"), Collections.singletonList(null), Collections.singletonList(null))); } @Test // GH-3211 From aabf688744b62320535666ed58726acc661d0cdb Mon Sep 17 00:00:00 2001 From: "viktoriya.kutsarova" Date: Fri, 24 Oct 2025 16:20:49 +0300 Subject: [PATCH 2/2] Increase expiration timeout for HSETEX integration test. Signed-off-by: viktoriya.kutsarova --- .../redis/connection/AbstractConnectionIntegrationTests.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/java/org/springframework/data/redis/connection/AbstractConnectionIntegrationTests.java b/src/test/java/org/springframework/data/redis/connection/AbstractConnectionIntegrationTests.java index 66a939d5ea..cfff2fa7fe 100644 --- a/src/test/java/org/springframework/data/redis/connection/AbstractConnectionIntegrationTests.java +++ b/src/test/java/org/springframework/data/redis/connection/AbstractConnectionIntegrationTests.java @@ -3774,7 +3774,7 @@ public void hSetExWorksAsExpected() { Map fieldMap = Map.of("field-1", "value-1", "field-2", "value-2"); actual.add(connection.hSetEx("hash-hsetex", fieldMap, RedisHashCommands.HashFieldSetOption.upsert(), - Expiration.seconds(2))); + Expiration.seconds(30))); actual.add(connection.hGet("hash-hsetex", "field-1")); actual.add(connection.hGet("hash-hsetex", "field-2"));