zeebe_bpmn_rspec 0.4.1 → 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 +10 -0
- 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 +2 -0
- data/lib/zeebe_bpmn_rspec/activated_job.rb +7 -6
- data/lib/zeebe_bpmn_rspec/deprecate_workflow_alias.rb +14 -0
- data/lib/zeebe_bpmn_rspec/helpers.rb +41 -34
- data/lib/zeebe_bpmn_rspec/version.rb +1 -1
- data/zeebe_bpmn_rspec.gemspec +4 -2
- metadata +12 -10
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,5 +1,15 @@
|
|
1
1
|
# zeebe_bpmn_rspec
|
2
2
|
|
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)
|
9
|
+
- Require Ruby 2.6 or later.
|
10
|
+
- Require `worker` to be specified when activating a job. This argument is
|
11
|
+
defaulted but can no longer be specified as blank.
|
12
|
+
|
3
13
|
## v0.4.1
|
4
14
|
- Allow `with_workflow_instance` to be called without a block.
|
5
15
|
- Allow `worker` to be specified when activating a job.
|
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.
|
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.0
|
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
@@ -1,7 +1,9 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require "active_support"
|
3
4
|
require "rspec"
|
4
5
|
require "zeebe/client"
|
6
|
+
require "zeebe_bpmn_rspec/deprecate_workflow_alias"
|
5
7
|
require "zeebe_bpmn_rspec/helpers"
|
6
8
|
require "zeebe_bpmn_rspec/version"
|
7
9
|
require "zeebe_bpmn_rspec/matchers/have_activated"
|
@@ -1,19 +1,19 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require "active_support"
|
4
3
|
require "active_support/core_ext/hash/keys"
|
5
4
|
require "json"
|
6
5
|
|
7
6
|
module ZeebeBpmnRspec
|
8
7
|
class ActivatedJob
|
9
8
|
include ::Zeebe::Client::GatewayProtocol # for direct reference of request classes
|
9
|
+
extend DeprecateWorkflowAlias
|
10
10
|
|
11
11
|
attr_reader :job, :type
|
12
12
|
|
13
|
-
def initialize(job, type:,
|
13
|
+
def initialize(job, type:, process_instance_key:, client:, context:, validate:) # rubocop:disable Metrics/ParameterLists
|
14
14
|
@job = job
|
15
15
|
@type = type
|
16
|
-
@
|
16
|
+
@process_instance_key = process_instance_key
|
17
17
|
@client = client
|
18
18
|
@context = context
|
19
19
|
|
@@ -21,7 +21,7 @@ module ZeebeBpmnRspec
|
|
21
21
|
context.instance_eval do
|
22
22
|
expect(job).not_to be_nil, "expected to receive job of type '#{type}' but received none"
|
23
23
|
aggregate_failures do
|
24
|
-
expect(job.
|
24
|
+
expect(job.processInstanceKey).to eq(process_instance_key)
|
25
25
|
expect(job.type).to eq(type)
|
26
26
|
end
|
27
27
|
end
|
@@ -36,9 +36,10 @@ module ZeebeBpmnRspec
|
|
36
36
|
job.key
|
37
37
|
end
|
38
38
|
|
39
|
-
def
|
40
|
-
job.
|
39
|
+
def process_instance_key
|
40
|
+
job.processInstanceKey
|
41
41
|
end
|
42
|
+
deprecate_workflow_alias :workflow_instance_key, :process_instance_key
|
42
43
|
|
43
44
|
def retries
|
44
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
|
@@ -1,42 +1,44 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require "active_support/core_ext/object/blank"
|
3
4
|
require "zeebe_bpmn_rspec/activated_job"
|
4
5
|
|
5
6
|
module ZeebeBpmnRspec
|
6
7
|
module Helpers # rubocop:disable Metrics/ModuleLength
|
7
8
|
include ::Zeebe::Client::GatewayProtocol # for direct reference of request classes
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
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
|
+
))
|
17
18
|
rescue StandardError => e
|
18
|
-
raise "Failed to deploy
|
19
|
+
raise "Failed to deploy precess: #{e}"
|
19
20
|
end
|
21
|
+
deprecate_workflow_alias :deploy_workflow, :deploy_process
|
20
22
|
|
21
|
-
def
|
23
|
+
def with_process_instance(name, variables = {})
|
22
24
|
system_error = nil
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
@
|
29
|
-
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?
|
30
32
|
rescue Exception => e # rubocop:disable Lint/RescueException
|
31
33
|
# exceptions are rescued to ensure that instances are cancelled
|
32
34
|
# any error is re-raised below
|
33
35
|
system_error = e
|
34
36
|
ensure
|
35
|
-
if
|
37
|
+
if process&.processInstanceKey
|
36
38
|
begin
|
37
|
-
_zeebe_client.
|
38
|
-
|
39
|
-
|
39
|
+
_zeebe_client.cancel_process_instance(CancelProcessInstanceRequest.new(
|
40
|
+
processInstanceKey: process.processInstanceKey
|
41
|
+
))
|
40
42
|
rescue GRPC::NotFound => _e
|
41
43
|
# expected
|
42
44
|
rescue StandardError => _e
|
@@ -45,26 +47,31 @@ module ZeebeBpmnRspec
|
|
45
47
|
end
|
46
48
|
raise system_error if system_error
|
47
49
|
end
|
50
|
+
deprecate_workflow_alias :with_workflow_instance, :with_process_instance
|
48
51
|
|
49
|
-
def
|
52
|
+
def process_complete!(wait_seconds: 0.25)
|
50
53
|
error = nil
|
51
|
-
sleep
|
54
|
+
sleep(wait_seconds)
|
52
55
|
begin
|
53
|
-
_zeebe_client.
|
54
|
-
|
55
|
-
|
56
|
+
_zeebe_client.cancel_process_instance(CancelProcessInstanceRequest.new(
|
57
|
+
processInstanceKey: process_instance_key
|
58
|
+
))
|
56
59
|
rescue GRPC::NotFound => e
|
57
60
|
error = e
|
58
61
|
end
|
59
62
|
|
60
|
-
raise "Expected
|
63
|
+
raise "Expected process instance #{process_instance_key} to be complete" if error.nil?
|
61
64
|
end
|
65
|
+
deprecate_workflow_alias :workflow_complete!, :process_complete!
|
62
66
|
|
63
|
-
def
|
64
|
-
@
|
67
|
+
def process_instance_key
|
68
|
+
@__process_instance_key
|
65
69
|
end
|
70
|
+
deprecate_workflow_alias :workflow_instance_key, :process_instance_key
|
66
71
|
|
67
72
|
def activate_job(type, fetch_variables: nil, validate: true, worker: "#{type}-#{SecureRandom.hex}")
|
73
|
+
raise ArgumentError.new("'worker' cannot be blank") if worker.blank?
|
74
|
+
|
68
75
|
stream = _zeebe_client.activate_jobs(ActivateJobsRequest.new({
|
69
76
|
type: type,
|
70
77
|
worker: worker,
|
@@ -80,13 +87,13 @@ module ZeebeBpmnRspec
|
|
80
87
|
|
81
88
|
ActivatedJob.new(job,
|
82
89
|
type: type,
|
83
|
-
|
90
|
+
process_instance_key: process_instance_key,
|
84
91
|
client: _zeebe_client,
|
85
92
|
context: self,
|
86
93
|
validate: validate)
|
87
94
|
end
|
88
95
|
alias process_job activate_job
|
89
|
-
|
96
|
+
deprecate process_job: :activate_job
|
90
97
|
|
91
98
|
def job_with_type(type, fetch_variables: nil)
|
92
99
|
activate_job(type, fetch_variables: fetch_variables, validate: false)
|
@@ -111,7 +118,7 @@ module ZeebeBpmnRspec
|
|
111
118
|
response.jobs.each do |job|
|
112
119
|
yielder << ActivatedJob.new(job,
|
113
120
|
type: type,
|
114
|
-
|
121
|
+
process_instance_key: process_instance_key,
|
115
122
|
client: _zeebe_client,
|
116
123
|
context: self,
|
117
124
|
validate: true)
|
@@ -140,7 +147,7 @@ module ZeebeBpmnRspec
|
|
140
147
|
end
|
141
148
|
|
142
149
|
def reset_zeebe!
|
143
|
-
@
|
150
|
+
@__process_instance_key = nil
|
144
151
|
end
|
145
152
|
|
146
153
|
private
|
data/zeebe_bpmn_rspec.gemspec
CHANGED
@@ -41,7 +41,9 @@ Gem::Specification.new do |spec|
|
|
41
41
|
spec.executables = []
|
42
42
|
spec.require_paths = ["lib"]
|
43
43
|
|
44
|
-
spec.
|
44
|
+
spec.required_ruby_version = ">= 2.6"
|
45
|
+
|
46
|
+
spec.add_development_dependency "bundler", "~> 2.1"
|
45
47
|
spec.add_development_dependency "ezcater_rubocop", "2.0.0"
|
46
48
|
spec.add_development_dependency "overcommit"
|
47
49
|
spec.add_development_dependency "rake", "~> 10.0"
|
@@ -50,5 +52,5 @@ Gem::Specification.new do |spec|
|
|
50
52
|
|
51
53
|
spec.add_runtime_dependency "activesupport"
|
52
54
|
spec.add_runtime_dependency "rspec", "~> 3.4"
|
53
|
-
spec.add_runtime_dependency "zeebe-client"
|
55
|
+
spec.add_runtime_dependency "zeebe-client", "~> 0.14.0"
|
54
56
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
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
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-05-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '1
|
19
|
+
version: '2.1'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '1
|
26
|
+
version: '2.1'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: ezcater_rubocop
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -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
|
@@ -170,14 +172,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
170
172
|
requirements:
|
171
173
|
- - ">="
|
172
174
|
- !ruby/object:Gem::Version
|
173
|
-
version: '
|
175
|
+
version: '2.6'
|
174
176
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
175
177
|
requirements:
|
176
178
|
- - ">="
|
177
179
|
- !ruby/object:Gem::Version
|
178
180
|
version: '0'
|
179
181
|
requirements: []
|
180
|
-
rubygems_version: 3.
|
182
|
+
rubygems_version: 3.1.4
|
181
183
|
signing_key:
|
182
184
|
specification_version: 4
|
183
185
|
summary: Zeebe BPMN testing using RSpec
|