-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(zeebe): support Job Corrections in complete command fixes #347 #348
Draft
jwulf
wants to merge
4
commits into
alpha
Choose a base branch
from
fix-347
base: alpha
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+242
−10
Draft
Changes from 3 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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> |
62 changes: 62 additions & 0 deletions
62
src/__tests__/zeebe/integration/Worker-CompleteWithResult.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,62 @@ | ||
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-JobResult.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.completeWithJobResult({ | ||
variables: {}, | ||
result: { | ||
denied: true, | ||
}, | ||
}) | ||
// @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
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
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💭 Given the test case (the process has a service task for which this job worker code will run) this code may eventually break.
Job result is at this time only meant to be used for User Task Listeners.
For now, we allow regular job completions with a job result ignoring the result. However, in the future we may add validations against it.
🔧 As a more durable test case, please consider a
Camunda User Task
with acompleting
task listener. You can then try to complete the user task, which creates a job that you can activate and complete with a job result.