Skip to content

Commit b6ae9b5

Browse files
authored
De-flake asserting slot metrics (#2478)
1 parent 8808c40 commit b6ae9b5

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

temporal-sdk/src/test/java/io/temporal/worker/ResourceBasedTunerTests.java

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
import io.temporal.client.WorkflowOptions;
3232
import io.temporal.common.reporter.TestStatsReporter;
3333
import io.temporal.serviceclient.MetricsTag;
34+
import io.temporal.testUtils.Eventually;
3435
import io.temporal.testing.internal.SDKTestWorkflowRule;
3536
import io.temporal.worker.tuning.*;
3637
import io.temporal.workflow.*;
@@ -115,10 +116,16 @@ public void canShutdownInTheMiddle() throws InterruptedException {
115116
workflow.activitiesStarted();
116117
testWorkflowRule.getTestEnvironment().getWorkerFactory().shutdownNow();
117118
testWorkflowRule.getTestEnvironment().getWorkerFactory().awaitTermination(3, TimeUnit.SECONDS);
118-
reporter.assertGauge(MetricsType.WORKER_TASK_SLOTS_USED, getWorkerTags("WorkflowWorker"), 0);
119-
reporter.assertGauge(MetricsType.WORKER_TASK_SLOTS_USED, getWorkerTags("ActivityWorker"), 0);
120-
reporter.assertGauge(
121-
MetricsType.WORKER_TASK_SLOTS_USED, getWorkerTags("LocalActivityWorker"), 0);
119+
Eventually.assertEventually(
120+
Duration.ofMillis(2000),
121+
() -> {
122+
reporter.assertGauge(
123+
MetricsType.WORKER_TASK_SLOTS_USED, getWorkerTags("WorkflowWorker"), 0);
124+
reporter.assertGauge(
125+
MetricsType.WORKER_TASK_SLOTS_USED, getWorkerTags("ActivityWorker"), 0);
126+
reporter.assertGauge(
127+
MetricsType.WORKER_TASK_SLOTS_USED, getWorkerTags("LocalActivityWorker"), 0);
128+
});
122129
}
123130

124131
@WorkflowInterface

0 commit comments

Comments
 (0)