From 8452f8216e669bf0534473a36fc8c237c5d387d3 Mon Sep 17 00:00:00 2001 From: addjuarez <6789375+addjuarez@users.noreply.github.com> Date: Fri, 5 Jan 2024 12:52:03 -0600 Subject: [PATCH 1/4] migrate upload-artifact v4 breaking change to fix github workflows (#979) * set upload-artifact to old version Signed-off-by: addjuarez <6789375+addjuarez@users.noreply.github.com> * use distinct artifact names Signed-off-by: addjuarez <6789375+addjuarez@users.noreply.github.com> --------- Signed-off-by: addjuarez <6789375+addjuarez@users.noreply.github.com> --- .github/workflows/build.yml | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 4d97ab54b..f0a01f3fe 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -126,26 +126,26 @@ jobs: id: integration_tests run: PRODUCT_SPRING_BOOT_VERSION=${{ matrix.spring-boot-version }} ./mvnw -B -f sdk-tests/pom.xml verify - name: Upload test report for sdk - uses: actions/upload-artifact@master + uses: actions/upload-artifact@v4 with: - name: report-dapr-java-sdk + name: report-dapr-java-sdk-jdk${{ matrix.java }}-sb${{ matrix.spring-boot-version }} path: sdk/target/jacoco-report/ - name: Upload test report for sdk-actors - uses: actions/upload-artifact@master + uses: actions/upload-artifact@v4 with: - name: report-dapr-java-sdk-actors + name: report-dapr-java-sdk-actors-jdk${{ matrix.java }}-sb${{ matrix.spring-boot-version }} path: sdk-actors/target/jacoco-report/ - name: Upload failsafe test report for sdk-tests on failure if: ${{ failure() && steps.integration_tests.conclusion == 'failure' }} - uses: actions/upload-artifact@master + uses: actions/upload-artifact@v4 with: - name: failsafe-report-sdk-tests + name: failsafe-report-sdk-tests-jdk${{ matrix.java }}-sb${{ matrix.spring-boot-version }} path: sdk-tests/target/failsafe-reports - name: Upload surefire test report for sdk-tests on failure if: ${{ failure() && steps.integration_tests.conclusion == 'failure' }} - uses: actions/upload-artifact@master + uses: actions/upload-artifact@v4 with: - name: surefire-report-sdk-tests + name: surefire-report-sdk-tests-jdk${{ matrix.java }}-sb${{ matrix.spring-boot-version }} path: sdk-tests/target/surefire-reports publish: From f65e252d0e7bd9c8168e382852ef5b1bd9f42884 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 5 Jan 2024 10:52:58 -0800 Subject: [PATCH 2/4] Bump actions/setup-go from 3 to 4 (#841) Bumps [actions/setup-go](https://github.com/actions/setup-go) from 3 to 4. - [Release notes](https://github.com/actions/setup-go/releases) - [Commits](https://github.com/actions/setup-go/compare/v3...v4) --- updated-dependencies: - dependency-name: actions/setup-go 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: Artur Souza --- .github/workflows/build.yml | 2 +- .github/workflows/validate.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index f0a01f3fe..da161ef83 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -60,7 +60,7 @@ jobs: run: wget -q ${{ env.DAPR_INSTALL_URL }} -O - | /bin/bash -s ${{ env.DAPR_CLI_VER }} - name: Set up Go ${{ env.GOVER }} if: env.DAPR_REF != '' || env.DAPR_CLI_REF != '' - uses: actions/setup-go@v3 + uses: actions/setup-go@v4 with: go-version: ${{ env.GOVER }} - name: Checkout Dapr CLI repo to override dapr command. diff --git a/.github/workflows/validate.yml b/.github/workflows/validate.yml index ca78b3402..fb0ead2c0 100644 --- a/.github/workflows/validate.yml +++ b/.github/workflows/validate.yml @@ -53,7 +53,7 @@ jobs: run: wget -q ${{ env.DAPR_INSTALL_URL }} -O - | /bin/bash -s ${{ env.DAPR_CLI_VER }} - name: Set up Go ${{ env.GOVER }} if: env.DAPR_REF != '' || env.DAPR_CLI_REF != '' - uses: actions/setup-go@v3 + uses: actions/setup-go@v4 with: go-version: ${{ env.GOVER }} - name: Checkout Dapr CLI repo to override dapr command. From 40617f1c62fcc291c8a3d5a74c1b3dad6635d185 Mon Sep 17 00:00:00 2001 From: MregXN <46479059+MregXN@users.noreply.github.com> Date: Sat, 6 Jan 2024 03:48:15 +0800 Subject: [PATCH 3/4] wait for actor to be ready (#969) Signed-off-by: MregXN Co-authored-by: Mukundan Sundararajan <65565396+mukundansundar@users.noreply.github.com> Co-authored-by: Dapr Bot <56698301+dapr-bot@users.noreply.github.com> Co-authored-by: Artur Souza --- sdk-tests/src/test/java/io/dapr/it/actors/ActorStateIT.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/sdk-tests/src/test/java/io/dapr/it/actors/ActorStateIT.java b/sdk-tests/src/test/java/io/dapr/it/actors/ActorStateIT.java index 8ce674aa3..90a160ef8 100644 --- a/sdk-tests/src/test/java/io/dapr/it/actors/ActorStateIT.java +++ b/sdk-tests/src/test/java/io/dapr/it/actors/ActorStateIT.java @@ -167,6 +167,9 @@ public void writeReadState(DaprApiProtocol daprClientProtocol, DaprApiProtocol s proxyBuilder = new ActorProxyBuilder(actorType, ActorProxy.class, newActorClient()); ActorProxy newProxy = proxyBuilder.build(actorId); + // wating for actor to be activated + Thread.sleep(2000); + callWithRetry(() -> { logger.debug("Invoking readMessage where data is not cached ... "); String result = newProxy.invokeMethod("readMessage", String.class).block(); From 81a3058223c0bde8c04e841d56ef0928fa625f29 Mon Sep 17 00:00:00 2001 From: Ryan Lettieri <67934986+RyanLettieri@users.noreply.github.com> Date: Fri, 5 Jan 2024 17:21:59 -0700 Subject: [PATCH 4/4] Improving and Adding Logs for Workflow (#978) * Initial push for improving/adding logs for workflow Signed-off-by: Ryan Lettieri * Cleaning up linter issues Signed-off-by: Ryan Lettieri * Altering log level for logging registered activities and workflows Signed-off-by: Ryan Lettieri * Adding in time format to workflow log statements Signed-off-by: Ryan Lettieri * Fixing month format for workflow logs Signed-off-by: Ryan Lettieri * Adding in logging test for workflow Signed-off-by: Ryan Lettieri * Removing log-level setting from workflow sdk Signed-off-by: Ryan Lettieri * Removing time format logging from workflow sdk Signed-off-by: Ryan Lettieri * Fixing workflow logging test Signed-off-by: Ryan Lettieri * Update WorkflowRuntimeBuilderTest.java Signed-off-by: Artur Souza --------- Signed-off-by: Ryan Lettieri Signed-off-by: Artur Souza Co-authored-by: Artur Souza --- .../runtime/WorkflowRuntimeBuilder.java | 21 ++++++++- .../runtime/WorkflowRuntimeBuilderTest.java | 46 +++++++++++++++++++ 2 files changed, 65 insertions(+), 2 deletions(-) diff --git a/sdk-workflows/src/main/java/io/dapr/workflows/runtime/WorkflowRuntimeBuilder.java b/sdk-workflows/src/main/java/io/dapr/workflows/runtime/WorkflowRuntimeBuilder.java index fb9ed14a4..99d8a0d7b 100644 --- a/sdk-workflows/src/main/java/io/dapr/workflows/runtime/WorkflowRuntimeBuilder.java +++ b/sdk-workflows/src/main/java/io/dapr/workflows/runtime/WorkflowRuntimeBuilder.java @@ -19,14 +19,26 @@ import io.dapr.workflows.internal.ApiTokenClientInterceptor; import io.grpc.ClientInterceptor; +import java.util.HashSet; +import java.util.Set; +import java.util.logging.Level; +import java.util.logging.Logger; + public class WorkflowRuntimeBuilder { private static volatile WorkflowRuntime instance; private DurableTaskGrpcWorkerBuilder builder; + private Logger logger; + private Set workflows = new HashSet(); + private Set activities = new HashSet(); private static ClientInterceptor WORKFLOW_INTERCEPTOR = new ApiTokenClientInterceptor(); + /** + * Constructs the WorkflowRuntimeBuilder. + */ public WorkflowRuntimeBuilder() { this.builder = new DurableTaskGrpcWorkerBuilder().grpcChannel( NetworkUtils.buildGrpcManagedChannel(WORKFLOW_INTERCEPTOR)); + this.logger = Logger.getLogger(WorkflowRuntimeBuilder.class.getName()); } /** @@ -42,6 +54,7 @@ public WorkflowRuntime build() { } } } + this.logger.log(Level.INFO, "Successfully built dapr workflow runtime"); return instance; } @@ -56,7 +69,8 @@ public WorkflowRuntimeBuilder registerWorkflow(Class cla this.builder = this.builder.addOrchestration( new OrchestratorWrapper<>(clazz) ); - + this.logger.log(Level.INFO, "Registered Workflow: " + clazz.getSimpleName()); + this.workflows.add(clazz.getSimpleName()); return this; } @@ -70,5 +84,8 @@ public void registerActivity(Class clazz) { this.builder = this.builder.addActivity( new ActivityWrapper<>(clazz) ); + this.logger.log(Level.INFO, "Registered Activity: " + clazz.getSimpleName()); + this.activities.add(clazz.getSimpleName()); } -} + +} \ No newline at end of file diff --git a/sdk-workflows/src/test/java/io/dapr/workflows/runtime/WorkflowRuntimeBuilderTest.java b/sdk-workflows/src/test/java/io/dapr/workflows/runtime/WorkflowRuntimeBuilderTest.java index faded869b..e563a04f7 100644 --- a/sdk-workflows/src/test/java/io/dapr/workflows/runtime/WorkflowRuntimeBuilderTest.java +++ b/sdk-workflows/src/test/java/io/dapr/workflows/runtime/WorkflowRuntimeBuilderTest.java @@ -5,8 +5,15 @@ import io.dapr.workflows.WorkflowStub; import org.junit.jupiter.api.Test; +import static org.junit.Assert.assertNotEquals; import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; +import java.io.ByteArrayOutputStream; +import java.io.PrintStream; +import java.util.logging.Logger; +import java.util.logging.Handler; +import java.util.logging.LogRecord; + public class WorkflowRuntimeBuilderTest { public static class TestWorkflow extends Workflow { @Override @@ -37,4 +44,43 @@ public void registerValidWorkflowActivityClass() { public void buildTest() { assertDoesNotThrow(() -> new WorkflowRuntimeBuilder().build()); } + + @Test + public void loggingOutputTest() { + // Set the output stream for log capturing + ByteArrayOutputStream outStreamCapture = new ByteArrayOutputStream(); + System.setOut(new PrintStream(outStreamCapture)); + + LogCaptureHandler testLoggerHandler = new LogCaptureHandler(); + Logger testLogger = Logger.getLogger(WorkflowRuntimeBuilder.class.getName()); + + testLogger.addHandler(testLoggerHandler); + + // indexOf will return -1 if the string is not found. + assertDoesNotThrow(() -> new WorkflowRuntimeBuilder().registerWorkflow(TestWorkflow.class)); + assertNotEquals(-1, testLoggerHandler.capturedLog.indexOf("Registered Workflow: TestWorkflow")); + assertDoesNotThrow(() -> new WorkflowRuntimeBuilder().registerActivity(TestActivity.class)); + assertNotEquals(-1, testLoggerHandler.capturedLog.indexOf("Registered Activity: TestActivity")); + + WorkflowRuntimeBuilder wfRuntime = new WorkflowRuntimeBuilder(); + + wfRuntime.build(); + } + + private static class LogCaptureHandler extends Handler { + private StringBuilder capturedLog = new StringBuilder(); + + @Override + public void publish(LogRecord record) { + capturedLog.append(record.getMessage()).append(System.lineSeparator()); + } + + @Override + public void flush(){ + } + + @Override + public void close() throws SecurityException { + } + } }