dynflow 1.3.0 → 1.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +1 -1
- data/.travis.yml +3 -4
- data/Dockerfile +9 -0
- data/Gemfile +6 -0
- data/Rakefile +1 -0
- data/doc/pages/Gemfile +1 -0
- data/doc/pages/Rakefile +1 -0
- data/doc/pages/plugins/alert_block.rb +1 -0
- data/doc/pages/plugins/div_tag.rb +1 -0
- data/doc/pages/plugins/graphviz.rb +1 -0
- data/doc/pages/plugins/plantuml.rb +1 -0
- data/doc/pages/plugins/play.rb +1 -0
- data/doc/pages/plugins/tags.rb +1 -0
- data/doc/pages/plugins/toc.rb +1 -0
- data/docker-compose.yml +41 -0
- data/dynflow.gemspec +1 -0
- data/examples/clock_benchmark.rb +1 -0
- data/examples/example_helper.rb +19 -2
- data/examples/future_execution.rb +2 -1
- data/examples/memory_limit_watcher.rb +1 -0
- data/examples/orchestrate.rb +4 -5
- data/examples/orchestrate_evented.rb +3 -2
- data/examples/remote_executor.rb +68 -0
- data/examples/singletons.rb +4 -3
- data/examples/sub_plan_concurrency_control.rb +2 -1
- data/examples/sub_plans.rb +3 -2
- data/examples/termination.rb +1 -0
- data/lib/dynflow.rb +20 -0
- data/lib/dynflow/action.rb +28 -3
- data/lib/dynflow/action/cancellable.rb +1 -0
- data/lib/dynflow/action/format.rb +1 -0
- data/lib/dynflow/action/missing.rb +1 -0
- data/lib/dynflow/action/polling.rb +3 -1
- data/lib/dynflow/action/progress.rb +1 -0
- data/lib/dynflow/action/rescue.rb +1 -0
- data/lib/dynflow/action/singleton.rb +1 -0
- data/lib/dynflow/action/suspended.rb +9 -2
- data/lib/dynflow/action/timeouts.rb +2 -1
- data/lib/dynflow/action/with_bulk_sub_plans.rb +2 -1
- data/lib/dynflow/action/with_polling_sub_plans.rb +7 -5
- data/lib/dynflow/action/with_sub_plans.rb +1 -0
- data/lib/dynflow/active_job/queue_adapter.rb +1 -0
- data/lib/dynflow/actor.rb +13 -5
- data/lib/dynflow/actors.rb +1 -0
- data/lib/dynflow/actors/execution_plan_cleaner.rb +1 -0
- data/lib/dynflow/clock.rb +27 -47
- data/lib/dynflow/config.rb +11 -2
- data/lib/dynflow/connectors.rb +1 -0
- data/lib/dynflow/connectors/abstract.rb +1 -0
- data/lib/dynflow/connectors/database.rb +1 -0
- data/lib/dynflow/connectors/direct.rb +1 -0
- data/lib/dynflow/coordinator.rb +1 -0
- data/lib/dynflow/coordinator_adapters.rb +1 -0
- data/lib/dynflow/coordinator_adapters/abstract.rb +1 -0
- data/lib/dynflow/coordinator_adapters/sequel.rb +1 -0
- data/lib/dynflow/dead_letter_silencer.rb +2 -0
- data/lib/dynflow/debug/telemetry/persistence.rb +1 -0
- data/lib/dynflow/delayed_executors.rb +1 -0
- data/lib/dynflow/delayed_executors/abstract.rb +1 -0
- data/lib/dynflow/delayed_executors/abstract_core.rb +1 -0
- data/lib/dynflow/delayed_executors/polling.rb +1 -0
- data/lib/dynflow/delayed_plan.rb +1 -0
- data/lib/dynflow/director.rb +80 -15
- data/lib/dynflow/director/execution_plan_manager.rb +17 -3
- data/lib/dynflow/director/flow_manager.rb +1 -0
- data/lib/dynflow/director/{work_queue.rb → queue_hash.rb} +9 -8
- data/lib/dynflow/director/running_steps_manager.rb +55 -18
- data/lib/dynflow/director/sequence_cursor.rb +1 -0
- data/lib/dynflow/director/sequential_manager.rb +12 -2
- data/lib/dynflow/dispatcher.rb +4 -2
- data/lib/dynflow/dispatcher/abstract.rb +1 -0
- data/lib/dynflow/dispatcher/client_dispatcher.rb +6 -4
- data/lib/dynflow/dispatcher/executor_dispatcher.rb +13 -1
- data/lib/dynflow/errors.rb +1 -0
- data/lib/dynflow/execution_history.rb +1 -0
- data/lib/dynflow/execution_plan.rb +3 -2
- data/lib/dynflow/execution_plan/dependency_graph.rb +1 -0
- data/lib/dynflow/execution_plan/hooks.rb +1 -0
- data/lib/dynflow/execution_plan/output_reference.rb +2 -1
- data/lib/dynflow/execution_plan/steps.rb +1 -0
- data/lib/dynflow/execution_plan/steps/abstract.rb +10 -5
- data/lib/dynflow/execution_plan/steps/abstract_flow_step.rb +2 -0
- data/lib/dynflow/execution_plan/steps/error.rb +1 -0
- data/lib/dynflow/execution_plan/steps/finalize_step.rb +1 -0
- data/lib/dynflow/execution_plan/steps/plan_step.rb +1 -0
- data/lib/dynflow/execution_plan/steps/run_step.rb +1 -0
- data/lib/dynflow/executors.rb +1 -1
- data/lib/dynflow/executors/abstract/core.rb +132 -0
- data/lib/dynflow/executors/parallel.rb +24 -11
- data/lib/dynflow/executors/parallel/core.rb +10 -91
- data/lib/dynflow/executors/parallel/pool.rb +4 -2
- data/lib/dynflow/executors/parallel/worker.rb +2 -1
- data/lib/dynflow/executors/sidekiq/core.rb +121 -0
- data/lib/dynflow/executors/sidekiq/internal_job_base.rb +24 -0
- data/lib/dynflow/executors/sidekiq/orchestrator_jobs.rb +60 -0
- data/lib/dynflow/executors/sidekiq/redis_locking.rb +69 -0
- data/lib/dynflow/executors/sidekiq/serialization.rb +33 -0
- data/lib/dynflow/executors/sidekiq/worker_jobs.rb +42 -0
- data/lib/dynflow/flows.rb +1 -0
- data/lib/dynflow/flows/abstract.rb +1 -0
- data/lib/dynflow/flows/abstract_composed.rb +1 -0
- data/lib/dynflow/flows/atom.rb +1 -0
- data/lib/dynflow/flows/concurrence.rb +1 -0
- data/lib/dynflow/flows/sequence.rb +1 -0
- data/lib/dynflow/logger_adapters.rb +1 -0
- data/lib/dynflow/logger_adapters/abstract.rb +1 -0
- data/lib/dynflow/logger_adapters/delegator.rb +1 -0
- data/lib/dynflow/logger_adapters/formatters.rb +1 -0
- data/lib/dynflow/logger_adapters/formatters/abstract.rb +1 -0
- data/lib/dynflow/logger_adapters/formatters/exception.rb +1 -0
- data/lib/dynflow/logger_adapters/simple.rb +1 -0
- data/lib/dynflow/middleware.rb +1 -0
- data/lib/dynflow/middleware/common/singleton.rb +1 -0
- data/lib/dynflow/middleware/common/transaction.rb +1 -0
- data/lib/dynflow/middleware/register.rb +1 -0
- data/lib/dynflow/middleware/resolver.rb +1 -0
- data/lib/dynflow/middleware/stack.rb +1 -0
- data/lib/dynflow/middleware/world.rb +1 -0
- data/lib/dynflow/persistence.rb +3 -2
- data/lib/dynflow/persistence_adapters.rb +1 -0
- data/lib/dynflow/persistence_adapters/abstract.rb +1 -0
- data/lib/dynflow/persistence_adapters/sequel.rb +10 -7
- data/lib/dynflow/persistence_adapters/sequel_migrations/001_initial.rb +1 -0
- data/lib/dynflow/persistence_adapters/sequel_migrations/002_incremental_progress.rb +1 -0
- data/lib/dynflow/persistence_adapters/sequel_migrations/003_parent_action.rb +1 -0
- data/lib/dynflow/persistence_adapters/sequel_migrations/004_coordinator_records.rb +1 -0
- data/lib/dynflow/persistence_adapters/sequel_migrations/005_envelopes.rb +1 -0
- data/lib/dynflow/persistence_adapters/sequel_migrations/006_fix_data_length.rb +1 -0
- data/lib/dynflow/persistence_adapters/sequel_migrations/007_future_execution.rb +1 -0
- data/lib/dynflow/persistence_adapters/sequel_migrations/008_rename_scheduled_plans_to_delayed_plans.rb +1 -0
- data/lib/dynflow/persistence_adapters/sequel_migrations/009_fix_mysql_data_length.rb +1 -0
- data/lib/dynflow/persistence_adapters/sequel_migrations/010_add_execution_plans_label.rb +1 -0
- data/lib/dynflow/persistence_adapters/sequel_migrations/011_placeholder.rb +1 -0
- data/lib/dynflow/persistence_adapters/sequel_migrations/012_add_delayed_plans_serialized_args.rb +1 -0
- data/lib/dynflow/persistence_adapters/sequel_migrations/013_add_action_columns.rb +1 -0
- data/lib/dynflow/persistence_adapters/sequel_migrations/014_add_step_columns.rb +1 -0
- data/lib/dynflow/persistence_adapters/sequel_migrations/015_add_execution_plan_columns.rb +1 -0
- data/lib/dynflow/persistence_adapters/sequel_migrations/016_add_step_queue.rb +1 -0
- data/lib/dynflow/persistence_adapters/sequel_migrations/017_add_delayed_plan_frozen.rb +1 -0
- data/lib/dynflow/persistence_adapters/sequel_migrations/018_add_uuid_column.rb +1 -0
- data/lib/dynflow/persistence_adapters/sequel_migrations/019_update_mysql_time_precision.rb +48 -0
- data/lib/dynflow/rails.rb +1 -0
- data/lib/dynflow/rails/configuration.rb +6 -3
- data/lib/dynflow/rails/daemon.rb +1 -0
- data/lib/dynflow/round_robin.rb +1 -0
- data/lib/dynflow/semaphores.rb +1 -0
- data/lib/dynflow/semaphores/abstract.rb +1 -0
- data/lib/dynflow/semaphores/aggregating.rb +1 -0
- data/lib/dynflow/semaphores/dummy.rb +1 -0
- data/lib/dynflow/semaphores/stateful.rb +1 -0
- data/lib/dynflow/serializable.rb +13 -4
- data/lib/dynflow/serializer.rb +24 -0
- data/lib/dynflow/serializers.rb +1 -0
- data/lib/dynflow/serializers/abstract.rb +1 -0
- data/lib/dynflow/serializers/noop.rb +1 -0
- data/lib/dynflow/stateful.rb +1 -0
- data/lib/dynflow/telemetry.rb +1 -0
- data/lib/dynflow/telemetry_adapters/abstract.rb +1 -0
- data/lib/dynflow/telemetry_adapters/dummy.rb +1 -0
- data/lib/dynflow/telemetry_adapters/statsd.rb +1 -0
- data/lib/dynflow/testing.rb +1 -0
- data/lib/dynflow/testing/assertions.rb +6 -5
- data/lib/dynflow/testing/dummy_execution_plan.rb +1 -0
- data/lib/dynflow/testing/dummy_executor.rb +19 -2
- data/lib/dynflow/testing/dummy_planned_action.rb +1 -0
- data/lib/dynflow/testing/dummy_step.rb +3 -1
- data/lib/dynflow/testing/dummy_world.rb +9 -0
- data/lib/dynflow/testing/factories.rb +6 -1
- data/lib/dynflow/testing/in_thread_executor.rb +22 -3
- data/lib/dynflow/testing/in_thread_world.rb +9 -0
- data/lib/dynflow/testing/managed_clock.rb +1 -0
- data/lib/dynflow/testing/mimic.rb +1 -0
- data/lib/dynflow/throttle_limiter.rb +1 -0
- data/lib/dynflow/transaction_adapters.rb +1 -0
- data/lib/dynflow/transaction_adapters/abstract.rb +1 -0
- data/lib/dynflow/transaction_adapters/active_record.rb +1 -0
- data/lib/dynflow/transaction_adapters/none.rb +1 -0
- data/lib/dynflow/utils.rb +1 -0
- data/lib/dynflow/utils/indifferent_hash.rb +1 -0
- data/lib/dynflow/utils/priority_queue.rb +1 -0
- data/lib/dynflow/version.rb +2 -1
- data/lib/dynflow/watchers/memory_consumption_watcher.rb +1 -0
- data/lib/dynflow/web.rb +1 -0
- data/lib/dynflow/web/console.rb +1 -0
- data/lib/dynflow/web/console_helpers.rb +1 -0
- data/lib/dynflow/web/filtering_helpers.rb +1 -0
- data/lib/dynflow/web/world_helpers.rb +1 -0
- data/lib/dynflow/web_console.rb +1 -0
- data/lib/dynflow/world.rb +11 -1
- data/lib/dynflow/world/invalidation.rb +7 -1
- data/test/abnormal_states_recovery_test.rb +41 -40
- data/test/action_test.rb +160 -110
- data/test/activejob_adapter_test.rb +1 -0
- data/test/batch_sub_tasks_test.rb +12 -11
- data/test/clock_test.rb +2 -1
- data/test/concurrency_control_test.rb +20 -19
- data/test/coordinator_test.rb +20 -21
- data/test/daemon_test.rb +2 -1
- data/test/dead_letter_silencer_test.rb +9 -7
- data/test/dispatcher_test.rb +2 -1
- data/test/execution_plan_cleaner_test.rb +13 -12
- data/test/execution_plan_hooks_test.rb +3 -2
- data/test/execution_plan_test.rb +33 -32
- data/test/executor_test.rb +533 -489
- data/test/future_execution_test.rb +45 -44
- data/test/memory_cosumption_watcher_test.rb +5 -4
- data/test/middleware_test.rb +55 -54
- data/test/persistence_test.rb +56 -53
- data/test/rescue_test.rb +36 -35
- data/test/round_robin_test.rb +13 -12
- data/test/semaphores_test.rb +31 -30
- data/test/support/code_workflow_example.rb +1 -0
- data/test/support/dummy_example.rb +14 -1
- data/test/support/middleware_example.rb +2 -1
- data/test/support/rails/config/environment.rb +1 -0
- data/test/support/rescue_example.rb +1 -0
- data/test/support/test_execution_log.rb +1 -0
- data/test/test_helper.rb +18 -17
- data/test/testing_test.rb +45 -44
- data/test/utils_test.rb +18 -17
- data/test/web_console_test.rb +1 -0
- data/test/world_test.rb +7 -6
- metadata +13 -4
- data/lib/dynflow/executors/abstract.rb +0 -40
data/test/rescue_test.rb
CHANGED
@@ -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
|
|
data/test/round_robin_test.rb
CHANGED
@@ -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
|
10
|
-
rr.next
|
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
|
24
|
-
rr.must_be_empty
|
24
|
+
assert_nil rr.next
|
25
|
+
_(rr).must_be_empty
|
25
26
|
end
|
26
27
|
end
|
27
28
|
end
|
data/test/semaphores_test.rb
CHANGED
@@ -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
|
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
|
@@ -114,7 +115,7 @@ module Support
|
|
114
115
|
end
|
115
116
|
end
|
116
117
|
|
117
|
-
class
|
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
|
|
data/test/test_helper.rb
CHANGED
@@ -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,
|
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
|
-
|
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::
|
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)
|