3030import com .uber .cadence .migration .MigrationActivitiesImpl ;
3131import com .uber .cadence .migration .MigrationIWorkflowService ;
3232import com .uber .cadence .migration .MigrationInterceptorFactory ;
33- import com .uber .cadence .serviceclient .ClientOptions ;
3433import com .uber .cadence .serviceclient .IWorkflowService ;
35- import com .uber .cadence .serviceclient . WorkflowServiceTChannel ;
34+ import com .uber .cadence .testUtils . CadenceTestRule ;
3635import com .uber .cadence .worker .Worker ;
3736import com .uber .cadence .worker .WorkerFactory ;
3837import com .uber .cadence .worker .WorkerFactoryOptions ;
4140import java .util .UUID ;
4241import java .util .concurrent .CancellationException ;
4342import 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 .*;
4844
4945public class WorkflowMigrationTest {
5046 private WorkflowClient migrationWorkflowClient , workflowClientCurr , workflowClientNew ;
51- private boolean useDockerService = Boolean .parseBoolean (System .getenv ("USE_DOCKER_SERVICE" ));
5247 private static final String TASKLIST = "TASKLIST" ;
5348 private TracingWorkflowInterceptorFactory tracer ;
5449 WorkerFactory factoryCurr , factoryNew ;
5550 Worker workerCurr , workerNew ;
5651
52+ @ Rule public CadenceTestRule testRuleCur = CadenceTestRule .builder ().withDomain (DOMAIN ).build ();
53+
54+ @ Rule public CadenceTestRule testRuleNew = CadenceTestRule .builder ().withDomain (DOMAIN2 ).build ();
55+
5756 @ Before
5857 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 ();
6560 workflowClientCurr =
6661 WorkflowClient .newInstance (
67- service , WorkflowClientOptions .newBuilder ().setDomain (DOMAIN ).build ());
62+ serviceCur , WorkflowClientOptions .newBuilder ().setDomain (DOMAIN ).build ());
6863 workflowClientNew =
6964 WorkflowClient .newInstance (
70- service , WorkflowClientOptions .newBuilder ().setDomain (DOMAIN2 ).build ());
65+ serviceNew , WorkflowClientOptions .newBuilder ().setDomain (DOMAIN2 ).build ());
7166 MigrationIWorkflowService migrationService =
7267 new MigrationIWorkflowService (
73- service , DOMAIN ,
74- service , DOMAIN2 );
68+ serviceCur , DOMAIN ,
69+ serviceNew , DOMAIN2 );
7570 migrationWorkflowClient =
7671 WorkflowClient .newInstance (
7772 migrationService , WorkflowClientOptions .newBuilder ().setDomain (DOMAIN ).build ());
@@ -154,8 +149,7 @@ public void execute(int iter) {
154149 }
155150
156151 @ Test
157- public void whenUseDockerService_cronWorkflowMigration () {
158- Assume .assumeTrue (useDockerService );
152+ public void cronWorkflowMigration () {
159153 String workflowID = UUID .randomUUID ().toString ();
160154 try {
161155 workflowClientCurr
@@ -164,16 +158,15 @@ public void whenUseDockerService_cronWorkflowMigration() {
164158 .execute ("for test" );
165159 } catch (CancellationException e ) {
166160 try {
167- describeWorkflowExecution (workflowClientNew , workflowID );
161+ getWorkflowHistory (workflowClientNew , workflowID );
168162 } catch (Exception eDesc ) {
169163 fail ("fail to describe workflow execution in new domain: " + eDesc );
170164 }
171165 }
172166 }
173167
174168 @ Test
175- public void whenUseDockerService_continueAsNewWorkflowMigration () {
176- Assume .assumeTrue (useDockerService );
169+ public void continueAsNewWorkflowMigration () {
177170 String workflowID = UUID .randomUUID ().toString ();
178171 try {
179172 workflowClientCurr
@@ -183,18 +176,18 @@ public void whenUseDockerService_continueAsNewWorkflowMigration() {
183176 .execute (0 );
184177 } catch (CancellationException e ) {
185178 try {
186- describeWorkflowExecution (workflowClientNew , workflowID );
179+ getWorkflowHistory (workflowClientNew , workflowID );
187180 } catch (Exception eDesc ) {
188181 fail ("fail to describe workflow execution in new domain: " + eDesc );
189182 }
190183 }
191184 }
192185
193- private DescribeWorkflowExecutionResponse describeWorkflowExecution (
186+ private GetWorkflowExecutionHistoryResponse getWorkflowHistory (
194187 WorkflowClient wc , String workflowID ) throws TException {
195188 return wc .getService ()
196- .DescribeWorkflowExecution (
197- new DescribeWorkflowExecutionRequest ()
189+ .GetWorkflowExecutionHistory (
190+ new GetWorkflowExecutionHistoryRequest ()
198191 .setExecution (new WorkflowExecution ().setWorkflowId (workflowID ))
199192 .setDomain (wc .getOptions ().getDomain ()));
200193 }
0 commit comments