Skip to content

Commit 313a1c1

Browse files
committed
Fix Domain GRPC->Thrift mapping and increase test coverage
1 parent 9746755 commit 313a1c1

File tree

4 files changed

+712
-95
lines changed

4 files changed

+712
-95
lines changed

src/main/java/com/uber/cadence/internal/compatibility/thrift/TypeMapper.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -500,7 +500,9 @@ static DescribeDomainResponse describeDomainResponseDomain(com.uber.cadence.api.
500500
domainInfo.setOwnerEmail(t.getOwnerEmail());
501501
domainInfo.setData(t.getDataMap());
502502
domainInfo.setUuid(t.getId());
503+
503504
DomainConfiguration domainConfiguration = new DomainConfiguration();
505+
res.setConfiguration(domainConfiguration);
504506

505507
domainConfiguration.setWorkflowExecutionRetentionPeriodInDays(
506508
durationToDays(t.getWorkflowExecutionRetentionPeriod()));
@@ -511,8 +513,10 @@ static DescribeDomainResponse describeDomainResponseDomain(com.uber.cadence.api.
511513
domainConfiguration.setVisibilityArchivalStatus(
512514
archivalStatus(t.getVisibilityArchivalStatus()));
513515
domainConfiguration.setVisibilityArchivalURI(t.getVisibilityArchivalUri());
516+
514517
DomainReplicationConfiguration domainReplicationConfiguration =
515518
new DomainReplicationConfiguration();
519+
res.setReplicationConfiguration(domainReplicationConfiguration);
516520

517521
domainReplicationConfiguration.setActiveClusterName(t.getActiveClusterName());
518522
domainReplicationConfiguration.setClusters(

src/test/java/com/uber/cadence/internal/compatibility/ProtoObjects.java

Lines changed: 302 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import com.google.protobuf.DoubleValue;
2121
import com.google.protobuf.Duration;
2222
import com.google.protobuf.FieldMask;
23+
import com.google.protobuf.Int64Value;
2324
import com.google.protobuf.Timestamp;
2425
import com.uber.cadence.api.v1.*;
2526
import java.util.Map;
@@ -90,6 +91,143 @@ public final class ProtoObjects {
9091
ResetPoints.newBuilder().addPoints(RESET_POINT_INFO).build();
9192
public static final ClusterReplicationConfiguration CLUSTER_REPLICATION_CONFIGURATION =
9293
ClusterReplicationConfiguration.newBuilder().setClusterName("cluster").build();
94+
public static final PollerInfo POLLER_INFO =
95+
PollerInfo.newBuilder()
96+
.setIdentity("identity")
97+
.setLastAccessTime(timestampNanos(1))
98+
.setRatePerSecond(2.0)
99+
.build();
100+
public static final TaskIDBlock TASK_ID_BLOCK =
101+
TaskIDBlock.newBuilder().setStartId(1).setEndId(2).build();
102+
public static final TaskListStatus TASK_LIST_STATUS =
103+
TaskListStatus.newBuilder()
104+
.setTaskIdBlock(TASK_ID_BLOCK)
105+
.setAckLevel(1)
106+
.setBacklogCountHint(2)
107+
.setReadLevel(3)
108+
.setRatePerSecond(4.0)
109+
.build();
110+
public static final WorkflowExecutionConfiguration WORKFLOW_EXECUTION_CONFIGURATION =
111+
WorkflowExecutionConfiguration.newBuilder()
112+
.setTaskList(TASK_LIST)
113+
.setExecutionStartToCloseTimeout(seconds(1))
114+
.setTaskStartToCloseTimeout(seconds(2))
115+
.build();
116+
public static final WorkflowExecutionInfo WORKFLOW_EXECUTION_INFO =
117+
WorkflowExecutionInfo.newBuilder()
118+
.setWorkflowExecution(WORKFLOW_EXECUTION)
119+
.setType(WORKFLOW_TYPE)
120+
.setStartTime(timestampNanos(1))
121+
.setCloseTime(timestampNanos(2))
122+
.setCloseStatus(WorkflowExecutionCloseStatus.WORKFLOW_EXECUTION_CLOSE_STATUS_FAILED)
123+
.setHistoryLength(3)
124+
.setParentExecutionInfo(
125+
ParentExecutionInfo.newBuilder()
126+
.setDomainId("parentDomainId")
127+
.setWorkflowExecution(PARENT_WORKFLOW_EXECUTION)
128+
.setInitiatedId(1)
129+
.build())
130+
.setExecutionTime(timestampNanos(4))
131+
.setMemo(MEMO)
132+
.setSearchAttributes(SEARCH_ATTRIBUTES)
133+
.setAutoResetPoints(RESET_POINTS)
134+
.setTaskList(TASK_LIST.getName())
135+
.setIsCron(true)
136+
.build();
137+
public static final PendingActivityInfo PENDING_ACTIVITY_INFO =
138+
PendingActivityInfo.newBuilder()
139+
.setActivityId("activityId")
140+
.setActivityType(ACTIVITY_TYPE)
141+
.setState(PendingActivityState.PENDING_ACTIVITY_STATE_STARTED)
142+
.setHeartbeatDetails(payload("heartbeatDetails"))
143+
.setLastHeartbeatTime(timestampNanos(1))
144+
.setLastStartedTime(timestampNanos(2))
145+
.setAttempt(3)
146+
.setMaximumAttempts(4)
147+
.setScheduledTime(timestampNanos(5))
148+
.setExpirationTime(timestampNanos(6))
149+
.setLastWorkerIdentity("lastWorkerIdentity")
150+
.setLastFailure(
151+
Failure.newBuilder()
152+
.setReason("lastFailureReason")
153+
.setDetails(utf8("lastFailureDetails")))
154+
.build();
155+
public static final PendingChildExecutionInfo PENDING_CHILD_EXECUTION_INFO =
156+
PendingChildExecutionInfo.newBuilder()
157+
.setWorkflowExecution(WORKFLOW_EXECUTION)
158+
.setWorkflowTypeName(WORKFLOW_TYPE.getName())
159+
.setInitiatedId(1)
160+
.setParentClosePolicy(ParentClosePolicy.PARENT_CLOSE_POLICY_REQUEST_CANCEL)
161+
.build();
162+
public static final PendingDecisionInfo PENDING_DECISION_INFO =
163+
PendingDecisionInfo.newBuilder()
164+
.setState(PendingDecisionState.PENDING_DECISION_STATE_STARTED)
165+
.setScheduledTime(timestampNanos(1))
166+
.setStartedTime(timestampNanos(2))
167+
.setAttempt(3)
168+
.setOriginalScheduledTime(timestampNanos(4))
169+
.build();
170+
public static final SupportedClientVersions SUPPORTED_CLIENT_VERSIONS =
171+
SupportedClientVersions.newBuilder().setGoSdk("goSdk").setJavaSdk("javaSdk").build();
172+
public static final Map<String, IndexedValueType> INDEXED_VALUES =
173+
ImmutableMap.of(
174+
"STRING",
175+
IndexedValueType.INDEXED_VALUE_TYPE_STRING,
176+
"KEYWORD",
177+
IndexedValueType.INDEXED_VALUE_TYPE_KEYWORD,
178+
"INT",
179+
IndexedValueType.INDEXED_VALUE_TYPE_INT,
180+
"DOUBLE",
181+
IndexedValueType.INDEXED_VALUE_TYPE_DOUBLE,
182+
"BOOL",
183+
IndexedValueType.INDEXED_VALUE_TYPE_BOOL,
184+
"DATETIME",
185+
IndexedValueType.INDEXED_VALUE_TYPE_DATETIME);
186+
public static final DataBlob DATA_BLOB =
187+
DataBlob.newBuilder()
188+
.setData(utf8("data"))
189+
.setEncodingType(EncodingType.ENCODING_TYPE_JSON)
190+
.build();
191+
public static final TaskListPartitionMetadata TASK_LIST_PARTITION_METADATA =
192+
TaskListPartitionMetadata.newBuilder()
193+
.setKey("key")
194+
.setOwnerHostName("ownerHostName")
195+
.build();
196+
public static final ActivityLocalDispatchInfo ACTIVITY_LOCAL_DISPATCH_INFO =
197+
ActivityLocalDispatchInfo.newBuilder()
198+
.setActivityId("activityId")
199+
.setScheduledTime(timestampNanos(1))
200+
.setStartedTime(timestampNanos(2))
201+
.setScheduledTimeOfThisAttempt(timestampNanos(3))
202+
.setTaskToken(utf8("taskToken"))
203+
.build();
204+
public static final Domain DOMAIN =
205+
Domain.newBuilder()
206+
.setId("uuid")
207+
.setName("domain")
208+
.setStatus(DomainStatus.DOMAIN_STATUS_DEPRECATED)
209+
.setDescription("description")
210+
.setOwnerEmail("email")
211+
.putAllData(DATA)
212+
.setWorkflowExecutionRetentionPeriod(days(2))
213+
.setBadBinaries(
214+
BadBinaries.newBuilder()
215+
.putBinaries(
216+
"badBinaryKey",
217+
BadBinaryInfo.newBuilder()
218+
.setReason("reason")
219+
.setOperator("operator")
220+
.setCreatedTime(timestampNanos(3))
221+
.build()))
222+
.setHistoryArchivalStatus(ArchivalStatus.ARCHIVAL_STATUS_ENABLED)
223+
.setHistoryArchivalUri("historyArchivalUri")
224+
.setVisibilityArchivalStatus(ArchivalStatus.ARCHIVAL_STATUS_DISABLED)
225+
.setVisibilityArchivalUri("visibilityArchivalUri")
226+
.setActiveClusterName("activeCluster")
227+
.addClusters(CLUSTER_REPLICATION_CONFIGURATION)
228+
.setFailoverVersion(1)
229+
.setIsGlobalDomain(true)
230+
.build();
93231

94232
public static Decision DECISION_SCHEDULE_ACTIVITY_TASK =
95233
Decision.newBuilder()
@@ -669,6 +807,18 @@ public final class ProtoObjects {
669807
.setWorkflowExecution(WORKFLOW_EXECUTION)
670808
.setControl(utf8("control"))
671809
.build();
810+
811+
public static final HistoryEvent HISTORY_EVENT =
812+
HistoryEvent.newBuilder()
813+
.setEventId(1)
814+
.setEventTime(timestampNanos(2))
815+
.setVersion(3)
816+
.setTaskId(4)
817+
.setWorkflowExecutionStartedEventAttributes(WORKFLOW_EXECUTION_STARTED_EVENT_ATTRIBUTES)
818+
.build();
819+
820+
public static final History HISTORY = History.newBuilder().addEvents(HISTORY_EVENT).build();
821+
672822
public static final CountWorkflowExecutionsRequest COUNT_WORKFLOW_EXECUTIONS_REQUEST =
673823
CountWorkflowExecutionsRequest.newBuilder().setDomain("domain").setQuery("query").build();
674824
public static final DescribeTaskListRequest DESCRIBE_TASK_LIST_REQUEST =
@@ -1026,6 +1176,154 @@ public final class ProtoObjects {
10261176
.setLatestTime(timestampNanos(3)))
10271177
.build();
10281178

1179+
public static final StartWorkflowExecutionResponse START_WORKFLOW_EXECUTION_RESPONSE =
1180+
StartWorkflowExecutionResponse.newBuilder().setRunId(WORKFLOW_EXECUTION.getRunId()).build();
1181+
public static final StartWorkflowExecutionAsyncResponse START_WORKFLOW_EXECUTION_ASYNC_RESPONSE =
1182+
StartWorkflowExecutionAsyncResponse.newBuilder().build();
1183+
1184+
public static final DescribeTaskListResponse DESCRIBE_TASK_LIST_RESPONSE =
1185+
DescribeTaskListResponse.newBuilder()
1186+
.addPollers(POLLER_INFO)
1187+
.setTaskListStatus(TASK_LIST_STATUS)
1188+
.build();
1189+
1190+
public static final DescribeWorkflowExecutionResponse DESCRIBE_WORKFLOW_EXECUTION_RESPONSE =
1191+
DescribeWorkflowExecutionResponse.newBuilder()
1192+
.setExecutionConfiguration(WORKFLOW_EXECUTION_CONFIGURATION)
1193+
.setWorkflowExecutionInfo(WORKFLOW_EXECUTION_INFO)
1194+
.addPendingActivities(PENDING_ACTIVITY_INFO)
1195+
.addPendingChildren(PENDING_CHILD_EXECUTION_INFO)
1196+
.setPendingDecision(PENDING_DECISION_INFO)
1197+
.build();
1198+
1199+
public static final GetClusterInfoResponse GET_CLUSTER_INFO_RESPONSE =
1200+
GetClusterInfoResponse.newBuilder()
1201+
.setSupportedClientVersions(SUPPORTED_CLIENT_VERSIONS)
1202+
.build();
1203+
1204+
public static final GetSearchAttributesResponse GET_SEARCH_ATTRIBUTES_RESPONSE =
1205+
GetSearchAttributesResponse.newBuilder().putAllKeys(INDEXED_VALUES).build();
1206+
public static final GetWorkflowExecutionHistoryResponse GET_WORKFLOW_EXECUTION_HISTORY_RESPONSE =
1207+
GetWorkflowExecutionHistoryResponse.newBuilder()
1208+
.setHistory(HISTORY)
1209+
.addRawHistory(DATA_BLOB)
1210+
.setNextPageToken(utf8("nextPageToken"))
1211+
.setArchived(true)
1212+
.build();
1213+
1214+
public static final ListArchivedWorkflowExecutionsResponse
1215+
LIST_ARCHIVED_WORKFLOW_EXECUTIONS_RESPONSE =
1216+
ListArchivedWorkflowExecutionsResponse.newBuilder()
1217+
.addExecutions(WORKFLOW_EXECUTION_INFO)
1218+
.setNextPageToken(utf8("nextPageToken"))
1219+
.build();
1220+
1221+
public static final ListClosedWorkflowExecutionsResponse
1222+
LIST_CLOSED_WORKFLOW_EXECUTIONS_RESPONSE =
1223+
ListClosedWorkflowExecutionsResponse.newBuilder()
1224+
.addExecutions(WORKFLOW_EXECUTION_INFO)
1225+
.setNextPageToken(utf8("nextPageToken"))
1226+
.build();
1227+
public static final ListOpenWorkflowExecutionsResponse LIST_OPEN_WORKFLOW_EXECUTIONS_RESPONSE =
1228+
ListOpenWorkflowExecutionsResponse.newBuilder()
1229+
.addExecutions(WORKFLOW_EXECUTION_INFO)
1230+
.setNextPageToken(utf8("nextPageToken"))
1231+
.build();
1232+
public static final ListTaskListPartitionsResponse LIST_TASK_LIST_PARTITIONS_RESPONSE =
1233+
ListTaskListPartitionsResponse.newBuilder()
1234+
.addActivityTaskListPartitions(TASK_LIST_PARTITION_METADATA)
1235+
.addDecisionTaskListPartitions(TASK_LIST_PARTITION_METADATA)
1236+
.build();
1237+
public static final ScanWorkflowExecutionsResponse SCAN_WORKFLOW_EXECUTIONS_RESPONSE =
1238+
ScanWorkflowExecutionsResponse.newBuilder()
1239+
.addExecutions(WORKFLOW_EXECUTION_INFO)
1240+
.setNextPageToken(utf8("nextPageToken"))
1241+
.build();
1242+
public static final ListWorkflowExecutionsResponse LIST_WORKFLOW_EXECUTIONS_RESPONSE =
1243+
ListWorkflowExecutionsResponse.newBuilder()
1244+
.addExecutions(WORKFLOW_EXECUTION_INFO)
1245+
.setNextPageToken(utf8("nextPageToken"))
1246+
.build();
1247+
public static final PollForActivityTaskResponse POLL_FOR_ACTIVITY_TASK_RESPONSE =
1248+
PollForActivityTaskResponse.newBuilder()
1249+
.setTaskToken(utf8("taskToken"))
1250+
.setWorkflowExecution(WORKFLOW_EXECUTION)
1251+
.setActivityId("activityId")
1252+
.setActivityType(ACTIVITY_TYPE)
1253+
.setInput(payload("input"))
1254+
.setScheduledTime(timestampNanos(1))
1255+
.setStartedTime(timestampNanos(2))
1256+
.setScheduleToCloseTimeout(seconds(3))
1257+
.setStartToCloseTimeout(seconds(4))
1258+
.setHeartbeatTimeout(seconds(5))
1259+
.setAttempt(6)
1260+
.setScheduledTimeOfThisAttempt(timestampNanos(7))
1261+
.setHeartbeatDetails(payload("heartbeatDetails"))
1262+
.setWorkflowType(WORKFLOW_TYPE)
1263+
.setWorkflowDomain("domain")
1264+
.setHeader(HEADER)
1265+
.build();
1266+
public static final PollForDecisionTaskResponse POLL_FOR_DECISION_TASK_RESPONSE =
1267+
PollForDecisionTaskResponse.newBuilder()
1268+
.setTaskToken(utf8("taskToken"))
1269+
.setWorkflowExecution(WORKFLOW_EXECUTION)
1270+
.setWorkflowType(WORKFLOW_TYPE)
1271+
.setPreviousStartedEventId(int64(1))
1272+
.setStartedEventId(2)
1273+
.setAttempt(3)
1274+
.setBacklogCountHint(4)
1275+
.setHistory(HISTORY)
1276+
.setNextPageToken(utf8("nextPageToken"))
1277+
.setQuery(WORKFLOW_QUERY)
1278+
.setWorkflowExecutionTaskList(TASK_LIST)
1279+
.setScheduledTime(timestampNanos(5))
1280+
.setStartedTime(timestampNanos(6))
1281+
.putAllQueries(ImmutableMap.of("query", WORKFLOW_QUERY))
1282+
.setNextEventId(7)
1283+
.build();
1284+
1285+
public static final QueryWorkflowResponse QUERY_WORKFLOW_RESPONSE =
1286+
QueryWorkflowResponse.newBuilder()
1287+
.setQueryResult(payload("result"))
1288+
.setQueryRejected(
1289+
QueryRejected.newBuilder()
1290+
.setCloseStatus(
1291+
WorkflowExecutionCloseStatus.WORKFLOW_EXECUTION_CLOSE_STATUS_FAILED))
1292+
.build();
1293+
1294+
public static final RecordActivityTaskHeartbeatResponse RECORD_ACTIVITY_TASK_HEARTBEAT_RESPONSE =
1295+
RecordActivityTaskHeartbeatResponse.newBuilder().setCancelRequested(true).build();
1296+
public static final RecordActivityTaskHeartbeatByIDResponse
1297+
RECORD_ACTIVITY_TASK_HEARTBEAT_BY_ID_RESPONSE =
1298+
RecordActivityTaskHeartbeatByIDResponse.newBuilder().setCancelRequested(true).build();
1299+
public static final ResetWorkflowExecutionResponse RESET_WORKFLOW_EXECUTION_RESPONSE =
1300+
ResetWorkflowExecutionResponse.newBuilder().setRunId(WORKFLOW_EXECUTION.getRunId()).build();
1301+
public static final RespondDecisionTaskCompletedResponse
1302+
RESPOND_DECISION_TASK_COMPLETED_RESPONSE =
1303+
RespondDecisionTaskCompletedResponse.newBuilder()
1304+
.setDecisionTask(POLL_FOR_DECISION_TASK_RESPONSE)
1305+
.putActivitiesToDispatchLocally("activity", ACTIVITY_LOCAL_DISPATCH_INFO)
1306+
.build();
1307+
public static final CountWorkflowExecutionsResponse COUNT_WORKFLOW_EXECUTIONS_RESPONSE =
1308+
CountWorkflowExecutionsResponse.newBuilder().setCount(1000).build();
1309+
public static final DescribeDomainResponse DESCRIBE_DOMAIN_RESPONSE =
1310+
DescribeDomainResponse.newBuilder().setDomain(DOMAIN).build();
1311+
public static final ListDomainsResponse LIST_DOMAINS_RESPONSE =
1312+
ListDomainsResponse.newBuilder()
1313+
.addDomains(DOMAIN)
1314+
.setNextPageToken(utf8("nextPageToken"))
1315+
.build();
1316+
public static final SignalWithStartWorkflowExecutionResponse
1317+
SIGNAL_WITH_START_WORKFLOW_EXECUTION_RESPONSE =
1318+
SignalWithStartWorkflowExecutionResponse.newBuilder()
1319+
.setRunId(WORKFLOW_EXECUTION.getRunId())
1320+
.build();
1321+
public static final SignalWithStartWorkflowExecutionAsyncResponse
1322+
SIGNAL_WITH_START_WORKFLOW_EXECUTION_ASYNC_RESPONSE =
1323+
SignalWithStartWorkflowExecutionAsyncResponse.newBuilder().build();
1324+
public static final UpdateDomainResponse UPDATE_DOMAIN_RESPONSE =
1325+
UpdateDomainResponse.newBuilder().setDomain(DOMAIN).build();
1326+
10291327
private ProtoObjects() {}
10301328

10311329
private static Payload payload(String value) {
@@ -1047,4 +1345,8 @@ private static Timestamp timestampNanos(int value) {
10471345
private static ByteString utf8(String value) {
10481346
return ByteString.copyFromUtf8(value);
10491347
}
1348+
1349+
private static Int64Value int64(long value) {
1350+
return Int64Value.newBuilder().setValue(value).build();
1351+
}
10501352
}

0 commit comments

Comments
 (0)