cadence-java-client icon indicating copy to clipboard operation
cadence-java-client copied to clipboard

replayWorkflowExecutionFromResource miss detecting breaking workflow update

Open vancexu opened this issue 5 years ago • 0 comments

It seems WorkflowReplayer.replayWorkflowExecutionFromResource cannot detect non-deterministic change for the last decision.

Repro workflow:

public static class TestGetVersionAddedImpl implements TestWorkflow1 {

    @Override
    public String execute(String taskList) {
      Workflow.sleep(10); // This is new added code, and not exist in previous run
      int version = Workflow.getVersion("cid1", Workflow.DEFAULT_VERSION, 1);
      System.out.println(version);
      return "hello";
    }
  }

history

[
  {
    "eventId":1,
    "timestamp":1599168190229914000,
    "eventType":"WorkflowExecutionStarted",
    "version":-24,
    "taskId":10485920,
    "workflowExecutionStartedEventAttributes":{
      "workflowType":{
        "name":"TestWorkflow1::execute"
      },
      "taskList":{
        "name":"WorkflowTest-testGetVersionAdded[Docker Sticky ON]-fdfe366b-fc85-48da-b08b-24280fd99bd9"
      },
      "input":"IldvcmtmbG93VGVzdC10ZXN0R2V0VmVyc2lvbkFkZGVkW0RvY2tlciBTdGlja3kgT05dLWZkZmUzNjZiLWZjODUtNDhkYS1iMDhiLTI0MjgwZmQ5OWJkOSI=",
      "executionStartToCloseTimeoutSeconds":30,
      "taskStartToCloseTimeoutSeconds":5,
      "originalExecutionRunId":"ed36bf23-0d59-4852-842b-a2ad9609fa21",
      "identity":"",
      "firstExecutionRunId":"ed36bf23-0d59-4852-842b-a2ad9609fa21",
      "attempt":0,
      "firstDecisionTaskBackoffSeconds":0
    }
  },
  {
    "eventId":2,
    "timestamp":1599168190229928000,
    "eventType":"DecisionTaskScheduled",
    "version":-24,
    "taskId":10485921,
    "decisionTaskScheduledEventAttributes":{
      "taskList":{
        "name":"WorkflowTest-testGetVersionAdded[Docker Sticky ON]-fdfe366b-fc85-48da-b08b-24280fd99bd9"
      },
      "startToCloseTimeoutSeconds":5,
      "attempt":0
    }
  },
  {
    "eventId":3,
    "timestamp":1599168190248954000,
    "eventType":"DecisionTaskStarted",
    "version":-24,
    "taskId":10485926,
    "decisionTaskStartedEventAttributes":{
      "scheduledEventId":2,
      "identity":"11972@boweixu-C02V61JZHTDG",
      "requestId":"843c8c94-5499-43c7-8f76-e9ef7350cd6a"
    }
  },
  {
    "eventId":4,
    "timestamp":1599168190499844000,
    "eventType":"DecisionTaskCompleted",
    "version":-24,
    "taskId":10485929,
    "decisionTaskCompletedEventAttributes":{
      "scheduledEventId":2,
      "startedEventId":3,
      "identity":"11972@boweixu-C02V61JZHTDG"
    }
  },
  {
    "eventId":5,
    "timestamp":1599168190499866000,
    "eventType":"MarkerRecorded",
    "version":-24,
    "taskId":10485930,
    "markerRecordedEventAttributes":{
      "markerName":"Version",
      "details":"MQ==",
      "decisionTaskCompletedEventId":4,
      "header":{
        "fields":{
          "MutableMarkerHeader":"eyJpZCI6ImNpZDEiLCJldmVudElkIjo1LCJhY2Nlc3NDb3VudCI6MH0="
        }
      }
    }
  },
  {
    "eventId":6,
    "timestamp":1599168190499878000,
    "eventType":"WorkflowExecutionCompleted",
    "version":-24,
    "taskId":10485931,
    "workflowExecutionCompletedEventAttributes":{
      "result":"ImhlbGxvIg==",
      "decisionTaskCompletedEventId":4
    }
  }
]

Expect follow code to fail, but it pass

@Test
  public void testGetVersionAdded() {
    try {
      WorkflowReplayer.replayWorkflowExecutionFromResource(
          "testGetVersionAdded.json", TestGetVersionAddedImpl.class);
    } catch (Exception e) {
      e.printStackTrace();
      fail();
    }
  }

vancexu avatar Sep 11 '20 18:09 vancexu