-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(zeebe): support Job Corrections in complete command fixes #347
- Loading branch information
Showing
5 changed files
with
188 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:zeebe="http://camunda.org/schema/zeebe/1.0" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:modeler="http://camunda.org/schema/modeler/1.0" id="Definitions_1ob4kc6" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="5.30.0" modeler:executionPlatform="Camunda Cloud" modeler:executionPlatformVersion="8.6.0"> | ||
<bpmn:process id="job-correction" name="Job Correction Test" isExecutable="true"> | ||
<bpmn:startEvent id="StartEvent_1" name="Start Job Correction Test"> | ||
<bpmn:outgoing>Flow_107kyon</bpmn:outgoing> | ||
</bpmn:startEvent> | ||
<bpmn:sequenceFlow id="Flow_107kyon" sourceRef="StartEvent_1" targetRef="Activity_01g5b4t" /> | ||
<bpmn:serviceTask id="Activity_01g5b4t" name="Job Correction Job"> | ||
<bpmn:extensionElements> | ||
<zeebe:taskDefinition type="job-correction" /> | ||
</bpmn:extensionElements> | ||
<bpmn:incoming>Flow_107kyon</bpmn:incoming> | ||
<bpmn:outgoing>Flow_0y0j0w9</bpmn:outgoing> | ||
</bpmn:serviceTask> | ||
<bpmn:endEvent id="Event_1hmqn2y" name="Job Correction Test Completed Successfully"> | ||
<bpmn:incoming>Flow_0y0j0w9</bpmn:incoming> | ||
</bpmn:endEvent> | ||
<bpmn:sequenceFlow id="Flow_0y0j0w9" sourceRef="Activity_01g5b4t" targetRef="Event_1hmqn2y" /> | ||
</bpmn:process> | ||
<bpmndi:BPMNDiagram id="BPMNDiagram_1"> | ||
<bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="job-correction"> | ||
<bpmndi:BPMNShape id="StartEvent_1_di" bpmnElement="StartEvent_1"> | ||
<dc:Bounds x="182" y="102" width="36" height="36" /> | ||
<bpmndi:BPMNLabel> | ||
<dc:Bounds x="163" y="145" width="74" height="27" /> | ||
</bpmndi:BPMNLabel> | ||
</bpmndi:BPMNShape> | ||
<bpmndi:BPMNShape id="Activity_0s25xnu_di" bpmnElement="Activity_01g5b4t"> | ||
<dc:Bounds x="270" y="80" width="100" height="80" /> | ||
<bpmndi:BPMNLabel /> | ||
</bpmndi:BPMNShape> | ||
<bpmndi:BPMNShape id="Event_1hmqn2y_di" bpmnElement="Event_1hmqn2y"> | ||
<dc:Bounds x="422" y="102" width="36" height="36" /> | ||
<bpmndi:BPMNLabel> | ||
<dc:Bounds x="402" y="145" width="77" height="40" /> | ||
</bpmndi:BPMNLabel> | ||
</bpmndi:BPMNShape> | ||
<bpmndi:BPMNEdge id="Flow_107kyon_di" bpmnElement="Flow_107kyon"> | ||
<di:waypoint x="218" y="120" /> | ||
<di:waypoint x="270" y="120" /> | ||
</bpmndi:BPMNEdge> | ||
<bpmndi:BPMNEdge id="Flow_0y0j0w9_di" bpmnElement="Flow_0y0j0w9"> | ||
<di:waypoint x="370" y="120" /> | ||
<di:waypoint x="422" y="120" /> | ||
</bpmndi:BPMNEdge> | ||
</bpmndi:BPMNPlane> | ||
</bpmndi:BPMNDiagram> | ||
</bpmn:definitions> |
58 changes: 58 additions & 0 deletions
58
src/__tests__/zeebe/integration/Worker-JobCorrection.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
import { restoreZeebeLogging, suppressZeebeLogging } from '../../../lib' | ||
import { ZeebeGrpcClient } from '../../../zeebe' | ||
import { cancelProcesses } from '../../../zeebe/lib/cancelProcesses' | ||
import { CreateProcessInstanceResponse } from '../../../zeebe/lib/interfaces-grpc-1.0' | ||
|
||
jest.setTimeout(30000) | ||
suppressZeebeLogging() | ||
|
||
const zbc = new ZeebeGrpcClient() | ||
let wf: CreateProcessInstanceResponse | undefined | ||
let processDefinitionKey1: string | ||
let bpmnProcessId1: string | ||
|
||
beforeAll(async () => { | ||
const res1 = await zbc.deployResource({ | ||
processFilename: './src/__tests__/testdata/Worker-JobCorrection.bpmn', | ||
}) | ||
;({ | ||
processDefinitionKey: processDefinitionKey1, | ||
bpmnProcessId: bpmnProcessId1, | ||
} = res1.deployments[0].process) | ||
await cancelProcesses(processDefinitionKey1) | ||
}) | ||
|
||
afterEach(async () => { | ||
if (wf?.processInstanceKey) { | ||
await zbc.cancelProcessInstance(wf.processInstanceKey).catch((e) => e) | ||
} | ||
}) | ||
|
||
afterAll(async () => { | ||
await zbc.close() | ||
await cancelProcesses(processDefinitionKey1) | ||
restoreZeebeLogging() | ||
}) | ||
|
||
test('Can complete a task with job corrections', (done) => { | ||
zbc | ||
.createProcessInstance({ | ||
bpmnProcessId: bpmnProcessId1, | ||
variables: {}, | ||
}) | ||
.then((res) => { | ||
wf = res | ||
zbc.createWorker({ | ||
taskType: 'job-correction', | ||
taskHandler: async (job) => { | ||
expect(job.processInstanceKey).toBe(wf?.processInstanceKey) | ||
const res1 = await job.complete({ | ||
// @TODO: correction interface | ||
}) | ||
done(null) | ||
return res1 | ||
}, | ||
loglevel: 'NONE', | ||
}) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters