aws-flow 1.0.8 → 1.0.9

Sign up to get free protection for your applications and to get access to all the features.
Files changed (55) hide show
  1. checksums.yaml +7 -0
  2. data/Gemfile +1 -1
  3. data/Rakefile +18 -31
  4. data/aws-flow.gemspec +1 -1
  5. data/lib/aws/decider.rb +1 -2
  6. data/lib/aws/decider/activity.rb +99 -53
  7. data/lib/aws/decider/activity_definition.rb +43 -7
  8. data/lib/aws/decider/async_decider.rb +56 -57
  9. data/lib/aws/decider/async_retrying_executor.rb +4 -5
  10. data/lib/aws/decider/data_converter.rb +2 -2
  11. data/lib/aws/decider/decider.rb +46 -41
  12. data/lib/aws/decider/decision_context.rb +2 -2
  13. data/lib/aws/decider/exceptions.rb +6 -6
  14. data/lib/aws/decider/executor.rb +15 -11
  15. data/lib/aws/decider/flow_defaults.rb +54 -22
  16. data/lib/aws/decider/generic_client.rb +7 -7
  17. data/lib/aws/decider/history_helper.rb +0 -0
  18. data/lib/aws/decider/implementation.rb +5 -5
  19. data/lib/aws/decider/options.rb +285 -155
  20. data/lib/aws/decider/state_machines.rb +10 -10
  21. data/lib/aws/decider/task_handler.rb +5 -5
  22. data/lib/aws/decider/task_poller.rb +152 -15
  23. data/lib/aws/decider/utilities.rb +14 -14
  24. data/lib/aws/decider/version.rb +1 -1
  25. data/lib/aws/decider/worker.rb +21 -20
  26. data/lib/aws/decider/workflow_client.rb +78 -31
  27. data/lib/aws/decider/workflow_clock.rb +1 -1
  28. data/lib/aws/decider/workflow_definition.rb +5 -5
  29. data/lib/aws/decider/workflow_definition_factory.rb +1 -1
  30. data/lib/aws/decider/workflow_enabled.rb +1 -1
  31. data/lib/aws/flow/async_backtrace.rb +19 -18
  32. data/lib/aws/flow/async_scope.rb +32 -16
  33. data/lib/aws/flow/begin_rescue_ensure.rb +61 -56
  34. data/lib/aws/flow/fiber.rb +14 -6
  35. data/lib/aws/flow/flow_utils.rb +9 -6
  36. data/lib/aws/flow/future.rb +43 -18
  37. data/lib/aws/flow/implementation.rb +34 -18
  38. data/lib/aws/flow/simple_dfa.rb +12 -4
  39. data/lib/aws/flow/tasks.rb +120 -86
  40. data/{test/aws → spec/aws/integration}/integration_spec.rb +0 -0
  41. data/{test/aws → spec/aws/unit}/async_backtrace_spec.rb +1 -0
  42. data/{test/aws → spec/aws/unit}/async_scope_spec.rb +0 -0
  43. data/{test/aws → spec/aws/unit}/begin_rescue_ensure_spec.rb +90 -2
  44. data/{test/aws → spec/aws/unit}/decider_spec.rb +41 -53
  45. data/{test/aws → spec/aws/unit}/external_task_spec.rb +0 -0
  46. data/{test/aws → spec/aws/unit}/factories.rb +0 -0
  47. data/{test/aws → spec/aws/unit}/fiber_condition_variable_spec.rb +0 -0
  48. data/{test/aws → spec/aws/unit}/fiber_spec.rb +0 -0
  49. data/{test/aws → spec/aws/unit}/flow_spec.rb +0 -0
  50. data/{test/aws → spec/aws/unit}/future_spec.rb +0 -0
  51. data/{test/aws → spec/aws/unit}/preinclude_tests.rb +0 -0
  52. data/{test/aws → spec/aws/unit}/rubyflow.rb +0 -0
  53. data/{test/aws → spec/aws/unit}/simple_dfa_spec.rb +0 -0
  54. data/{test/aws → spec}/spec_helper.rb +0 -0
  55. metadata +30 -30
@@ -12,6 +12,7 @@
12
12
  # express or implied. See the License for the specific language governing
13
13
  # permissions and limitations under the License.
14
14
  ##
15
+ require 'spec_helper'
15
16
 
16
17
  def validate_stacktrace_content(method_to_call_on_async_backtrace, thing_to_look_for, should_it_be_there)
17
18
  it "makes sure that any of #{thing_to_look_for.join", "} #{should_it_be_there} be printed when we call #{method_to_call_on_async_backtrace} on AsyncBacktrace" do
@@ -62,6 +62,7 @@ describe BeginRescueEnsure do
62
62
  let(:catching_BRE) do
63
63
  make_catching_BRE
64
64
  end
65
+
65
66
  context "BeginRescueEnsure in the :trying state" do
66
67
  subject { trying_BRE }
67
68
  its(:heirs) { should_not be_empty }
@@ -361,7 +362,7 @@ describe BeginRescueEnsure do
361
362
  end
362
363
  # TODO Make rescue give a specific error in this case
363
364
 
364
- expect { scope.eventLoop }.to raise_error /You have already registered RescueTestingError/
365
+ expect { scope.eventLoop }.to raise_error /You have already registered \[RescueTestingError\]/
365
366
  end
366
367
 
367
368
  it "ensures that stack traces work properly" do
@@ -499,7 +500,94 @@ describe BeginRescueEnsure do
499
500
  trace.should == []
500
501
  end
501
502
 
502
- describe "BRE's closed behavior" do
503
+ # Tests in the following context are used to test the feature
504
+ context "when handling multiple exceptions in one block" do
505
+ it "ensures that rescue blocks can take in multiple exceptions" do
506
+ scope = AsyncScope.new do
507
+ error_handler do |t|
508
+ t.begin do
509
+ trace << :in_the_begin
510
+ raise RescueTestingError
511
+ end
512
+ t.rescue(RescueTestingError, ArgumentError) { trace << :in_the_rescue }
513
+ end
514
+ end
515
+ scope.eventLoop
516
+ trace.should == [:in_the_begin, :in_the_rescue]
517
+ end
518
+
519
+ it "ensures that blocks go to the first applicable block" do
520
+ scope = AsyncScope.new do
521
+ error_handler do |t|
522
+ t.begin do
523
+ trace << :in_the_begin
524
+ raise RescueTestingError
525
+ end
526
+ t.rescue(IOError) { trace << :bad_rescue }
527
+ t.rescue(RescueTestingError, ArgumentError) { trace << :in_the_rescue }
528
+ t.rescue(RescueTestingError) { trace << :bad_rescue_2 }
529
+ end
530
+ end
531
+ scope.eventLoop
532
+ trace.should == [:in_the_begin, :in_the_rescue]
533
+ end
534
+
535
+ it "makes sure an error is raised if none of the rescue blocks apply to it" do
536
+ scope = AsyncScope.new do
537
+ error_handler do |t|
538
+ t.begin { raise RescueTestingError }
539
+ t.rescue(IOError, ArgumentError) { p "nothing doing here" }
540
+ end
541
+ end
542
+ expect { scope.eventLoop }.to raise_error RescueTestingError
543
+ end
544
+
545
+ it "ensures that the ensure block is called with a rescue path" do
546
+ scope = AsyncScope.new do
547
+ error_handler do |t|
548
+ t.begin do
549
+ trace << :in_the_begin
550
+ raise RescueTestingError
551
+ end
552
+ t.rescue(IOError, RescueTestingError) { trace << :in_the_rescue }
553
+ t.ensure { trace << :in_the_ensure }
554
+ end
555
+ end
556
+ scope.eventLoop
557
+ trace.should == [:in_the_begin, :in_the_rescue, :in_the_ensure]
558
+ end
559
+
560
+ it "ensures that the ensure block is called and the error is passed up
561
+ without an applicable rescue case" do
562
+ scope = AsyncScope.new do
563
+ error_handler do |t|
564
+ t.begin do
565
+ trace << :in_the_begin
566
+ raise RescueTestingError
567
+ end
568
+ t.rescue(IOError, ArgumentError) { trace << :in_the_rescue }
569
+ t.ensure { trace << :in_the_ensure }
570
+ expect { scope.eventLoop }.to raise_error RescueTestingError
571
+ trace.should == [:in_the_begin, :in_the_ensure]
572
+ end
573
+ end
574
+ end
575
+
576
+ it "ensures that the same rescue exception twice causes an exception" do
577
+ scope = AsyncScope.new do
578
+ error_handler do |t|
579
+ t.begin {}
580
+ t.rescue(RescueTestingError, ArgumentError) {}
581
+ t.rescue(RescueTestingError, ArgumentError) {}
582
+ end
583
+ end
584
+ # TODO Make rescue give a specific error in this case
585
+
586
+ expect { scope.eventLoop }.to raise_error /You have already registered \[RescueTestingError, ArgumentError\]/
587
+ end
588
+ end
589
+
590
+ describe "BRE's closed behavior" do
503
591
  before (:each) do
504
592
  @scope = AsyncScope.new do
505
593
  @error_handler = error_handler do |t|
@@ -22,6 +22,30 @@ class FakeConfig
22
22
 
23
23
  end
24
24
  end
25
+ class FakeServiceClient
26
+ attr_accessor :trace
27
+ def respond_decision_task_completed(task_completed_request)
28
+ @trace ||= []
29
+ @trace << task_completed_request
30
+ end
31
+ def start_workflow_execution(options)
32
+ @trace ||= []
33
+ @trace << options
34
+ {"runId" => "blah"}
35
+ end
36
+ def register_activity_type(options)
37
+ end
38
+ def register_workflow_type(options)
39
+ end
40
+ def respond_activity_task_completed(task_token, result)
41
+ end
42
+ def start_workflow_execution(options)
43
+ {"runId" => "blah"}
44
+ end
45
+ def config
46
+ FakeConfig.new
47
+ end
48
+ end
25
49
 
26
50
  $RUBYFLOW_DECIDER_DOMAIN = "rubyflow_decider_domain_06-12-2012"
27
51
  $RUBYFLOW_DECIDER_TASK_LIST = 'test_task_list'
@@ -178,21 +202,6 @@ end
178
202
 
179
203
  describe WorkflowClient do
180
204
 
181
- class FakeServiceClient
182
- attr_accessor :trace
183
- def respond_decision_task_completed(task_completed_request)
184
- @trace ||= []
185
- @trace << task_completed_request
186
- end
187
- def start_workflow_execution(options)
188
- @trace ||= []
189
- @trace << options
190
- {"runId" => "blah"}
191
- end
192
- def register_workflow_type(options)
193
- end
194
-
195
- end
196
205
  class TestWorkflow
197
206
  extend Decider
198
207
 
@@ -388,20 +397,6 @@ end
388
397
  describe WorkflowFactory do
389
398
  it "ensures that you can create a workflow_client without access to the Workflow definition" do
390
399
  workflow_type_object = double("workflow_type", :name => "NonExistantWorkflow.some_entry_method", :start_execution => "" )
391
- class FakeServiceClient
392
- attr_accessor :trace
393
- def respond_decision_task_completed(task_completed_request)
394
- @trace ||= []
395
- @trace << task_completed_request
396
- end
397
- def start_workflow_execution(options)
398
- @trace ||= []
399
- @trace << options
400
- {"runId" => "blah"}
401
- end
402
- def register_workflow_type(options)
403
- end
404
- end
405
400
  domain = FakeDomain.new(workflow_type_object)
406
401
  swf_client = FakeServiceClient.new
407
402
  my_workflow_factory = workflow_factory(swf_client, domain) do |options|
@@ -431,30 +426,6 @@ describe "FakeHistory" do
431
426
  end
432
427
  end
433
428
 
434
- class FakeServiceClient
435
- attr_accessor :trace
436
- def respond_decision_task_completed(task_completed_request)
437
- @trace ||= []
438
- @trace << task_completed_request
439
- end
440
- def start_workflow_execution(options)
441
- @trace ||= []
442
- @trace << options
443
- {"runId" => "blah"}
444
- end
445
- def register_activity_type(options)
446
- end
447
- def register_workflow_type(options)
448
- end
449
- def respond_activity_task_completed(task_token, result)
450
- end
451
- def start_workflow_execution(options)
452
- {"runId" => "blah"}
453
- end
454
- def config
455
- FakeConfig.new
456
- end
457
- end
458
429
 
459
430
  class Hash
460
431
  def to_h; self; end
@@ -1820,4 +1791,21 @@ describe "testing changing default values in RetryOptions and RetryPolicy" do
1820
1791
  result = FlowConstants.exponential_retry_function.call(first, time_of_failure, attempts, options)
1821
1792
  result.should == 5
1822
1793
  end
1794
+
1795
+ it "ensures that the next_retry_delay_seconds honors -1 returned by the retry function" do
1796
+ my_retry_func = lambda do |first, time_of_failure, attempts|
1797
+ -1
1798
+ end
1799
+ options = {
1800
+ :should_jitter => true
1801
+ }
1802
+ retry_policy = RetryPolicy.new(my_retry_func, RetryOptions.new(options))
1803
+ result = retry_policy.next_retry_delay_seconds(Time.now, 0, {Exception=>10}, Exception, 1)
1804
+ result.should == -1
1805
+ end
1806
+
1807
+ it "ensures that the jitter function checks arguments passed to it" do
1808
+ expect { FlowConstants.jitter_function.call(1, -1) }.to raise_error(
1809
+ ArgumentError, "max_value should be greater than 0")
1810
+ end
1823
1811
  end
File without changes
File without changes
File without changes
File without changes
metadata CHANGED
@@ -1,46 +1,47 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: aws-flow
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.8
5
- prerelease:
4
+ version: 1.0.9
6
5
  platform: ruby
7
6
  authors:
8
7
  - Michael Steger
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2014-01-03 00:00:00.000000000 Z
11
+ date: 2014-03-31 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: aws-sdk
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
17
  - - ~>
20
18
  - !ruby/object:Gem::Version
21
19
  version: '1'
20
+ - - '>='
21
+ - !ruby/object:Gem::Version
22
+ version: 1.36.2
22
23
  type: :runtime
23
24
  prerelease: false
24
25
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
26
  requirements:
27
27
  - - ~>
28
28
  - !ruby/object:Gem::Version
29
29
  version: '1'
30
+ - - '>='
31
+ - !ruby/object:Gem::Version
32
+ version: 1.36.2
30
33
  - !ruby/object:Gem::Dependency
31
34
  name: aws-flow-core
32
35
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
36
  requirements:
35
- - - ! '>='
37
+ - - '>='
36
38
  - !ruby/object:Gem::Version
37
39
  version: 1.0.1
38
40
  type: :runtime
39
41
  prerelease: false
40
42
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
43
  requirements:
43
- - - ! '>='
44
+ - - '>='
44
45
  - !ruby/object:Gem::Version
45
46
  version: 1.0.1
46
47
  description: Library to provide the AWS Flow Framework for Ruby
@@ -90,44 +91,43 @@ files:
90
91
  - lib/aws/flow/implementation.rb
91
92
  - lib/aws/flow/simple_dfa.rb
92
93
  - lib/aws/flow/tasks.rb
93
- - test/aws/async_backtrace_spec.rb
94
- - test/aws/async_scope_spec.rb
95
- - test/aws/begin_rescue_ensure_spec.rb
96
- - test/aws/decider_spec.rb
97
- - test/aws/external_task_spec.rb
98
- - test/aws/factories.rb
99
- - test/aws/fiber_condition_variable_spec.rb
100
- - test/aws/fiber_spec.rb
101
- - test/aws/flow_spec.rb
102
- - test/aws/future_spec.rb
103
- - test/aws/integration_spec.rb
104
- - test/aws/preinclude_tests.rb
105
- - test/aws/rubyflow.rb
106
- - test/aws/simple_dfa_spec.rb
107
- - test/aws/spec_helper.rb
94
+ - spec/aws/integration/integration_spec.rb
95
+ - spec/aws/unit/async_backtrace_spec.rb
96
+ - spec/aws/unit/async_scope_spec.rb
97
+ - spec/aws/unit/begin_rescue_ensure_spec.rb
98
+ - spec/aws/unit/decider_spec.rb
99
+ - spec/aws/unit/external_task_spec.rb
100
+ - spec/aws/unit/factories.rb
101
+ - spec/aws/unit/fiber_condition_variable_spec.rb
102
+ - spec/aws/unit/fiber_spec.rb
103
+ - spec/aws/unit/flow_spec.rb
104
+ - spec/aws/unit/future_spec.rb
105
+ - spec/aws/unit/preinclude_tests.rb
106
+ - spec/aws/unit/rubyflow.rb
107
+ - spec/aws/unit/simple_dfa_spec.rb
108
+ - spec/spec_helper.rb
108
109
  homepage:
109
110
  licenses: []
111
+ metadata: {}
110
112
  post_install_message:
111
113
  rdoc_options: []
112
114
  require_paths:
113
115
  - lib
114
116
  - lib/aws/
115
117
  required_ruby_version: !ruby/object:Gem::Requirement
116
- none: false
117
118
  requirements:
118
- - - ! '>='
119
+ - - '>='
119
120
  - !ruby/object:Gem::Version
120
121
  version: '0'
121
122
  required_rubygems_version: !ruby/object:Gem::Requirement
122
- none: false
123
123
  requirements:
124
- - - ! '>='
124
+ - - '>='
125
125
  - !ruby/object:Gem::Version
126
126
  version: '0'
127
127
  requirements: []
128
128
  rubyforge_project:
129
- rubygems_version: 1.8.23
129
+ rubygems_version: 2.0.3
130
130
  signing_key:
131
- specification_version: 3
131
+ specification_version: 4
132
132
  summary: AWS Flow Decider package decider
133
133
  test_files: []