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
@@ -1,3 +1,4 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
require_relative 'test_helper'
|
2
3
|
|
3
4
|
module Dynflow
|
@@ -17,7 +18,7 @@ module Dynflow
|
|
17
18
|
let(:world) { WorldFactory.create_world }
|
18
19
|
let(:delayed_plan) do
|
19
20
|
delayed_plan = world.delay(::Support::DummyExample::Dummy, { :start_at => @start_at })
|
20
|
-
delayed_plan.must_be :scheduled?
|
21
|
+
_(delayed_plan).must_be :scheduled?
|
21
22
|
world.persistence.load_delayed_plan(delayed_plan.execution_plan_id)
|
22
23
|
end
|
23
24
|
let(:history_names) do
|
@@ -31,40 +32,40 @@ module Dynflow
|
|
31
32
|
it 'handles wrong plan state' do
|
32
33
|
delayed_plan.execution_plan.state = :planning
|
33
34
|
abstract_delayed_executor.send(:process, [delayed_plan], @start_at)
|
34
|
-
delayed_plan.execution_plan.state.must_equal :planned
|
35
|
+
_(delayed_plan.execution_plan.state).must_equal :planned
|
35
36
|
|
36
37
|
delayed_plan.execution_plan.set_state(:running, true)
|
37
38
|
abstract_delayed_executor.send(:process, [delayed_plan], @start_at)
|
38
|
-
delayed_plan.execution_plan.state.must_equal :running
|
39
|
+
_(delayed_plan.execution_plan.state).must_equal :running
|
39
40
|
end
|
40
41
|
end
|
41
42
|
|
42
43
|
it 'returns the progress as 0' do
|
43
|
-
execution_plan.progress.must_equal 0
|
44
|
+
_(execution_plan.progress).must_equal 0
|
44
45
|
end
|
45
46
|
|
46
47
|
it 'marks the plan as failed when issues in serialied phase' do
|
47
48
|
world.persistence.delete_execution_plans({})
|
48
|
-
e = proc { world.delay(::Support::DummyExample::DummyCustomDelaySerializer, { :start_at => @start_at }, :fail) }.must_raise RuntimeError
|
49
|
-
e.message.must_equal 'Enforced serializer failure'
|
49
|
+
e = _(proc { world.delay(::Support::DummyExample::DummyCustomDelaySerializer, { :start_at => @start_at }, :fail) }).must_raise RuntimeError
|
50
|
+
_(e.message).must_equal 'Enforced serializer failure'
|
50
51
|
plan = world.persistence.find_execution_plans(page: 0, per_page: 1, order_by: :ended_at, desc: true).first
|
51
|
-
plan.state.must_equal :stopped
|
52
|
-
plan.result.must_equal :error
|
52
|
+
_(plan.state).must_equal :stopped
|
53
|
+
_(plan.result).must_equal :error
|
53
54
|
end
|
54
55
|
|
55
56
|
it 'delays the action' do
|
56
|
-
execution_plan.steps.count.must_equal 1
|
57
|
-
delayed_plan.start_at.inspect.must_equal (@start_at).inspect
|
58
|
-
history_names.call(execution_plan).must_equal ['delay']
|
57
|
+
_(execution_plan.steps.count).must_equal 1
|
58
|
+
_(delayed_plan.start_at.inspect).must_equal (@start_at).inspect
|
59
|
+
_(history_names.call(execution_plan)).must_equal ['delay']
|
59
60
|
end
|
60
61
|
|
61
62
|
it 'allows cancelling the delayed plan' do
|
62
|
-
execution_plan.state.must_equal :scheduled
|
63
|
-
execution_plan.cancellable
|
63
|
+
_(execution_plan.state).must_equal :scheduled
|
64
|
+
_(execution_plan.cancellable?).must_equal true
|
64
65
|
execution_plan.cancel.each(&:wait)
|
65
66
|
execution_plan = world.persistence.load_execution_plan(self.execution_plan.id)
|
66
|
-
execution_plan.state.must_equal :stopped
|
67
|
-
execution_plan.result.must_equal :cancelled
|
67
|
+
_(execution_plan.state).must_equal :stopped
|
68
|
+
_(execution_plan.result).must_equal :cancelled
|
68
69
|
assert_nil execution_plan.delay_record
|
69
70
|
end
|
70
71
|
|
@@ -72,30 +73,30 @@ module Dynflow
|
|
72
73
|
@start_at = Time.now.utc - 100
|
73
74
|
delayed_plan
|
74
75
|
past_delayed_plans = world.persistence.find_past_delayed_plans(@start_at + 10)
|
75
|
-
past_delayed_plans.length.must_equal 1
|
76
|
-
past_delayed_plans.first.execution_plan_uuid.must_equal execution_plan.id
|
76
|
+
_(past_delayed_plans.length).must_equal 1
|
77
|
+
_(past_delayed_plans.first.execution_plan_uuid).must_equal execution_plan.id
|
77
78
|
end
|
78
79
|
|
79
80
|
it 'delayed plans can be planned and executed' do
|
80
|
-
execution_plan.state.must_equal :scheduled
|
81
|
+
_(execution_plan.state).must_equal :scheduled
|
81
82
|
delayed_plan.plan
|
82
|
-
execution_plan.state.must_equal :planned
|
83
|
-
execution_plan.result.must_equal :pending
|
83
|
+
_(execution_plan.state).must_equal :planned
|
84
|
+
_(execution_plan.result).must_equal :pending
|
84
85
|
assert_planning_success execution_plan
|
85
|
-
history_names.call(execution_plan).must_equal ['delay']
|
86
|
+
_(history_names.call(execution_plan)).must_equal ['delay']
|
86
87
|
delayed_plan.execute.future.wait
|
87
88
|
executed = world.persistence.load_execution_plan(delayed_plan.execution_plan_uuid)
|
88
|
-
executed.state.must_equal :stopped
|
89
|
-
executed.result.must_equal :success
|
90
|
-
executed.execution_history.count.must_equal 3
|
89
|
+
_(executed.state).must_equal :stopped
|
90
|
+
_(executed.result).must_equal :success
|
91
|
+
_(executed.execution_history.count).must_equal 3
|
91
92
|
end
|
92
93
|
|
93
94
|
it 'expired plans can be failed' do
|
94
95
|
delayed_plan.timeout
|
95
|
-
execution_plan.state.must_equal :stopped
|
96
|
-
execution_plan.result.must_equal :error
|
97
|
-
execution_plan.errors.first.message.must_match /could not be started before set time/
|
98
|
-
history_names.call(execution_plan).must_equal %W(delay timeout)
|
96
|
+
_(execution_plan.state).must_equal :stopped
|
97
|
+
_(execution_plan.result).must_equal :error
|
98
|
+
_(execution_plan.errors.first.message).must_match /could not be started before set time/
|
99
|
+
_(history_names.call(execution_plan)).must_equal %W(delay timeout)
|
99
100
|
end
|
100
101
|
|
101
102
|
end
|
@@ -112,18 +113,18 @@ module Dynflow
|
|
112
113
|
persistence.expect(:find_past_delayed_plans, [], [start_time])
|
113
114
|
persistence.expect(:find_past_delayed_plans, [], [start_time + options[:poll_interval]])
|
114
115
|
dummy_world.stub :persistence, persistence do
|
115
|
-
klok.pending_pings.length.must_equal 0
|
116
|
+
_(klok.pending_pings.length).must_equal 0
|
116
117
|
delayed_executor.start.wait
|
117
|
-
klok.pending_pings.length.must_equal 1
|
118
|
-
klok.pending_pings.first.who.ref.must_be_same_as delayed_executor.core
|
119
|
-
klok.pending_pings.first.when.must_equal start_time + options[:poll_interval]
|
118
|
+
_(klok.pending_pings.length).must_equal 1
|
119
|
+
_(klok.pending_pings.first.who.ref).must_be_same_as delayed_executor.core
|
120
|
+
_(klok.pending_pings.first.when).must_equal start_time + options[:poll_interval]
|
120
121
|
klok.progress
|
121
122
|
delayed_executor.terminate.wait
|
122
|
-
klok.pending_pings.length.must_equal 1
|
123
|
-
klok.pending_pings.first.who.ref.must_be_same_as delayed_executor.core
|
124
|
-
klok.pending_pings.first.when.must_equal start_time + 2 * options[:poll_interval]
|
123
|
+
_(klok.pending_pings.length).must_equal 1
|
124
|
+
_(klok.pending_pings.first.who.ref).must_be_same_as delayed_executor.core
|
125
|
+
_(klok.pending_pings.first.when).must_equal start_time + 2 * options[:poll_interval]
|
125
126
|
klok.progress
|
126
|
-
klok.pending_pings.length.must_equal 0
|
127
|
+
_(klok.pending_pings.length).must_equal 0
|
127
128
|
end
|
128
129
|
end
|
129
130
|
end
|
@@ -149,27 +150,27 @@ module Dynflow
|
|
149
150
|
|
150
151
|
it 'noop serializer [de]serializes correctly for simple types' do
|
151
152
|
input = [1, 2.0, 'three', ['four-1', 'four-2'], { 'five' => 5 }]
|
152
|
-
simulated_use.call(Dynflow::Serializers::Noop, input).must_equal input
|
153
|
+
_(simulated_use.call(Dynflow::Serializers::Noop, input)).must_equal input
|
153
154
|
end
|
154
155
|
|
155
156
|
it 'args! raises if not deserialized' do
|
156
|
-
proc { serialized_serializer.args! }.must_raise RuntimeError
|
157
|
+
_(proc { serialized_serializer.args! }).must_raise RuntimeError
|
157
158
|
deserialized_serializer.args! # Must not raise
|
158
159
|
end
|
159
160
|
|
160
161
|
it 'serialized_args! raises if not serialized' do
|
161
|
-
proc { deserialized_serializer.serialized_args! }.must_raise RuntimeError
|
162
|
+
_(proc { deserialized_serializer.serialized_args! }).must_raise RuntimeError
|
162
163
|
serialized_serializer.serialized_args! # Must not raise
|
163
164
|
end
|
164
165
|
|
165
166
|
it 'performs_serialization!' do
|
166
167
|
deserialized_serializer.perform_serialization!
|
167
|
-
deserialized_serializer.serialized_args
|
168
|
+
_(deserialized_serializer.serialized_args!).must_equal args
|
168
169
|
end
|
169
170
|
|
170
171
|
it 'performs_deserialization!' do
|
171
172
|
serialized_serializer.perform_deserialization!
|
172
|
-
serialized_serializer.args.must_equal args
|
173
|
+
_(serialized_serializer.args).must_equal args
|
173
174
|
end
|
174
175
|
end
|
175
176
|
|
@@ -181,9 +182,9 @@ module Dynflow
|
|
181
182
|
end
|
182
183
|
|
183
184
|
it "allows access to serializer's args" do
|
184
|
-
serializer.args.must_be :nil?
|
185
|
-
delayed_plan.args.must_equal args
|
186
|
-
serializer.args.must_equal args
|
185
|
+
_(serializer.args).must_be :nil?
|
186
|
+
_(delayed_plan.args).must_equal args
|
187
|
+
_(serializer.args).must_equal args
|
187
188
|
end
|
188
189
|
end
|
189
190
|
end
|
@@ -1,3 +1,4 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
require_relative 'test_helper'
|
2
3
|
require 'fileutils'
|
3
4
|
require 'dynflow/watchers/memory_consumption_watcher'
|
@@ -12,7 +13,7 @@ module Dynflow
|
|
12
13
|
world.expect(:clock, clock)
|
13
14
|
init_interval = 1000
|
14
15
|
clock.expect(:ping, true) do |clock_who, clock_when, _|
|
15
|
-
clock_when.must_equal init_interval
|
16
|
+
_(clock_when).must_equal init_interval
|
16
17
|
end
|
17
18
|
|
18
19
|
Dynflow::Watchers::MemoryConsumptionWatcher.new world, 1, initial_wait: init_interval
|
@@ -30,11 +31,11 @@ module Dynflow
|
|
30
31
|
init_interval = 1000
|
31
32
|
polling_interval = 2000
|
32
33
|
clock.expect(:ping, true) do |clock_who, clock_when, _|
|
33
|
-
clock_when.must_equal init_interval
|
34
|
+
_(clock_when).must_equal init_interval
|
34
35
|
true
|
35
36
|
end
|
36
37
|
clock.expect(:ping, true) do |clock_who, clock_when, _|
|
37
|
-
clock_when.must_equal polling_interval
|
38
|
+
_(clock_when).must_equal polling_interval
|
38
39
|
true
|
39
40
|
end
|
40
41
|
memory_info_provider.expect(:bytes, 0)
|
@@ -63,7 +64,7 @@ module Dynflow
|
|
63
64
|
|
64
65
|
init_interval = 1000
|
65
66
|
clock.expect(:ping, true) do |clock_who, clock_when, _|
|
66
|
-
clock_when.must_equal init_interval
|
67
|
+
_(clock_when).must_equal init_interval
|
67
68
|
true
|
68
69
|
end
|
69
70
|
memory_info_provider.expect(:bytes, 10)
|
data/test/middleware_test.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
require_relative 'test_helper'
|
2
3
|
|
3
4
|
module Dynflow
|
@@ -16,31 +17,31 @@ module Dynflow
|
|
16
17
|
plan = world.persistence.load_delayed_plan delay.execution_plan_id
|
17
18
|
plan.plan
|
18
19
|
plan.execute.future.wait
|
19
|
-
log.must_equal %w[LogMiddleware::before_delay
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
20
|
+
_(log).must_equal %w[LogMiddleware::before_delay
|
21
|
+
delay
|
22
|
+
LogMiddleware::after_delay
|
23
|
+
LogMiddleware::before_plan_phase
|
24
|
+
LogMiddleware::before_plan
|
25
|
+
plan
|
26
|
+
LogMiddleware::after_plan
|
27
|
+
LogMiddleware::after_plan_phase
|
28
|
+
LogMiddleware::before_run
|
29
|
+
run
|
30
|
+
LogMiddleware::after_run
|
31
|
+
LogMiddleware::before_finalize_phase
|
32
|
+
LogMiddleware::before_finalize
|
33
|
+
finalize
|
34
|
+
LogMiddleware::after_finalize
|
35
|
+
LogMiddleware::after_finalize_phase]
|
35
36
|
end
|
36
37
|
|
37
38
|
it "inherits the middleware" do
|
38
39
|
world.trigger(Support::MiddlewareExample::SubAction, {}).finished.wait
|
39
|
-
log.must_equal %w[LogRunMiddleware::before_run
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
40
|
+
_(log).must_equal %w[LogRunMiddleware::before_run
|
41
|
+
AnotherLogRunMiddleware::before_run
|
42
|
+
run
|
43
|
+
AnotherLogRunMiddleware::after_run
|
44
|
+
LogRunMiddleware::after_run]
|
44
45
|
end
|
45
46
|
|
46
47
|
describe "world.middleware" do
|
@@ -52,11 +53,11 @@ module Dynflow
|
|
52
53
|
|
53
54
|
it "puts the middleware to the beginning of the stack" do
|
54
55
|
world_with_middleware.trigger(Support::MiddlewareExample::Action, {}).finished.wait
|
55
|
-
log.must_equal %w[AnotherLogRunMiddleware::before_run
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
56
|
+
_(log).must_equal %w[AnotherLogRunMiddleware::before_run
|
57
|
+
LogRunMiddleware::before_run
|
58
|
+
run
|
59
|
+
LogRunMiddleware::after_run
|
60
|
+
AnotherLogRunMiddleware::after_run]
|
60
61
|
end
|
61
62
|
end
|
62
63
|
|
@@ -64,11 +65,11 @@ module Dynflow
|
|
64
65
|
describe "before" do
|
65
66
|
specify do
|
66
67
|
world.trigger(Support::MiddlewareExample::SubActionBeforeRule, {}).finished.wait
|
67
|
-
log.must_equal %w[AnotherLogRunMiddleware::before_run
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
68
|
+
_(log).must_equal %w[AnotherLogRunMiddleware::before_run
|
69
|
+
LogRunMiddleware::before_run
|
70
|
+
run
|
71
|
+
LogRunMiddleware::after_run
|
72
|
+
AnotherLogRunMiddleware::after_run]
|
72
73
|
end
|
73
74
|
end
|
74
75
|
|
@@ -83,27 +84,27 @@ module Dynflow
|
|
83
84
|
|
84
85
|
specify do
|
85
86
|
world_with_middleware.trigger(Support::MiddlewareExample::Action, {}).finished.wait
|
86
|
-
log.must_equal %w[LogRunMiddleware::before_run
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
87
|
+
_(log).must_equal %w[LogRunMiddleware::before_run
|
88
|
+
AnotherLogRunMiddleware::before_run
|
89
|
+
run
|
90
|
+
AnotherLogRunMiddleware::after_run
|
91
|
+
LogRunMiddleware::after_run]
|
91
92
|
end
|
92
93
|
end
|
93
94
|
|
94
95
|
describe "replace" do
|
95
96
|
specify do
|
96
97
|
world.trigger(Support::MiddlewareExample::SubActionReplaceRule, {}).finished.wait
|
97
|
-
log.must_equal %w[AnotherLogRunMiddleware::before_run
|
98
|
-
|
99
|
-
|
98
|
+
_(log).must_equal %w[AnotherLogRunMiddleware::before_run
|
99
|
+
run
|
100
|
+
AnotherLogRunMiddleware::after_run]
|
100
101
|
end
|
101
102
|
end
|
102
103
|
|
103
104
|
describe "remove" do
|
104
105
|
specify do
|
105
106
|
world.trigger(Support::MiddlewareExample::SubActionDoNotUseRule, {}).finished.wait
|
106
|
-
log.must_equal %w[run]
|
107
|
+
_(log).must_equal %w[run]
|
107
108
|
end
|
108
109
|
end
|
109
110
|
end
|
@@ -113,9 +114,9 @@ module Dynflow
|
|
113
114
|
world.middleware.use(Support::MiddlewareExample::ObservingMiddleware,
|
114
115
|
replace: Support::MiddlewareExample::LogRunMiddleware)
|
115
116
|
world.trigger(Support::MiddlewareExample::Action, message: 'hello').finished.wait
|
116
|
-
log.must_equal %w[input#message:hello
|
117
|
-
|
118
|
-
|
117
|
+
_(log).must_equal %w[input#message:hello
|
118
|
+
run
|
119
|
+
output#message:finished]
|
119
120
|
end
|
120
121
|
|
121
122
|
it "allows modification of the running action when delaying execution" do
|
@@ -126,11 +127,11 @@ module Dynflow
|
|
126
127
|
plan = world.persistence.load_delayed_plan delay.execution_plan_id
|
127
128
|
plan.plan
|
128
129
|
plan.execute.future.wait
|
129
|
-
log.must_equal ["delay#set-input:#{world.id}",
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
130
|
+
_(log).must_equal ["delay#set-input:#{world.id}",
|
131
|
+
"plan#input:#{world.id}",
|
132
|
+
"input#message:#{world.id}",
|
133
|
+
'run',
|
134
|
+
'output#message:finished']
|
134
135
|
end
|
135
136
|
|
136
137
|
describe 'Presnet middleware' do
|
@@ -142,13 +143,13 @@ module Dynflow
|
|
142
143
|
|
143
144
|
let :execution_plan do
|
144
145
|
result = world.trigger(Support::CodeWorkflowExample::IncomingIssue, issue_data)
|
145
|
-
result.must_be :planned?
|
146
|
+
_(result).must_be :planned?
|
146
147
|
result.finished.value
|
147
148
|
end
|
148
149
|
|
149
150
|
let :execution_plan_2 do
|
150
151
|
result = world.trigger(Support::MiddlewareExample::SecretAction)
|
151
|
-
result.must_be :planned?
|
152
|
+
_(result).must_be :planned?
|
152
153
|
result.finished.value
|
153
154
|
end
|
154
155
|
|
@@ -173,13 +174,13 @@ module Dynflow
|
|
173
174
|
end
|
174
175
|
|
175
176
|
it 'filters the data ===' do
|
176
|
-
presenter.input['text'].must_equal('You-Know-Who is comming')
|
177
|
-
presenter_2.output['spell'].must_equal('***')
|
177
|
+
_(presenter.input['text']).must_equal('You-Know-Who is comming')
|
178
|
+
_(presenter_2.output['spell']).must_equal('***')
|
178
179
|
end
|
179
180
|
|
180
181
|
it "doesn't affect stored data" do
|
181
|
-
presenter.input['text'].must_equal('You-Know-Who is comming')
|
182
|
-
presenter_without_middleware.input['text'].must_equal('Lord Voldemort is comming')
|
182
|
+
_(presenter.input['text']).must_equal('You-Know-Who is comming')
|
183
|
+
_(presenter_without_middleware.input['text']).must_equal('Lord Voldemort is comming')
|
183
184
|
end
|
184
185
|
end
|
185
186
|
|
data/test/persistence_test.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
require_relative 'test_helper'
|
2
3
|
require 'tmpdir'
|
3
4
|
|
@@ -84,11 +85,13 @@ module Dynflow
|
|
84
85
|
original.each do |key, value|
|
85
86
|
loaded_value = loaded[key.to_s]
|
86
87
|
if value.is_a?(Time)
|
87
|
-
loaded_value.inspect.must_equal value.inspect
|
88
|
+
_(loaded_value.inspect).must_equal value.inspect
|
88
89
|
elsif value.is_a?(Hash)
|
89
90
|
assert_equal_attributes!(value, loaded_value)
|
91
|
+
elsif value.nil?
|
92
|
+
assert_nil loaded[key.to_s]
|
90
93
|
else
|
91
|
-
loaded[key.to_s].must_equal value
|
94
|
+
_(loaded[key.to_s]).must_equal value
|
92
95
|
end
|
93
96
|
end
|
94
97
|
end
|
@@ -104,10 +107,10 @@ module Dynflow
|
|
104
107
|
prepare_and_save_plans
|
105
108
|
if adapter.pagination?
|
106
109
|
loaded_plans = adapter.find_execution_plans(page: 0, per_page: 1)
|
107
|
-
loaded_plans.map { |h| h[:id] }.must_equal ['plan1']
|
110
|
+
_(loaded_plans.map { |h| h[:id] }).must_equal ['plan1']
|
108
111
|
|
109
112
|
loaded_plans = adapter.find_execution_plans(page: 1, per_page: 1)
|
110
|
-
loaded_plans.map { |h| h[:id] }.must_equal ['plan2']
|
113
|
+
_(loaded_plans.map { |h| h[:id] }).must_equal ['plan2']
|
111
114
|
end
|
112
115
|
end
|
113
116
|
|
@@ -115,10 +118,10 @@ module Dynflow
|
|
115
118
|
prepare_and_save_plans
|
116
119
|
if adapter.ordering_by.include?('state')
|
117
120
|
loaded_plans = adapter.find_execution_plans(order_by: 'state')
|
118
|
-
loaded_plans.map { |h| h[:id] }.must_equal %w(plan1 plan3 plan4 plan2)
|
121
|
+
_(loaded_plans.map { |h| h[:id] }).must_equal %w(plan1 plan3 plan4 plan2)
|
119
122
|
|
120
123
|
loaded_plans = adapter.find_execution_plans(order_by: 'state', desc: true)
|
121
|
-
loaded_plans.map { |h| h[:id] }.must_equal %w(plan2 plan1 plan3 plan4)
|
124
|
+
_(loaded_plans.map { |h| h[:id] }).must_equal %w(plan2 plan1 plan3 plan4)
|
122
125
|
end
|
123
126
|
end
|
124
127
|
|
@@ -126,31 +129,31 @@ module Dynflow
|
|
126
129
|
prepare_and_save_plans
|
127
130
|
if adapter.ordering_by.include?('state')
|
128
131
|
loaded_plans = adapter.find_execution_plans(filters: { label: ['test1'] })
|
129
|
-
loaded_plans.map { |h| h[:id] }.must_equal ['plan1']
|
132
|
+
_(loaded_plans.map { |h| h[:id] }).must_equal ['plan1']
|
130
133
|
loaded_plans = adapter.find_execution_plans(filters: { state: ['paused'] })
|
131
|
-
loaded_plans.map { |h| h[:id] }.must_equal ['plan1', 'plan3', 'plan4']
|
134
|
+
_(loaded_plans.map { |h| h[:id] }).must_equal ['plan1', 'plan3', 'plan4']
|
132
135
|
|
133
136
|
loaded_plans = adapter.find_execution_plans(filters: { state: ['stopped'] })
|
134
|
-
loaded_plans.map { |h| h[:id] }.must_equal ['plan2']
|
137
|
+
_(loaded_plans.map { |h| h[:id] }).must_equal ['plan2']
|
135
138
|
|
136
139
|
loaded_plans = adapter.find_execution_plans(filters: { state: [] })
|
137
|
-
loaded_plans.map { |h| h[:id] }.must_equal []
|
140
|
+
_(loaded_plans.map { |h| h[:id] }).must_equal []
|
138
141
|
|
139
142
|
loaded_plans = adapter.find_execution_plans(filters: { state: ['stopped', 'paused'] })
|
140
|
-
loaded_plans.map { |h| h[:id] }.must_equal %w(plan1 plan2 plan3 plan4)
|
143
|
+
_(loaded_plans.map { |h| h[:id] }).must_equal %w(plan1 plan2 plan3 plan4)
|
141
144
|
|
142
145
|
loaded_plans = adapter.find_execution_plans(filters: { 'state' => ['stopped', 'paused'] })
|
143
|
-
loaded_plans.map { |h| h[:id] }.must_equal %w(plan1 plan2 plan3 plan4)
|
146
|
+
_(loaded_plans.map { |h| h[:id] }).must_equal %w(plan1 plan2 plan3 plan4)
|
144
147
|
|
145
148
|
loaded_plans = adapter.find_execution_plans(filters: { label: ['test1'], :delayed => true })
|
146
|
-
loaded_plans.must_be_empty
|
149
|
+
_(loaded_plans).must_be_empty
|
147
150
|
|
148
151
|
adapter.save_delayed_plan('plan1',
|
149
152
|
:execution_plan_uuid => 'plan1',
|
150
153
|
:start_at => format_time(Time.now + 60),
|
151
154
|
:start_before => format_time(Time.now - 60))
|
152
155
|
loaded_plans = adapter.find_execution_plans(filters: { label: ['test1'], :delayed => true })
|
153
|
-
loaded_plans.map { |h| h[:id] }.must_equal ['plan1']
|
156
|
+
_(loaded_plans.map { |h| h[:id] }).must_equal ['plan1']
|
154
157
|
end
|
155
158
|
end
|
156
159
|
end
|
@@ -165,57 +168,57 @@ module Dynflow
|
|
165
168
|
prepare_and_save_plans
|
166
169
|
if adapter.ordering_by.include?('state')
|
167
170
|
loaded_plans = adapter.find_execution_plan_counts(filters: { label: ['test1'] })
|
168
|
-
loaded_plans.must_equal 1
|
171
|
+
_(loaded_plans).must_equal 1
|
169
172
|
loaded_plans = adapter.find_execution_plan_counts(filters: { state: ['paused'] })
|
170
|
-
loaded_plans.must_equal 3
|
173
|
+
_(loaded_plans).must_equal 3
|
171
174
|
|
172
175
|
loaded_plans = adapter.find_execution_plan_counts(filters: { state: ['stopped'] })
|
173
|
-
loaded_plans.must_equal 1
|
176
|
+
_(loaded_plans).must_equal 1
|
174
177
|
|
175
178
|
loaded_plans = adapter.find_execution_plan_counts(filters: { state: [] })
|
176
|
-
loaded_plans.must_equal 0
|
179
|
+
_(loaded_plans).must_equal 0
|
177
180
|
|
178
181
|
loaded_plans = adapter.find_execution_plan_counts(filters: { state: ['stopped', 'paused'] })
|
179
|
-
loaded_plans.must_equal 4
|
182
|
+
_(loaded_plans).must_equal 4
|
180
183
|
|
181
184
|
loaded_plans = adapter.find_execution_plan_counts(filters: { 'state' => ['stopped', 'paused'] })
|
182
|
-
loaded_plans.must_equal 4
|
185
|
+
_(loaded_plans).must_equal 4
|
183
186
|
|
184
187
|
loaded_plans = adapter.find_execution_plan_counts(filters: { label: ['test1'], :delayed => true })
|
185
|
-
loaded_plans.must_equal 0
|
188
|
+
_(loaded_plans).must_equal 0
|
186
189
|
|
187
190
|
adapter.save_delayed_plan('plan1',
|
188
191
|
:execution_plan_uuid => 'plan1',
|
189
192
|
:start_at => format_time(Time.now + 60),
|
190
193
|
:start_before => format_time(Time.now - 60))
|
191
194
|
loaded_plans = adapter.find_execution_plan_counts(filters: { label: ['test1'], :delayed => true })
|
192
|
-
loaded_plans.must_equal 1
|
195
|
+
_(loaded_plans).must_equal 1
|
193
196
|
end
|
194
197
|
end
|
195
198
|
end
|
196
199
|
|
197
200
|
describe '#load_execution_plan and #save_execution_plan' do
|
198
201
|
it 'serializes/deserializes the plan data' do
|
199
|
-
-> { adapter.load_execution_plan('plan1') }.must_raise KeyError
|
202
|
+
_(-> { adapter.load_execution_plan('plan1') }).must_raise KeyError
|
200
203
|
plan = prepare_and_save_plans.first
|
201
204
|
loaded_plan = adapter.load_execution_plan('plan1')
|
202
|
-
loaded_plan[:id].must_equal 'plan1'
|
203
|
-
loaded_plan['id'].must_equal 'plan1'
|
205
|
+
_(loaded_plan[:id]).must_equal 'plan1'
|
206
|
+
_(loaded_plan['id']).must_equal 'plan1'
|
204
207
|
|
205
208
|
assert_equal_attributes!(plan, loaded_plan)
|
206
209
|
|
207
210
|
adapter.save_execution_plan('plan1', nil)
|
208
|
-
-> { adapter.load_execution_plan('plan1') }.must_raise KeyError
|
211
|
+
_(-> { adapter.load_execution_plan('plan1') }).must_raise KeyError
|
209
212
|
end
|
210
213
|
end
|
211
214
|
|
212
215
|
describe '#delete_execution_plans' do
|
213
216
|
it 'deletes selected execution plans, including steps and actions' do
|
214
217
|
prepare_plans_with_steps
|
215
|
-
adapter.delete_execution_plans('uuid' => 'plan1').must_equal 1
|
216
|
-
-> { adapter.load_execution_plan('plan1') }.must_raise KeyError
|
217
|
-
-> { adapter.load_action('plan1', action_data[:id]) }.must_raise KeyError
|
218
|
-
-> { adapter.load_step('plan1', step_data[:id]) }.must_raise KeyError
|
218
|
+
_(adapter.delete_execution_plans('uuid' => 'plan1')).must_equal 1
|
219
|
+
_(-> { adapter.load_execution_plan('plan1') }).must_raise KeyError
|
220
|
+
_(-> { adapter.load_action('plan1', action_data[:id]) }).must_raise KeyError
|
221
|
+
_(-> { adapter.load_step('plan1', step_data[:id]) }).must_raise KeyError
|
219
222
|
|
220
223
|
# testing that no other plans where affected
|
221
224
|
adapter.load_execution_plan('plan2')
|
@@ -223,16 +226,16 @@ module Dynflow
|
|
223
226
|
adapter.load_step('plan2', step_data[:id])
|
224
227
|
|
225
228
|
prepare_plans_with_steps
|
226
|
-
adapter.delete_execution_plans('state' => 'paused').must_equal 3
|
227
|
-
-> { adapter.load_execution_plan('plan1') }.must_raise KeyError
|
229
|
+
_(adapter.delete_execution_plans('state' => 'paused')).must_equal 3
|
230
|
+
_(-> { adapter.load_execution_plan('plan1') }).must_raise KeyError
|
228
231
|
adapter.load_execution_plan('plan2') # nothing raised
|
229
|
-
-> { adapter.load_execution_plan('plan3') }.must_raise KeyError
|
232
|
+
_(-> { adapter.load_execution_plan('plan3') }).must_raise KeyError
|
230
233
|
end
|
231
234
|
|
232
235
|
it 'creates backup dir and produce backup including steps and actions' do
|
233
236
|
prepare_plans_with_steps
|
234
237
|
Dir.mktmpdir do |backup_dir|
|
235
|
-
adapter.delete_execution_plans({'uuid' => 'plan1'}, 100, backup_dir).must_equal 1
|
238
|
+
_(adapter.delete_execution_plans({'uuid' => 'plan1'}, 100, backup_dir)).must_equal 1
|
236
239
|
plans = CSV.read(backup_dir + "/execution_plans.csv", :headers => true)
|
237
240
|
assert_equal 1, plans.count
|
238
241
|
assert_equal 'plan1', plans.first.to_hash['uuid']
|
@@ -251,16 +254,16 @@ module Dynflow
|
|
251
254
|
prepare_and_save_plans
|
252
255
|
action = action_data.dup
|
253
256
|
action_id = action_data[:id]
|
254
|
-
-> { adapter.load_action('plan1', action_id) }.must_raise KeyError
|
257
|
+
_(-> { adapter.load_action('plan1', action_id) }).must_raise KeyError
|
255
258
|
|
256
259
|
prepare_action('plan1')
|
257
260
|
loaded_action = adapter.load_action('plan1', action_id)
|
258
|
-
loaded_action[:id].must_equal action_id
|
261
|
+
_(loaded_action[:id]).must_equal action_id
|
259
262
|
|
260
263
|
assert_equal_attributes!(action, loaded_action)
|
261
264
|
|
262
265
|
adapter.save_action('plan1', action_id, nil)
|
263
|
-
-> { adapter.load_action('plan1', action_id) }.must_raise KeyError
|
266
|
+
_(-> { adapter.load_action('plan1', action_id) }).must_raise KeyError
|
264
267
|
|
265
268
|
adapter.save_execution_plan('plan1', nil)
|
266
269
|
end
|
@@ -269,9 +272,9 @@ module Dynflow
|
|
269
272
|
prepare_and_save_plans
|
270
273
|
prepare_action('plan1')
|
271
274
|
loaded_data = adapter.load_actions_attributes('plan1', [:id, :run_step_id]).first
|
272
|
-
loaded_data.keys.count.must_equal 2
|
273
|
-
loaded_data[:id].must_equal action_data[:id]
|
274
|
-
loaded_data[:run_step_id].must_equal action_data[:run_step_id]
|
275
|
+
_(loaded_data.keys.count).must_equal 2
|
276
|
+
_(loaded_data[:id]).must_equal action_data[:id]
|
277
|
+
_(loaded_data[:run_step_id]).must_equal action_data[:run_step_id]
|
275
278
|
end
|
276
279
|
|
277
280
|
it 'allows to load actions in bulk using #load_actions' do
|
@@ -279,7 +282,7 @@ module Dynflow
|
|
279
282
|
prepare_action('plan1')
|
280
283
|
action = action_data.dup
|
281
284
|
loaded_actions = adapter.load_actions('plan1', [1])
|
282
|
-
loaded_actions.count.must_equal 1
|
285
|
+
_(loaded_actions.count).must_equal 1
|
283
286
|
loaded_action = loaded_actions.first
|
284
287
|
|
285
288
|
assert_equal_attributes!(action, loaded_action)
|
@@ -292,7 +295,7 @@ module Dynflow
|
|
292
295
|
step_id = step_data[:id]
|
293
296
|
prepare_and_save_step('plan1')
|
294
297
|
loaded_step = adapter.load_step('plan1', step_id)
|
295
|
-
loaded_step[:id].must_equal step_id
|
298
|
+
_(loaded_step[:id]).must_equal step_id
|
296
299
|
|
297
300
|
assert_equal_attributes!(step_data, loaded_step)
|
298
301
|
end
|
@@ -309,8 +312,8 @@ module Dynflow
|
|
309
312
|
adapter.save_delayed_plan('plan4', :execution_plan_uuid => 'plan4', :frozen => false, :start_at => format_time(start_time - 60),
|
310
313
|
:start_before => format_time(start_time - 60))
|
311
314
|
plans = adapter.find_past_delayed_plans(start_time)
|
312
|
-
plans.length.must_equal 3
|
313
|
-
plans.map { |plan| plan[:execution_plan_uuid] }.must_equal %w(plan2 plan4 plan1)
|
315
|
+
_(plans.length).must_equal 3
|
316
|
+
_(plans.map { |plan| plan[:execution_plan_uuid] }).must_equal %w(plan2 plan4 plan1)
|
314
317
|
end
|
315
318
|
|
316
319
|
it 'does not find plans that are frozen' do
|
@@ -323,8 +326,8 @@ module Dynflow
|
|
323
326
|
:start_before => format_time(start_time - 60))
|
324
327
|
|
325
328
|
plans = adapter.find_past_delayed_plans(start_time)
|
326
|
-
plans.length.must_equal 1
|
327
|
-
plans.first[:execution_plan_uuid].must_equal 'plan1'
|
329
|
+
_(plans.length).must_equal 1
|
330
|
+
_(plans.first[:execution_plan_uuid]).must_equal 'plan1'
|
328
331
|
end
|
329
332
|
end
|
330
333
|
end
|
@@ -342,11 +345,11 @@ module Dynflow
|
|
342
345
|
adapter.class::META_DATA.fetch(:execution_plan).each do |name|
|
343
346
|
value = original.fetch(name.to_sym)
|
344
347
|
if value.nil?
|
345
|
-
stored.fetch(name.to_sym)
|
348
|
+
assert_nil stored.fetch(name.to_sym)
|
346
349
|
elsif value.is_a?(Time)
|
347
|
-
stored.fetch(name.to_sym).inspect.must_equal value.inspect
|
350
|
+
_(stored.fetch(name.to_sym).inspect).must_equal value.inspect
|
348
351
|
else
|
349
|
-
stored.fetch(name.to_sym).must_equal value
|
352
|
+
_(stored.fetch(name.to_sym)).must_equal value
|
350
353
|
end
|
351
354
|
end
|
352
355
|
end
|
@@ -356,8 +359,8 @@ module Dynflow
|
|
356
359
|
client_world_id = '5678'
|
357
360
|
executor_world_id = '1234'
|
358
361
|
envelope_hash = ->(envelope) { Dynflow::Utils.indifferent_hash(Dynflow.serializer.dump(envelope)) }
|
359
|
-
executor_envelope = envelope_hash.call(Dispatcher::Envelope[123, client_world_id, executor_world_id, Dispatcher::Execution['111']])
|
360
|
-
client_envelope = envelope_hash.call(Dispatcher::Envelope[123, executor_world_id, client_world_id, Dispatcher::Accepted])
|
362
|
+
executor_envelope = envelope_hash.call(Dispatcher::Envelope['123', client_world_id, executor_world_id, Dispatcher::Execution['111']])
|
363
|
+
client_envelope = envelope_hash.call(Dispatcher::Envelope['123', executor_world_id, client_world_id, Dispatcher::Accepted])
|
361
364
|
envelopes = [client_envelope, executor_envelope]
|
362
365
|
|
363
366
|
envelopes.each { |e| adapter.push_envelope(e) }
|
@@ -418,8 +421,8 @@ module Dynflow
|
|
418
421
|
|
419
422
|
# Check the plan has the changed columns populated
|
420
423
|
raw_plan = db[:dynflow_execution_plans].where(:uuid => 'plan1').first
|
421
|
-
raw_plan[:state].must_equal 'stopped'
|
422
|
-
raw_plan[:result].must_equal 'success'
|
424
|
+
_(raw_plan[:state]).must_equal 'stopped'
|
425
|
+
_(raw_plan[:result]).must_equal 'success'
|
423
426
|
|
424
427
|
# Load the plan and assert it doesn't read attributes from data
|
425
428
|
loaded_plan = adapter.load_execution_plan(plan[:id])
|