dynflow 0.8.5 → 0.8.6
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.
- checksums.yaml +8 -8
- data/lib/dynflow/execution_plan/steps/plan_step.rb +1 -0
- data/lib/dynflow/persistence_adapters/sequel.rb +1 -1
- data/lib/dynflow/serializers/abstract.rb +4 -4
- data/lib/dynflow/serializers/noop.rb +4 -4
- data/lib/dynflow/version.rb +1 -1
- data/test/middleware_test.rb +15 -0
- data/test/persistence_test.rb +18 -2
- data/test/support/dummy_example.rb +4 -10
- data/test/support/middleware_example.rb +16 -0
- data/test/test_helper.rb +2 -4
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
YWQyYzY3YTljZmEwZmFjODNjYTQ2ZDcxODhjOTIyNjIzMjU3MWQxOQ==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
NmU1MDM2NWM3YTk2NmE2NGExZWRhNzUxNzg3YmNmZTg5M2EzOTQ5Mg==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
Nzk0NjlhYTAwNzQ4NzU0NDIwNzFiYWQ2NjliZGQxYzJiODAxZTMwOWM4ZDI0
|
10
|
+
MWNhYTI2NzA2YWE4YTVjZWYwYTY0YmNmZmU2M2I1NWEzYjQ5MTM0ODliYTYw
|
11
|
+
ZWQ4MmY1ZGE0MTgzYzM3ZWRhZjhjMjRlYWVhNTM1MmZiNWNjYWI=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
MmViMjEzZDliZjg2ZThkNDgzMjQ1ZWU5MTNlN2ZlM2JkYjMwYzBmMGE1MDhj
|
14
|
+
Yjc3ZWU0ZmYxOGU3ZTA2MzgxMTAxZjdjMmE3YjVlZGUxYmQxNGUyYWZmOGZj
|
15
|
+
ODM0Yjg3ODQ0MTVmMGM4NTNlZGE5ZWJlY2Q3ZGVjMjc2ZDhjMTc=
|
@@ -93,7 +93,7 @@ module Dynflow
|
|
93
93
|
|
94
94
|
def find_past_delayed_plans(time)
|
95
95
|
table(:delayed)
|
96
|
-
.where('start_at <= ?', time)
|
96
|
+
.where('start_at <= ? OR (start_before IS NOT NULL AND start_before <= ?)', time, time)
|
97
97
|
.order_by(:start_at)
|
98
98
|
.all
|
99
99
|
.map { |plan| load_data(plan) }
|
@@ -20,19 +20,19 @@ module Dynflow
|
|
20
20
|
end
|
21
21
|
|
22
22
|
def perform_serialization!
|
23
|
-
@serialized_args = serialize
|
23
|
+
@serialized_args = args.map { |arg| serialize arg }
|
24
24
|
end
|
25
25
|
|
26
26
|
def perform_deserialization!
|
27
27
|
raise "@serialized_args not set" if @serialized_args.nil?
|
28
|
-
@args = deserialize
|
28
|
+
@args = serialized_args.map { |arg| deserialize arg }
|
29
29
|
end
|
30
30
|
|
31
|
-
def serialize
|
31
|
+
def serialize(arg)
|
32
32
|
raise NotImplementedError
|
33
33
|
end
|
34
34
|
|
35
|
-
def deserialize
|
35
|
+
def deserialize(arg)
|
36
36
|
raise NotImplementedError
|
37
37
|
end
|
38
38
|
|
data/lib/dynflow/version.rb
CHANGED
data/test/middleware_test.rb
CHANGED
@@ -110,6 +110,21 @@ module Dynflow
|
|
110
110
|
run
|
111
111
|
output#message:finished]
|
112
112
|
end
|
113
|
+
|
114
|
+
it "allows modification of the running action when delaying execution" do
|
115
|
+
world = WorldFactory.create_world
|
116
|
+
world.middleware.use(Support::MiddlewareExample::AnotherObservingMiddleware,
|
117
|
+
replace: Support::MiddlewareExample::LogRunMiddleware)
|
118
|
+
delay = world.delay(Support::MiddlewareExample::Action, { :start_at => Time.now - 60 })
|
119
|
+
plan = world.persistence.load_delayed_plan delay.execution_plan_id
|
120
|
+
plan.plan
|
121
|
+
plan.execute.wait
|
122
|
+
log.must_equal ["delay#set-input:#{world.id}",
|
123
|
+
"plan#input:#{world.id}",
|
124
|
+
"input#message:#{world.id}",
|
125
|
+
'run',
|
126
|
+
'output#message:finished']
|
127
|
+
end
|
113
128
|
end
|
114
129
|
end
|
115
130
|
end
|
data/test/persistence_test.rb
CHANGED
@@ -8,7 +8,8 @@ module Dynflow
|
|
8
8
|
let :execution_plans_data do
|
9
9
|
[{ id: 'plan1', state: 'paused' },
|
10
10
|
{ id: 'plan2', state: 'stopped' },
|
11
|
-
{ id: 'plan3', state: 'paused' }
|
11
|
+
{ id: 'plan3', state: 'paused' },
|
12
|
+
{ id: 'plan4', state: 'paused' }]
|
12
13
|
end
|
13
14
|
|
14
15
|
let :action_data do
|
@@ -132,7 +133,7 @@ module Dynflow
|
|
132
133
|
adapter.load_step('plan2', step_data[:id])
|
133
134
|
|
134
135
|
prepare_plans_with_steps
|
135
|
-
adapter.delete_execution_plans('state' => 'paused').must_equal
|
136
|
+
adapter.delete_execution_plans('state' => 'paused').must_equal 3
|
136
137
|
-> { adapter.load_execution_plan('plan1') }.must_raise KeyError
|
137
138
|
adapter.load_execution_plan('plan2') # nothing raised
|
138
139
|
-> { adapter.load_execution_plan('plan3') }.must_raise KeyError
|
@@ -167,6 +168,21 @@ module Dynflow
|
|
167
168
|
loaded_step.must_equal(Utils.stringify_keys(step_data))
|
168
169
|
end
|
169
170
|
end
|
171
|
+
|
172
|
+
describe '#find_past_delayed_plans' do
|
173
|
+
it 'finds plans with start_before in past' do
|
174
|
+
start_time = Time.now
|
175
|
+
prepare_plans
|
176
|
+
fmt =->(time) { time.strftime('%Y-%m-%d %H:%M:%S') }
|
177
|
+
adapter.save_delayed_plan('plan1', :execution_plan_uuid => 'plan1', :start_at => fmt.call(start_time + 60), :start_before => fmt.call(start_time - 60))
|
178
|
+
adapter.save_delayed_plan('plan2', :execution_plan_uuid => 'plan2', :start_at => fmt.call(start_time - 60))
|
179
|
+
adapter.save_delayed_plan('plan3', :execution_plan_uuid => 'plan3', :start_at => fmt.call(start_time + 60))
|
180
|
+
adapter.save_delayed_plan('plan4', :execution_plan_uuid => 'plan4', :start_at => fmt.call(start_time - 60), :start_before => fmt.call(start_time - 60))
|
181
|
+
plans = adapter.find_past_delayed_plans(start_time)
|
182
|
+
plans.length.must_equal 3
|
183
|
+
plans.map { |plan| plan[:execution_plan_uuid] }.must_equal %w(plan2 plan4 plan1)
|
184
|
+
end
|
185
|
+
end
|
170
186
|
end
|
171
187
|
|
172
188
|
describe Dynflow::PersistenceAdapters::Sequel do
|
@@ -6,16 +6,10 @@ module Support
|
|
6
6
|
def run; end
|
7
7
|
end
|
8
8
|
|
9
|
-
class MySerializer < Dynflow::Serializers::
|
10
|
-
def serialize
|
11
|
-
if
|
12
|
-
|
13
|
-
end
|
14
|
-
args
|
15
|
-
end
|
16
|
-
|
17
|
-
def deserialize
|
18
|
-
serialized_args
|
9
|
+
class MySerializer < Dynflow::Serializers::Noop
|
10
|
+
def serialize(arg)
|
11
|
+
raise 'Enforced serializer failure' if arg == :fail
|
12
|
+
super arg
|
19
13
|
end
|
20
14
|
end
|
21
15
|
|
@@ -111,6 +111,22 @@ module Support
|
|
111
111
|
end
|
112
112
|
end
|
113
113
|
|
114
|
+
class AnotherObservingMiddleware < ObservingMiddleware
|
115
|
+
|
116
|
+
def delay(*args)
|
117
|
+
pass(*args).tap do
|
118
|
+
log("delay#set-input:#{action.world.id}")
|
119
|
+
action.input[:message] = action.world.id
|
120
|
+
end
|
121
|
+
end
|
122
|
+
|
123
|
+
def plan(*args)
|
124
|
+
log("plan#input:#{action.input[:message]}")
|
125
|
+
pass(*args)
|
126
|
+
end
|
127
|
+
|
128
|
+
end
|
129
|
+
|
114
130
|
class Action < Dynflow::Action
|
115
131
|
middleware.use LogRunMiddleware
|
116
132
|
|
data/test/test_helper.rb
CHANGED
@@ -1,11 +1,9 @@
|
|
1
1
|
require 'bundler/setup'
|
2
|
+
require 'minitest/reporters'
|
2
3
|
require 'minitest/autorun'
|
3
4
|
require 'minitest/spec'
|
4
5
|
|
5
|
-
if ENV['RM_INFO']
|
6
|
-
require 'minitest/reporters'
|
7
|
-
MiniTest::Reporters.use!
|
8
|
-
end
|
6
|
+
MiniTest::Reporters.use! if ENV['RM_INFO']
|
9
7
|
|
10
8
|
load_path = File.expand_path(File.dirname(__FILE__))
|
11
9
|
$LOAD_PATH << load_path unless $LOAD_PATH.include? load_path
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dynflow
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.8.
|
4
|
+
version: 0.8.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ivan Necas
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2015-
|
12
|
+
date: 2015-09-17 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: multi_json
|