dynflow 1.0.2 → 1.0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: a92e48caa3237c278bd91fe10690740859ae29fc
4
- data.tar.gz: 79b17f3f3119f954c58e6d2544f3a9725d51778d
2
+ SHA256:
3
+ metadata.gz: 496dae66a524bd0ede6a777b555b2cd38488fbe31db105d1fb0d8f71d765038e
4
+ data.tar.gz: 696856cee44db5d23f0ca4a3b139397ab942a31c573f133aac1f5c2115852833
5
5
  SHA512:
6
- metadata.gz: 58e2dab7d4634009ba158642d3959c60e2633d9ebdbe3b0c6afaa3c3b9f338868fb788e0ec4c55a9bc66032ff2e420375e496bc1c77c970edde83a57c965fe77
7
- data.tar.gz: d9f22b6954465c5c08f9a0f9fdd059e8a9e4ebeb04f21ee2791b27597edf2b5697f7b7ee4926412b85d9095d29ff6e4c47a8258d03252745af0f2d25b9d1f233
6
+ metadata.gz: 27cf8a56c6a94d0407051542dfbe495c67e46ca5a0b1c6558835f37cf8ba0335c9c3e249866d9dfa45247c54ed64cf7b355f759147150546b7b885b3ad521581
7
+ data.tar.gz: c40e8eaa9977fa076cf86281d84dd05dc90335260b97453a50a60dc9e05fe45534204ca0d89530c94fdcc2c9dc81f9e3fbfd0f363f0e9085aed3a43b05def968
@@ -120,7 +120,7 @@ module Dynflow
120
120
  @ended_at = Time.now
121
121
  @real_time = @ended_at - @started_at unless @started_at.nil?
122
122
  @execution_time = compute_execution_time
123
- hooks_to_run << (error? ? :failure : :success)
123
+ hooks_to_run << (failure? ? :failure : :success)
124
124
  unlock_all_singleton_locks!
125
125
  when :paused
126
126
  unlock_all_singleton_locks!
@@ -165,6 +165,10 @@ module Dynflow
165
165
  result == :error
166
166
  end
167
167
 
168
+ def failure?
169
+ [:error, :warning, :cancelled].include?(result)
170
+ end
171
+
168
172
  def error_in_plan?
169
173
  steps_in_state(:error).any? { |step| step.is_a? Steps::PlanStep }
170
174
  end
@@ -44,11 +44,8 @@ module Dynflow
44
44
  end
45
45
 
46
46
  require rails_env_file
47
- world_id = if ::Rails.application.dynflow.initialized?
48
- ::Rails.application.dynflow.world.id
49
- else
50
- nil
51
- end
47
+ ::Rails.application.dynflow.initialize!
48
+ world_id = ::Rails.application.dynflow.world.id
52
49
  STDOUT.puts("Everything ready for world: #{world_id}")
53
50
  sleep
54
51
  ensure
@@ -1,3 +1,3 @@
1
1
  module Dynflow
2
- VERSION = '1.0.2'.freeze
2
+ VERSION = '1.0.3'.freeze
3
3
  end
@@ -15,6 +15,7 @@ class DaemonTest < ActiveSupport::TestCase
15
15
  )
16
16
  @world_class = mock('dummy world factory')
17
17
  @dummy_world = ::Dynflow::Testing::DummyWorld.new
18
+ @dummy_world.stubs(:id => '123')
18
19
  @dummy_world.stubs(:auto_execute)
19
20
  @dummy_world.stubs(:perform_validity_checks)
20
21
  @event = Concurrent.event
@@ -28,6 +29,7 @@ class DaemonTest < ActiveSupport::TestCase
28
29
  ::Rails.stubs(:root).returns('support/rails')
29
30
  ::Rails.stubs(:logger).returns(Logging.logger(STDOUT))
30
31
  @dynflow.require!
32
+ @dynflow.config.stubs(:increase_db_pool_size? => false)
31
33
  @daemon.stubs(:sleep).returns(true) # don't pause the execution
32
34
  @current_folder = File.expand_path('../support/rails/', __FILE__)
33
35
  ::ActiveRecord::Base.configurations = { 'development' => {} }
@@ -46,12 +46,19 @@ module Dynflow
46
46
  execution_plan_hooks.use :controlled_failure, :on => :stopped
47
47
  end
48
48
 
49
+ class ActionOnFailure < ::Dynflow::Action
50
+ include FlagHook
51
+
52
+ execution_plan_hooks.use :raise_flag, :on => :failure
53
+ end
54
+
49
55
  class Inherited < ActionWithHooks; end
50
56
  class Overriden < ActionWithHooks
51
57
  execution_plan_hooks.do_not_use :raise_flag
52
58
  end
53
59
 
54
60
  before { Flag.lower! }
61
+ after { world.persistence.delete_delayed_plans({}) }
55
62
 
56
63
  it 'runs the on_success hook' do
57
64
  refute Flag.raised?
@@ -60,6 +67,15 @@ module Dynflow
60
67
  assert Flag.raised?
61
68
  end
62
69
 
70
+ it 'runs the on_failure hook on cancel' do
71
+ refute Flag.raised?
72
+ @start_at = Time.now.utc + 180
73
+ delay = world.delay(ActionOnFailure, { :start_at => @start_at })
74
+ delayed_plan = world.persistence.load_delayed_plan(delay.execution_plan_id)
75
+ delayed_plan.execution_plan.cancel.each(&:wait)
76
+ assert Flag.raised?
77
+ end
78
+
63
79
  it 'does not alter the execution plan when exception happens in the hook' do
64
80
  refute Flag.raised?
65
81
  plan = world.plan(ActionOnStop)
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: 1.0.2
4
+ version: 1.0.3
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: 2018-05-03 00:00:00.000000000 Z
12
+ date: 2018-05-15 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: multi_json
@@ -602,7 +602,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
602
602
  version: '0'
603
603
  requirements: []
604
604
  rubyforge_project:
605
- rubygems_version: 2.6.12
605
+ rubygems_version: 2.7.3
606
606
  signing_key:
607
607
  specification_version: 4
608
608
  summary: DYNamic workFLOW engine