From b9d59111dfd02cb796391f0dbde882e2d1aee6fc Mon Sep 17 00:00:00 2001 From: salaboy Date: Thu, 20 Mar 2025 11:22:54 -0300 Subject: [PATCH 01/11] supporting appHttpPipelines for middleware Signed-off-by: salaboy --- .../consumer/DaprTestContainersConfig.java | 2 +- .../dapr/testcontainers/AppHttpPipeline.java | 19 +++++++++ .../io/dapr/testcontainers/Configuration.java | 9 ++++- .../io/dapr/testcontainers/ListEntry.java | 40 +++++++++++++++++++ .../converter/ConfigurationYamlConverter.java | 13 ++++++ .../converter/YamlMapperFactory.java | 2 + .../ConfigurationYamlConverterTest.java | 19 ++++++++- 7 files changed, 99 insertions(+), 5 deletions(-) create mode 100644 testcontainers-dapr/src/main/java/io/dapr/testcontainers/AppHttpPipeline.java create mode 100644 testcontainers-dapr/src/main/java/io/dapr/testcontainers/ListEntry.java diff --git a/spring-boot-examples/consumer-app/src/test/java/io/dapr/springboot/examples/consumer/DaprTestContainersConfig.java b/spring-boot-examples/consumer-app/src/test/java/io/dapr/springboot/examples/consumer/DaprTestContainersConfig.java index 34fa4d82ff..32419d3887 100644 --- a/spring-boot-examples/consumer-app/src/test/java/io/dapr/springboot/examples/consumer/DaprTestContainersConfig.java +++ b/spring-boot-examples/consumer-app/src/test/java/io/dapr/springboot/examples/consumer/DaprTestContainersConfig.java @@ -35,7 +35,7 @@ public class DaprTestContainersConfig { @Bean - public Network getDaprNetwork() { + public Network getNetwork() { Network defaultDaprNetwork = new Network() { @Override public String getId() { diff --git a/testcontainers-dapr/src/main/java/io/dapr/testcontainers/AppHttpPipeline.java b/testcontainers-dapr/src/main/java/io/dapr/testcontainers/AppHttpPipeline.java new file mode 100644 index 0000000000..bedd42b91b --- /dev/null +++ b/testcontainers-dapr/src/main/java/io/dapr/testcontainers/AppHttpPipeline.java @@ -0,0 +1,19 @@ +package io.dapr.testcontainers; + +import java.util.Collections; +import java.util.List; + +public class AppHttpPipeline implements ConfigurationSettings { + private List handlers; + + public AppHttpPipeline(){} + + public AppHttpPipeline(List handlers){ + this.handlers = Collections.unmodifiableList(handlers); + } + + public List getHandlers(){ + return handlers; + } + +} diff --git a/testcontainers-dapr/src/main/java/io/dapr/testcontainers/Configuration.java b/testcontainers-dapr/src/main/java/io/dapr/testcontainers/Configuration.java index e884551eee..c423b7e583 100644 --- a/testcontainers-dapr/src/main/java/io/dapr/testcontainers/Configuration.java +++ b/testcontainers-dapr/src/main/java/io/dapr/testcontainers/Configuration.java @@ -19,8 +19,8 @@ public class Configuration { private final String name; private final TracingConfigurationSettings tracing; + private final AppHttpPipeline appHttpPipeline; - //@TODO: add httpPipeline //@TODO: add secrets //@TODO: add components //@TODO: add accessControl @@ -30,9 +30,10 @@ public class Configuration { * @param name Configuration name. * @param tracing TracingConfigParameters tracing configuration parameters. */ - public Configuration(String name, TracingConfigurationSettings tracing) { + public Configuration(String name, TracingConfigurationSettings tracing, AppHttpPipeline appHttpPipeline) { this.name = name; this.tracing = tracing; + this.appHttpPipeline = appHttpPipeline; } public String getName() { @@ -42,4 +43,8 @@ public String getName() { public TracingConfigurationSettings getTracing() { return tracing; } + + public AppHttpPipeline getAppHttpPipeline(){ + return appHttpPipeline; + } } diff --git a/testcontainers-dapr/src/main/java/io/dapr/testcontainers/ListEntry.java b/testcontainers-dapr/src/main/java/io/dapr/testcontainers/ListEntry.java new file mode 100644 index 0000000000..db1dc46911 --- /dev/null +++ b/testcontainers-dapr/src/main/java/io/dapr/testcontainers/ListEntry.java @@ -0,0 +1,40 @@ +/* + * Copyright 2024 The Dapr Authors + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and +limitations under the License. +*/ + +package io.dapr.testcontainers; + +public class ListEntry { + private String name; + private String type; + + public ListEntry(String name, String type) { + this.name = name; + this.type = type; + } + + public String getName() { + return name; + } + + public String getType() { + return type; + } + + public void setName(String name) { + this.name = name; + } + + public void setType(String type) { + this.type = type; + } +} diff --git a/testcontainers-dapr/src/main/java/io/dapr/testcontainers/converter/ConfigurationYamlConverter.java b/testcontainers-dapr/src/main/java/io/dapr/testcontainers/converter/ConfigurationYamlConverter.java index d7f87cefe9..85dc0a6a7f 100644 --- a/testcontainers-dapr/src/main/java/io/dapr/testcontainers/converter/ConfigurationYamlConverter.java +++ b/testcontainers-dapr/src/main/java/io/dapr/testcontainers/converter/ConfigurationYamlConverter.java @@ -1,12 +1,15 @@ package io.dapr.testcontainers.converter; +import io.dapr.testcontainers.AppHttpPipeline; import io.dapr.testcontainers.Configuration; +import io.dapr.testcontainers.ListEntry; import io.dapr.testcontainers.OtelTracingConfigurationSettings; import io.dapr.testcontainers.TracingConfigurationSettings; import io.dapr.testcontainers.ZipkinTracingConfigurationSettings; import org.yaml.snakeyaml.Yaml; import java.util.LinkedHashMap; +import java.util.List; import java.util.Map; public class ConfigurationYamlConverter implements YamlConverter { @@ -58,6 +61,16 @@ public String convert(Configuration configuration) { } configurationSpec.put("tracing", tracingMap); + + } + + AppHttpPipeline appHttpPipeline = configuration.getAppHttpPipeline(); + if( appHttpPipeline != null ){ + Map appHttpPipelineMap = new LinkedHashMap<>(); + List handlers = appHttpPipeline.getHandlers(); + appHttpPipelineMap.put("handlers", handlers); + configurationSpec.put("appHttpPipeline", appHttpPipelineMap); + } configurationProps.put("spec", configurationSpec); diff --git a/testcontainers-dapr/src/main/java/io/dapr/testcontainers/converter/YamlMapperFactory.java b/testcontainers-dapr/src/main/java/io/dapr/testcontainers/converter/YamlMapperFactory.java index 1c04ee1651..2af820f4a9 100644 --- a/testcontainers-dapr/src/main/java/io/dapr/testcontainers/converter/YamlMapperFactory.java +++ b/testcontainers-dapr/src/main/java/io/dapr/testcontainers/converter/YamlMapperFactory.java @@ -1,5 +1,6 @@ package io.dapr.testcontainers.converter; +import io.dapr.testcontainers.ListEntry; import io.dapr.testcontainers.MetadataEntry; import org.yaml.snakeyaml.DumperOptions; import org.yaml.snakeyaml.Yaml; @@ -21,6 +22,7 @@ public static Yaml create() { options.setPrettyFlow(true); Representer representer = new Representer(options); representer.addClassTag(MetadataEntry.class, Tag.MAP); + representer.addClassTag(ListEntry.class, Tag.MAP); return new Yaml(representer); } } diff --git a/testcontainers-dapr/src/test/java/io/dapr/testcontainers/converter/ConfigurationYamlConverterTest.java b/testcontainers-dapr/src/test/java/io/dapr/testcontainers/converter/ConfigurationYamlConverterTest.java index cbe081d01b..903374ff2f 100644 --- a/testcontainers-dapr/src/test/java/io/dapr/testcontainers/converter/ConfigurationYamlConverterTest.java +++ b/testcontainers-dapr/src/test/java/io/dapr/testcontainers/converter/ConfigurationYamlConverterTest.java @@ -1,7 +1,9 @@ package io.dapr.testcontainers.converter; +import io.dapr.testcontainers.AppHttpPipeline; import io.dapr.testcontainers.Configuration; import io.dapr.testcontainers.DaprContainer; +import io.dapr.testcontainers.ListEntry; import io.dapr.testcontainers.OtelTracingConfigurationSettings; import io.dapr.testcontainers.TracingConfigurationSettings; import org.junit.jupiter.api.Test; @@ -10,6 +12,9 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertNotNull; +import java.util.ArrayList; +import java.util.List; + class ConfigurationYamlConverterTest { private final Yaml MAPPER = YamlMapperFactory.create(); private final ConfigurationYamlConverter converter = new ConfigurationYamlConverter(MAPPER); @@ -28,10 +33,16 @@ public void testConfigurationToYaml() { null ); + + List handlers = new ArrayList<>(); + handlers.add(new ListEntry("alias", "middleware.http.routeralias")); + + AppHttpPipeline appHttpPipeline = new AppHttpPipeline(handlers); + DaprContainer dapr = new DaprContainer("daprio/daprd") .withAppName("dapr-app") .withAppPort(8081) - .withConfiguration(new Configuration("my-config", tracing)) + .withConfiguration(new Configuration("my-config", tracing, appHttpPipeline)) .withAppChannelAddress("host.testcontainers.internal"); Configuration configuration = dapr.getConfiguration(); @@ -50,7 +61,11 @@ public void testConfigurationToYaml() { + " otel:\n" + " endpointAddress: localhost:4317\n" + " isSecure: false\n" - + " protocol: grpc\n"; + + " protocol: grpc\n" + + " appHttpPipeline:\n" + + " handlers:\n" + + " - name: alias\n" + + " type: middleware.http.routeralias\n"; assertEquals(expectedConfigurationYaml, configurationYaml); } From ea51ad4dee06dc7a2e024d510189f148a1d5e9db Mon Sep 17 00:00:00 2001 From: salaboy Date: Thu, 20 Mar 2025 11:46:45 -0300 Subject: [PATCH 02/11] adding test with inline string Signed-off-by: salaboy --- .../converter/ComponentYamlConverterTest.java | 43 +++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/testcontainers-dapr/src/test/java/io/dapr/testcontainers/converter/ComponentYamlConverterTest.java b/testcontainers-dapr/src/test/java/io/dapr/testcontainers/converter/ComponentYamlConverterTest.java index 38ced68d97..dd48baeff8 100644 --- a/testcontainers-dapr/src/test/java/io/dapr/testcontainers/converter/ComponentYamlConverterTest.java +++ b/testcontainers-dapr/src/test/java/io/dapr/testcontainers/converter/ComponentYamlConverterTest.java @@ -48,4 +48,47 @@ public void testComponentToYaml() { assertEquals(expectedComponentYaml, componentYaml); } + + @Test + public void testComponentWithInLineStringToYaml() { + DaprContainer dapr = new DaprContainer("daprio/daprd") + .withAppName("dapr-app") + .withAppPort(8081) + .withComponent(new Component( + "alias", + "middleware.http.routeralias", + "v1", + Map.of("routes", "{\n" + + " \"/mall/activity/info\": \"/v1.0/invoke/srv.default/method/mall/activity/info\",\n" + + " \"/hello/activity/{id}/info\": \"/v1.0/invoke/srv.default/method/hello/activity/info\",\n" + // + " \"/hello/activity/{id}/user\": \"/v1.0/invoke/srv.default/method/hello/activity/user\"\n" + // + "}"))) + .withAppChannelAddress("host.testcontainers.internal"); + + Set components = dapr.getComponents(); + assertEquals(1, components.size()); + + Component kvstore = components.iterator().next(); + assertFalse(kvstore.getMetadata().isEmpty()); + + String componentYaml = converter.convert(kvstore); + String expectedComponentYaml = + "apiVersion: dapr.io/v1alpha1\n" + + "kind: Component\n" + + "metadata:\n" + + " name: alias\n" + + "spec:\n" + + " type: middleware.http.routeralias\n" + + " version: v1\n" + + " metadata:\n" + + " - name: routes\n" + + " value: |-\n" + + " {\n" + + " \"/mall/activity/info\": \"/v1.0/invoke/srv.default/method/mall/activity/info\",\n" + + " \"/hello/activity/{id}/info\": \"/v1.0/invoke/srv.default/method/hello/activity/info\",\n" + + " \"/hello/activity/{id}/user\": \"/v1.0/invoke/srv.default/method/hello/activity/user\"\n" + + " }\n"; + + assertEquals(expectedComponentYaml, componentYaml); + } } From 2b0c66ecf512f9c6ff40c3ce4458be1bb071dd7d Mon Sep 17 00:00:00 2001 From: salaboy Date: Thu, 20 Mar 2025 11:55:30 -0300 Subject: [PATCH 03/11] fixing checkstyle Signed-off-by: salaboy --- .../dapr/testcontainers/AppHttpPipeline.java | 19 +++++++++--------- .../io/dapr/testcontainers/Configuration.java | 15 ++++++++------ .../converter/ConfigurationYamlConverter.java | 3 ++- .../converter/ComponentYamlConverterTest.java | 20 +++++++++---------- 4 files changed, 30 insertions(+), 27 deletions(-) diff --git a/testcontainers-dapr/src/main/java/io/dapr/testcontainers/AppHttpPipeline.java b/testcontainers-dapr/src/main/java/io/dapr/testcontainers/AppHttpPipeline.java index bedd42b91b..8ea0bedaed 100644 --- a/testcontainers-dapr/src/main/java/io/dapr/testcontainers/AppHttpPipeline.java +++ b/testcontainers-dapr/src/main/java/io/dapr/testcontainers/AppHttpPipeline.java @@ -4,16 +4,17 @@ import java.util.List; public class AppHttpPipeline implements ConfigurationSettings { - private List handlers; - - public AppHttpPipeline(){} + private List handlers; - public AppHttpPipeline(List handlers){ - this.handlers = Collections.unmodifiableList(handlers); - } + public AppHttpPipeline() { + } - public List getHandlers(){ - return handlers; - } + public AppHttpPipeline(List handlers) { + this.handlers = Collections.unmodifiableList(handlers); + } + + public List getHandlers() { + return handlers; + } } diff --git a/testcontainers-dapr/src/main/java/io/dapr/testcontainers/Configuration.java b/testcontainers-dapr/src/main/java/io/dapr/testcontainers/Configuration.java index c423b7e583..d7c1de798b 100644 --- a/testcontainers-dapr/src/main/java/io/dapr/testcontainers/Configuration.java +++ b/testcontainers-dapr/src/main/java/io/dapr/testcontainers/Configuration.java @@ -21,14 +21,17 @@ public class Configuration { private final TracingConfigurationSettings tracing; private final AppHttpPipeline appHttpPipeline; - //@TODO: add secrets - //@TODO: add components - //@TODO: add accessControl + // @TODO: add secrets + // @TODO: add components + // @TODO: add accessControl /** * Creates a new configuration. - * @param name Configuration name. - * @param tracing TracingConfigParameters tracing configuration parameters. + * + * @param name Configuration name. + * @param tracing TracingConfigParameters tracing configuration + * parameters. + * @param appHttpPipeline AppHttpPipeline middleware configuration. */ public Configuration(String name, TracingConfigurationSettings tracing, AppHttpPipeline appHttpPipeline) { this.name = name; @@ -44,7 +47,7 @@ public TracingConfigurationSettings getTracing() { return tracing; } - public AppHttpPipeline getAppHttpPipeline(){ + public AppHttpPipeline getAppHttpPipeline() { return appHttpPipeline; } } diff --git a/testcontainers-dapr/src/main/java/io/dapr/testcontainers/converter/ConfigurationYamlConverter.java b/testcontainers-dapr/src/main/java/io/dapr/testcontainers/converter/ConfigurationYamlConverter.java index 85dc0a6a7f..1f8cbb6bd6 100644 --- a/testcontainers-dapr/src/main/java/io/dapr/testcontainers/converter/ConfigurationYamlConverter.java +++ b/testcontainers-dapr/src/main/java/io/dapr/testcontainers/converter/ConfigurationYamlConverter.java @@ -65,7 +65,8 @@ public String convert(Configuration configuration) { } AppHttpPipeline appHttpPipeline = configuration.getAppHttpPipeline(); - if( appHttpPipeline != null ){ + if (appHttpPipeline != null) { + Map appHttpPipelineMap = new LinkedHashMap<>(); List handlers = appHttpPipeline.getHandlers(); appHttpPipelineMap.put("handlers", handlers); diff --git a/testcontainers-dapr/src/test/java/io/dapr/testcontainers/converter/ComponentYamlConverterTest.java b/testcontainers-dapr/src/test/java/io/dapr/testcontainers/converter/ComponentYamlConverterTest.java index dd48baeff8..eced458096 100644 --- a/testcontainers-dapr/src/test/java/io/dapr/testcontainers/converter/ComponentYamlConverterTest.java +++ b/testcontainers-dapr/src/test/java/io/dapr/testcontainers/converter/ComponentYamlConverterTest.java @@ -34,8 +34,7 @@ public void testComponentToYaml() { assertFalse(kvstore.getMetadata().isEmpty()); String componentYaml = converter.convert(kvstore); - String expectedComponentYaml = - "apiVersion: dapr.io/v1alpha1\n" + String expectedComponentYaml = "apiVersion: dapr.io/v1alpha1\n" + "kind: Component\n" + "metadata:\n" + " name: statestore\n" @@ -58,11 +57,11 @@ public void testComponentWithInLineStringToYaml() { "alias", "middleware.http.routeralias", "v1", - Map.of("routes", "{\n" + - " \"/mall/activity/info\": \"/v1.0/invoke/srv.default/method/mall/activity/info\",\n" + - " \"/hello/activity/{id}/info\": \"/v1.0/invoke/srv.default/method/hello/activity/info\",\n" + // - " \"/hello/activity/{id}/user\": \"/v1.0/invoke/srv.default/method/hello/activity/user\"\n" + // - "}"))) + Map.of("routes", "{\n" + + " \"/mall/activity/info\": \"/v1.0/invoke/srv.default/method/mall/activity/info\",\n" + + " \"/hello/activity/{id}/info\": \"/v1.0/invoke/srv.default/method/hello/activity/info\",\n" + // + " \"/hello/activity/{id}/user\": \"/v1.0/invoke/srv.default/method/hello/activity/user\"\n" + // + "}"))) .withAppChannelAddress("host.testcontainers.internal"); Set components = dapr.getComponents(); @@ -72,8 +71,7 @@ public void testComponentWithInLineStringToYaml() { assertFalse(kvstore.getMetadata().isEmpty()); String componentYaml = converter.convert(kvstore); - String expectedComponentYaml = - "apiVersion: dapr.io/v1alpha1\n" + String expectedComponentYaml = "apiVersion: dapr.io/v1alpha1\n" + "kind: Component\n" + "metadata:\n" + " name: alias\n" @@ -83,10 +81,10 @@ public void testComponentWithInLineStringToYaml() { + " metadata:\n" + " - name: routes\n" + " value: |-\n" - + " {\n" + + " {\n" + " \"/mall/activity/info\": \"/v1.0/invoke/srv.default/method/mall/activity/info\",\n" + " \"/hello/activity/{id}/info\": \"/v1.0/invoke/srv.default/method/hello/activity/info\",\n" - + " \"/hello/activity/{id}/user\": \"/v1.0/invoke/srv.default/method/hello/activity/user\"\n" + + " \"/hello/activity/{id}/user\": \"/v1.0/invoke/srv.default/method/hello/activity/user\"\n" + " }\n"; assertEquals(expectedComponentYaml, componentYaml); From 84c874531b7291a7d4185d0a04f39cd66b09c8eb Mon Sep 17 00:00:00 2001 From: salaboy Date: Thu, 27 Mar 2025 16:00:15 +0000 Subject: [PATCH 04/11] adding license hearders and TODO references Signed-off-by: salaboy --- .../dapr/testcontainers/AppHttpPipeline.java | 20 +++++++++++++++---- .../io/dapr/testcontainers/Configuration.java | 10 +++++++--- .../ConfigurationYamlConverterTest.java | 13 ++++++++++++ 3 files changed, 36 insertions(+), 7 deletions(-) diff --git a/testcontainers-dapr/src/main/java/io/dapr/testcontainers/AppHttpPipeline.java b/testcontainers-dapr/src/main/java/io/dapr/testcontainers/AppHttpPipeline.java index 8ea0bedaed..d412a87086 100644 --- a/testcontainers-dapr/src/main/java/io/dapr/testcontainers/AppHttpPipeline.java +++ b/testcontainers-dapr/src/main/java/io/dapr/testcontainers/AppHttpPipeline.java @@ -1,3 +1,16 @@ +/* + * Copyright 2025 The Dapr Authors + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and +limitations under the License. +*/ + package io.dapr.testcontainers; import java.util.Collections; @@ -6,11 +19,10 @@ public class AppHttpPipeline implements ConfigurationSettings { private List handlers; - public AppHttpPipeline() { - } - public AppHttpPipeline(List handlers) { - this.handlers = Collections.unmodifiableList(handlers); + if (handlers != null ){ + this.handlers = Collections.unmodifiableList(handlers); + } } public List getHandlers() { diff --git a/testcontainers-dapr/src/main/java/io/dapr/testcontainers/Configuration.java b/testcontainers-dapr/src/main/java/io/dapr/testcontainers/Configuration.java index d7c1de798b..4a431400c4 100644 --- a/testcontainers-dapr/src/main/java/io/dapr/testcontainers/Configuration.java +++ b/testcontainers-dapr/src/main/java/io/dapr/testcontainers/Configuration.java @@ -21,9 +21,13 @@ public class Configuration { private final TracingConfigurationSettings tracing; private final AppHttpPipeline appHttpPipeline; - // @TODO: add secrets - // @TODO: add components - // @TODO: add accessControl + // @TODO: add secrets https://github.com/dapr/java-sdk/issues/1280 + // @TODO: add metrics https://github.com/dapr/java-sdk/issues/1281 + // @TODO: add logging https://github.com/dapr/java-sdk/issues/1282 + // @TODO: add middleware httpPipeline https://github.com/dapr/java-sdk/issues/1283 + // @TODO: add nameResolution https://github.com/dapr/java-sdk/issues/1284 + // @TODO: add disallow components https://github.com/dapr/java-sdk/issues/1285 + // @TODO: add mtls https://github.com/dapr/java-sdk/issues/1286 /** * Creates a new configuration. diff --git a/testcontainers-dapr/src/test/java/io/dapr/testcontainers/converter/ConfigurationYamlConverterTest.java b/testcontainers-dapr/src/test/java/io/dapr/testcontainers/converter/ConfigurationYamlConverterTest.java index 903374ff2f..01b8968d56 100644 --- a/testcontainers-dapr/src/test/java/io/dapr/testcontainers/converter/ConfigurationYamlConverterTest.java +++ b/testcontainers-dapr/src/test/java/io/dapr/testcontainers/converter/ConfigurationYamlConverterTest.java @@ -1,3 +1,16 @@ +/* + * Copyright 2025 The Dapr Authors + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and +limitations under the License. +*/ + package io.dapr.testcontainers.converter; import io.dapr.testcontainers.AppHttpPipeline; From ef7b7e759090a9c96401f41d2f91ef0fa97a9f1c Mon Sep 17 00:00:00 2001 From: Siri Varma Vegiraju Date: Mon, 24 Mar 2025 10:06:08 -0700 Subject: [PATCH 05/11] Move dependency management and plugin management to parent pom (#1260) * Clean up pom Signed-off-by: sirivarma * downgrade dependency Signed-off-by: sirivarma * Fix Signed-off-by: sirivarma * Fix thigns Signed-off-by: sirivarma * Fix class not found Signed-off-by: sirivarma * Remove import Signed-off-by: sirivarma * Address comments Signed-off-by: Siri Varma Vegiraju * cleanup Signed-off-by: Siri Varma Vegiraju * Fix deps Signed-off-by: siri-varma * cleanup Signed-off-by: Siri Varma Vegiraju Signed-off-by: siri-varma * Fix deps Signed-off-by: siri-varma * Fix things Signed-off-by: siri-varma * Fix finals Signed-off-by: siri-varma * Fix finals Signed-off-by: siri-varma * upgrade test containers to .5 Signed-off-by: sirivarma * This is it Signed-off-by: sirivarma * Fix feedback Signed-off-by: sirivarma * Add comment Signed-off-by: sirivarma * Add comment Signed-off-by: sirivarma * Change to properties Signed-off-by: sirivarma --------- Signed-off-by: sirivarma Signed-off-by: Siri Varma Vegiraju Signed-off-by: siri-varma Co-authored-by: Siri Varma Vegiraju Co-authored-by: salaboy Co-authored-by: artur-ciocanu Co-authored-by: Cassie Coyle Signed-off-by: salaboy --- dapr-spring/pom.xml | 29 ++++ pom.xml | 168 +++++++++++++++++++++- sdk-tests/pom.xml | 68 +++++++++ spring-boot-examples/consumer-app/pom.xml | 23 --- spring-boot-examples/pom.xml | 14 +- spring-boot-examples/producer-app/pom.xml | 29 +--- testcontainers-dapr/pom.xml | 51 ------- 7 files changed, 279 insertions(+), 103 deletions(-) diff --git a/dapr-spring/pom.xml b/dapr-spring/pom.xml index 04f59acaaa..fe4ebaa172 100644 --- a/dapr-spring/pom.xml +++ b/dapr-spring/pom.xml @@ -32,6 +32,8 @@ 11 11 11 + 1.19.8 + 5.10.2 @@ -43,6 +45,31 @@ pom import + + org.junit.jupiter + junit-jupiter-api + ${junit.version} + + + org.junit.jupiter + junit-jupiter-params + ${junit.version} + + + org.junit.jupiter + junit-jupiter-engine + ${junit.version} + + + org.junit.jupiter + junit-jupiter + ${junit.version} + + + org.testcontainers + junit-jupiter + ${testcontainers.version} + @@ -73,6 +100,7 @@ org.springframework.boot spring-boot-configuration-processor + ${springboot.version} true @@ -80,6 +108,7 @@ org.springframework.boot spring-boot-starter-test + ${springboot.version} test diff --git a/pom.xml b/pom.xml index 5ab3051c25..729eb0a71b 100644 --- a/pom.xml +++ b/pom.xml @@ -26,6 +26,9 @@ 2.7 3.3.1 3.13.0 + 3.2.1 + 0.8.11 + 80% 11 11 11 @@ -42,9 +45,9 @@ --add-opens java.base/java.lang=ALL-UNNAMED --add-opens java.base/java.util=ALL-UNNAMED 3.2.2 3.2.2 - 5.8.2 + 5.11.4 2.0 - 1.20.0 + 1.20.5 3.4.3 1.7.0 @@ -95,7 +98,6 @@ org.mockito mockito-core 3.11.2 - test io.projectreactor @@ -120,12 +122,129 @@ kotlin-stdlib 2.1.0 + + org.yaml + snakeyaml + ${snakeyaml.version} + + + org.testcontainers + testcontainers + ${testcontainers.version} + + + io.dapr + dapr-sdk + ${dapr.sdk.version} + compile + + + org.junit.jupiter + junit-jupiter + ${junit-bom.version} + + + org.junit.jupiter + junit-jupiter-api + ${junit-bom.version} + + + org.junit.jupiter + junit-jupiter-engine + ${junit-bom.version} + + + org.junit.jupiter + junit-jupiter-params + ${junit-bom.version} + + + org.testcontainers + junit-jupiter + ${testcontainers.version} + + + org.testcontainers + kafka + ${testcontainers.version} + + + org.springframework.boot + spring-boot-dependencies + ${springboot.version} + pom + + + org.testcontainers + postgresql + ${testcontainers.version} + + + org.testcontainers + rabbitmq + ${testcontainers.version} + + + io.rest-assured + rest-assured + 5.5.1 + + + io.dapr.spring + dapr-spring-boot-starter + ${dapr.sdk.alpha.version} + + + io.dapr.spring + dapr-spring-boot-starter-test + ${dapr.sdk.alpha.version} + + + org.springframework.boot + spring-boot-starter-web + ${springboot.version} + + + org.springframework.boot + spring-boot-starter-actuator + ${springboot.version} + + + org.springframework.boot + spring-boot-starter-test + ${springboot.version} + + + org.springframework.data + spring-data-keyvalue + ${springboot.version} + + + org.springframework.data + spring-data-commons + ${springboot.version} + + + org.springframework.boot + spring-boot-testcontainers + ${springboot.version} + + + org.springframework.boot + spring-boot-maven-plugin + ${springboot.version} + + + org.apache.maven.plugins + maven-source-plugin + ${maven-sources-plugin.version} + org.apache.maven.plugins maven-compiler-plugin @@ -174,6 +293,49 @@ true + + org.jacoco + jacoco-maven-plugin + ${jacoco-maven-plugin.version} + + + default-prepare-agent + + prepare-agent + + + + report + test + + report + + + target/jacoco-report/ + + + + check + + check + + + + + BUNDLE + + + LINE + COVEREDRATIO + ${jacoco-maven-plugin.coverage-ratio} + + + + + + + + diff --git a/sdk-tests/pom.xml b/sdk-tests/pom.xml index c448aa5866..c1ffacad0e 100644 --- a/sdk-tests/pom.xml +++ b/sdk-tests/pom.xml @@ -33,6 +33,11 @@ 1.5.16 3.9.1 1.20.0 + + + 0% + 1.11.4 @@ -45,6 +50,16 @@ pom import + + org.junit.platform + junit-platform-commons + ${junit-platform.version} + + + org.junit.platform + junit-platform-engine + ${junit-platform.version} + @@ -235,10 +250,63 @@ jakarta.servlet-api compile + + org.junit.platform + junit-platform-commons + test + + + org.junit.platform + junit-platform-engine + test + + + org.jacoco + jacoco-maven-plugin + ${jacoco-maven-plugin.version} + + + default-prepare-agent + + prepare-agent + + + + report + test + + report + + + target/jacoco-report/ + + + + check + + check + + + + + BUNDLE + + + LINE + COVEREDRATIO + ${jacoco-maven-plugin.coverage-ratio} + + + + + + + + com.github.os72 protoc-jar-maven-plugin diff --git a/spring-boot-examples/consumer-app/pom.xml b/spring-boot-examples/consumer-app/pom.xml index 9255bb13a0..b2e2d09406 100644 --- a/spring-boot-examples/consumer-app/pom.xml +++ b/spring-boot-examples/consumer-app/pom.xml @@ -12,19 +12,6 @@ consumer-app Spring Boot, Testcontainers and Dapr Integration Examples :: Consumer App - - - - - org.springframework.boot - spring-boot-dependencies - ${springboot.version} - pom - import - - - - org.springframework.boot @@ -37,16 +24,12 @@ io.dapr.spring dapr-spring-boot-starter - ${dapr.sdk.alpha.version} - io.dapr.spring dapr-spring-boot-starter-test - ${dapr.sdk.alpha.version} test - org.testcontainers junit-jupiter @@ -55,22 +38,18 @@ org.testcontainers postgresql - 1.20.0 test org.testcontainers rabbitmq - 1.20.0 test org.testcontainers kafka - 1.20.0 test - io.rest-assured rest-assured @@ -83,12 +62,10 @@ org.springframework.boot spring-boot-maven-plugin - ${springboot.version} org.apache.maven.plugins maven-site-plugin - 3.12.1 true diff --git a/spring-boot-examples/pom.xml b/spring-boot-examples/pom.xml index 4ed1fbe494..75a32364f7 100644 --- a/spring-boot-examples/pom.xml +++ b/spring-boot-examples/pom.xml @@ -15,6 +15,7 @@ true + 3.4.3 @@ -22,12 +23,23 @@ consumer-app + + + + org.springframework.boot + spring-boot-dependencies + ${springboot.version} + pom + import + + + + org.apache.maven.plugins maven-site-plugin - 3.12.1 true diff --git a/spring-boot-examples/producer-app/pom.xml b/spring-boot-examples/producer-app/pom.xml index dd7a4fee5b..b9ab6fcbfa 100644 --- a/spring-boot-examples/producer-app/pom.xml +++ b/spring-boot-examples/producer-app/pom.xml @@ -13,55 +13,36 @@ producer-app Spring Boot, Testcontainers and Dapr Integration Examples :: Producer App - - - - - org.springframework.boot - spring-boot-dependencies - ${springboot.version} - pom - import - - - - org.springframework.boot spring-boot-starter-actuator - org.springframework.boot spring-boot-starter-web + + org.springframework.boot + spring-boot-starter-test + io.dapr.spring dapr-spring-boot-starter - ${dapr.sdk.alpha.version} io.dapr.spring dapr-spring-boot-starter-test - ${dapr.sdk.alpha.version} - test - - - org.testcontainers - junit-jupiter test org.testcontainers postgresql - 1.20.0 test org.testcontainers rabbitmq - 1.20.0 test @@ -76,12 +57,10 @@ org.springframework.boot spring-boot-maven-plugin - ${springboot.version} org.apache.maven.plugins maven-site-plugin - 3.12.1 true diff --git a/testcontainers-dapr/pom.xml b/testcontainers-dapr/pom.xml index 13110b70b3..2f4fbb7e17 100644 --- a/testcontainers-dapr/pom.xml +++ b/testcontainers-dapr/pom.xml @@ -28,19 +28,11 @@ org.yaml snakeyaml - ${snakeyaml.version} org.testcontainers testcontainers - ${testcontainers.version} - - io.dapr - dapr-sdk - ${project.parent.version} - compile - @@ -52,7 +44,6 @@ org.apache.maven.plugins maven-source-plugin - 3.2.1 attach-sources @@ -62,11 +53,9 @@ - org.apache.maven.plugins maven-javadoc-plugin - 3.2.0 attach-javadocs @@ -79,46 +68,6 @@ org.jacoco jacoco-maven-plugin - 0.8.11 - - - default-prepare-agent - - prepare-agent - - - - report - test - - report - - - target/jacoco-report/ - - - - check - - check - - - - - BUNDLE - - - LINE - COVEREDRATIO - 80% - - - - - - - - From 2a19f6e474fdd6404aadd7d14c32eec00321616e Mon Sep 17 00:00:00 2001 From: salaboy Date: Tue, 25 Mar 2025 13:38:36 +0000 Subject: [PATCH 06/11] Update docker version for CI to fix flaky tests (#1276) * update docker version for ci Signed-off-by: salaboy * adding DOCKER_HOST to all tests Signed-off-by: salaboy * Move dependency management and plugin management to parent pom (#1260) * Clean up pom Signed-off-by: sirivarma * downgrade dependency Signed-off-by: sirivarma * Fix Signed-off-by: sirivarma * Fix thigns Signed-off-by: sirivarma * Fix class not found Signed-off-by: sirivarma * Remove import Signed-off-by: sirivarma * Address comments Signed-off-by: Siri Varma Vegiraju * cleanup Signed-off-by: Siri Varma Vegiraju * Fix deps Signed-off-by: siri-varma * cleanup Signed-off-by: Siri Varma Vegiraju Signed-off-by: siri-varma * Fix deps Signed-off-by: siri-varma * Fix things Signed-off-by: siri-varma * Fix finals Signed-off-by: siri-varma * Fix finals Signed-off-by: siri-varma * upgrade test containers to .5 Signed-off-by: sirivarma * This is it Signed-off-by: sirivarma * Fix feedback Signed-off-by: sirivarma * Add comment Signed-off-by: sirivarma * Add comment Signed-off-by: sirivarma * Change to properties Signed-off-by: sirivarma --------- Signed-off-by: sirivarma Signed-off-by: Siri Varma Vegiraju Signed-off-by: siri-varma Co-authored-by: Siri Varma Vegiraju Co-authored-by: salaboy Co-authored-by: artur-ciocanu Co-authored-by: Cassie Coyle Signed-off-by: salaboy * fixing flaky docker network Signed-off-by: salaboy --------- Signed-off-by: salaboy Signed-off-by: sirivarma Signed-off-by: Siri Varma Vegiraju Signed-off-by: siri-varma Co-authored-by: Siri Varma Vegiraju Co-authored-by: Siri Varma Vegiraju Co-authored-by: artur-ciocanu Co-authored-by: Cassie Coyle Signed-off-by: salaboy --- .github/workflows/build.yml | 9 +++ .github/workflows/validate.yml | 39 +++++++++- .../consumer/DaprTestContainersConfig.java | 72 ++++++++++--------- .../producer/DaprTestContainersConfig.java | 52 +++++++------- 4 files changed, 113 insertions(+), 59 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 03e7e14278..441228ce5e 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -45,6 +45,11 @@ jobs: DAPR_REF: TOXIPROXY_URL: https://github.com/Shopify/toxiproxy/releases/download/v2.5.0/toxiproxy-server-linux-amd64 steps: + - name: Install Stable Docker + id: setup_docker + uses: docker/setup-docker-action@v4 + - name: Check Docker version + run: docker version - uses: actions/checkout@v4 - name: Set up OpenJDK ${{ env.JDK_VER }} uses: actions/setup-java@v4 @@ -113,6 +118,8 @@ jobs: run: ./mvnw compile -B -q - name: Unit tests run: ./mvnw test # making it temporarily verbose. + env: + DOCKER_HOST: ${{steps.setup_docker.outputs.sock}} - name: Codecov uses: codecov/codecov-action@v4.4.1 - name: Install jars @@ -120,6 +127,8 @@ jobs: - name: Integration tests using spring boot version ${{ matrix.spring-boot-version }} id: integration_tests run: PRODUCT_SPRING_BOOT_VERSION=${{ matrix.spring-boot-version }} ./mvnw -B -Pintegration-tests verify + env: + DOCKER_HOST: ${{steps.setup_docker.outputs.sock}} - name: Upload test report for sdk uses: actions/upload-artifact@v4 with: diff --git a/.github/workflows/validate.yml b/.github/workflows/validate.yml index 6711b07c63..b8b478268c 100644 --- a/.github/workflows/validate.yml +++ b/.github/workflows/validate.yml @@ -49,6 +49,11 @@ jobs: with: distribution: 'temurin' java-version: ${{ env.JDK_VER }} + - name: Install Stable Docker + id: setup_docker + uses: docker/setup-docker-action@v4 + - name: Check Docker version + run: docker version - name: Set up Dapr CLI run: wget -q ${{ env.DAPR_INSTALL_URL }} -O - | /bin/bash -s ${{ env.DAPR_CLI_VER }} - name: Set up Go ${{ env.GOVER }} @@ -108,63 +113,95 @@ jobs: run: ./mvnw compile -q - name: Install jars run: ./mvnw install -q + env: + DOCKER_HOST: ${{steps.setup_docker.outputs.sock}} - name: Validate invoke http example working-directory: ./examples run: | mm.py ./src/main/java/io/dapr/examples/invoke/http/README.md + env: + DOCKER_HOST: ${{steps.setup_docker.outputs.sock}} - name: Validate invoke grpc example working-directory: ./examples run: | mm.py ./src/main/java/io/dapr/examples/invoke/grpc/README.md + env: + DOCKER_HOST: ${{steps.setup_docker.outputs.sock}} - name: Validate tracing example working-directory: ./examples run: | mm.py ./src/main/java/io/dapr/examples/tracing/README.md + env: + DOCKER_HOST: ${{steps.setup_docker.outputs.sock}} - name: Validate expection handling example working-directory: ./examples run: | mm.py ./src/main/java/io/dapr/examples/exception/README.md + env: + DOCKER_HOST: ${{steps.setup_docker.outputs.sock}} - name: Validate state example working-directory: ./examples run: | mm.py ./src/main/java/io/dapr/examples/state/README.md + env: + DOCKER_HOST: ${{steps.setup_docker.outputs.sock}} - name: Validate pubsub example working-directory: ./examples run: | mm.py ./src/main/java/io/dapr/examples/pubsub/README.md + env: + DOCKER_HOST: ${{steps.setup_docker.outputs.sock}} - name: Validate bindings HTTP example working-directory: ./examples run: | mm.py ./src/main/java/io/dapr/examples/bindings/http/README.md + env: + DOCKER_HOST: ${{steps.setup_docker.outputs.sock}} - name: Validate secrets example working-directory: ./examples run: | mm.py ./src/main/java/io/dapr/examples/secrets/README.md + env: + DOCKER_HOST: ${{steps.setup_docker.outputs.sock}} - name: Validate unit testing example working-directory: ./examples run: | mm.py ./src/main/java/io/dapr/examples/unittesting/README.md + env: + DOCKER_HOST: ${{steps.setup_docker.outputs.sock}} - name: Validate Configuration API example working-directory: ./examples run: | mm.py ./src/main/java/io/dapr/examples/configuration/README.md + env: + DOCKER_HOST: ${{steps.setup_docker.outputs.sock}} - name: Validate actors example working-directory: ./examples run: | mm.py ./src/main/java/io/dapr/examples/actors/README.md + env: + DOCKER_HOST: ${{steps.setup_docker.outputs.sock}} - name: Validate query state HTTP example working-directory: ./examples run: | mm.py ./src/main/java/io/dapr/examples/querystate/README.md + env: + DOCKER_HOST: ${{steps.setup_docker.outputs.sock}} - name: Validate workflows example working-directory: ./examples run: | mm.py ./src/main/java/io/dapr/examples/workflows/README.md + env: + DOCKER_HOST: ${{steps.setup_docker.outputs.sock}} - name: Validate streaming subscription example working-directory: ./examples run: | mm.py ./src/main/java/io/dapr/examples/pubsub/stream/README.md + env: + DOCKER_HOST: ${{steps.setup_docker.outputs.sock}} - name: Validate Spring Boot examples working-directory: ./spring-boot-examples run: | - mm.py README.md + mm.py README.md + env: + DOCKER_HOST: ${{steps.setup_docker.outputs.sock}} diff --git a/spring-boot-examples/consumer-app/src/test/java/io/dapr/springboot/examples/consumer/DaprTestContainersConfig.java b/spring-boot-examples/consumer-app/src/test/java/io/dapr/springboot/examples/consumer/DaprTestContainersConfig.java index 32419d3887..dc584b26b9 100644 --- a/spring-boot-examples/consumer-app/src/test/java/io/dapr/springboot/examples/consumer/DaprTestContainersConfig.java +++ b/spring-boot-examples/consumer-app/src/test/java/io/dapr/springboot/examples/consumer/DaprTestContainersConfig.java @@ -35,31 +35,36 @@ public class DaprTestContainersConfig { @Bean - public Network getNetwork() { - Network defaultDaprNetwork = new Network() { - @Override - public String getId() { - return "dapr-network"; - } + public Network getDaprNetwork(Environment env) { + boolean reuse = env.getProperty("reuse", Boolean.class, false); + if (reuse) { + Network defaultDaprNetwork = new Network() { + @Override + public String getId() { + return "dapr-network"; + } - @Override - public void close() { + @Override + public void close() { - } + } - @Override - public Statement apply(Statement base, Description description) { - return null; - } - }; + @Override + public Statement apply(Statement base, Description description) { + return null; + } + }; - List networks = DockerClientFactory.instance().client().listNetworksCmd() - .withNameFilter("dapr-network").exec(); - if (networks.isEmpty()) { - Network.builder().createNetworkCmdModifier(cmd -> cmd.withName("dapr-network")).build().getId(); - return defaultDaprNetwork; + List networks = DockerClientFactory.instance().client().listNetworksCmd() + .withNameFilter("dapr-network").exec(); + if (networks.isEmpty()) { + Network.builder().createNetworkCmdModifier(cmd -> cmd.withName("dapr-network")).build().getId(); + return defaultDaprNetwork; + } else { + return defaultDaprNetwork; + } } else { - return defaultDaprNetwork; + return Network.newNetwork(); } } @@ -67,10 +72,10 @@ public Statement apply(Statement base, Description description) { public RabbitMQContainer rabbitMQContainer(Network daprNetwork, Environment env) { boolean reuse = env.getProperty("reuse", Boolean.class, false); return new RabbitMQContainer(DockerImageName.parse("rabbitmq:3.7.25-management-alpine")) - .withExposedPorts(5672) - .withNetworkAliases("rabbitmq") - .withReuse(reuse) - .withNetwork(daprNetwork); + .withExposedPorts(5672) + .withNetworkAliases("rabbitmq") + .withReuse(reuse) + .withNetwork(daprNetwork); } @Bean @@ -83,16 +88,15 @@ public DaprContainer daprContainer(Network daprNetwork, RabbitMQContainer rabbit rabbitMqProperties.put("password", "guest"); return new DaprContainer("daprio/daprd:1.14.4") - .withAppName("consumer-app") - .withNetwork(daprNetwork).withComponent(new Component("pubsub", - "pubsub.rabbitmq", "v1", rabbitMqProperties)) - .withDaprLogLevel(DaprLogLevel.INFO) - .withLogConsumer(outputFrame -> System.out.println(outputFrame.getUtf8String())) - .withAppPort(8081).withAppChannelAddress("host.testcontainers.internal") - .withReusablePlacement(reuse) - .withAppHealthCheckPath("/actuator/health") - .dependsOn(rabbitMQContainer); + .withAppName("consumer-app") + .withNetwork(daprNetwork).withComponent(new Component("pubsub", + "pubsub.rabbitmq", "v1", rabbitMqProperties)) + .withDaprLogLevel(DaprLogLevel.INFO) + .withLogConsumer(outputFrame -> System.out.println(outputFrame.getUtf8String())) + .withAppPort(8081).withAppChannelAddress("host.testcontainers.internal") + .withReusablePlacement(reuse) + .withAppHealthCheckPath("/actuator/health") + .dependsOn(rabbitMQContainer); } - } diff --git a/spring-boot-examples/producer-app/src/test/java/io/dapr/springboot/examples/producer/DaprTestContainersConfig.java b/spring-boot-examples/producer-app/src/test/java/io/dapr/springboot/examples/producer/DaprTestContainersConfig.java index b3ecb2e43c..5d38f5841e 100644 --- a/spring-boot-examples/producer-app/src/test/java/io/dapr/springboot/examples/producer/DaprTestContainersConfig.java +++ b/spring-boot-examples/producer-app/src/test/java/io/dapr/springboot/examples/producer/DaprTestContainersConfig.java @@ -44,32 +44,36 @@ public class DaprTestContainersConfig { @Bean - public Network getNetwork() { - Network defaultDaprNetwork = new Network() { - @Override - public String getId() { - return "dapr-network"; - } - - @Override - public void close() { - - } - - @Override - public Statement apply(Statement base, Description description) { - return null; + public Network getDaprNetwork(Environment env) { + boolean reuse = env.getProperty("reuse", Boolean.class, false); + if (reuse) { + Network defaultDaprNetwork = new Network() { + @Override + public String getId() { + return "dapr-network"; + } + + @Override + public void close() { + + } + + @Override + public Statement apply(Statement base, Description description) { + return null; + } + }; + + List networks = DockerClientFactory.instance().client().listNetworksCmd() + .withNameFilter("dapr-network").exec(); + if (networks.isEmpty()) { + Network.builder().createNetworkCmdModifier(cmd -> cmd.withName("dapr-network")).build().getId(); + return defaultDaprNetwork; + } else { + return defaultDaprNetwork; } - }; - - List networks = DockerClientFactory.instance().client().listNetworksCmd().withNameFilter("dapr-network").exec(); - if (networks.isEmpty()) { - Network.builder() - .createNetworkCmdModifier(cmd -> cmd.withName("dapr-network")) - .build().getId(); - return defaultDaprNetwork; } else { - return defaultDaprNetwork; + return Network.newNetwork(); } } From c06791b9d0ef2caaf709a24839e45ba7ad2d4642 Mon Sep 17 00:00:00 2001 From: Matheus Cruz <56329339+mcruzdev@users.noreply.github.com> Date: Tue, 25 Mar 2025 11:17:13 -0300 Subject: [PATCH 07/11] Change CountWordsAcitivy output format due to clashing (#1279) Signed-off-by: Matheus Cruz Co-authored-by: Cassie Coyle Signed-off-by: salaboy --- .../java/io/dapr/examples/workflows/README.md | 25 ++++++++++--------- .../faninout/CountWordsActivity.java | 4 +-- 2 files changed, 15 insertions(+), 14 deletions(-) diff --git a/examples/src/main/java/io/dapr/examples/workflows/README.md b/examples/src/main/java/io/dapr/examples/workflows/README.md index 4cd4c135a3..047f1d744f 100644 --- a/examples/src/main/java/io/dapr/examples/workflows/README.md +++ b/examples/src/main/java/io/dapr/examples/workflows/README.md @@ -226,13 +226,13 @@ public class CountWordsActivity implements WorkflowActivity { @Override public Object run(WorkflowActivityContext ctx) { Logger logger = LoggerFactory.getLogger(ToUpperCaseActivity.class); - logger.info("Starting Activity: " + ctx.getName()); + logger.info("Starting Activity: {}", ctx.getName()); String input = ctx.getInput(String.class); StringTokenizer tokenizer = new StringTokenizer(input); int result = tokenizer.countTokens(); - logger.info("Activity returned: " + result); + logger.info("Activity returned: {}.", result); logger.info("Activity finished"); return result; @@ -244,10 +244,11 @@ name: Run Chaining Pattern workflow match_order: none output_match_mode: substring expected_stdout_lines: - - 'Activity returned: 2' - - 'Activity returned: 9' - - 'Activity returned: 21' - - 'Activity returned: 17' + - 'Activity returned: 2.' + - 'Activity returned: 9.' + - 'Activity returned: 21.' + - 'Activity returned: 17.' + - 'Activity returned: 11.' - 'Workflow finished with result: 60' background: true sleep: 60 @@ -270,19 +271,19 @@ Now you can see the logs from worker: ```text == APP == 2023-11-07 14:52:03,075 {HH:mm:ss.SSS} [main] INFO io.dapr.workflows.WorkflowContext - Starting Workflow: io.dapr.examples.workflows.faninout.DemoFanInOutWorkflow == APP == 2023-11-07 14:52:03,144 {HH:mm:ss.SSS} [main] INFO i.d.e.w.faninout.CountWordsActivity - Starting Activity: io.dapr.examples.workflows.faninout.CountWordsActivity -== APP == 2023-11-07 14:52:03,147 {HH:mm:ss.SSS} [main] INFO i.d.e.w.faninout.CountWordsActivity - Activity returned: 2 +== APP == 2023-11-07 14:52:03,147 {HH:mm:ss.SSS} [main] INFO i.d.e.w.faninout.CountWordsActivity - Activity returned: 2. == APP == 2023-11-07 14:52:03,148 {HH:mm:ss.SSS} [main] INFO i.d.e.w.faninout.CountWordsActivity - Activity finished == APP == 2023-11-07 14:52:03,152 {HH:mm:ss.SSS} [main] INFO i.d.e.w.faninout.CountWordsActivity - Starting Activity: io.dapr.examples.workflows.faninout.CountWordsActivity -== APP == 2023-11-07 14:52:03,152 {HH:mm:ss.SSS} [main] INFO i.d.e.w.faninout.CountWordsActivity - Activity returned: 9 +== APP == 2023-11-07 14:52:03,152 {HH:mm:ss.SSS} [main] INFO i.d.e.w.faninout.CountWordsActivity - Activity returned: 9. == APP == 2023-11-07 14:52:03,152 {HH:mm:ss.SSS} [main] INFO i.d.e.w.faninout.CountWordsActivity - Activity finished == APP == 2023-11-07 14:52:03,167 {HH:mm:ss.SSS} [main] INFO i.d.e.w.faninout.CountWordsActivity - Starting Activity: io.dapr.examples.workflows.faninout.CountWordsActivity -== APP == 2023-11-07 14:52:03,167 {HH:mm:ss.SSS} [main] INFO i.d.e.w.faninout.CountWordsActivity - Activity returned: 21 +== APP == 2023-11-07 14:52:03,167 {HH:mm:ss.SSS} [main] INFO i.d.e.w.faninout.CountWordsActivity - Activity returned: 21. == APP == 2023-11-07 14:52:03,167 {HH:mm:ss.SSS} [main] INFO i.d.e.w.faninout.CountWordsActivity - Activity finished == APP == 2023-11-07 14:52:03,170 {HH:mm:ss.SSS} [main] INFO i.d.e.w.faninout.CountWordsActivity - Starting Activity: io.dapr.examples.workflows.faninout.CountWordsActivity -== APP == 2023-11-07 14:52:03,170 {HH:mm:ss.SSS} [main] INFO i.d.e.w.faninout.CountWordsActivity - Activity returned: 17 +== APP == 2023-11-07 14:52:03,170 {HH:mm:ss.SSS} [main] INFO i.d.e.w.faninout.CountWordsActivity - Activity returned: 17. == APP == 2023-11-07 14:52:03,170 {HH:mm:ss.SSS} [main] INFO i.d.e.w.faninout.CountWordsActivity - Activity finished == APP == 2023-11-07 14:52:03,173 {HH:mm:ss.SSS} [main] INFO i.d.e.w.faninout.CountWordsActivity - Starting Activity: io.dapr.examples.workflows.faninout.CountWordsActivity -== APP == 2023-11-07 14:52:03,173 {HH:mm:ss.SSS} [main] INFO i.d.e.w.faninout.CountWordsActivity - Activity returned: 11 +== APP == 2023-11-07 14:52:03,173 {HH:mm:ss.SSS} [main] INFO i.d.e.w.faninout.CountWordsActivity - Activity returned: 11. == APP == 2023-11-07 14:52:03,174 {HH:mm:ss.SSS} [main] INFO i.d.e.w.faninout.CountWordsActivity - Activity finished == APP == 2023-11-07 14:52:03,212 {HH:mm:ss.SSS} [main] INFO io.dapr.workflows.WorkflowContext - Workflow finished with result: 60 ``` @@ -538,4 +539,4 @@ The log from client: ```text Started a new child-workflow model workflow with instance ID: c2fb9c83-435b-4b55-bdf1-833b39366cfb workflow instance with ID: c2fb9c83-435b-4b55-bdf1-833b39366cfb completed with result: !wolfkroW rpaD olleH -``` \ No newline at end of file +``` diff --git a/examples/src/main/java/io/dapr/examples/workflows/faninout/CountWordsActivity.java b/examples/src/main/java/io/dapr/examples/workflows/faninout/CountWordsActivity.java index 654b4e884e..cf3f637208 100644 --- a/examples/src/main/java/io/dapr/examples/workflows/faninout/CountWordsActivity.java +++ b/examples/src/main/java/io/dapr/examples/workflows/faninout/CountWordsActivity.java @@ -24,13 +24,13 @@ public class CountWordsActivity implements WorkflowActivity { @Override public Object run(WorkflowActivityContext ctx) { Logger logger = LoggerFactory.getLogger(CountWordsActivity.class); - logger.info("Starting Activity: " + ctx.getName()); + logger.info("Starting Activity: {}", ctx.getName()); String input = ctx.getInput(String.class); StringTokenizer tokenizer = new StringTokenizer(input); int result = tokenizer.countTokens(); - logger.info("Activity returned: " + result); + logger.info("Activity returned: {}.", result); logger.info("Activity finished"); return result; From 04d98aeafdfc1471efc0a129c595a3220f03c46e Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 25 Mar 2025 14:41:23 -0500 Subject: [PATCH 08/11] Bump codecov/codecov-action from 4.4.1 to 5.4.0 (#1278) Bumps [codecov/codecov-action](https://github.com/codecov/codecov-action) from 4.4.1 to 5.4.0. - [Release notes](https://github.com/codecov/codecov-action/releases) - [Changelog](https://github.com/codecov/codecov-action/blob/main/CHANGELOG.md) - [Commits](https://github.com/codecov/codecov-action/compare/v4.4.1...v5.4.0) --- updated-dependencies: - dependency-name: codecov/codecov-action dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Cassie Coyle Signed-off-by: salaboy --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 441228ce5e..021e6f5f19 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -121,7 +121,7 @@ jobs: env: DOCKER_HOST: ${{steps.setup_docker.outputs.sock}} - name: Codecov - uses: codecov/codecov-action@v4.4.1 + uses: codecov/codecov-action@v5.4.0 - name: Install jars run: ./mvnw install -q -B -DskipTests - name: Integration tests using spring boot version ${{ matrix.spring-boot-version }} From 9b3ba0f6c09d47d383623bfdb9de69f82ba99a4e Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 25 Mar 2025 15:44:57 -0500 Subject: [PATCH 09/11] Bump fossas/fossa-action from 1.3.3 to 1.6.0 (#1277) Bumps [fossas/fossa-action](https://github.com/fossas/fossa-action) from 1.3.3 to 1.6.0. - [Release notes](https://github.com/fossas/fossa-action/releases) - [Commits](https://github.com/fossas/fossa-action/compare/v1.3.3...v1.6.0) --- updated-dependencies: - dependency-name: fossas/fossa-action dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Cassie Coyle Signed-off-by: salaboy --- .github/workflows/fossa.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/fossa.yml b/.github/workflows/fossa.yml index bdfd728095..5e5581db7b 100644 --- a/.github/workflows/fossa.yml +++ b/.github/workflows/fossa.yml @@ -35,12 +35,12 @@ jobs: uses: actions/checkout@v4 - name: "Run FOSSA Scan" - uses: fossas/fossa-action@v1.3.3 # Use a specific version if locking is preferred + uses: fossas/fossa-action@v1.6.0 # Use a specific version if locking is preferred with: api-key: ${{ env.FOSSA_API_KEY }} - name: "Run FOSSA Test" - uses: fossas/fossa-action@v1.3.3 # Use a specific version if locking is preferred + uses: fossas/fossa-action@v1.6.0 # Use a specific version if locking is preferred with: api-key: ${{ env.FOSSA_API_KEY }} run-tests: true From c45ee9086f5b6d45269452e1fb8cff416a75dea9 Mon Sep 17 00:00:00 2001 From: salaboy Date: Thu, 27 Mar 2025 16:17:03 +0000 Subject: [PATCH 10/11] update instructions to cover podman (#1274) Signed-off-by: salaboy Co-authored-by: artur-ciocanu Co-authored-by: Cassie Coyle Signed-off-by: salaboy --- spring-boot-examples/kubernetes/README.md | 25 +++++++++++++++++-- .../kubernetes/kind-with-registry.sh | 6 +++-- 2 files changed, 27 insertions(+), 4 deletions(-) diff --git a/spring-boot-examples/kubernetes/README.md b/spring-boot-examples/kubernetes/README.md index 4c3fc709d9..3bb5da421e 100644 --- a/spring-boot-examples/kubernetes/README.md +++ b/spring-boot-examples/kubernetes/README.md @@ -13,6 +13,17 @@ with a local container registry, so we can push our container images to it. This ./kind-with-registry.sh ``` +**Note**: If you are using Podman Desktop, instead of Docker you need to run the following command to enable insecure registries: + +``` +read -r -d '' registry_conf < /etc/containers/registries.conf.d/local.conf' <<<$registry_conf +``` + Once you have the cluster up and running you can install Dapr: ```bash @@ -39,10 +50,15 @@ Once we have the container image created, we need to tag and push to the local r Alternatively, you can push the images to a public registry and update the Kubernetes manifests accordingly. ```bash -docker tag producer-app:0.14.0-SNAPSHOT localhost:5001/sb-producer-app +docker tag producer-app:0.15.0-SNAPSHOT localhost:5001/sb-producer-app docker push localhost:5001/sb-producer-app ``` +**Note**: for Podman you need to run: +``` +podman push localhost:5001/sb-producer-app --tls-verify=false +``` + From inside the `spring-boot-examples/consumer-app` directory you can run the following command to create a container: ```bash mvn spring-boot:build-image @@ -52,10 +68,15 @@ Once we have the container image created, we need to tag and push to the local r Alternatively, you can push the images to a public registry and update the Kubernetes manifests accordingly. ```bash -docker tag consumer-app:0.14.0-SNAPSHOT localhost:5001/sb-consumer-app +docker tag consumer-app:0.15.0-SNAPSHOT localhost:5001/sb-consumer-app docker push localhost:5001/sb-consumer-app ``` +**Note**: for Podman you need to run: +``` +podman push localhost:5001/sb-consumer-app --tls-verify=false +``` + Now we are ready to install our application into the cluster. ## Installing and interacting with the application diff --git a/spring-boot-examples/kubernetes/kind-with-registry.sh b/spring-boot-examples/kubernetes/kind-with-registry.sh index 9fe55a821a..78a8692a17 100755 --- a/spring-boot-examples/kubernetes/kind-with-registry.sh +++ b/spring-boot-examples/kubernetes/kind-with-registry.sh @@ -11,8 +11,10 @@ if [ "$(docker inspect -f '{{.State.Running}}' "${reg_name}" 2>/dev/null || true fi # 2. Create kind cluster with containerd registry config dir enabled -# TODO: kind will eventually enable this by default and this patch will -# be unnecessary. +# +# NOTE: the containerd config patch is not necessary with images from kind v0.27.0+ +# It may enable some older images to work similarly. +# If you're only supporting newer relases, you can just use `kind create cluster` here. # # See: # https://github.com/kubernetes-sigs/kind/issues/2875 From ca97f7bfa970005ff4d40743b4040f4a6551b4ef Mon Sep 17 00:00:00 2001 From: salaboy Date: Thu, 27 Mar 2025 16:26:46 +0000 Subject: [PATCH 11/11] following checkstyle Signed-off-by: salaboy --- .../main/java/io/dapr/testcontainers/AppHttpPipeline.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/testcontainers-dapr/src/main/java/io/dapr/testcontainers/AppHttpPipeline.java b/testcontainers-dapr/src/main/java/io/dapr/testcontainers/AppHttpPipeline.java index d412a87086..9a4fcb0a92 100644 --- a/testcontainers-dapr/src/main/java/io/dapr/testcontainers/AppHttpPipeline.java +++ b/testcontainers-dapr/src/main/java/io/dapr/testcontainers/AppHttpPipeline.java @@ -19,8 +19,13 @@ public class AppHttpPipeline implements ConfigurationSettings { private List handlers; + /** + * Creates an AppHttpPipeline. + * + * @param handlers List of handlers for the AppHttpPipeline + */ public AppHttpPipeline(List handlers) { - if (handlers != null ){ + if (handlers != null) { this.handlers = Collections.unmodifiableList(handlers); } }