dynflow 0.8.9 → 0.8.10

Sign up to get free protection for your applications and to get access to all the features.
@@ -69,11 +69,11 @@ module Dynflow
69
69
  execution_plan.result.must_equal :pending
70
70
  assert_planning_success execution_plan
71
71
  history_names.call(execution_plan).must_equal ['delay']
72
- executed = delayed_plan.execute
73
- executed.wait
74
- executed.value.state.must_equal :stopped
75
- executed.value.result.must_equal :success
76
- executed.value.execution_history.count.must_equal 3
72
+ delayed_plan.execute.future.wait
73
+ executed = world.persistence.load_execution_plan(delayed_plan.execution_plan_uuid)
74
+ executed.state.must_equal :stopped
75
+ executed.result.must_equal :success
76
+ executed.execution_history.count.must_equal 3
77
77
  end
78
78
 
79
79
  it 'expired plans can be failed' do
@@ -15,7 +15,7 @@ module Dynflow
15
15
  delay = world.delay(Support::MiddlewareExample::LoggingAction, { :start_at => Time.now.utc - 60 }, {})
16
16
  plan = world.persistence.load_delayed_plan delay.execution_plan_id
17
17
  plan.plan
18
- plan.execute.wait
18
+ plan.execute.future.wait
19
19
  log.must_equal %w[LogMiddleware::before_delay
20
20
  delay
21
21
  LogMiddleware::after_delay
@@ -125,7 +125,7 @@ module Dynflow
125
125
  delay = world.delay(Support::MiddlewareExample::Action, { :start_at => Time.now - 60 })
126
126
  plan = world.persistence.load_delayed_plan delay.execution_plan_id
127
127
  plan.plan
128
- plan.execute.wait
128
+ plan.execute.future.wait
129
129
  log.must_equal ["delay#set-input:#{world.id}",
130
130
  "plan#input:#{world.id}",
131
131
  "input#message:#{world.id}",
@@ -31,5 +31,5 @@ if [ "$CONCURRENT_RUBY_EXT" = "true" ]; then
31
31
  echo "Enabling concurrent-ruby-ext"
32
32
  sed -i 's/:concurrent_ruby_ext//'g $BUNDLE_CONFIG
33
33
  fi
34
-
34
+ gem update bundler
35
35
  bundle install
@@ -0,0 +1,98 @@
1
+ require_relative 'test_helper'
2
+
3
+ module Dynflow
4
+ module SemaphoresTest
5
+ describe ::Dynflow::Semaphores::Stateful do
6
+
7
+ let(:semaphore_class) { ::Dynflow::Semaphores::Stateful }
8
+ let(:tickets_count) { 5 }
9
+
10
+ it 'can be used as counter' do
11
+ expected_state = { :tickets => tickets_count, :free => 4, :meta => {} }
12
+ 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)
22
+ semaphore.release
23
+ semaphore.free.must_equal tickets_count - (3 + 1)
24
+ semaphore.release 3
25
+ semaphore.free.must_equal tickets_count - 1
26
+ semaphore.to_hash.must_equal expected_state
27
+ end
28
+
29
+ it 'can have things waiting on it' do
30
+ semaphore = semaphore_class.new 1
31
+ allowed = semaphore.wait(1)
32
+ allowed.must_equal true
33
+ semaphore.free.must_equal 0
34
+ allowed = semaphore.wait(2)
35
+ allowed.must_equal false
36
+ allowed = semaphore.wait(3)
37
+ allowed.must_equal false
38
+ waiting = semaphore.get_waiting
39
+ waiting.must_equal 2
40
+ waiting = semaphore.get_waiting
41
+ waiting.must_equal 3
42
+ end
43
+
44
+ end
45
+
46
+ describe ::Dynflow::Semaphores::Dummy do
47
+ let(:semaphore_class) { ::Dynflow::Semaphores::Dummy }
48
+
49
+ it 'always has free' do
50
+ semaphore = semaphore_class.new
51
+ semaphore.free.must_equal 1
52
+ semaphore.get(5).must_equal 5
53
+ semaphore.free.must_equal 1
54
+ end
55
+
56
+ it 'cannot have things waiting on it' do
57
+ semaphore = semaphore_class.new
58
+ semaphore.wait(1).must_equal true
59
+ semaphore.has_waiting?.must_equal false
60
+ end
61
+ end
62
+
63
+ describe ::Dynflow::Semaphores::Aggregating do
64
+ let(:klass) { ::Dynflow::Semaphores::Aggregating }
65
+ let(:child_class) { ::Dynflow::Semaphores::Stateful }
66
+ let(:children) do
67
+ {
68
+ :child_A => child_class.new(3),
69
+ :child_B => child_class.new(2)
70
+ }
71
+ end
72
+
73
+ 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
77
+ end
78
+
79
+ it 'can be used as counter' do
80
+ semaphore = klass.new(children)
81
+ assert_semaphore_state semaphore, 3, 2
82
+ semaphore.get.must_equal 1
83
+ assert_semaphore_state semaphore, 2, 1
84
+ semaphore.get.must_equal 1
85
+ assert_semaphore_state semaphore, 1, 0
86
+ semaphore.get.must_equal 0
87
+ assert_semaphore_state semaphore, 1, 0
88
+ semaphore.release
89
+ assert_semaphore_state semaphore, 2, 1
90
+ semaphore.release(1, :child_B)
91
+ assert_semaphore_state semaphore, 2, 2
92
+ semaphore.drain.must_equal 2
93
+ assert_semaphore_state semaphore, 0, 0
94
+ end
95
+ end
96
+
97
+ end
98
+ end
@@ -166,7 +166,7 @@ module TestHelpers
166
166
  return ret if ret
167
167
  sleep 0.3
168
168
  end
169
- raise 'waiting for something to happend was not successful'
169
+ raise 'waiting for something to happen was not successful'
170
170
  end
171
171
 
172
172
  def executor_id_for_plan(execution_plan_id)
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.9
4
+ version: 0.8.10
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-04 00:00:00.000000000 Z
12
+ date: 2016-02-15 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: multi_json
@@ -59,28 +59,28 @@ dependencies:
59
59
  requirements:
60
60
  - - "~>"
61
61
  - !ruby/object:Gem::Version
62
- version: 1.0.0
62
+ version: '1.0'
63
63
  type: :runtime
64
64
  prerelease: false
65
65
  version_requirements: !ruby/object:Gem::Requirement
66
66
  requirements:
67
67
  - - "~>"
68
68
  - !ruby/object:Gem::Version
69
- version: 1.0.0
69
+ version: '1.0'
70
70
  - !ruby/object:Gem::Dependency
71
71
  name: concurrent-ruby-edge
72
72
  requirement: !ruby/object:Gem::Requirement
73
73
  requirements:
74
74
  - - "~>"
75
75
  - !ruby/object:Gem::Version
76
- version: 0.2.0
76
+ version: '0.2'
77
77
  type: :runtime
78
78
  prerelease: false
79
79
  version_requirements: !ruby/object:Gem::Requirement
80
80
  requirements:
81
81
  - - "~>"
82
82
  - !ruby/object:Gem::Version
83
- version: 0.2.0
83
+ version: '0.2'
84
84
  - !ruby/object:Gem::Dependency
85
85
  name: sequel
86
86
  requirement: !ruby/object:Gem::Requirement
@@ -332,6 +332,7 @@ files:
332
332
  - examples/orchestrate.rb
333
333
  - examples/orchestrate_evented.rb
334
334
  - examples/remote_executor.rb
335
+ - examples/sub_plan_concurrency_control.rb
335
336
  - examples/sub_plans.rb
336
337
  - lib/dynflow.rb
337
338
  - lib/dynflow/action.rb
@@ -420,6 +421,11 @@ files:
420
421
  - lib/dynflow/persistence_adapters/sequel_migrations/007_future_execution.rb
421
422
  - lib/dynflow/persistence_adapters/sequel_migrations/008_rename_scheduled_plans_to_delayed_plans.rb
422
423
  - lib/dynflow/round_robin.rb
424
+ - lib/dynflow/semaphores.rb
425
+ - lib/dynflow/semaphores/abstract.rb
426
+ - lib/dynflow/semaphores/aggregating.rb
427
+ - lib/dynflow/semaphores/dummy.rb
428
+ - lib/dynflow/semaphores/stateful.rb
423
429
  - lib/dynflow/serializable.rb
424
430
  - lib/dynflow/serializer.rb
425
431
  - lib/dynflow/serializers.rb
@@ -436,6 +442,7 @@ files:
436
442
  - lib/dynflow/testing/factories.rb
437
443
  - lib/dynflow/testing/managed_clock.rb
438
444
  - lib/dynflow/testing/mimic.rb
445
+ - lib/dynflow/throttle_limiter.rb
439
446
  - lib/dynflow/transaction_adapters.rb
440
447
  - lib/dynflow/transaction_adapters/abstract.rb
441
448
  - lib/dynflow/transaction_adapters/active_record.rb
@@ -452,6 +459,7 @@ files:
452
459
  - test/abnormal_states_recovery_test.rb
453
460
  - test/action_test.rb
454
461
  - test/clock_test.rb
462
+ - test/concurrency_control_test.rb
455
463
  - test/coordinator_test.rb
456
464
  - test/dispatcher_test.rb
457
465
  - test/execution_plan_test.rb
@@ -462,6 +470,7 @@ files:
462
470
  - test/prepare_travis_env.sh
463
471
  - test/rescue_test.rb
464
472
  - test/round_robin_test.rb
473
+ - test/semaphores_test.rb
465
474
  - test/support/code_workflow_example.rb
466
475
  - test/support/dummy_example.rb
467
476
  - test/support/middleware_example.rb
@@ -519,7 +528,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
519
528
  version: '0'
520
529
  requirements: []
521
530
  rubyforge_project:
522
- rubygems_version: 2.4.5
531
+ rubygems_version: 2.2.0
523
532
  signing_key:
524
533
  specification_version: 4
525
534
  summary: DYNamic workFLOW engine
@@ -527,6 +536,7 @@ test_files:
527
536
  - test/abnormal_states_recovery_test.rb
528
537
  - test/action_test.rb
529
538
  - test/clock_test.rb
539
+ - test/concurrency_control_test.rb
530
540
  - test/coordinator_test.rb
531
541
  - test/dispatcher_test.rb
532
542
  - test/execution_plan_test.rb
@@ -537,6 +547,7 @@ test_files:
537
547
  - test/prepare_travis_env.sh
538
548
  - test/rescue_test.rb
539
549
  - test/round_robin_test.rb
550
+ - test/semaphores_test.rb
540
551
  - test/support/code_workflow_example.rb
541
552
  - test/support/dummy_example.rb
542
553
  - test/support/middleware_example.rb