Skip to content

Commit

Permalink
Ensure identity copied to Builder from source WorkerOptions (#2151)
Browse files Browse the repository at this point in the history
  • Loading branch information
dustin10 authored and Quinn-With-Two-Ns committed Jul 31, 2024
1 parent eb7d9ee commit fc37b39
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ private Builder(WorkerOptions o) {
this.useBuildIdForVersioning = o.useBuildIdForVersioning;
this.buildId = o.buildId;
this.stickyTaskQueueDrainTimeout = o.stickyTaskQueueDrainTimeout;
this.identity = o.identity;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

import static org.junit.Assert.assertEquals;

import java.time.Duration;
import org.junit.Test;

public class WorkerOptionsTest {
Expand All @@ -47,4 +48,57 @@ public void verifyWorkerOptionsEquality() {
WorkerOptions w2 = WorkerOptions.newBuilder().build();
assertEquals(w1, w2);
}

@Test
public void verifyNewBuilderFromExistingWorkerOptions() {
WorkerOptions w1 =
WorkerOptions.newBuilder()
.setMaxWorkerActivitiesPerSecond(100)
.setMaxConcurrentActivityExecutionSize(1000)
.setMaxConcurrentWorkflowTaskExecutionSize(500)
.setMaxConcurrentLocalActivityExecutionSize(200)
.setMaxTaskQueueActivitiesPerSecond(50)
.setMaxConcurrentWorkflowTaskPollers(4)
.setMaxConcurrentActivityTaskPollers(3)
.setLocalActivityWorkerOnly(false)
.setDefaultDeadlockDetectionTimeout(2)
.setMaxHeartbeatThrottleInterval(Duration.ofSeconds(10))
.setDefaultHeartbeatThrottleInterval(Duration.ofSeconds(7))
.setStickyQueueScheduleToStartTimeout(Duration.ofSeconds(60))
.setDisableEagerExecution(false)
.setUseBuildIdForVersioning(false)
.setBuildId("build-id")
.setStickyTaskQueueDrainTimeout(Duration.ofSeconds(15))
.setIdentity("worker-identity")
.build();

WorkerOptions w2 = WorkerOptions.newBuilder(w1).build();

assertEquals(w1.getMaxWorkerActivitiesPerSecond(), w2.getMaxWorkerActivitiesPerSecond(), 0);
assertEquals(
w1.getMaxConcurrentActivityExecutionSize(), w2.getMaxConcurrentActivityExecutionSize());
assertEquals(
w1.getMaxConcurrentWorkflowTaskExecutionSize(),
w2.getMaxConcurrentWorkflowTaskExecutionSize());
assertEquals(
w1.getMaxConcurrentLocalActivityExecutionSize(),
w2.getMaxConcurrentLocalActivityExecutionSize());
assertEquals(
w1.getMaxTaskQueueActivitiesPerSecond(), w2.getMaxTaskQueueActivitiesPerSecond(), 0);
assertEquals(
w1.getMaxConcurrentWorkflowTaskPollers(), w2.getMaxConcurrentWorkflowTaskPollers());
assertEquals(
w1.getMaxConcurrentActivityTaskPollers(), w2.getMaxConcurrentActivityTaskPollers());
assertEquals(w1.isLocalActivityWorkerOnly(), w2.isLocalActivityWorkerOnly());
assertEquals(w1.getMaxHeartbeatThrottleInterval(), w2.getMaxHeartbeatThrottleInterval());
assertEquals(
w1.getDefaultHeartbeatThrottleInterval(), w2.getDefaultHeartbeatThrottleInterval());
assertEquals(
w1.getStickyQueueScheduleToStartTimeout(), w2.getStickyQueueScheduleToStartTimeout());
assertEquals(w1.isEagerExecutionDisabled(), w2.isEagerExecutionDisabled());
assertEquals(w1.isUsingBuildIdForVersioning(), w2.isUsingBuildIdForVersioning());
assertEquals(w1.getBuildId(), w2.getBuildId());
assertEquals(w1.getStickyTaskQueueDrainTimeout(), w2.getStickyTaskQueueDrainTimeout());
assertEquals(w1.getIdentity(), w2.getIdentity());
}
}

0 comments on commit fc37b39

Please sign in to comment.