Skip to content

Commit

Permalink
Merge branch 'master' into bulk-subscriber-grpc
Browse files Browse the repository at this point in the history
  • Loading branch information
MregXN authored Jan 8, 2024
2 parents 1855e1f + 81a3058 commit d080a40
Show file tree
Hide file tree
Showing 5 changed files with 78 additions and 12 deletions.
18 changes: 9 additions & 9 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/validate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
3 changes: 3 additions & 0 deletions sdk-tests/src/test/java/io/dapr/it/actors/ActorStateIT.java
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<String> workflows = new HashSet<String>();
private Set<String> activities = new HashSet<String>();
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());
}

/**
Expand All @@ -42,6 +54,7 @@ public WorkflowRuntime build() {
}
}
}
this.logger.log(Level.INFO, "Successfully built dapr workflow runtime");
return instance;
}

Expand All @@ -56,7 +69,8 @@ public <T extends Workflow> WorkflowRuntimeBuilder registerWorkflow(Class<T> 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;
}

Expand All @@ -70,5 +84,8 @@ public <T extends WorkflowActivity> void registerActivity(Class<T> clazz) {
this.builder = this.builder.addActivity(
new ActivityWrapper<>(clazz)
);
this.logger.log(Level.INFO, "Registered Activity: " + clazz.getSimpleName());
this.activities.add(clazz.getSimpleName());
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 {
}
}
}

0 comments on commit d080a40

Please sign in to comment.