Skip to content
Merged
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 @@ -558,6 +558,8 @@ void recordMarker(String markerName, Header header, byte[] details) {
}

void upsertSearchAttributes(SearchAttributes searchAttributes) {
addAllMissingVersionMarker(false, Optional.empty());

UpsertWorkflowSearchAttributesDecisionAttributes decisionAttr =
new UpsertWorkflowSearchAttributesDecisionAttributes()
.setSearchAttributes(searchAttributes);
Expand Down
31 changes: 31 additions & 0 deletions src/test/java/com/uber/cadence/workflow/WorkflowTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -4524,6 +4524,37 @@ public void testGetVersionRemovedInReplay2() {
assertEquals("activity", workflowStub.query());
}

// The following test covers the scenario where getVersion call is removed before
// upsertSearchAttributes.
public static class TestGetVersionRemovedInReplay3WorkflowImpl implements TestWorkflow1 {
@Override
public String execute(String taskList) {
Map<String, Object> searchAttrMap = new HashMap<>();
searchAttrMap.put("CustomKeywordField", "abc");
// Test removing a version check in replay code.
if (!getVersionExecuted.contains(taskList)) {
Workflow.getVersion("test_change", Workflow.DEFAULT_VERSION, 1);
Workflow.upsertSearchAttributes(searchAttrMap);
getVersionExecuted.add(taskList);
} else {
Workflow.upsertSearchAttributes(searchAttrMap);
}

return "done";
}
}

@Test
public void testGetVersionRemovedInReplay3() {
startWorkerFor(TestGetVersionRemovedInReplay3WorkflowImpl.class);
TestWorkflow1 workflowStub =
workflowClient.newWorkflowStub(
TestWorkflow1.class, newWorkflowOptionsBuilder(taskList).build());
String result = workflowStub.execute(taskList);
assertEquals("done", result);
tracer.setExpected("getVersion", "upsertSearchAttributes");
}

public static class TestVersionNotSupportedWorkflowImpl implements TestWorkflow1 {

@Override
Expand Down