Skip to content
Open
Show file tree
Hide file tree
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 @@ -61,6 +61,9 @@ public WorkerDeploymentOptions build() {
Preconditions.checkState(
!(useVersioning && version == null),
"If useVersioning is set, setVersion must be called");
Preconditions.checkState(
useVersioning || defaultVersioningBehavior == VersioningBehavior.UNSPECIFIED,
"defaultVersioningBehavior must be UNSPECIFIED when useVersioning is false");
return new WorkerDeploymentOptions(useVersioning, version, defaultVersioningBehavior);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -387,6 +387,63 @@ public void testAnnotationNotAllowedOnInterface() {
e.getMessage());
}

@Test
public void testWorkerWithDeploymentOptionsVersioningOffCanRunWorkflows() {
assumeTrue("Test Server doesn't support versioning", SDKTestWorkflowRule.useExternalService);

Worker w1 =
testWorkflowRule.newWorker(
(opts) ->
opts.setDeploymentOptions(
WorkerDeploymentOptions.newBuilder()
.setVersion(
new WorkerDeploymentVersion(
testWorkflowRule.getDeploymentName(), "my-custom-build-id-1.0"))
.setUseVersioning(false)
.build()));
w1.registerWorkflowImplementationTypes(TestWorkerVersioningMissingAnnotation.class);
w1.start();

TestWorkflows.QueryableWorkflow wf =
testWorkflowRule.newWorkflowStubTimeoutOptions(
TestWorkflows.QueryableWorkflow.class, "versioning-off-build-id");
WorkflowExecution we = WorkflowClient.start(wf::execute);
wf.mySignal("done");
String result =
testWorkflowRule
.getWorkflowClient()
.newUntypedWorkflowStub(we.getWorkflowId())
.getResult(String.class);
Assert.assertEquals("no-annotation", result);

WorkflowExecutionHistory hist = testWorkflowRule.getExecutionHistory(we.getWorkflowId());
Assert.assertTrue(
"Expected build ID to appear in workflow history",
hist.getHistory().getEventsList().stream()
.anyMatch(
e ->
e.getEventType() == EventType.EVENT_TYPE_WORKFLOW_TASK_COMPLETED
&& e.getWorkflowTaskCompletedEventAttributes()
.getDeploymentVersion()
.getBuildId()
.equals("my-custom-build-id-1.0")));
}

@Test
public void testRejectsVersioningBehaviorWhenVersioningOff() {
IllegalStateException e =
Assert.assertThrows(
IllegalStateException.class,
() ->
WorkerDeploymentOptions.newBuilder()
.setVersion(
new WorkerDeploymentVersion(testWorkflowRule.getDeploymentName(), "1.0"))
.setUseVersioning(false)
.setDefaultVersioningBehavior(VersioningBehavior.AUTO_UPGRADE)
.build());
Assert.assertTrue(e.getMessage().contains("defaultVersioningBehavior must be UNSPECIFIED"));
}

@SuppressWarnings("deprecation")
@Test
public void testWorkflowsCanUseVersioningOverride() {
Expand Down
Loading