Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -488,7 +488,7 @@ public void testStickyCacheSize() throws InterruptedException, ExecutionExceptio
setUp(WorkerFactoryOptions.getDefaultInstance());

Worker worker = testEnvironment.newWorker(TASK_QUEUE);
worker.registerWorkflowImplementationTypes(TestWorkflowWithSleep.class);
worker.registerWorkflowImplementationTypes(TestWorkflowWithSignal.class);
testEnvironment.start();

Thread.sleep(REPORTING_FLUSH_TIME);
Expand All @@ -500,14 +500,16 @@ public void testStickyCacheSize() throws InterruptedException, ExecutionExceptio
.setWorkflowRunTimeout(Duration.ofSeconds(7000))
.setTaskQueue(TASK_QUEUE)
.build();
NoArgsWorkflow workflow = workflowClient.newWorkflowStub(NoArgsWorkflow.class, options);
CacheMetricsWorkflow workflow =
workflowClient.newWorkflowStub(CacheMetricsWorkflow.class, options);
CompletableFuture<Void> wfFuture = WorkflowClient.execute(workflow::execute);
SDKTestWorkflowRule.waitForOKQuery(WorkflowStub.fromTyped(workflow));

Thread.sleep(REPORTING_FLUSH_TIME);
reporter.assertGauge(STICKY_CACHE_SIZE, TAGS_NAMESPACE, 1);
reporter.assertGauge(WORKFLOW_ACTIVE_THREAD_COUNT, TAGS_NAMESPACE, val -> val == 1 || val == 2);

workflow.complete();
wfFuture.get();

Thread.sleep(REPORTING_FLUSH_TIME);
Expand Down Expand Up @@ -645,11 +647,26 @@ public String execute() {
}
}

public static class TestWorkflowWithSleep implements NoArgsWorkflow {
@WorkflowInterface
public interface CacheMetricsWorkflow {
@WorkflowMethod
void execute();

@SignalMethod
void complete();
}

public static class TestWorkflowWithSignal implements CacheMetricsWorkflow {
private boolean complete;

@Override
public void execute() {
Workflow.sleep(5000);
Workflow.await(() -> complete);
}

@Override
public void complete() {
complete = true;
}
}

Expand Down