@@ -1010,49 +1010,41 @@ func (s *workflowRunSuite) TestExecuteWorkflowWithUpdate_Retry() {
1010
1010
},
1011
1011
}, nil )
1012
1012
1013
- updOp := NewUpdateWithStartWorkflowOperation (
1014
- UpdateWorkflowOptions {
1015
- UpdateName : "update" ,
1016
- WaitForStage : WorkflowUpdateStageCompleted ,
1017
- })
1018
-
1019
- _ , err := s .workflowClient .ExecuteWorkflow (
1020
- context .Background (),
1013
+ startOp := s .workflowClient .NewWithStartWorkflowOperation (
1021
1014
StartWorkflowOptions {
1022
- ID : workflowID ,
1023
- TaskQueue : taskqueue ,
1024
- WithStartOperation : updOp ,
1015
+ ID : workflowID ,
1016
+ WorkflowIDConflictPolicy : enumspb . WORKFLOW_ID_CONFLICT_POLICY_FAIL ,
1017
+ TaskQueue : taskqueue ,
1025
1018
}, workflowType ,
1026
1019
)
1020
+
1021
+ _ , err := s .workflowClient .UpdateWithStartWorkflow (
1022
+ context .Background (),
1023
+ UpdateWithStartWorkflowOptions {
1024
+ UpdateOptions : UpdateWorkflowOptions {
1025
+ UpdateName : "update" ,
1026
+ WaitForStage : WorkflowUpdateStageCompleted ,
1027
+ },
1028
+ StartWorkflowOperation : startOp ,
1029
+ },
1030
+ )
1027
1031
s .NoError (err )
1028
1032
}
1029
1033
1030
1034
func (s * workflowRunSuite ) TestExecuteWorkflowWithUpdate_OperationNotExecuted () {
1031
- s .workflowServiceClient .EXPECT ().StartWorkflowExecution (gomock .Any (), gomock .Any (), gomock .Any ()).
1032
- Return (& workflowservice.StartWorkflowExecutionResponse {
1033
- RunId : runID ,
1034
- }, nil )
1035
-
1036
- updOp := NewUpdateWithStartWorkflowOperation (
1037
- UpdateWorkflowOptions {
1038
- UpdateName : "update" ,
1039
- WaitForStage : WorkflowUpdateStageCompleted ,
1040
- })
1041
-
1042
- ctxWithTimeout , cancel := context .WithTimeout (context .Background (), 500 * time .Millisecond )
1043
- defer cancel ()
1044
1035
1045
- _ , err := s .workflowClient .ExecuteWorkflow (
1046
- ctxWithTimeout ,
1036
+ startOp := s .workflowClient .NewWithStartWorkflowOperation (
1047
1037
StartWorkflowOptions {
1048
- ID : workflowID ,
1049
- TaskQueue : taskqueue ,
1050
- // WithStartOperation is not specified!
1038
+ ID : workflowID ,
1039
+ WorkflowIDConflictPolicy : enumspb . WORKFLOW_ID_CONFLICT_POLICY_FAIL ,
1040
+ TaskQueue : taskqueue ,
1051
1041
}, workflowType ,
1052
1042
)
1053
- require .NoError (s .T (), err )
1054
1043
1055
- _ , err = updOp .Get (ctxWithTimeout )
1044
+ ctxWithTimeout , cancel := context .WithTimeout (context .Background (), 500 * time .Millisecond )
1045
+ defer cancel ()
1046
+
1047
+ _ , err := startOp .Get (ctxWithTimeout )
1056
1048
require .EqualError (s .T (), err , "context deadline exceeded: operation was not executed" )
1057
1049
}
1058
1050
@@ -1092,22 +1084,26 @@ func (s *workflowRunSuite) TestExecuteWorkflowWithUpdate_Abort() {
1092
1084
ExecuteMultiOperation (gomock .Any (), gomock .Any (), gomock .Any ()).
1093
1085
DoAndReturn (tt .respFunc )
1094
1086
1095
- updOp := NewUpdateWithStartWorkflowOperation (
1096
- UpdateWorkflowOptions {
1097
- UpdateName : "update" ,
1098
- WaitForStage : WorkflowUpdateStageCompleted ,
1099
- })
1087
+ startOp := s .workflowClient .NewWithStartWorkflowOperation (
1088
+ StartWorkflowOptions {
1089
+ ID : workflowID ,
1090
+ WorkflowIDConflictPolicy : enumspb .WORKFLOW_ID_CONFLICT_POLICY_FAIL ,
1091
+ TaskQueue : taskqueue ,
1092
+ }, workflowType ,
1093
+ )
1100
1094
1101
1095
ctxWithTimeout , cancel := context .WithTimeout (context .Background (), 100 * time .Millisecond )
1102
1096
defer cancel ()
1103
1097
1104
- _ , err := s .workflowClient .ExecuteWorkflow (
1098
+ _ , err := s .workflowClient .UpdateWithStartWorkflow (
1105
1099
ctxWithTimeout ,
1106
- StartWorkflowOptions {
1107
- ID : workflowID ,
1108
- TaskQueue : taskqueue ,
1109
- WithStartOperation : updOp ,
1110
- }, workflowType ,
1100
+ UpdateWithStartWorkflowOptions {
1101
+ UpdateOptions : UpdateWorkflowOptions {
1102
+ UpdateName : "update" ,
1103
+ WaitForStage : WorkflowUpdateStageCompleted ,
1104
+ },
1105
+ StartWorkflowOperation : startOp ,
1106
+ },
1111
1107
)
1112
1108
1113
1109
var expectedErr * WorkflowUpdateServiceTimeoutOrCanceledError
@@ -1122,20 +1118,24 @@ func (s *workflowRunSuite) TestExecuteWorkflowWithUpdate_NonMultiOperationError(
1122
1118
ExecuteMultiOperation (gomock .Any (), gomock .Any (), gomock .Any ()).
1123
1119
Return (nil , serviceerror .NewInternal ("internal error" )).Times (1 )
1124
1120
1125
- updOp := NewUpdateWithStartWorkflowOperation (
1126
- UpdateWorkflowOptions {
1127
- UpdateName : "update" ,
1128
- WaitForStage : WorkflowUpdateStageCompleted ,
1129
- })
1130
-
1131
- _ , err := s .workflowClient .ExecuteWorkflow (
1132
- context .Background (),
1121
+ startOp := s .workflowClient .NewWithStartWorkflowOperation (
1133
1122
StartWorkflowOptions {
1134
- ID : workflowID ,
1135
- TaskQueue : taskqueue ,
1136
- WithStartOperation : updOp ,
1123
+ ID : workflowID ,
1124
+ WorkflowIDConflictPolicy : enumspb . WORKFLOW_ID_CONFLICT_POLICY_FAIL ,
1125
+ TaskQueue : taskqueue ,
1137
1126
}, workflowType ,
1138
1127
)
1128
+
1129
+ _ , err := s .workflowClient .UpdateWithStartWorkflow (
1130
+ context .Background (),
1131
+ UpdateWithStartWorkflowOptions {
1132
+ UpdateOptions : UpdateWorkflowOptions {
1133
+ UpdateName : "update" ,
1134
+ WaitForStage : WorkflowUpdateStageCompleted ,
1135
+ },
1136
+ StartWorkflowOperation : startOp ,
1137
+ },
1138
+ )
1139
1139
s .ErrorContains (err , "internal error" )
1140
1140
}
1141
1141
@@ -1146,20 +1146,24 @@ func (s *workflowRunSuite) TestExecuteWorkflowWithUpdate_ServerResponseCountMism
1146
1146
Responses : []* workflowservice.ExecuteMultiOperationResponse_Response {},
1147
1147
}, nil ).Times (1 )
1148
1148
1149
- updOp := NewUpdateWithStartWorkflowOperation (
1150
- UpdateWorkflowOptions {
1151
- UpdateName : "update" ,
1152
- WaitForStage : WorkflowUpdateStageCompleted ,
1153
- })
1154
-
1155
- _ , err := s .workflowClient .ExecuteWorkflow (
1156
- context .Background (),
1149
+ startOp := s .workflowClient .NewWithStartWorkflowOperation (
1157
1150
StartWorkflowOptions {
1158
- ID : workflowID ,
1159
- TaskQueue : taskqueue ,
1160
- WithStartOperation : updOp ,
1151
+ ID : workflowID ,
1152
+ WorkflowIDConflictPolicy : enumspb . WORKFLOW_ID_CONFLICT_POLICY_FAIL ,
1153
+ TaskQueue : taskqueue ,
1161
1154
}, workflowType ,
1162
1155
)
1156
+
1157
+ _ , err := s .workflowClient .UpdateWithStartWorkflow (
1158
+ context .Background (),
1159
+ UpdateWithStartWorkflowOptions {
1160
+ UpdateOptions : UpdateWorkflowOptions {
1161
+ UpdateName : "update" ,
1162
+ WaitForStage : WorkflowUpdateStageCompleted ,
1163
+ },
1164
+ StartWorkflowOperation : startOp ,
1165
+ },
1166
+ )
1163
1167
s .ErrorContains (err , "invalid server response: 0 instead of 2 operation results" )
1164
1168
}
1165
1169
@@ -1168,20 +1172,24 @@ func (s *workflowRunSuite) TestExecuteWorkflowWithUpdate_ServerErrorResponseCoun
1168
1172
ExecuteMultiOperation (gomock .Any (), gomock .Any (), gomock .Any ()).
1169
1173
Return (nil , serviceerror .NewMultiOperationExecution ("Error" , []error {})).Times (1 )
1170
1174
1171
- updOp := NewUpdateWithStartWorkflowOperation (
1172
- UpdateWorkflowOptions {
1173
- UpdateName : "update" ,
1174
- WaitForStage : WorkflowUpdateStageCompleted ,
1175
- })
1176
-
1177
- _ , err := s .workflowClient .ExecuteWorkflow (
1178
- context .Background (),
1175
+ startOp := s .workflowClient .NewWithStartWorkflowOperation (
1179
1176
StartWorkflowOptions {
1180
- ID : workflowID ,
1181
- TaskQueue : taskqueue ,
1182
- WithStartOperation : updOp ,
1177
+ ID : workflowID ,
1178
+ WorkflowIDConflictPolicy : enumspb . WORKFLOW_ID_CONFLICT_POLICY_FAIL ,
1179
+ TaskQueue : taskqueue ,
1183
1180
}, workflowType ,
1184
1181
)
1182
+
1183
+ _ , err := s .workflowClient .UpdateWithStartWorkflow (
1184
+ context .Background (),
1185
+ UpdateWithStartWorkflowOptions {
1186
+ UpdateOptions : UpdateWorkflowOptions {
1187
+ UpdateName : "update" ,
1188
+ WaitForStage : WorkflowUpdateStageCompleted ,
1189
+ },
1190
+ StartWorkflowOperation : startOp ,
1191
+ },
1192
+ )
1185
1193
s .ErrorContains (err , "invalid server response: 0 instead of 2 operation errors" )
1186
1194
}
1187
1195
@@ -1197,20 +1205,24 @@ func (s *workflowRunSuite) TestExecuteWorkflowWithUpdate_ServerStartResponseType
1197
1205
},
1198
1206
}, nil ).Times (1 )
1199
1207
1200
- updOp := NewUpdateWithStartWorkflowOperation (
1201
- UpdateWorkflowOptions {
1202
- UpdateName : "update" ,
1203
- WaitForStage : WorkflowUpdateStageCompleted ,
1204
- })
1205
-
1206
- _ , err := s .workflowClient .ExecuteWorkflow (
1207
- context .Background (),
1208
+ startOp := s .workflowClient .NewWithStartWorkflowOperation (
1208
1209
StartWorkflowOptions {
1209
- ID : workflowID ,
1210
- TaskQueue : taskqueue ,
1211
- WithStartOperation : updOp ,
1210
+ ID : workflowID ,
1211
+ WorkflowIDConflictPolicy : enumspb . WORKFLOW_ID_CONFLICT_POLICY_FAIL ,
1212
+ TaskQueue : taskqueue ,
1212
1213
}, workflowType ,
1213
1214
)
1215
+
1216
+ _ , err := s .workflowClient .UpdateWithStartWorkflow (
1217
+ context .Background (),
1218
+ UpdateWithStartWorkflowOptions {
1219
+ UpdateOptions : UpdateWorkflowOptions {
1220
+ UpdateName : "update" ,
1221
+ WaitForStage : WorkflowUpdateStageCompleted ,
1222
+ },
1223
+ StartWorkflowOperation : startOp ,
1224
+ },
1225
+ )
1214
1226
s .ErrorContains (err , "invalid server response: StartWorkflow response has the wrong type *workflowservice.ExecuteMultiOperationResponse_Response_UpdateWorkflow" )
1215
1227
}
1216
1228
@@ -1220,28 +1232,36 @@ func (s *workflowRunSuite) TestExecuteWorkflowWithUpdate_ServerUpdateResponseTyp
1220
1232
Return (& workflowservice.ExecuteMultiOperationResponse {
1221
1233
Responses : []* workflowservice.ExecuteMultiOperationResponse_Response {
1222
1234
{
1223
- Response : & workflowservice.ExecuteMultiOperationResponse_Response_StartWorkflow {},
1235
+ Response : & workflowservice.ExecuteMultiOperationResponse_Response_StartWorkflow {
1236
+ StartWorkflow : & workflowservice.StartWorkflowExecutionResponse {
1237
+ RunId : "RUN_ID" ,
1238
+ },
1239
+ },
1224
1240
},
1225
1241
{
1226
1242
Response : & workflowservice.ExecuteMultiOperationResponse_Response_StartWorkflow {}, // wrong!
1227
1243
},
1228
1244
},
1229
1245
}, nil ).Times (1 )
1230
1246
1231
- updOp := NewUpdateWithStartWorkflowOperation (
1232
- UpdateWorkflowOptions {
1233
- UpdateName : "update" ,
1234
- WaitForStage : WorkflowUpdateStageCompleted ,
1235
- })
1236
-
1237
- _ , err := s .workflowClient .ExecuteWorkflow (
1238
- context .Background (),
1247
+ startOp := s .workflowClient .NewWithStartWorkflowOperation (
1239
1248
StartWorkflowOptions {
1240
- ID : workflowID ,
1241
- TaskQueue : taskqueue ,
1242
- WithStartOperation : updOp ,
1249
+ ID : workflowID ,
1250
+ WorkflowIDConflictPolicy : enumspb . WORKFLOW_ID_CONFLICT_POLICY_FAIL ,
1251
+ TaskQueue : taskqueue ,
1243
1252
}, workflowType ,
1244
1253
)
1254
+
1255
+ _ , err := s .workflowClient .UpdateWithStartWorkflow (
1256
+ context .Background (),
1257
+ UpdateWithStartWorkflowOptions {
1258
+ UpdateOptions : UpdateWorkflowOptions {
1259
+ UpdateName : "update" ,
1260
+ WaitForStage : WorkflowUpdateStageCompleted ,
1261
+ },
1262
+ StartWorkflowOperation : startOp ,
1263
+ },
1264
+ )
1245
1265
s .ErrorContains (err , "invalid server response: UpdateWorkflow response has the wrong type *workflowservice.ExecuteMultiOperationResponse_Response_StartWorkflow" )
1246
1266
}
1247
1267
@@ -1358,15 +1378,6 @@ func (s *workflowClientTestSuite) TestSignalWithStartWorkflowValidation() {
1358
1378
context .Background (), "workflow-id-1" , "my-signal" , "my-signal-value" ,
1359
1379
StartWorkflowOptions {ID : "workflow-id-2" }, workflowType )
1360
1380
s .ErrorContains (err , "workflow ID from options not used" )
1361
-
1362
- // unsupported WithStartOperation
1363
- _ , err = s .client .SignalWithStartWorkflow (
1364
- context .Background (), "workflow-id" , "my-signal" , "my-signal-value" ,
1365
- StartWorkflowOptions {
1366
- ID : "workflow-id" ,
1367
- WithStartOperation : & UpdateWithStartWorkflowOperation {},
1368
- }, workflowType )
1369
- s .ErrorContains (err , "option WithStartOperation is not allowed" )
1370
1381
}
1371
1382
1372
1383
func (s * workflowClientTestSuite ) TestStartWorkflow () {
0 commit comments