30
30
import com .uber .cadence .migration .MigrationActivitiesImpl ;
31
31
import com .uber .cadence .migration .MigrationIWorkflowService ;
32
32
import com .uber .cadence .migration .MigrationInterceptorFactory ;
33
- import com .uber .cadence .serviceclient .ClientOptions ;
34
33
import com .uber .cadence .serviceclient .IWorkflowService ;
35
- import com .uber .cadence .serviceclient . WorkflowServiceTChannel ;
34
+ import com .uber .cadence .testUtils . CadenceTestRule ;
36
35
import com .uber .cadence .worker .Worker ;
37
36
import com .uber .cadence .worker .WorkerFactory ;
38
37
import com .uber .cadence .worker .WorkerFactoryOptions ;
41
40
import java .util .UUID ;
42
41
import java .util .concurrent .CancellationException ;
43
42
import org .apache .thrift .TException ;
44
- import org .junit .After ;
45
- import org .junit .Assume ;
46
- import org .junit .Before ;
47
- import org .junit .Test ;
43
+ import org .junit .*;
48
44
49
45
public class WorkflowMigrationTest {
50
46
private WorkflowClient migrationWorkflowClient , workflowClientCurr , workflowClientNew ;
51
- private boolean useDockerService = Boolean .parseBoolean (System .getenv ("USE_DOCKER_SERVICE" ));
52
47
private static final String TASKLIST = "TASKLIST" ;
53
48
private TracingWorkflowInterceptorFactory tracer ;
54
49
WorkerFactory factoryCurr , factoryNew ;
55
50
Worker workerCurr , workerNew ;
56
51
52
+ @ Rule public CadenceTestRule testRuleCur = CadenceTestRule .builder ().withDomain (DOMAIN ).build ();
53
+
54
+ @ Rule public CadenceTestRule testRuleNew = CadenceTestRule .builder ().withDomain (DOMAIN2 ).build ();
55
+
57
56
@ Before
58
57
public void setUp () {
59
- IWorkflowService service =
60
- new WorkflowServiceTChannel (
61
- ClientOptions .newBuilder ()
62
- .setFeatureFlags (
63
- new FeatureFlags ().setWorkflowExecutionAlreadyCompletedErrorEnabled (true ))
64
- .build ());
58
+ IWorkflowService serviceCur = testRuleCur .getWorkflowClient ().getService ();
59
+ IWorkflowService serviceNew = testRuleNew .getWorkflowClient ().getService ();
65
60
workflowClientCurr =
66
61
WorkflowClient .newInstance (
67
- service , WorkflowClientOptions .newBuilder ().setDomain (DOMAIN ).build ());
62
+ serviceCur , WorkflowClientOptions .newBuilder ().setDomain (DOMAIN ).build ());
68
63
workflowClientNew =
69
64
WorkflowClient .newInstance (
70
- service , WorkflowClientOptions .newBuilder ().setDomain (DOMAIN2 ).build ());
65
+ serviceNew , WorkflowClientOptions .newBuilder ().setDomain (DOMAIN2 ).build ());
71
66
MigrationIWorkflowService migrationService =
72
67
new MigrationIWorkflowService (
73
- service , DOMAIN ,
74
- service , DOMAIN2 );
68
+ serviceCur , DOMAIN ,
69
+ serviceNew , DOMAIN2 );
75
70
migrationWorkflowClient =
76
71
WorkflowClient .newInstance (
77
72
migrationService , WorkflowClientOptions .newBuilder ().setDomain (DOMAIN ).build ());
@@ -154,8 +149,7 @@ public void execute(int iter) {
154
149
}
155
150
156
151
@ Test
157
- public void whenUseDockerService_cronWorkflowMigration () {
158
- Assume .assumeTrue (useDockerService );
152
+ public void cronWorkflowMigration () {
159
153
String workflowID = UUID .randomUUID ().toString ();
160
154
try {
161
155
workflowClientCurr
@@ -164,16 +158,15 @@ public void whenUseDockerService_cronWorkflowMigration() {
164
158
.execute ("for test" );
165
159
} catch (CancellationException e ) {
166
160
try {
167
- describeWorkflowExecution (workflowClientNew , workflowID );
161
+ getWorkflowHistory (workflowClientNew , workflowID );
168
162
} catch (Exception eDesc ) {
169
163
fail ("fail to describe workflow execution in new domain: " + eDesc );
170
164
}
171
165
}
172
166
}
173
167
174
168
@ Test
175
- public void whenUseDockerService_continueAsNewWorkflowMigration () {
176
- Assume .assumeTrue (useDockerService );
169
+ public void continueAsNewWorkflowMigration () {
177
170
String workflowID = UUID .randomUUID ().toString ();
178
171
try {
179
172
workflowClientCurr
@@ -183,18 +176,18 @@ public void whenUseDockerService_continueAsNewWorkflowMigration() {
183
176
.execute (0 );
184
177
} catch (CancellationException e ) {
185
178
try {
186
- describeWorkflowExecution (workflowClientNew , workflowID );
179
+ getWorkflowHistory (workflowClientNew , workflowID );
187
180
} catch (Exception eDesc ) {
188
181
fail ("fail to describe workflow execution in new domain: " + eDesc );
189
182
}
190
183
}
191
184
}
192
185
193
- private DescribeWorkflowExecutionResponse describeWorkflowExecution (
186
+ private GetWorkflowExecutionHistoryResponse getWorkflowHistory (
194
187
WorkflowClient wc , String workflowID ) throws TException {
195
188
return wc .getService ()
196
- .DescribeWorkflowExecution (
197
- new DescribeWorkflowExecutionRequest ()
189
+ .GetWorkflowExecutionHistory (
190
+ new GetWorkflowExecutionHistoryRequest ()
198
191
.setExecution (new WorkflowExecution ().setWorkflowId (workflowID ))
199
192
.setDomain (wc .getOptions ().getDomain ()));
200
193
}
0 commit comments