From a2eb05f50588d3276299bc8a5259af12abecc408 Mon Sep 17 00:00:00 2001 From: Artur Ciocanu Date: Tue, 24 Sep 2024 15:43:29 +0300 Subject: [PATCH 1/8] Ensure we use the same GRPC version everywhere Signed-off-by: Artur Ciocanu --- pom.xml | 4 ++-- sdk-actors/pom.xml | 1 - sdk/pom.xml | 1 - 3 files changed, 2 insertions(+), 4 deletions(-) diff --git a/pom.xml b/pom.xml index c8cf9699c..17573f976 100644 --- a/pom.xml +++ b/pom.xml @@ -104,13 +104,13 @@ io.grpc grpc-testing - 1.56.1 + ${grpc.version} test io.grpc grpc-inprocess - 1.59.0 + ${grpc.version} test diff --git a/sdk-actors/pom.xml b/sdk-actors/pom.xml index e24f33ecb..940d25609 100644 --- a/sdk-actors/pom.xml +++ b/sdk-actors/pom.xml @@ -18,7 +18,6 @@ false - 1.59.0 diff --git a/sdk/pom.xml b/sdk/pom.xml index 66095e0b2..efa79cd6c 100644 --- a/sdk/pom.xml +++ b/sdk/pom.xml @@ -18,7 +18,6 @@ false - 1.59.0 --add-opens java.base/java.util=ALL-UNNAMED From 60041bfc067038c02371838b28e984514a114922 Mon Sep 17 00:00:00 2001 From: Artur Ciocanu Date: Tue, 24 Sep 2024 17:12:45 +0300 Subject: [PATCH 2/8] Fix actors tests assert Signed-off-by: Artur Ciocanu --- sdk-actors/src/test/java/io/dapr/actors/TestUtils.java | 2 -- .../test/java/io/dapr/actors/client/DaprGrpcClientTest.java | 3 +-- .../test/java/io/dapr/actors/runtime/DaprGrpcClientTest.java | 2 -- 3 files changed, 1 insertion(+), 6 deletions(-) diff --git a/sdk-actors/src/test/java/io/dapr/actors/TestUtils.java b/sdk-actors/src/test/java/io/dapr/actors/TestUtils.java index 67323aac2..a0f28bedf 100644 --- a/sdk-actors/src/test/java/io/dapr/actors/TestUtils.java +++ b/sdk-actors/src/test/java/io/dapr/actors/TestUtils.java @@ -47,13 +47,11 @@ public static void assertThrowsDaprException( public static void assertThrowsDaprException( Class expectedType, String expectedErrorCode, - String expectedErrorMessage, Executable executable) { DaprException daprException = Assertions.assertThrows(DaprException.class, executable); Assertions.assertNotNull(daprException.getCause()); Assertions.assertEquals(expectedType, daprException.getCause().getClass()); Assertions.assertEquals(expectedErrorCode, daprException.getErrorCode()); - Assertions.assertEquals(expectedErrorMessage, daprException.getMessage()); } public static String formatIpAddress(final String ipAddress) { diff --git a/sdk-actors/src/test/java/io/dapr/actors/client/DaprGrpcClientTest.java b/sdk-actors/src/test/java/io/dapr/actors/client/DaprGrpcClientTest.java index aeb450c9a..909eab933 100644 --- a/sdk-actors/src/test/java/io/dapr/actors/client/DaprGrpcClientTest.java +++ b/sdk-actors/src/test/java/io/dapr/actors/client/DaprGrpcClientTest.java @@ -128,8 +128,7 @@ public void invokeException() { assertThrowsDaprException( ExecutionException.class, "UNKNOWN", - "UNKNOWN: ", - () -> result.block()); + result::block); } @Test diff --git a/sdk-actors/src/test/java/io/dapr/actors/runtime/DaprGrpcClientTest.java b/sdk-actors/src/test/java/io/dapr/actors/runtime/DaprGrpcClientTest.java index 815186e60..de68aa436 100644 --- a/sdk-actors/src/test/java/io/dapr/actors/runtime/DaprGrpcClientTest.java +++ b/sdk-actors/src/test/java/io/dapr/actors/runtime/DaprGrpcClientTest.java @@ -96,7 +96,6 @@ public void getActorStateException() { assertThrowsDaprException( ExecutionException.class, "UNKNOWN", - "UNKNOWN: ", result::block); } @@ -112,7 +111,6 @@ public void saveActorStateTransactionallyException() { assertThrowsDaprException( ExecutionException.class, "UNKNOWN", - "UNKNOWN: ", result::block); } @Test From b751cbe9592ecced4da63eb7784143f7ab2afbcf Mon Sep 17 00:00:00 2001 From: Artur Ciocanu Date: Tue, 24 Sep 2024 22:49:38 +0300 Subject: [PATCH 3/8] Revert Dapr exception asserts Signed-off-by: Artur Ciocanu --- sdk-actors/src/test/java/io/dapr/actors/TestUtils.java | 2 ++ .../src/test/java/io/dapr/actors/client/DaprGrpcClientTest.java | 1 + .../test/java/io/dapr/actors/runtime/DaprGrpcClientTest.java | 2 ++ 3 files changed, 5 insertions(+) diff --git a/sdk-actors/src/test/java/io/dapr/actors/TestUtils.java b/sdk-actors/src/test/java/io/dapr/actors/TestUtils.java index a0f28bedf..67323aac2 100644 --- a/sdk-actors/src/test/java/io/dapr/actors/TestUtils.java +++ b/sdk-actors/src/test/java/io/dapr/actors/TestUtils.java @@ -47,11 +47,13 @@ public static void assertThrowsDaprException( public static void assertThrowsDaprException( Class expectedType, String expectedErrorCode, + String expectedErrorMessage, Executable executable) { DaprException daprException = Assertions.assertThrows(DaprException.class, executable); Assertions.assertNotNull(daprException.getCause()); Assertions.assertEquals(expectedType, daprException.getCause().getClass()); Assertions.assertEquals(expectedErrorCode, daprException.getErrorCode()); + Assertions.assertEquals(expectedErrorMessage, daprException.getMessage()); } public static String formatIpAddress(final String ipAddress) { diff --git a/sdk-actors/src/test/java/io/dapr/actors/client/DaprGrpcClientTest.java b/sdk-actors/src/test/java/io/dapr/actors/client/DaprGrpcClientTest.java index 909eab933..313eca5a7 100644 --- a/sdk-actors/src/test/java/io/dapr/actors/client/DaprGrpcClientTest.java +++ b/sdk-actors/src/test/java/io/dapr/actors/client/DaprGrpcClientTest.java @@ -128,6 +128,7 @@ public void invokeException() { assertThrowsDaprException( ExecutionException.class, "UNKNOWN", + "UNKNOWN: ", result::block); } diff --git a/sdk-actors/src/test/java/io/dapr/actors/runtime/DaprGrpcClientTest.java b/sdk-actors/src/test/java/io/dapr/actors/runtime/DaprGrpcClientTest.java index de68aa436..335ea575f 100644 --- a/sdk-actors/src/test/java/io/dapr/actors/runtime/DaprGrpcClientTest.java +++ b/sdk-actors/src/test/java/io/dapr/actors/runtime/DaprGrpcClientTest.java @@ -96,6 +96,7 @@ public void getActorStateException() { assertThrowsDaprException( ExecutionException.class, "UNKNOWN", + "UNKNOWN: Application error processing RPC", result::block); } @@ -111,6 +112,7 @@ public void saveActorStateTransactionallyException() { assertThrowsDaprException( ExecutionException.class, "UNKNOWN", + "UNKNOWN: Application error processing RPC", result::block); } @Test From 15e119ceb035973f642d92fcef4e5721dc371edf Mon Sep 17 00:00:00 2001 From: Artur Ciocanu Date: Wed, 25 Sep 2024 16:43:48 +0300 Subject: [PATCH 4/8] Increase sleep to allow Spring Context to bootstrap Signed-off-by: Artur Ciocanu --- .../java/io/dapr/it/spring/messaging/DaprSpringMessagingIT.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sdk-tests/src/test/java/io/dapr/it/spring/messaging/DaprSpringMessagingIT.java b/sdk-tests/src/test/java/io/dapr/it/spring/messaging/DaprSpringMessagingIT.java index 19b6e3252..2d04db728 100644 --- a/sdk-tests/src/test/java/io/dapr/it/spring/messaging/DaprSpringMessagingIT.java +++ b/sdk-tests/src/test/java/io/dapr/it/spring/messaging/DaprSpringMessagingIT.java @@ -91,7 +91,7 @@ public void testDaprMessagingTemplate() throws InterruptedException { } // Wait for the messages to arrive - Thread.sleep(1000); + Thread.sleep(2000); List> events = testRestController.getEvents(); From e5e5d4338cc8dde41acd9e0e6da4d67ebbcad52d Mon Sep 17 00:00:00 2001 From: Artur Ciocanu Date: Wed, 25 Sep 2024 17:12:11 +0300 Subject: [PATCH 5/8] Revert sleep value Signed-off-by: Artur Ciocanu --- .../java/io/dapr/it/spring/messaging/DaprSpringMessagingIT.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sdk-tests/src/test/java/io/dapr/it/spring/messaging/DaprSpringMessagingIT.java b/sdk-tests/src/test/java/io/dapr/it/spring/messaging/DaprSpringMessagingIT.java index 2d04db728..19b6e3252 100644 --- a/sdk-tests/src/test/java/io/dapr/it/spring/messaging/DaprSpringMessagingIT.java +++ b/sdk-tests/src/test/java/io/dapr/it/spring/messaging/DaprSpringMessagingIT.java @@ -91,7 +91,7 @@ public void testDaprMessagingTemplate() throws InterruptedException { } // Wait for the messages to arrive - Thread.sleep(2000); + Thread.sleep(1000); List> events = testRestController.getEvents(); From 529db5aef012d6527507507b7a676dbca25372e0 Mon Sep 17 00:00:00 2001 From: Artur Ciocanu Date: Wed, 25 Sep 2024 20:45:14 +0300 Subject: [PATCH 6/8] Increase the sleep for messaging test Signed-off-by: Artur Ciocanu --- .../java/io/dapr/it/spring/messaging/DaprSpringMessagingIT.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sdk-tests/src/test/java/io/dapr/it/spring/messaging/DaprSpringMessagingIT.java b/sdk-tests/src/test/java/io/dapr/it/spring/messaging/DaprSpringMessagingIT.java index 19b6e3252..0eb22fd99 100644 --- a/sdk-tests/src/test/java/io/dapr/it/spring/messaging/DaprSpringMessagingIT.java +++ b/sdk-tests/src/test/java/io/dapr/it/spring/messaging/DaprSpringMessagingIT.java @@ -91,7 +91,7 @@ public void testDaprMessagingTemplate() throws InterruptedException { } // Wait for the messages to arrive - Thread.sleep(1000); + Thread.sleep(10000); List> events = testRestController.getEvents(); From 7b850653e73b88823f5357dc4694a5a8e18ab8e9 Mon Sep 17 00:00:00 2001 From: Artur Ciocanu Date: Wed, 25 Sep 2024 22:49:06 +0300 Subject: [PATCH 7/8] Move sleep before each, to ensure Spring context starts Signed-off-by: Artur Ciocanu --- .../it/spring/messaging/DaprSpringMessagingIT.java | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/sdk-tests/src/test/java/io/dapr/it/spring/messaging/DaprSpringMessagingIT.java b/sdk-tests/src/test/java/io/dapr/it/spring/messaging/DaprSpringMessagingIT.java index 0eb22fd99..8640dc564 100644 --- a/sdk-tests/src/test/java/io/dapr/it/spring/messaging/DaprSpringMessagingIT.java +++ b/sdk-tests/src/test/java/io/dapr/it/spring/messaging/DaprSpringMessagingIT.java @@ -76,12 +76,17 @@ public class DaprSpringMessagingIT { private TestRestController testRestController; @BeforeAll - public static void setup(){ + public static void beforeAll(){ org.testcontainers.Testcontainers.exposeHostPorts(8080); } + @BeforeEach + public void beforeEach() throws InterruptedException { + Thread.sleep(1000); + } + @Test - public void testDaprMessagingTemplate() throws InterruptedException { + public void testDaprMessagingTemplate() { for (int i = 0; i < 10; i++) { var msg = "ProduceAndReadWithPrimitiveMessageType:" + i; @@ -90,12 +95,8 @@ public void testDaprMessagingTemplate() throws InterruptedException { logger.info("++++++PRODUCE {}------", msg); } - // Wait for the messages to arrive - Thread.sleep(10000); - List> events = testRestController.getEvents(); assertThat(events.size()).isEqualTo(10); } - } From 299535a28fa95cee31f627d4f12aca0c29ac093b Mon Sep 17 00:00:00 2001 From: Artur Ciocanu Date: Thu, 26 Sep 2024 10:18:25 +0300 Subject: [PATCH 8/8] Add more delays to ensure Spring Controller gets the messages Signed-off-by: Artur Ciocanu --- .../io/dapr/it/spring/messaging/DaprSpringMessagingIT.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/sdk-tests/src/test/java/io/dapr/it/spring/messaging/DaprSpringMessagingIT.java b/sdk-tests/src/test/java/io/dapr/it/spring/messaging/DaprSpringMessagingIT.java index 8640dc564..50d5b9114 100644 --- a/sdk-tests/src/test/java/io/dapr/it/spring/messaging/DaprSpringMessagingIT.java +++ b/sdk-tests/src/test/java/io/dapr/it/spring/messaging/DaprSpringMessagingIT.java @@ -86,7 +86,7 @@ public void beforeEach() throws InterruptedException { } @Test - public void testDaprMessagingTemplate() { + public void testDaprMessagingTemplate() throws InterruptedException { for (int i = 0; i < 10; i++) { var msg = "ProduceAndReadWithPrimitiveMessageType:" + i; @@ -95,6 +95,9 @@ public void testDaprMessagingTemplate() { logger.info("++++++PRODUCE {}------", msg); } + // Wait for the messages to arrive + Thread.sleep(1000); + List> events = testRestController.getEvents(); assertThat(events.size()).isEqualTo(10);