Skip to content

Commit

Permalink
all event types mocks
Browse files Browse the repository at this point in the history
  • Loading branch information
Assem-Hafez committed Sep 17, 2024
1 parent 1324316 commit f49702b
Show file tree
Hide file tree
Showing 7 changed files with 858 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import { type HistoryEvent } from '@/__generated__/proto-ts/uber/cadence/api/v1/HistoryEvent';

import type { ActivityHistoryEvent } from '../workflow-history.types';

export const scheduleActivityTaskEvent = {
Expand Down Expand Up @@ -50,7 +48,7 @@ export const scheduleActivityTaskEvent = {
},
},
attributes: 'activityTaskScheduledEventAttributes',
} as const satisfies HistoryEvent;
} as const satisfies ActivityHistoryEvent;

export const startActivityTaskEvent = {
eventId: '9',
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,265 @@
import type { ChildWorkflowExecutionHistoryEvent } from '../workflow-history.types';

export const initiateChildWorkflowEvent = {
eventId: "40",
eventTime: {
seconds: "172579671",
nanos: 830123299
},
version: "575102",
taskId: "5877269782",
startChildWorkflowExecutionInitiatedEventAttributes: {
domain: "cadence-domain",
workflowId: "workflow.cancellation-workflow.cancellation.external-child",
workflowType: {
name: "workflow.cancellation.external"
},
taskList: {
name: "canary-task-queue",
kind: "TASK_LIST_KIND_INVALID"
},
input: {
data: "MTcyNjQ5Mjc1MTc5ODgxMjMwOAozMDAwMDAwMDAwMAo="
},
executionStartToCloseTimeout: {
seconds: "360",
nanos: 0
},
taskStartToCloseTimeout: {
seconds: "10",
nanos: 0
},
parentClosePolicy: "PARENT_CLOSE_POLICY_ABANDON",
control: "",
decisionTaskCompletedEventId: "4",
workflowIdReusePolicy: "WORKFLOW_ID_REUSE_POLICY_ALLOW_DUPLICATE",
retryPolicy: null,
cronSchedule: "",
memo: null,
searchAttributes: null,
delayStart: null,
jitterStart: null,
firstRunAt: null,
header: {
fields: {
}
},
},
attributes: "startChildWorkflowExecutionInitiatedEventAttributes"
} as const satisfies ChildWorkflowExecutionHistoryEvent;

export const initiateFailureChildWorkflowEvent = {
eventId: "41",
eventTime: {
seconds: "1725769672",
nanos: 830123299
},
version: "575102",
taskId: "5877269783",
startChildWorkflowExecutionFailedEventAttributes: {
domain: "cadence-domain",
workflowId: "workflow.cancellation-workflow.cancellation.external-child",
workflowType: {
name: "workflow.cancellation.external"
},
control: "",
decisionTaskCompletedEventId: "4",
cause:'CHILD_WORKFLOW_EXECUTION_FAILED_CAUSE_INVALID',
initiatedEventId:''
},
attributes: "startChildWorkflowExecutionFailedEventAttributes"
} as const satisfies ChildWorkflowExecutionHistoryEvent;


export const startChildWorkflowEvent = {
eventId: "42",
eventTime: {
seconds: "1725769673",
nanos: 862443565
},
version: "575102",
taskId: "5877269784",
childWorkflowExecutionStartedEventAttributes: {
domain: "cadence-domain",
workflowExecution: {
workflowId: "workflow.cancellation-workflow.cancellation.external-child",
runId: "107495f0-ab19-4631-b6b9-dca2c2a30482"
},
workflowType: {
name: "workflow.cancellation.external"
},
initiatedEventId: "40",
header: {
fields: {
}
}
},
attributes: "childWorkflowExecutionStartedEventAttributes"
} as const satisfies ChildWorkflowExecutionHistoryEvent;

export const completeChildWorkflowEvent = {
eventId: "43",
eventTime: {
seconds: "1725769674",
nanos: 218146161
},
version: "575102",
taskId: "5877269785",
childWorkflowExecutionCompletedEventAttributes: {
domain: "cadence-domain",
workflowExecution: {
workflowId: "workflow.cancellation-workflow.cancellation.external-child",
runId: "107495f0-ab19-4631-b6b9-dca2c2a30482"
},
workflowType: {
name: "workflow.cancellation.external"
},
initiatedEventId: "9",
startedEventId: "41",
result: null
},
attributes: "childWorkflowExecutionCompletedEventAttributes"
} as const satisfies ChildWorkflowExecutionHistoryEvent;

export const cancelChildWorkflowEvent = {
eventId: "44",
eventTime: {
seconds: "1725769675",
nanos: 993971123
},
version: "575102",
taskId: "5877269786",
childWorkflowExecutionCanceledEventAttributes: {
domain: "cadence-domain",
workflowExecution: {
workflowId: "workflow.cancellation-workflow.cancellation.external-child",
runId: "107495f0-ab19-4631-b6b9-dca2c2a30482"
},
workflowType: {
name: "workflow.cancellation.external"
},
initiatedEventId: "40",
startedEventId: "42",
details: {
data: "Y2FuY2VsZWQgYmVmb3JlIHN0YXJ0aW5nIG90aGVyIHdvcmtmbG93OiBDYW5jZWxlZEVycm9y"
}
},
attributes: "childWorkflowExecutionCanceledEventAttributes"
} as const satisfies ChildWorkflowExecutionHistoryEvent;


export const terminateChildWorkflowEvent = {
eventId: "45",
eventTime: {
seconds: "1725769676",
nanos: 993971123
},
version: "575102",
taskId: "5877269787",
childWorkflowExecutionTerminatedEventAttributes: {
domain: "cadence-domain",
workflowExecution: {
workflowId: "workflow.cancellation-workflow.cancellation.external-child",
runId: "107495f0-ab19-4631-b6b9-dca2c2a30482"
},
workflowType: {
name: "workflow.cancellation.external"
},
initiatedEventId: "40",
startedEventId: "42",
},
attributes: "childWorkflowExecutionTerminatedEventAttributes"
} as const satisfies ChildWorkflowExecutionHistoryEvent;


export const timeoutChildWorkflowEvent = {
eventId: "46",
eventTime: {
seconds: "1725769677",
nanos: 993971123
},
version: "575102",
taskId: "5877269788",
childWorkflowExecutionTimedOutEventAttributes: {
domain: "cadence-domain",
workflowExecution: {
workflowId: "workflow.cancellation-workflow.cancellation.external-child",
runId: "107495f0-ab19-4631-b6b9-dca2c2a30482"
},
workflowType: {
name: "workflow.cancellation.external"
},
initiatedEventId: "40",
startedEventId: "42",
timeoutType: 'TIMEOUT_TYPE_HEARTBEAT',

},
attributes: "childWorkflowExecutionTimedOutEventAttributes"
} as const satisfies ChildWorkflowExecutionHistoryEvent;


export const failChildWorkflowEvent = {
eventId: "47",
eventTime: {
seconds: "1725769678",
nanos: 993971123
},
version: "575102",
taskId: "5877269789",
childWorkflowExecutionFailedEventAttributes: {
domain: "cadence-domain",
workflowExecution: {
workflowId: "workflow.cancellation-workflow.cancellation.external-child",
runId: "107495f0-ab19-4631-b6b9-dca2c2a30482"
},
workflowType: {
name: "workflow.cancellation.external"
},
initiatedEventId: "40",
startedEventId: "42",
failure: {
details: '',
reason: ''
}
},
attributes: "childWorkflowExecutionFailedEventAttributes"
} as const satisfies ChildWorkflowExecutionHistoryEvent;


export const completedChildeWorkflowEvents: ChildWorkflowExecutionHistoryEvent[] = [
initiateChildWorkflowEvent,
startChildWorkflowEvent,
completeChildWorkflowEvent,
]


export const failedChildeWorkflowEvents: ChildWorkflowExecutionHistoryEvent[] = [
initiateChildWorkflowEvent,
startChildWorkflowEvent,
failChildWorkflowEvent,

]

export const timedoutChildeWorkflowEvents: ChildWorkflowExecutionHistoryEvent[] = [
initiateChildWorkflowEvent,
startChildWorkflowEvent,
timeoutChildWorkflowEvent,
]

export const terminatedChildeWorkflowEvents: ChildWorkflowExecutionHistoryEvent[] = [
initiateChildWorkflowEvent,
startChildWorkflowEvent,
terminateChildWorkflowEvent,
]

export const canceledChildWorkflowEvents: ChildWorkflowExecutionHistoryEvent[] = [
initiateChildWorkflowEvent,
startChildWorkflowEvent,
cancelChildWorkflowEvent,
]


export const initationFailedChildeWorkflowEvents: ChildWorkflowExecutionHistoryEvent[] = [
initiateChildWorkflowEvent,
initiateFailureChildWorkflowEvent,
]
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,71 @@ export const completeDecisionTaskEvent = {
attributes: 'decisionTaskCompletedEventAttributes',
} as const satisfies DecisionHistoryEvent;


export const failedDecisionTaskEvent = {
eventId:'5',
eventTime: {
seconds: '1725747370',
nanos: 599272953,
},
attributes:'decisionTaskFailedEventAttributes',
version: '575102',
taskId: '22647174902',
decisionTaskFailedEventAttributes: {
scheduledEventId: '2',
startedEventId: '3',
cause: 'DECISION_TASK_FAILED_CAUSE_BAD_START_CHILD_EXECUTION_ATTRIBUTES',
failure: {
reason: '',
details:'WorkflowId exceeds length limit.',
},
identity: '1@dca50-hrk@cadence-canary-production@canary-task-queue@bd570bec-e2cf-470f-937b-0e71d3d8a6d8',
baseRunId: '',
newRunId: '',
forkEventVersion: '0',
binaryChecksum: 'uDeploy:ffc875a4c3571872881f79c939921e00398ab260',
requestId: '66f7f58b-3d3b-4178-972a-fa7825ceec39',
}
}as const satisfies DecisionHistoryEvent;

export const timeoutDecisionTaskEvent = {
eventId:'6',
eventTime: {
seconds: '1725747370',
nanos: 599273063,
},
attributes:'decisionTaskTimedOutEventAttributes',
version: '575102',
taskId: '22647174903',
decisionTaskTimedOutEventAttributes: {
scheduledEventId: '2',
startedEventId: '3',
cause: 'DECISION_TASK_TIMED_OUT_CAUSE_TIMEOUT',
timeoutType:'TIMEOUT_TYPE_HEARTBEAT',
reason:'Missed heart beat',
baseRunId: '',
newRunId: '',
forkEventVersion: '0',
requestId: '66f7f58b-3d3b-4178-972a-fa7825ceec40',
}
}as const satisfies DecisionHistoryEvent;


export const completedDecisionTaskEvents: DecisionHistoryEvent[] = [
scheduleDecisionTaskEvent,
startDecisionTaskEvent,
completeDecisionTaskEvent,
];

export const failedDecisionTaskEvents: DecisionHistoryEvent[] = [
scheduleDecisionTaskEvent,
startDecisionTaskEvent,
failedDecisionTaskEvent,
];


export const timedoutDecisionTaskEvents: DecisionHistoryEvent[] = [
scheduleDecisionTaskEvent,
startDecisionTaskEvent,
timeoutDecisionTaskEvent,
];
Loading

0 comments on commit f49702b

Please sign in to comment.