dynflow 1.3.0 → 1.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (225) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +1 -1
  3. data/.travis.yml +3 -4
  4. data/Dockerfile +9 -0
  5. data/Gemfile +6 -0
  6. data/Rakefile +1 -0
  7. data/doc/pages/Gemfile +1 -0
  8. data/doc/pages/Rakefile +1 -0
  9. data/doc/pages/plugins/alert_block.rb +1 -0
  10. data/doc/pages/plugins/div_tag.rb +1 -0
  11. data/doc/pages/plugins/graphviz.rb +1 -0
  12. data/doc/pages/plugins/plantuml.rb +1 -0
  13. data/doc/pages/plugins/play.rb +1 -0
  14. data/doc/pages/plugins/tags.rb +1 -0
  15. data/doc/pages/plugins/toc.rb +1 -0
  16. data/docker-compose.yml +41 -0
  17. data/dynflow.gemspec +1 -0
  18. data/examples/clock_benchmark.rb +1 -0
  19. data/examples/example_helper.rb +19 -2
  20. data/examples/future_execution.rb +2 -1
  21. data/examples/memory_limit_watcher.rb +1 -0
  22. data/examples/orchestrate.rb +4 -5
  23. data/examples/orchestrate_evented.rb +3 -2
  24. data/examples/remote_executor.rb +68 -0
  25. data/examples/singletons.rb +4 -3
  26. data/examples/sub_plan_concurrency_control.rb +2 -1
  27. data/examples/sub_plans.rb +3 -2
  28. data/examples/termination.rb +1 -0
  29. data/lib/dynflow.rb +20 -0
  30. data/lib/dynflow/action.rb +28 -3
  31. data/lib/dynflow/action/cancellable.rb +1 -0
  32. data/lib/dynflow/action/format.rb +1 -0
  33. data/lib/dynflow/action/missing.rb +1 -0
  34. data/lib/dynflow/action/polling.rb +3 -1
  35. data/lib/dynflow/action/progress.rb +1 -0
  36. data/lib/dynflow/action/rescue.rb +1 -0
  37. data/lib/dynflow/action/singleton.rb +1 -0
  38. data/lib/dynflow/action/suspended.rb +9 -2
  39. data/lib/dynflow/action/timeouts.rb +2 -1
  40. data/lib/dynflow/action/with_bulk_sub_plans.rb +2 -1
  41. data/lib/dynflow/action/with_polling_sub_plans.rb +7 -5
  42. data/lib/dynflow/action/with_sub_plans.rb +1 -0
  43. data/lib/dynflow/active_job/queue_adapter.rb +1 -0
  44. data/lib/dynflow/actor.rb +13 -5
  45. data/lib/dynflow/actors.rb +1 -0
  46. data/lib/dynflow/actors/execution_plan_cleaner.rb +1 -0
  47. data/lib/dynflow/clock.rb +27 -47
  48. data/lib/dynflow/config.rb +11 -2
  49. data/lib/dynflow/connectors.rb +1 -0
  50. data/lib/dynflow/connectors/abstract.rb +1 -0
  51. data/lib/dynflow/connectors/database.rb +1 -0
  52. data/lib/dynflow/connectors/direct.rb +1 -0
  53. data/lib/dynflow/coordinator.rb +1 -0
  54. data/lib/dynflow/coordinator_adapters.rb +1 -0
  55. data/lib/dynflow/coordinator_adapters/abstract.rb +1 -0
  56. data/lib/dynflow/coordinator_adapters/sequel.rb +1 -0
  57. data/lib/dynflow/dead_letter_silencer.rb +2 -0
  58. data/lib/dynflow/debug/telemetry/persistence.rb +1 -0
  59. data/lib/dynflow/delayed_executors.rb +1 -0
  60. data/lib/dynflow/delayed_executors/abstract.rb +1 -0
  61. data/lib/dynflow/delayed_executors/abstract_core.rb +1 -0
  62. data/lib/dynflow/delayed_executors/polling.rb +1 -0
  63. data/lib/dynflow/delayed_plan.rb +1 -0
  64. data/lib/dynflow/director.rb +80 -15
  65. data/lib/dynflow/director/execution_plan_manager.rb +17 -3
  66. data/lib/dynflow/director/flow_manager.rb +1 -0
  67. data/lib/dynflow/director/{work_queue.rb → queue_hash.rb} +9 -8
  68. data/lib/dynflow/director/running_steps_manager.rb +55 -18
  69. data/lib/dynflow/director/sequence_cursor.rb +1 -0
  70. data/lib/dynflow/director/sequential_manager.rb +12 -2
  71. data/lib/dynflow/dispatcher.rb +4 -2
  72. data/lib/dynflow/dispatcher/abstract.rb +1 -0
  73. data/lib/dynflow/dispatcher/client_dispatcher.rb +6 -4
  74. data/lib/dynflow/dispatcher/executor_dispatcher.rb +13 -1
  75. data/lib/dynflow/errors.rb +1 -0
  76. data/lib/dynflow/execution_history.rb +1 -0
  77. data/lib/dynflow/execution_plan.rb +3 -2
  78. data/lib/dynflow/execution_plan/dependency_graph.rb +1 -0
  79. data/lib/dynflow/execution_plan/hooks.rb +1 -0
  80. data/lib/dynflow/execution_plan/output_reference.rb +2 -1
  81. data/lib/dynflow/execution_plan/steps.rb +1 -0
  82. data/lib/dynflow/execution_plan/steps/abstract.rb +10 -5
  83. data/lib/dynflow/execution_plan/steps/abstract_flow_step.rb +2 -0
  84. data/lib/dynflow/execution_plan/steps/error.rb +1 -0
  85. data/lib/dynflow/execution_plan/steps/finalize_step.rb +1 -0
  86. data/lib/dynflow/execution_plan/steps/plan_step.rb +1 -0
  87. data/lib/dynflow/execution_plan/steps/run_step.rb +1 -0
  88. data/lib/dynflow/executors.rb +1 -1
  89. data/lib/dynflow/executors/abstract/core.rb +132 -0
  90. data/lib/dynflow/executors/parallel.rb +24 -11
  91. data/lib/dynflow/executors/parallel/core.rb +10 -91
  92. data/lib/dynflow/executors/parallel/pool.rb +4 -2
  93. data/lib/dynflow/executors/parallel/worker.rb +2 -1
  94. data/lib/dynflow/executors/sidekiq/core.rb +121 -0
  95. data/lib/dynflow/executors/sidekiq/internal_job_base.rb +24 -0
  96. data/lib/dynflow/executors/sidekiq/orchestrator_jobs.rb +60 -0
  97. data/lib/dynflow/executors/sidekiq/redis_locking.rb +69 -0
  98. data/lib/dynflow/executors/sidekiq/serialization.rb +33 -0
  99. data/lib/dynflow/executors/sidekiq/worker_jobs.rb +42 -0
  100. data/lib/dynflow/flows.rb +1 -0
  101. data/lib/dynflow/flows/abstract.rb +1 -0
  102. data/lib/dynflow/flows/abstract_composed.rb +1 -0
  103. data/lib/dynflow/flows/atom.rb +1 -0
  104. data/lib/dynflow/flows/concurrence.rb +1 -0
  105. data/lib/dynflow/flows/sequence.rb +1 -0
  106. data/lib/dynflow/logger_adapters.rb +1 -0
  107. data/lib/dynflow/logger_adapters/abstract.rb +1 -0
  108. data/lib/dynflow/logger_adapters/delegator.rb +1 -0
  109. data/lib/dynflow/logger_adapters/formatters.rb +1 -0
  110. data/lib/dynflow/logger_adapters/formatters/abstract.rb +1 -0
  111. data/lib/dynflow/logger_adapters/formatters/exception.rb +1 -0
  112. data/lib/dynflow/logger_adapters/simple.rb +1 -0
  113. data/lib/dynflow/middleware.rb +1 -0
  114. data/lib/dynflow/middleware/common/singleton.rb +1 -0
  115. data/lib/dynflow/middleware/common/transaction.rb +1 -0
  116. data/lib/dynflow/middleware/register.rb +1 -0
  117. data/lib/dynflow/middleware/resolver.rb +1 -0
  118. data/lib/dynflow/middleware/stack.rb +1 -0
  119. data/lib/dynflow/middleware/world.rb +1 -0
  120. data/lib/dynflow/persistence.rb +3 -2
  121. data/lib/dynflow/persistence_adapters.rb +1 -0
  122. data/lib/dynflow/persistence_adapters/abstract.rb +1 -0
  123. data/lib/dynflow/persistence_adapters/sequel.rb +10 -7
  124. data/lib/dynflow/persistence_adapters/sequel_migrations/001_initial.rb +1 -0
  125. data/lib/dynflow/persistence_adapters/sequel_migrations/002_incremental_progress.rb +1 -0
  126. data/lib/dynflow/persistence_adapters/sequel_migrations/003_parent_action.rb +1 -0
  127. data/lib/dynflow/persistence_adapters/sequel_migrations/004_coordinator_records.rb +1 -0
  128. data/lib/dynflow/persistence_adapters/sequel_migrations/005_envelopes.rb +1 -0
  129. data/lib/dynflow/persistence_adapters/sequel_migrations/006_fix_data_length.rb +1 -0
  130. data/lib/dynflow/persistence_adapters/sequel_migrations/007_future_execution.rb +1 -0
  131. data/lib/dynflow/persistence_adapters/sequel_migrations/008_rename_scheduled_plans_to_delayed_plans.rb +1 -0
  132. data/lib/dynflow/persistence_adapters/sequel_migrations/009_fix_mysql_data_length.rb +1 -0
  133. data/lib/dynflow/persistence_adapters/sequel_migrations/010_add_execution_plans_label.rb +1 -0
  134. data/lib/dynflow/persistence_adapters/sequel_migrations/011_placeholder.rb +1 -0
  135. data/lib/dynflow/persistence_adapters/sequel_migrations/012_add_delayed_plans_serialized_args.rb +1 -0
  136. data/lib/dynflow/persistence_adapters/sequel_migrations/013_add_action_columns.rb +1 -0
  137. data/lib/dynflow/persistence_adapters/sequel_migrations/014_add_step_columns.rb +1 -0
  138. data/lib/dynflow/persistence_adapters/sequel_migrations/015_add_execution_plan_columns.rb +1 -0
  139. data/lib/dynflow/persistence_adapters/sequel_migrations/016_add_step_queue.rb +1 -0
  140. data/lib/dynflow/persistence_adapters/sequel_migrations/017_add_delayed_plan_frozen.rb +1 -0
  141. data/lib/dynflow/persistence_adapters/sequel_migrations/018_add_uuid_column.rb +1 -0
  142. data/lib/dynflow/persistence_adapters/sequel_migrations/019_update_mysql_time_precision.rb +48 -0
  143. data/lib/dynflow/rails.rb +1 -0
  144. data/lib/dynflow/rails/configuration.rb +6 -3
  145. data/lib/dynflow/rails/daemon.rb +1 -0
  146. data/lib/dynflow/round_robin.rb +1 -0
  147. data/lib/dynflow/semaphores.rb +1 -0
  148. data/lib/dynflow/semaphores/abstract.rb +1 -0
  149. data/lib/dynflow/semaphores/aggregating.rb +1 -0
  150. data/lib/dynflow/semaphores/dummy.rb +1 -0
  151. data/lib/dynflow/semaphores/stateful.rb +1 -0
  152. data/lib/dynflow/serializable.rb +13 -4
  153. data/lib/dynflow/serializer.rb +24 -0
  154. data/lib/dynflow/serializers.rb +1 -0
  155. data/lib/dynflow/serializers/abstract.rb +1 -0
  156. data/lib/dynflow/serializers/noop.rb +1 -0
  157. data/lib/dynflow/stateful.rb +1 -0
  158. data/lib/dynflow/telemetry.rb +1 -0
  159. data/lib/dynflow/telemetry_adapters/abstract.rb +1 -0
  160. data/lib/dynflow/telemetry_adapters/dummy.rb +1 -0
  161. data/lib/dynflow/telemetry_adapters/statsd.rb +1 -0
  162. data/lib/dynflow/testing.rb +1 -0
  163. data/lib/dynflow/testing/assertions.rb +6 -5
  164. data/lib/dynflow/testing/dummy_execution_plan.rb +1 -0
  165. data/lib/dynflow/testing/dummy_executor.rb +19 -2
  166. data/lib/dynflow/testing/dummy_planned_action.rb +1 -0
  167. data/lib/dynflow/testing/dummy_step.rb +3 -1
  168. data/lib/dynflow/testing/dummy_world.rb +9 -0
  169. data/lib/dynflow/testing/factories.rb +6 -1
  170. data/lib/dynflow/testing/in_thread_executor.rb +22 -3
  171. data/lib/dynflow/testing/in_thread_world.rb +9 -0
  172. data/lib/dynflow/testing/managed_clock.rb +1 -0
  173. data/lib/dynflow/testing/mimic.rb +1 -0
  174. data/lib/dynflow/throttle_limiter.rb +1 -0
  175. data/lib/dynflow/transaction_adapters.rb +1 -0
  176. data/lib/dynflow/transaction_adapters/abstract.rb +1 -0
  177. data/lib/dynflow/transaction_adapters/active_record.rb +1 -0
  178. data/lib/dynflow/transaction_adapters/none.rb +1 -0
  179. data/lib/dynflow/utils.rb +1 -0
  180. data/lib/dynflow/utils/indifferent_hash.rb +1 -0
  181. data/lib/dynflow/utils/priority_queue.rb +1 -0
  182. data/lib/dynflow/version.rb +2 -1
  183. data/lib/dynflow/watchers/memory_consumption_watcher.rb +1 -0
  184. data/lib/dynflow/web.rb +1 -0
  185. data/lib/dynflow/web/console.rb +1 -0
  186. data/lib/dynflow/web/console_helpers.rb +1 -0
  187. data/lib/dynflow/web/filtering_helpers.rb +1 -0
  188. data/lib/dynflow/web/world_helpers.rb +1 -0
  189. data/lib/dynflow/web_console.rb +1 -0
  190. data/lib/dynflow/world.rb +11 -1
  191. data/lib/dynflow/world/invalidation.rb +7 -1
  192. data/test/abnormal_states_recovery_test.rb +41 -40
  193. data/test/action_test.rb +160 -110
  194. data/test/activejob_adapter_test.rb +1 -0
  195. data/test/batch_sub_tasks_test.rb +12 -11
  196. data/test/clock_test.rb +2 -1
  197. data/test/concurrency_control_test.rb +20 -19
  198. data/test/coordinator_test.rb +20 -21
  199. data/test/daemon_test.rb +2 -1
  200. data/test/dead_letter_silencer_test.rb +9 -7
  201. data/test/dispatcher_test.rb +2 -1
  202. data/test/execution_plan_cleaner_test.rb +13 -12
  203. data/test/execution_plan_hooks_test.rb +3 -2
  204. data/test/execution_plan_test.rb +33 -32
  205. data/test/executor_test.rb +533 -489
  206. data/test/future_execution_test.rb +45 -44
  207. data/test/memory_cosumption_watcher_test.rb +5 -4
  208. data/test/middleware_test.rb +55 -54
  209. data/test/persistence_test.rb +56 -53
  210. data/test/rescue_test.rb +36 -35
  211. data/test/round_robin_test.rb +13 -12
  212. data/test/semaphores_test.rb +31 -30
  213. data/test/support/code_workflow_example.rb +1 -0
  214. data/test/support/dummy_example.rb +14 -1
  215. data/test/support/middleware_example.rb +2 -1
  216. data/test/support/rails/config/environment.rb +1 -0
  217. data/test/support/rescue_example.rb +1 -0
  218. data/test/support/test_execution_log.rb +1 -0
  219. data/test/test_helper.rb +18 -17
  220. data/test/testing_test.rb +45 -44
  221. data/test/utils_test.rb +18 -17
  222. data/test/web_console_test.rb +1 -0
  223. data/test/world_test.rb +7 -6
  224. metadata +13 -4
  225. data/lib/dynflow/executors/abstract.rb +0 -40
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require_relative 'test_helper'
2
3
 
3
4
  module Dynflow
@@ -26,11 +27,11 @@ module Dynflow
26
27
  end
27
28
 
28
29
  it 'suggests skipping the action' do
29
- execution_plan.rescue_strategy.must_equal Action::Rescue::Skip
30
+ _(execution_plan.rescue_strategy).must_equal Action::Rescue::Skip
30
31
  end
31
32
 
32
33
  it "doesn't rescue" do
33
- rescued_plan.state.must_equal :paused
34
+ _(rescued_plan.state).must_equal :paused
34
35
  end
35
36
  end
36
37
 
@@ -41,11 +42,11 @@ module Dynflow
41
42
  end
42
43
 
43
44
  it 'suggests skipping the action' do
44
- execution_plan.rescue_strategy.must_equal Action::Rescue::Skip
45
+ _(execution_plan.rescue_strategy).must_equal Action::Rescue::Skip
45
46
  end
46
47
 
47
48
  it "doesn't rescue" do
48
- rescued_plan.state.must_equal :paused
49
+ _(rescued_plan.state).must_equal :paused
49
50
  end
50
51
  end
51
52
 
@@ -56,11 +57,11 @@ module Dynflow
56
57
  end
57
58
 
58
59
  it 'suggests skipping the action' do
59
- execution_plan.rescue_strategy.must_equal Action::Rescue::Skip
60
+ _(execution_plan.rescue_strategy).must_equal Action::Rescue::Skip
60
61
  end
61
62
 
62
63
  it "doesn't rescue" do
63
- rescued_plan.state.must_equal :paused
64
+ _(rescued_plan.state).must_equal :paused
64
65
  end
65
66
  end
66
67
 
@@ -71,11 +72,11 @@ module Dynflow
71
72
  end
72
73
 
73
74
  it 'suggests skipping the action' do
74
- execution_plan.rescue_strategy.must_equal Action::Rescue::Skip
75
+ _(execution_plan.rescue_strategy).must_equal Action::Rescue::Skip
75
76
  end
76
77
 
77
78
  it "doesn't rescue" do
78
- rescued_plan.state.must_equal :paused
79
+ _(rescued_plan.state).must_equal :paused
79
80
  end
80
81
  end
81
82
 
@@ -86,11 +87,11 @@ module Dynflow
86
87
  end
87
88
 
88
89
  it 'suggests pausing the plan' do
89
- execution_plan.rescue_strategy.must_equal Action::Rescue::Pause
90
+ _(execution_plan.rescue_strategy).must_equal Action::Rescue::Pause
90
91
  end
91
92
 
92
93
  it "doesn't rescue" do
93
- rescued_plan.state.must_equal :paused
94
+ _(rescued_plan.state).must_equal :paused
94
95
  end
95
96
  end
96
97
 
@@ -101,11 +102,11 @@ module Dynflow
101
102
  end
102
103
 
103
104
  it 'suggests failing the plan' do
104
- execution_plan.rescue_strategy.must_equal Action::Rescue::Fail
105
+ _(execution_plan.rescue_strategy).must_equal Action::Rescue::Fail
105
106
  end
106
107
 
107
108
  it "doesn't rescue" do
108
- rescued_plan.state.must_equal :paused
109
+ _(rescued_plan.state).must_equal :paused
109
110
  end
110
111
  end
111
112
  end
@@ -124,9 +125,9 @@ module Dynflow
124
125
  end
125
126
 
126
127
  it 'skips the action and continues' do
127
- rescued_plan.state.must_equal :stopped
128
- rescued_plan.result.must_equal :warning
129
- rescued_plan.entry_action.output[:message].
128
+ _(rescued_plan.state).must_equal :stopped
129
+ _(rescued_plan.result).must_equal :warning
130
+ _(rescued_plan.entry_action.output[:message]).
130
131
  must_equal "skipped because some error as you wish"
131
132
  end
132
133
  end
@@ -137,9 +138,9 @@ module Dynflow
137
138
  end
138
139
 
139
140
  it 'skips the action and continues' do
140
- rescued_plan.state.must_equal :stopped
141
- rescued_plan.result.must_equal :warning
142
- rescued_plan.entry_action.output[:message].must_equal "Been here"
141
+ _(rescued_plan.state).must_equal :stopped
142
+ _(rescued_plan.result).must_equal :warning
143
+ _(rescued_plan.entry_action.output[:message]).must_equal "Been here"
143
144
  end
144
145
  end
145
146
 
@@ -149,12 +150,12 @@ module Dynflow
149
150
  end
150
151
 
151
152
  it 'skips the action and continues automatically' do
152
- execution_plan.state.must_equal :stopped
153
- execution_plan.result.must_equal :warning
153
+ _(execution_plan.state).must_equal :stopped
154
+ _(execution_plan.result).must_equal :warning
154
155
  skipped_action = rescued_plan.actions.find do |action|
155
156
  action.run_step && action.run_step.state == :skipped
156
157
  end
157
- skipped_action.output[:message].must_equal "skipped because some error as you wish"
158
+ _(skipped_action.output[:message]).must_equal "skipped because some error as you wish"
158
159
  end
159
160
  end
160
161
 
@@ -164,12 +165,12 @@ module Dynflow
164
165
  end
165
166
 
166
167
  it 'skips the action and continues' do
167
- rescued_plan.state.must_equal :stopped
168
- rescued_plan.result.must_equal :warning
168
+ _(rescued_plan.state).must_equal :stopped
169
+ _(rescued_plan.result).must_equal :warning
169
170
  skipped_action = rescued_plan.actions.find do |action|
170
171
  action.steps.find { |step| step && step.state == :skipped }
171
172
  end
172
- skipped_action.output[:message].must_equal "Been here"
173
+ _(skipped_action.output[:message]).must_equal "Been here"
173
174
  end
174
175
  end
175
176
 
@@ -179,8 +180,8 @@ module Dynflow
179
180
  end
180
181
 
181
182
  it 'tried to rescue only once' do
182
- execution_plan.state.must_equal :paused
183
- execution_plan.result.must_equal :error
183
+ _(execution_plan.state).must_equal :paused
184
+ _(execution_plan.result).must_equal :error
184
185
  end
185
186
  end
186
187
 
@@ -190,11 +191,11 @@ module Dynflow
190
191
  end
191
192
 
192
193
  it 'skips the action and continues automatically' do
193
- execution_plan.state.must_equal :paused
194
- execution_plan.result.must_equal :error
194
+ _(execution_plan.state).must_equal :paused
195
+ _(execution_plan.result).must_equal :error
195
196
  expected_history = [['start execution', world.id],
196
197
  ['pause execution', world.id]]
197
- execution_plan.execution_history.map { |h| [h.name, h.world_id] }.must_equal(expected_history)
198
+ _(execution_plan.execution_history.map { |h| [h.name, h.world_id] }).must_equal(expected_history)
198
199
  end
199
200
  end
200
201
 
@@ -204,14 +205,14 @@ module Dynflow
204
205
  end
205
206
 
206
207
  it 'fails the execution plan automatically' do
207
- execution_plan.state.must_equal :stopped
208
- execution_plan.result.must_equal :error
209
- execution_plan.steps_in_state(:success).count.must_equal 6
210
- execution_plan.steps_in_state(:pending).count.must_equal 6
211
- execution_plan.steps_in_state(:error).count.must_equal 1
208
+ _(execution_plan.state).must_equal :stopped
209
+ _(execution_plan.result).must_equal :error
210
+ _(execution_plan.steps_in_state(:success).count).must_equal 6
211
+ _(execution_plan.steps_in_state(:pending).count).must_equal 6
212
+ _(execution_plan.steps_in_state(:error).count).must_equal 1
212
213
  expected_history = [['start execution', world.id],
213
214
  ['finish execution', world.id]]
214
- execution_plan.execution_history.map { |h| [h.name, h.world_id] }.must_equal(expected_history)
215
+ _(execution_plan.execution_history.map { |h| [h.name, h.world_id] }).must_equal(expected_history)
215
216
  end
216
217
  end
217
218
 
@@ -1,4 +1,5 @@
1
1
  # -*- coding: utf-8 -*-
2
+ # frozen_string_literal: true
2
3
  require_relative 'test_helper'
3
4
 
4
5
  module Dynflow
@@ -6,22 +7,22 @@ module Dynflow
6
7
  describe RoundRobin do
7
8
  let(:rr) { Dynflow::RoundRobin.new }
8
9
  specify do
9
- rr.next.must_be_nil
10
- rr.next.must_be_nil
11
- rr.must_be_empty
10
+ assert_nil rr.next
11
+ assert_nil rr.next
12
+ _(rr).must_be_empty
12
13
  rr.add 1
13
- rr.next.must_equal 1
14
- rr.next.must_equal 1
14
+ _(rr.next).must_equal 1
15
+ _(rr.next).must_equal 1
15
16
  rr.add 2
16
- rr.next.must_equal 2
17
- rr.next.must_equal 1
18
- rr.next.must_equal 2
17
+ _(rr.next).must_equal 2
18
+ _(rr.next).must_equal 1
19
+ _(rr.next).must_equal 2
19
20
  rr.delete 1
20
- rr.next.must_equal 2
21
- rr.next.must_equal 2
21
+ _(rr.next).must_equal 2
22
+ _(rr.next).must_equal 2
22
23
  rr.delete 2
23
- rr.next.must_be_nil
24
- rr.must_be_empty
24
+ assert_nil rr.next
25
+ _(rr).must_be_empty
25
26
  end
26
27
  end
27
28
  end
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require_relative 'test_helper'
2
3
 
3
4
  module Dynflow
@@ -10,35 +11,35 @@ module Dynflow
10
11
  it 'can be used as counter' do
11
12
  expected_state = { :tickets => tickets_count, :free => 4, :meta => {} }
12
13
  semaphore = semaphore_class.new(tickets_count)
13
- semaphore.tickets.must_equal tickets_count
14
- semaphore.free.must_equal tickets_count
15
- semaphore.waiting.must_be_empty
16
- semaphore.get.must_equal 1
17
- semaphore.free.must_equal tickets_count - 1
18
- semaphore.get(3).must_equal 3
19
- semaphore.free.must_equal tickets_count - (3 + 1)
20
- semaphore.drain.must_equal 1
21
- semaphore.free.must_equal tickets_count - (3 + 1 + 1)
14
+ _(semaphore.tickets).must_equal tickets_count
15
+ _(semaphore.free).must_equal tickets_count
16
+ _(semaphore.waiting).must_be_empty
17
+ _(semaphore.get).must_equal 1
18
+ _(semaphore.free).must_equal tickets_count - 1
19
+ _(semaphore.get(3)).must_equal 3
20
+ _(semaphore.free).must_equal tickets_count - (3 + 1)
21
+ _(semaphore.drain).must_equal 1
22
+ _(semaphore.free).must_equal tickets_count - (3 + 1 + 1)
22
23
  semaphore.release
23
- semaphore.free.must_equal tickets_count - (3 + 1)
24
+ _(semaphore.free).must_equal tickets_count - (3 + 1)
24
25
  semaphore.release 3
25
- semaphore.free.must_equal tickets_count - 1
26
- semaphore.to_hash.must_equal expected_state
26
+ _(semaphore.free).must_equal tickets_count - 1
27
+ _(semaphore.to_hash).must_equal expected_state
27
28
  end
28
29
 
29
30
  it 'can have things waiting on it' do
30
31
  semaphore = semaphore_class.new 1
31
32
  allowed = semaphore.wait(1)
32
- allowed.must_equal true
33
- semaphore.free.must_equal 0
33
+ _(allowed).must_equal true
34
+ _(semaphore.free).must_equal 0
34
35
  allowed = semaphore.wait(2)
35
- allowed.must_equal false
36
+ _(allowed).must_equal false
36
37
  allowed = semaphore.wait(3)
37
- allowed.must_equal false
38
+ _(allowed).must_equal false
38
39
  waiting = semaphore.get_waiting
39
- waiting.must_equal 2
40
+ _(waiting).must_equal 2
40
41
  waiting = semaphore.get_waiting
41
- waiting.must_equal 3
42
+ _(waiting).must_equal 3
42
43
  end
43
44
 
44
45
  end
@@ -48,15 +49,15 @@ module Dynflow
48
49
 
49
50
  it 'always has free' do
50
51
  semaphore = semaphore_class.new
51
- semaphore.free.must_equal 1
52
- semaphore.get(5).must_equal 5
53
- semaphore.free.must_equal 1
52
+ _(semaphore.free).must_equal 1
53
+ _(semaphore.get(5)).must_equal 5
54
+ _(semaphore.free).must_equal 1
54
55
  end
55
56
 
56
57
  it 'cannot have things waiting on it' do
57
58
  semaphore = semaphore_class.new
58
- semaphore.wait(1).must_equal true
59
- semaphore.has_waiting?.must_equal false
59
+ _(semaphore.wait(1)).must_equal true
60
+ _(semaphore.has_waiting?).must_equal false
60
61
  end
61
62
  end
62
63
 
@@ -71,25 +72,25 @@ module Dynflow
71
72
  end
72
73
 
73
74
  def assert_semaphore_state(semaphore, state_A, state_B)
74
- semaphore.children[:child_A].free.must_equal state_A
75
- semaphore.children[:child_B].free.must_equal state_B
76
- semaphore.free.must_equal [state_A, state_B].min
75
+ _(semaphore.children[:child_A].free).must_equal state_A
76
+ _(semaphore.children[:child_B].free).must_equal state_B
77
+ _(semaphore.free).must_equal [state_A, state_B].min
77
78
  end
78
79
 
79
80
  it 'can be used as counter' do
80
81
  semaphore = semaphore_class.new(children)
81
82
  assert_semaphore_state semaphore, 3, 2
82
- semaphore.get.must_equal 1
83
+ _(semaphore.get).must_equal 1
83
84
  assert_semaphore_state semaphore, 2, 1
84
- semaphore.get.must_equal 1
85
+ _(semaphore.get).must_equal 1
85
86
  assert_semaphore_state semaphore, 1, 0
86
- semaphore.get.must_equal 0
87
+ _(semaphore.get).must_equal 0
87
88
  assert_semaphore_state semaphore, 1, 0
88
89
  semaphore.release
89
90
  assert_semaphore_state semaphore, 2, 1
90
91
  semaphore.release(1, :child_B)
91
92
  assert_semaphore_state semaphore, 2, 2
92
- semaphore.drain.must_equal 2
93
+ _(semaphore.drain).must_equal 2
93
94
  assert_semaphore_state semaphore, 0, 0
94
95
  end
95
96
  end
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'logger'
2
3
 
3
4
  module Support
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'logger'
2
3
 
3
4
  module Support
@@ -114,7 +115,7 @@ module Support
114
115
  end
115
116
  end
116
117
 
117
- class EventedAction < Dynflow::Action
118
+ class DeprecatedEventedAction < Dynflow::Action
118
119
  def run(event = nil)
119
120
  case event
120
121
  when "timeout"
@@ -132,6 +133,18 @@ module Support
132
133
  end
133
134
  end
134
135
 
136
+ class PlanEventsAction < Dynflow::Action
137
+ def run(event = nil)
138
+ case event
139
+ when 'ping'
140
+ output[:result] = 'pinged'
141
+ when nil
142
+ plan_event('ping', input[:ping_time] || 0.5)
143
+ suspend
144
+ end
145
+ end
146
+ end
147
+
135
148
  class ComposedAction < Dynflow::Action
136
149
  def run(event = nil)
137
150
  match event,
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Support
2
3
  module MiddlewareExample
3
4
  class LogMiddleware < Dynflow::Middleware
@@ -99,7 +100,7 @@ module Support
99
100
  end
100
101
 
101
102
  def filter_sensitive_data
102
- output[:spell] = '***'
103
+ output[:spell] = '***'.dup
103
104
  end
104
105
  end
105
106
 
@@ -1 +1,2 @@
1
+ # frozen_string_literal: true
1
2
  # This is a mock
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'logger'
2
3
 
3
4
  module Support
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  class TestExecutionLog
2
3
 
3
4
  include Enumerable
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'bundler/setup'
2
3
  require 'minitest/reporters'
3
4
  require 'minitest/autorun'
@@ -110,7 +111,7 @@ module WorldFactory
110
111
  # This world survives though the whole run of the test suite: careful with it, it can
111
112
  # introduce unnecessary test dependencies
112
113
  def self.logger_adapter
113
- @adapter ||= Dynflow::LoggerAdapters::Simple.new $stderr, 4
114
+ @adapter ||= Dynflow::LoggerAdapters::Simple.new $stderr, ::Logger::FATAL
114
115
  end
115
116
 
116
117
  def self.persistence_adapter
@@ -176,7 +177,7 @@ module TestHelpers
176
177
  return ret if ret
177
178
  sleep 0.3
178
179
  end
179
- raise "waiting for #{waiting_message} was not successful"
180
+ assert false, "waiting for #{waiting_message} was not successful"
180
181
  end
181
182
 
182
183
  def executor_id_for_plan(execution_plan_id)
@@ -187,7 +188,7 @@ module TestHelpers
187
188
  end
188
189
 
189
190
  def trigger_waiting_action
190
- triggered = client_world.trigger(Support::DummyExample::EventedAction)
191
+ triggered = client_world.trigger(Support::DummyExample::DeprecatedEventedAction)
191
192
  wait_for { executor_id_for_plan(triggered.id) } # waiting for the plan to be picked by an executor
192
193
  triggered
193
194
  end
@@ -332,29 +333,29 @@ end
332
333
  module PlanAssertions
333
334
 
334
335
  def inspect_flow(execution_plan, flow)
335
- out = ""
336
- inspect_subflow(out, execution_plan, flow, "")
336
+ out = "".dup
337
+ inspect_subflow(out, execution_plan, flow, "".dup)
337
338
  out
338
339
  end
339
340
 
340
341
  def inspect_plan_steps(execution_plan)
341
- out = ""
342
- inspect_plan_step(out, execution_plan, execution_plan.root_plan_step, "")
342
+ out = "".dup
343
+ inspect_plan_step(out, execution_plan, execution_plan.root_plan_step, "".dup)
343
344
  out
344
345
  end
345
346
 
346
347
  def assert_planning_success(execution_plan)
347
- execution_plan.plan_steps.all? { |plan_step| plan_step.state.must_equal :success, plan_step.error }
348
+ execution_plan.plan_steps.all? { |plan_step| _(plan_step.state).must_equal :success, plan_step.error }
348
349
  end
349
350
 
350
351
  def assert_run_flow(expected, execution_plan)
351
352
  assert_planning_success(execution_plan)
352
- inspect_flow(execution_plan, execution_plan.run_flow).chomp.must_equal dedent(expected).chomp
353
+ _(inspect_flow(execution_plan, execution_plan.run_flow).chomp).must_equal dedent(expected).chomp
353
354
  end
354
355
 
355
356
  def assert_finalize_flow(expected, execution_plan)
356
357
  assert_planning_success(execution_plan)
357
- inspect_flow(execution_plan, execution_plan.finalize_flow).chomp.must_equal dedent(expected).chomp
358
+ _(inspect_flow(execution_plan, execution_plan.finalize_flow).chomp).must_equal dedent(expected).chomp
358
359
  end
359
360
 
360
361
  def assert_run_flow_equal(expected_plan, execution_plan)
@@ -364,19 +365,19 @@ module PlanAssertions
364
365
  end
365
366
 
366
367
  def assert_steps_equal(expected, current)
367
- current.id.must_equal expected.id
368
- current.class.must_equal expected.class
369
- current.state.must_equal expected.state
370
- current.action_class.must_equal expected.action_class
371
- current.action_id.must_equal expected.action_id
368
+ _(current.id).must_equal expected.id
369
+ _(current.class).must_equal expected.class
370
+ _(current.state).must_equal expected.state
371
+ _(current.action_class).must_equal expected.action_class
372
+ _(current.action_id).must_equal expected.action_id
372
373
 
373
374
  if expected.respond_to?(:children)
374
- current.children.must_equal(expected.children)
375
+ _(current.children).must_equal(expected.children)
375
376
  end
376
377
  end
377
378
 
378
379
  def assert_plan_steps(expected, execution_plan)
379
- inspect_plan_steps(execution_plan).chomp.must_equal dedent(expected).chomp
380
+ _(inspect_plan_steps(execution_plan).chomp).must_equal dedent(expected).chomp
380
381
  end
381
382
 
382
383
  def assert_finalized(action_class, input)