zeebe_bpmn_rspec 0.5.0 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -1
- data/README.md +19 -19
- data/docker-compose.simple-monitor.yml +17 -0
- data/docker-compose.yml +2 -15
- data/lib/zeebe_bpmn_rspec.rb +1 -0
- data/lib/zeebe_bpmn_rspec/activated_job.rb +7 -5
- data/lib/zeebe_bpmn_rspec/deprecate_workflow_alias.rb +14 -0
- data/lib/zeebe_bpmn_rspec/helpers.rb +38 -34
- data/lib/zeebe_bpmn_rspec/version.rb +1 -1
- data/zeebe_bpmn_rspec.gemspec +1 -1
- metadata +7 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dbc8b0a3a6bf05f4ef29f2a5285b452afa1e733f2e166a521ba28e48dc2f94d1
|
4
|
+
data.tar.gz: 5ef538eea22fce15ba4356ea06204891b69ec51170706cc804d005f1639107f6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 89756e04128e43c7386cc13f785dc3146568b76a7ed5b841c9ec71851f243f043c5d91e1709dd6a44ec41dc05f6e8c2c2414e20fb4227eb3a896b1ee12efad5f
|
7
|
+
data.tar.gz: 3e2f49b5e1ad94878f83ac4b6efb69028a77728e3f53b8f46b2fa134cc6ea63b19f7f3c9e88717ab9942cc0daf97d103ebdfdb12492e937c5f59361b1ec069dd
|
data/CHANGELOG.md
CHANGED
@@ -1,6 +1,11 @@
|
|
1
1
|
# zeebe_bpmn_rspec
|
2
2
|
|
3
|
-
##
|
3
|
+
## v1.0.0
|
4
|
+
- Support Zeebe 1.0.0. Method names now use `process` instead of `workflow`
|
5
|
+
to match the renaming in Zeebe. Previous methods are deprecated and will be
|
6
|
+
removed in a future release.
|
7
|
+
|
8
|
+
## v0.5.0 (unreleased)
|
4
9
|
- Require Ruby 2.6 or later.
|
5
10
|
- Require `worker` to be specified when activating a job. This argument is
|
6
11
|
defaulted but can no longer be specified as blank.
|
data/README.md
CHANGED
@@ -41,24 +41,24 @@ The gem adds the following helper methods to RSpec.
|
|
41
41
|
|
42
42
|
The gem also defines [Custom Matchers](#custom-matchers).
|
43
43
|
|
44
|
-
### Deploy
|
44
|
+
### Deploy Process
|
45
45
|
|
46
|
-
The `deploy_workflow` method requires a path to a BPMN file and deploys it to Zeebe. There is no support for
|
46
|
+
The `deploy_process` (previously `deploy_workflow`) method requires a path to a BPMN file and deploys it to Zeebe. There is no support for
|
47
47
|
removing a BPMN file once deployed, so this can be done once before the examples that use it.
|
48
48
|
|
49
49
|
```ruby
|
50
|
-
before(:all) {
|
50
|
+
before(:all) { deploy_process(filepath) }
|
51
51
|
```
|
52
52
|
|
53
|
-
A custom name can also be specified for the
|
53
|
+
A custom name can also be specified for the process:
|
54
54
|
|
55
55
|
```ruby
|
56
|
-
before(:all) {
|
56
|
+
before(:all) { deploy_process(filepath, "custom_name") }
|
57
57
|
```
|
58
58
|
|
59
|
-
### With
|
59
|
+
### With Process Instance
|
60
60
|
|
61
|
-
The `with_workflow_instance` method is used to create an instance for the specified
|
61
|
+
The `with_process_instance` (previously `with_workflow_instance`) method is used to create an instance for the specified process
|
62
62
|
and then yields a block that can interact with the instance.
|
63
63
|
|
64
64
|
This method ensures that an active instance is cancelled at the end of the block.
|
@@ -67,14 +67,14 @@ For testing BPMN files it is expected that most of the test definition will be w
|
|
67
67
|
call to this method.
|
68
68
|
|
69
69
|
```ruby
|
70
|
-
|
70
|
+
with_process_instance("file_basename") do
|
71
71
|
...
|
72
72
|
end
|
73
73
|
```
|
74
74
|
|
75
75
|
### Processing Jobs
|
76
76
|
|
77
|
-
A single job can be processed for a
|
77
|
+
A single job can be processed for a process by calling `activate_job` (previously `process_job`).
|
78
78
|
`activate_job` is called with a job type:
|
79
79
|
|
80
80
|
```ruby
|
@@ -129,8 +129,8 @@ activate_job("my_job").
|
|
129
129
|
expect_input(user_id: 123).
|
130
130
|
and_complete
|
131
131
|
|
132
|
-
# Jobs can be completed with data that is merged with variables in the
|
133
|
-
|
132
|
+
# Jobs can be completed with data that is merged with variables in the process
|
133
|
+
activate_job("my_job").
|
134
134
|
and_complete(status: "ACTIVATED")
|
135
135
|
```
|
136
136
|
|
@@ -198,17 +198,17 @@ The maximum number of jobs to return can be specified:
|
|
198
198
|
jobs = activate_jobs("my_job", max_jobs: 2).to_a
|
199
199
|
```
|
200
200
|
|
201
|
-
###
|
201
|
+
### Process Complete
|
202
202
|
|
203
|
-
The `workflow_complete!` method can be used to assert that the current
|
204
|
-
test. This is implemented by cancelling the
|
203
|
+
The `process_complete!` (previously `workflow_complete!`) method can be used to assert that the current process is complete at the end of a
|
204
|
+
test. This is implemented by cancelling the process and checking for an error that it is already
|
205
205
|
complete.
|
206
206
|
|
207
207
|
```ruby
|
208
|
-
|
208
|
+
with_process_instance("file_basename") do
|
209
209
|
...
|
210
210
|
|
211
|
-
|
211
|
+
process_complete!
|
212
212
|
end
|
213
213
|
```
|
214
214
|
|
@@ -242,8 +242,8 @@ The `set_variables` method can be used to set variables for a specified
|
|
242
242
|
scope in Zeebe:
|
243
243
|
|
244
244
|
```ruby
|
245
|
-
#
|
246
|
-
set_variables(
|
245
|
+
# process_instance_key is a method that returns the key for the current process instance
|
246
|
+
set_variables(process_instance_key, { foo: "bar" })
|
247
247
|
```
|
248
248
|
|
249
249
|
An activated job can be used to determine the key for the task that it is associated with:
|
@@ -370,7 +370,7 @@ to specify a short duration.
|
|
370
370
|
|
371
371
|
The current gem and approach have some limitations:
|
372
372
|
|
373
|
-
1. You can interact with only one
|
373
|
+
1. You can interact with only one process at a time.
|
374
374
|
|
375
375
|
## Development
|
376
376
|
|
@@ -0,0 +1,17 @@
|
|
1
|
+
version: "3.4"
|
2
|
+
|
3
|
+
services:
|
4
|
+
zeebe:
|
5
|
+
volumes:
|
6
|
+
- ./compose/zeebe-hazelcast-exporter.jar:/usr/local/zeebe/exporters/zeebe-hazelcast-exporter.jar
|
7
|
+
- ./compose/application.yml:/usr/local/zeebe/config/application.yaml
|
8
|
+
|
9
|
+
monitor:
|
10
|
+
image: camunda/zeebe-simple-monitor:0.19.1
|
11
|
+
environment:
|
12
|
+
- zeebe.client.broker.contactPoint=zeebe:26500
|
13
|
+
- zeebe.client.worker.hazelcast.connection=zeebe:5701
|
14
|
+
ports:
|
15
|
+
- "8082:8082"
|
16
|
+
depends_on:
|
17
|
+
- zeebe
|
data/docker-compose.yml
CHANGED
@@ -8,7 +8,7 @@ x-environment: &default-environment
|
|
8
8
|
BUNDLE_DISABLE_SHARED_GEMS: "true"
|
9
9
|
ZEEBE_ADDRESS: zeebe:26500
|
10
10
|
x-service: &default-service
|
11
|
-
image: ruby:2.7.
|
11
|
+
image: ruby:2.7.3
|
12
12
|
volumes:
|
13
13
|
- .:/usr/src/gem
|
14
14
|
- ./compose/entrypoint.sh:/tmp/entrypoint.sh
|
@@ -18,22 +18,9 @@ x-service: &default-service
|
|
18
18
|
stdin_open: true
|
19
19
|
services:
|
20
20
|
zeebe:
|
21
|
-
image: camunda/zeebe:${ZEEBE_VERSION:-0.
|
21
|
+
image: camunda/zeebe:${ZEEBE_VERSION:-1.0.0}
|
22
22
|
environment:
|
23
23
|
ZEEBE_LOG_LEVEL: debug
|
24
|
-
volumes:
|
25
|
-
- ./compose/zeebe-hazelcast-exporter.jar:/usr/local/zeebe/exporters/zeebe-hazelcast-exporter.jar
|
26
|
-
- ./compose/application.yml:/usr/local/zeebe/config/application.yaml
|
27
|
-
|
28
|
-
monitor:
|
29
|
-
image: camunda/zeebe-simple-monitor:0.19.1
|
30
|
-
environment:
|
31
|
-
- zeebe.client.broker.contactPoint=zeebe:26500
|
32
|
-
- zeebe.client.worker.hazelcast.connection=zeebe:5701
|
33
|
-
ports:
|
34
|
-
- "8082:8082"
|
35
|
-
depends_on:
|
36
|
-
- zeebe
|
37
24
|
|
38
25
|
console:
|
39
26
|
<<: *default-service
|
data/lib/zeebe_bpmn_rspec.rb
CHANGED
@@ -6,13 +6,14 @@ require "json"
|
|
6
6
|
module ZeebeBpmnRspec
|
7
7
|
class ActivatedJob
|
8
8
|
include ::Zeebe::Client::GatewayProtocol # for direct reference of request classes
|
9
|
+
extend DeprecateWorkflowAlias
|
9
10
|
|
10
11
|
attr_reader :job, :type
|
11
12
|
|
12
|
-
def initialize(job, type:,
|
13
|
+
def initialize(job, type:, process_instance_key:, client:, context:, validate:) # rubocop:disable Metrics/ParameterLists
|
13
14
|
@job = job
|
14
15
|
@type = type
|
15
|
-
@
|
16
|
+
@process_instance_key = process_instance_key
|
16
17
|
@client = client
|
17
18
|
@context = context
|
18
19
|
|
@@ -20,7 +21,7 @@ module ZeebeBpmnRspec
|
|
20
21
|
context.instance_eval do
|
21
22
|
expect(job).not_to be_nil, "expected to receive job of type '#{type}' but received none"
|
22
23
|
aggregate_failures do
|
23
|
-
expect(job.
|
24
|
+
expect(job.processInstanceKey).to eq(process_instance_key)
|
24
25
|
expect(job.type).to eq(type)
|
25
26
|
end
|
26
27
|
end
|
@@ -35,9 +36,10 @@ module ZeebeBpmnRspec
|
|
35
36
|
job.key
|
36
37
|
end
|
37
38
|
|
38
|
-
def
|
39
|
-
job.
|
39
|
+
def process_instance_key
|
40
|
+
job.processInstanceKey
|
40
41
|
end
|
42
|
+
deprecate_workflow_alias :workflow_instance_key, :process_instance_key
|
41
43
|
|
42
44
|
def retries
|
43
45
|
job.retries
|
@@ -0,0 +1,14 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "active_support/deprecation"
|
4
|
+
|
5
|
+
module ZeebeBpmnRspec
|
6
|
+
module DeprecateWorkflowAlias
|
7
|
+
WorkflowDeprecation = ActiveSupport::Deprecation.new("v2.0", "ZeebeBpmnRspec")
|
8
|
+
|
9
|
+
def deprecate_workflow_alias(deprecated_name, new_name)
|
10
|
+
alias_method deprecated_name, new_name
|
11
|
+
deprecate deprecated_name => new_name, deprecator: WorkflowDeprecation
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -6,38 +6,39 @@ require "zeebe_bpmn_rspec/activated_job"
|
|
6
6
|
module ZeebeBpmnRspec
|
7
7
|
module Helpers # rubocop:disable Metrics/ModuleLength
|
8
8
|
include ::Zeebe::Client::GatewayProtocol # for direct reference of request classes
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
9
|
+
extend DeprecateWorkflowAlias
|
10
|
+
|
11
|
+
def deploy_process(path, name = nil)
|
12
|
+
_zeebe_client.deploy_process(DeployProcessRequest.new(
|
13
|
+
processes: [ProcessRequestObject.new(
|
14
|
+
name: (name && "#{name}.bpmn") || File.basename(path),
|
15
|
+
definition: File.read(path)
|
16
|
+
)]
|
17
|
+
))
|
18
18
|
rescue StandardError => e
|
19
|
-
raise "Failed to deploy
|
19
|
+
raise "Failed to deploy precess: #{e}"
|
20
20
|
end
|
21
|
+
deprecate_workflow_alias :deploy_workflow, :deploy_process
|
21
22
|
|
22
|
-
def
|
23
|
+
def with_process_instance(name, variables = {})
|
23
24
|
system_error = nil
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
@
|
30
|
-
yield(
|
25
|
+
process = _zeebe_client.create_process_instance(CreateProcessInstanceRequest.new(
|
26
|
+
bpmnProcessId: name,
|
27
|
+
version: -1, # always latest
|
28
|
+
variables: variables.to_json
|
29
|
+
))
|
30
|
+
@__process_instance_key = process.processInstanceKey
|
31
|
+
yield(process.processInstanceKey) if block_given?
|
31
32
|
rescue Exception => e # rubocop:disable Lint/RescueException
|
32
33
|
# exceptions are rescued to ensure that instances are cancelled
|
33
34
|
# any error is re-raised below
|
34
35
|
system_error = e
|
35
36
|
ensure
|
36
|
-
if
|
37
|
+
if process&.processInstanceKey
|
37
38
|
begin
|
38
|
-
_zeebe_client.
|
39
|
-
|
40
|
-
|
39
|
+
_zeebe_client.cancel_process_instance(CancelProcessInstanceRequest.new(
|
40
|
+
processInstanceKey: process.processInstanceKey
|
41
|
+
))
|
41
42
|
rescue GRPC::NotFound => _e
|
42
43
|
# expected
|
43
44
|
rescue StandardError => _e
|
@@ -46,24 +47,27 @@ module ZeebeBpmnRspec
|
|
46
47
|
end
|
47
48
|
raise system_error if system_error
|
48
49
|
end
|
50
|
+
deprecate_workflow_alias :with_workflow_instance, :with_process_instance
|
49
51
|
|
50
|
-
def
|
52
|
+
def process_complete!(wait_seconds: 0.25)
|
51
53
|
error = nil
|
52
|
-
sleep
|
54
|
+
sleep(wait_seconds)
|
53
55
|
begin
|
54
|
-
_zeebe_client.
|
55
|
-
|
56
|
-
|
56
|
+
_zeebe_client.cancel_process_instance(CancelProcessInstanceRequest.new(
|
57
|
+
processInstanceKey: process_instance_key
|
58
|
+
))
|
57
59
|
rescue GRPC::NotFound => e
|
58
60
|
error = e
|
59
61
|
end
|
60
62
|
|
61
|
-
raise "Expected
|
63
|
+
raise "Expected process instance #{process_instance_key} to be complete" if error.nil?
|
62
64
|
end
|
65
|
+
deprecate_workflow_alias :workflow_complete!, :process_complete!
|
63
66
|
|
64
|
-
def
|
65
|
-
@
|
67
|
+
def process_instance_key
|
68
|
+
@__process_instance_key
|
66
69
|
end
|
70
|
+
deprecate_workflow_alias :workflow_instance_key, :process_instance_key
|
67
71
|
|
68
72
|
def activate_job(type, fetch_variables: nil, validate: true, worker: "#{type}-#{SecureRandom.hex}")
|
69
73
|
raise ArgumentError.new("'worker' cannot be blank") if worker.blank?
|
@@ -83,13 +87,13 @@ module ZeebeBpmnRspec
|
|
83
87
|
|
84
88
|
ActivatedJob.new(job,
|
85
89
|
type: type,
|
86
|
-
|
90
|
+
process_instance_key: process_instance_key,
|
87
91
|
client: _zeebe_client,
|
88
92
|
context: self,
|
89
93
|
validate: validate)
|
90
94
|
end
|
91
95
|
alias process_job activate_job
|
92
|
-
|
96
|
+
deprecate process_job: :activate_job
|
93
97
|
|
94
98
|
def job_with_type(type, fetch_variables: nil)
|
95
99
|
activate_job(type, fetch_variables: fetch_variables, validate: false)
|
@@ -114,7 +118,7 @@ module ZeebeBpmnRspec
|
|
114
118
|
response.jobs.each do |job|
|
115
119
|
yielder << ActivatedJob.new(job,
|
116
120
|
type: type,
|
117
|
-
|
121
|
+
process_instance_key: process_instance_key,
|
118
122
|
client: _zeebe_client,
|
119
123
|
context: self,
|
120
124
|
validate: true)
|
@@ -143,7 +147,7 @@ module ZeebeBpmnRspec
|
|
143
147
|
end
|
144
148
|
|
145
149
|
def reset_zeebe!
|
146
|
-
@
|
150
|
+
@__process_instance_key = nil
|
147
151
|
end
|
148
152
|
|
149
153
|
private
|
data/zeebe_bpmn_rspec.gemspec
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: zeebe_bpmn_rspec
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- ezCater, Inc
|
@@ -126,16 +126,16 @@ dependencies:
|
|
126
126
|
name: zeebe-client
|
127
127
|
requirement: !ruby/object:Gem::Requirement
|
128
128
|
requirements:
|
129
|
-
- - "
|
129
|
+
- - "~>"
|
130
130
|
- !ruby/object:Gem::Version
|
131
|
-
version:
|
131
|
+
version: 0.14.0
|
132
132
|
type: :runtime
|
133
133
|
prerelease: false
|
134
134
|
version_requirements: !ruby/object:Gem::Requirement
|
135
135
|
requirements:
|
136
|
-
- - "
|
136
|
+
- - "~>"
|
137
137
|
- !ruby/object:Gem::Version
|
138
|
-
version:
|
138
|
+
version: 0.14.0
|
139
139
|
description: Zeebe BPMN testing using RSpec
|
140
140
|
email:
|
141
141
|
- engineering@ezcater.com
|
@@ -148,9 +148,11 @@ files:
|
|
148
148
|
- Gemfile
|
149
149
|
- LICENSE.txt
|
150
150
|
- README.md
|
151
|
+
- docker-compose.simple-monitor.yml
|
151
152
|
- docker-compose.yml
|
152
153
|
- lib/zeebe_bpmn_rspec.rb
|
153
154
|
- lib/zeebe_bpmn_rspec/activated_job.rb
|
155
|
+
- lib/zeebe_bpmn_rspec/deprecate_workflow_alias.rb
|
154
156
|
- lib/zeebe_bpmn_rspec/helpers.rb
|
155
157
|
- lib/zeebe_bpmn_rspec/matchers/have_activated.rb
|
156
158
|
- lib/zeebe_bpmn_rspec/matchers/have_headers.rb
|