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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 28a2727e47b273a44521d2f74ecf03c97ee84c22ccd9c2d16cd70eb97e2a2b3f
4
- data.tar.gz: '065783a4f62345e2fa7b7a121d090153bdbf67e3b683c2156c40e74238e862b6'
3
+ metadata.gz: dbc8b0a3a6bf05f4ef29f2a5285b452afa1e733f2e166a521ba28e48dc2f94d1
4
+ data.tar.gz: 5ef538eea22fce15ba4356ea06204891b69ec51170706cc804d005f1639107f6
5
5
  SHA512:
6
- metadata.gz: 50711d2a17a5141d4734e5bcc40d10c73b7a43e369561ad74cbdb60de3d6631f804f175f777aed911a369d5aeaf4be619772d330d7c54ab26b8b24bc1d033f24
7
- data.tar.gz: f81b79f8603d00b9c8714a85dd6d927e3e13c4b14d8f204e5dd0eeb172a4c04952e90f8d7419d20a788647125c9e362bb3ed81cd116cd6320414c2ebc2436503
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
- ## v0.5.0
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 Workflow
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) { deploy_workflow(filepath) }
50
+ before(:all) { deploy_process(filepath) }
51
51
  ```
52
52
 
53
- A custom name can also be specified for the workflow:
53
+ A custom name can also be specified for the process:
54
54
 
55
55
  ```ruby
56
- before(:all) { deploy_workflow(filepath, "custom_name") }
56
+ before(:all) { deploy_process(filepath, "custom_name") }
57
57
  ```
58
58
 
59
- ### With Workflow Instance
59
+ ### With Process Instance
60
60
 
61
- The `with_workflow_instance` method is used to create an instance for the specified workflow
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
- with_workflow_instance("file_basename") do
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 workflow by calling `activate_job` (previously `process_job`).
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 workflow
133
- project_job("my_job").
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
- ### Workflow Complete
201
+ ### Process Complete
202
202
 
203
- The `workflow_complete!` method can be used to assert that the current workflow is complete at the end of a
204
- test. This is implemented by cancelling the workflow and checking for an error that it is already
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
- with_workflow_instance("file_basename") do
208
+ with_process_instance("file_basename") do
209
209
  ...
210
210
 
211
- workflow_complete!
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
- # workflow_instance_key is a method that returns the key for the current workflow instance
246
- set_variables(workflow_instance_key, { foo: "bar" })
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 workflow at a time.
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.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.26.1}
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
@@ -3,6 +3,7 @@
3
3
  require "active_support"
4
4
  require "rspec"
5
5
  require "zeebe/client"
6
+ require "zeebe_bpmn_rspec/deprecate_workflow_alias"
6
7
  require "zeebe_bpmn_rspec/helpers"
7
8
  require "zeebe_bpmn_rspec/version"
8
9
  require "zeebe_bpmn_rspec/matchers/have_activated"
@@ -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:, workflow_instance_key:, client:, context:, validate:) # rubocop:disable Metrics/ParameterLists
13
+ def initialize(job, type:, process_instance_key:, client:, context:, validate:) # rubocop:disable Metrics/ParameterLists
13
14
  @job = job
14
15
  @type = type
15
- @workflow_instance_key = workflow_instance_key
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.workflowInstanceKey).to eq(workflow_instance_key)
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 workflow_instance_key
39
- job.workflowInstanceKey
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
- def deploy_workflow(path, name = nil)
11
- _zeebe_client.deploy_workflow(DeployWorkflowRequest.new(
12
- workflows: [WorkflowRequestObject.new(
13
- name: (name && "#{name}.bpmn") || File.basename(path),
14
- type: WorkflowRequestObject::ResourceType::FILE,
15
- definition: File.read(path)
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 workflow: #{e}"
19
+ raise "Failed to deploy precess: #{e}"
20
20
  end
21
+ deprecate_workflow_alias :deploy_workflow, :deploy_process
21
22
 
22
- def with_workflow_instance(name, variables = {})
23
+ def with_process_instance(name, variables = {})
23
24
  system_error = nil
24
- workflow = _zeebe_client.create_workflow_instance(CreateWorkflowInstanceRequest.new(
25
- bpmnProcessId: name,
26
- version: -1, # always latest
27
- variables: variables.to_json
28
- ))
29
- @__workflow_instance_key = workflow.workflowInstanceKey
30
- yield(workflow.workflowInstanceKey) if block_given?
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 workflow&.workflowInstanceKey
37
+ if process&.processInstanceKey
37
38
  begin
38
- _zeebe_client.cancel_workflow_instance(CancelWorkflowInstanceRequest.new(
39
- workflowInstanceKey: workflow.workflowInstanceKey
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 workflow_complete!
52
+ def process_complete!(wait_seconds: 0.25)
51
53
  error = nil
52
- sleep 0.25 # TODO: configurable?
54
+ sleep(wait_seconds)
53
55
  begin
54
- _zeebe_client.cancel_workflow_instance(CancelWorkflowInstanceRequest.new(
55
- workflowInstanceKey: workflow_instance_key
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 workflow instance #{workflow_instance_key} to be complete" if error.nil?
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 workflow_instance_key
65
- @__workflow_instance_key
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
- workflow_instance_key: workflow_instance_key,
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
- # TODO: deprecate process_job
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
- workflow_instance_key: workflow_instance_key,
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
- @__workflow_instance_key = nil
150
+ @__process_instance_key = nil
147
151
  end
148
152
 
149
153
  private
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ZeebeBpmnRspec
4
- VERSION = "0.5.0"
4
+ VERSION = "1.0.0"
5
5
  end
@@ -52,5 +52,5 @@ Gem::Specification.new do |spec|
52
52
 
53
53
  spec.add_runtime_dependency "activesupport"
54
54
  spec.add_runtime_dependency "rspec", "~> 3.4"
55
- spec.add_runtime_dependency "zeebe-client"
55
+ spec.add_runtime_dependency "zeebe-client", "~> 0.14.0"
56
56
  end
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.5.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: '0'
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: '0'
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