Skip to content

Commit 461f119

Browse files
authored
Add Replay test (#31)
1 parent fe2c19d commit 461f119

File tree

2 files changed

+196
-0
lines changed

2 files changed

+196
-0
lines changed
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
/*
2+
* Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
3+
*
4+
* Modifications copyright (C) 2017 Uber Technologies, Inc.
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License"). You may not
7+
* use this file except in compliance with the License. A copy of the License is
8+
* located at
9+
*
10+
* http://aws.amazon.com/apache2.0
11+
*
12+
* or in the "license" file accompanying this file. This file is distributed on
13+
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
14+
* express or implied. See the License for the specific language governing
15+
* permissions and limitations under the License.
16+
*/
17+
18+
package com.uber.cadence.samples.hello;
19+
20+
import com.uber.cadence.testing.WorkflowReplayer;
21+
import org.junit.Test;
22+
23+
// This replay test is the recommended way to make sure changing workflow code is backward
24+
// compatible without non-deterministic errors.
25+
// "HelloActivity.json" can be downloaded from cadence CLI:
26+
// cadence --do samples-domain wf show -w helloworld_d002cd3a-aeee-4a11-aa30-1c62385b4d87
27+
// --output_filename ~/tmp/HelloActivity.json
28+
// Or from Cadence Web UI. (You may need to put history file in resources folder; and change
29+
// workflowType in the first event of history).
30+
public class HelloActivityReplayTest {
31+
@Test
32+
public void testReplay() throws Exception {
33+
WorkflowReplayer.replayWorkflowExecutionFromResource(
34+
"HelloActivity.json", HelloActivity.GreetingWorkflowImpl.class);
35+
}
36+
}

src/test/resources/HelloActivity.json

Lines changed: 160 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,160 @@
1+
[
2+
{
3+
"eventId":1,
4+
"timestamp":1583541984904345000,
5+
"eventType":"WorkflowExecutionStarted",
6+
"version":-24,
7+
"taskId":2097355,
8+
"workflowExecutionStartedEventAttributes":{
9+
"workflowType":{
10+
"name":"GreetingWorkflow::getGreeting"
11+
},
12+
"taskList":{
13+
"name":"HelloActivity"
14+
},
15+
"input":"IldvcmxkIg==",
16+
"executionStartToCloseTimeoutSeconds":10,
17+
"taskStartToCloseTimeoutSeconds":10,
18+
"originalExecutionRunId":"85bbaa12-e001-48ca-82f2-b85b52191c83",
19+
"identity":"",
20+
"firstExecutionRunId":"85bbaa12-e001-48ca-82f2-b85b52191c83",
21+
"attempt":0,
22+
"firstDecisionTaskBackoffSeconds":0
23+
}
24+
},
25+
{
26+
"eventId":2,
27+
"timestamp":1583541984904358000,
28+
"eventType":"DecisionTaskScheduled",
29+
"version":-24,
30+
"taskId":2097356,
31+
"decisionTaskScheduledEventAttributes":{
32+
"taskList":{
33+
"name":"HelloActivity"
34+
},
35+
"startToCloseTimeoutSeconds":10,
36+
"attempt":0
37+
}
38+
},
39+
{
40+
"eventId":3,
41+
"timestamp":1583541984915114000,
42+
"eventType":"DecisionTaskStarted",
43+
"version":-24,
44+
"taskId":2097361,
45+
"decisionTaskStartedEventAttributes":{
46+
"scheduledEventId":2,
47+
"identity":"57055@boweixu-C02V61JZHTDG",
48+
"requestId":"61ea6a38-cd58-4cd7-bede-71cf905c88ec"
49+
}
50+
},
51+
{
52+
"eventId":4,
53+
"timestamp":1583541985053488000,
54+
"eventType":"DecisionTaskCompleted",
55+
"version":-24,
56+
"taskId":2097364,
57+
"decisionTaskCompletedEventAttributes":{
58+
"scheduledEventId":2,
59+
"startedEventId":3,
60+
"identity":"57055@boweixu-C02V61JZHTDG"
61+
}
62+
},
63+
{
64+
"eventId":5,
65+
"timestamp":1583541985053516000,
66+
"eventType":"ActivityTaskScheduled",
67+
"version":-24,
68+
"taskId":2097365,
69+
"activityTaskScheduledEventAttributes":{
70+
"activityId":"0",
71+
"activityType":{
72+
"name":"GreetingActivities::composeGreeting"
73+
},
74+
"taskList":{
75+
"name":"HelloActivity"
76+
},
77+
"input":"WyJIZWxsbyIsIldvcmxkIl0=",
78+
"scheduleToCloseTimeoutSeconds":2,
79+
"scheduleToStartTimeoutSeconds":2,
80+
"startToCloseTimeoutSeconds":2,
81+
"heartbeatTimeoutSeconds":2,
82+
"decisionTaskCompletedEventId":4
83+
}
84+
},
85+
{
86+
"eventId":6,
87+
"timestamp":1583541985058429000,
88+
"eventType":"ActivityTaskStarted",
89+
"version":-24,
90+
"taskId":2097369,
91+
"activityTaskStartedEventAttributes":{
92+
"scheduledEventId":5,
93+
"identity":"57055@boweixu-C02V61JZHTDG",
94+
"requestId":"41f9bffa-2236-489a-8169-e347114f9d0e",
95+
"attempt":0
96+
}
97+
},
98+
{
99+
"eventId":7,
100+
"timestamp":1583541985078449000,
101+
"eventType":"ActivityTaskCompleted",
102+
"version":-24,
103+
"taskId":2097372,
104+
"activityTaskCompletedEventAttributes":{
105+
"result":"IkhlbGxvIFdvcmxkISI=",
106+
"scheduledEventId":5,
107+
"startedEventId":6,
108+
"identity":"57055@boweixu-C02V61JZHTDG"
109+
}
110+
},
111+
{
112+
"eventId":8,
113+
"timestamp":1583541985078458000,
114+
"eventType":"DecisionTaskScheduled",
115+
"version":-24,
116+
"taskId":2097374,
117+
"decisionTaskScheduledEventAttributes":{
118+
"taskList":{
119+
"name":"boweixu-C02V61JZHTDG:3ee5a654-96e8-4183-bb5d-ddf838095d51"
120+
},
121+
"startToCloseTimeoutSeconds":10,
122+
"attempt":0
123+
}
124+
},
125+
{
126+
"eventId":9,
127+
"timestamp":1583541985082616000,
128+
"eventType":"DecisionTaskStarted",
129+
"version":-24,
130+
"taskId":2097378,
131+
"decisionTaskStartedEventAttributes":{
132+
"scheduledEventId":8,
133+
"identity":"3ee5a654-96e8-4183-bb5d-ddf838095d51",
134+
"requestId":"ff427594-c6ad-4623-a599-9c83f5179e77"
135+
}
136+
},
137+
{
138+
"eventId":10,
139+
"timestamp":1583541985100050000,
140+
"eventType":"DecisionTaskCompleted",
141+
"version":-24,
142+
"taskId":2097381,
143+
"decisionTaskCompletedEventAttributes":{
144+
"scheduledEventId":8,
145+
"startedEventId":9,
146+
"identity":"57055@boweixu-C02V61JZHTDG"
147+
}
148+
},
149+
{
150+
"eventId":11,
151+
"timestamp":1583541985100064000,
152+
"eventType":"WorkflowExecutionCompleted",
153+
"version":-24,
154+
"taskId":2097382,
155+
"workflowExecutionCompletedEventAttributes":{
156+
"result":"IkhlbGxvIFdvcmxkISI=",
157+
"decisionTaskCompletedEventId":10
158+
}
159+
}
160+
]

0 commit comments

Comments
 (0)