aws-flow 1.3.0 → 2.0.0
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 +15 -0
- data/aws-flow.gemspec +1 -0
- data/lib/aws/decider/activity.rb +8 -6
- data/lib/aws/decider/async_decider.rb +1 -0
- data/lib/aws/decider/async_retrying_executor.rb +3 -3
- data/lib/aws/decider/decider.rb +16 -14
- data/lib/aws/decider/executor.rb +35 -22
- data/lib/aws/decider/flow_defaults.rb +28 -14
- data/lib/aws/decider/generic_client.rb +3 -4
- data/lib/aws/decider/options.rb +91 -117
- data/lib/aws/decider/state_machines.rb +1 -0
- data/lib/aws/decider/utilities.rb +15 -0
- data/lib/aws/decider/version.rb +1 -1
- data/lib/aws/decider/worker.rb +14 -8
- data/lib/aws/decider/workflow_client.rb +16 -11
- data/lib/aws/runner.rb +43 -39
- data/spec/aws/decider/integration/activity_spec.rb +345 -0
- data/spec/aws/{integration → decider/integration}/integration_spec.rb +818 -1183
- data/spec/aws/decider/integration/setup.rb +3 -0
- data/spec/aws/decider/unit/activity_spec.rb +233 -0
- data/spec/aws/decider/unit/async_retrying_executor_spec.rb +131 -0
- data/spec/aws/{unit → decider/unit}/decider_spec.rb +171 -718
- data/spec/aws/decider/unit/executor_spec.rb +123 -0
- data/spec/aws/decider/unit/flow_defaults_spec.rb +62 -0
- data/spec/aws/decider/unit/misc_spec.rb +101 -0
- data/spec/aws/decider/unit/options_spec.rb +289 -0
- data/spec/aws/decider/unit/retry_spec.rb +217 -0
- data/spec/aws/{unit → decider/unit}/rubyflow.rb +0 -0
- data/spec/aws/decider/unit/setup.rb +3 -0
- data/spec/aws/decider/unit/worker_spec.rb +325 -0
- data/spec/aws/decider/unit/workflow_client_spec.rb +83 -0
- data/spec/aws/{unit → flow}/async_backtrace_spec.rb +0 -0
- data/spec/aws/{unit → flow}/async_scope_spec.rb +0 -0
- data/spec/aws/{unit → flow}/begin_rescue_ensure_spec.rb +1 -0
- data/spec/aws/{unit → flow}/external_task_spec.rb +0 -0
- data/spec/aws/{unit → flow}/factories.rb +0 -0
- data/spec/aws/{unit → flow}/fiber_condition_variable_spec.rb +0 -0
- data/spec/aws/{unit → flow}/fiber_spec.rb +0 -0
- data/spec/aws/{unit → flow}/flow_spec.rb +0 -0
- data/spec/aws/{unit → flow}/future_spec.rb +0 -0
- data/spec/aws/{unit → flow}/simple_dfa_spec.rb +0 -0
- data/spec/aws/{integration → runner/integration}/runner_integration_spec.rb +16 -43
- data/spec/aws/{unit → runner/unit}/runner_unit_spec.rb +18 -18
- data/spec/spec_helper.rb +264 -2
- metadata +37 -28
- data/spec/aws/unit/executor_spec.rb +0 -49
- data/spec/aws/unit/options_spec.rb +0 -293
- data/spec/aws/unit/preinclude_tests.rb +0 -149
@@ -0,0 +1,123 @@
|
|
1
|
+
##
|
2
|
+
# Copyright 2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
3
|
+
#
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "License").
|
5
|
+
# You may not use this file except in compliance with the License.
|
6
|
+
# A copy of the License is located at
|
7
|
+
#
|
8
|
+
# http://aws.amazon.com/apache2.0
|
9
|
+
#
|
10
|
+
# or in the "license" file accompanying this file. This file is distributed
|
11
|
+
# on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
|
12
|
+
# express or implied. See the License for the specific language governing
|
13
|
+
# permissions and limitations under the License.
|
14
|
+
##
|
15
|
+
|
16
|
+
require_relative 'setup'
|
17
|
+
|
18
|
+
describe ForkingExecutor do
|
19
|
+
|
20
|
+
it "makes sure that forking executors basic execute works" do
|
21
|
+
test_file_name = "ForkingExecutorTestFile"
|
22
|
+
begin
|
23
|
+
forking_executor = ForkingExecutor.new
|
24
|
+
File.exists?(test_file_name).should == false
|
25
|
+
forking_executor.execute do
|
26
|
+
File.new(test_file_name, 'w')
|
27
|
+
end
|
28
|
+
sleep 3
|
29
|
+
File.exists?(test_file_name).should == true
|
30
|
+
ensure
|
31
|
+
File.unlink(test_file_name)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
it "ensures that one worker for forking executor will only allow one thing to be processed at a time" do
|
36
|
+
executor = ForkingExecutor.new(:max_workers => 1)
|
37
|
+
|
38
|
+
test_file_name = "ForkingExecutorRunOne"
|
39
|
+
File.new(test_file_name, "w")
|
40
|
+
start_time = Time.now
|
41
|
+
executor.execute do
|
42
|
+
File.open(test_file_name, "a+") { |f| f.write("First Execution\n")}
|
43
|
+
sleep 4
|
44
|
+
end
|
45
|
+
# Because execute will block if the worker queue is full, we will wait here
|
46
|
+
# if we have reached the max number of workers
|
47
|
+
executor.execute { 2 + 2 }
|
48
|
+
finish_time = Time.now
|
49
|
+
# If we waited for the first task to finish, then we will have waited at
|
50
|
+
# least 4 seconds; if we didn't, we should not have waited. Thus, if we have
|
51
|
+
# waited > 3 seconds, we have likely waited for the first task to finish
|
52
|
+
# before doing the second one
|
53
|
+
(finish_time - start_time).should > 3
|
54
|
+
File.unlink(test_file_name)
|
55
|
+
end
|
56
|
+
|
57
|
+
it "ensures that you cannot execute more tasks on a shutdown executor" do
|
58
|
+
forking_executor = ForkingExecutor.new
|
59
|
+
forking_executor.execute {}
|
60
|
+
forking_executor.execute {}
|
61
|
+
forking_executor.shutdown(1)
|
62
|
+
expect { forking_executor.execute { "yay" } }.to raise_error RejectedExecutionException
|
63
|
+
end
|
64
|
+
|
65
|
+
context "#remove_completed_pids" do
|
66
|
+
class Status
|
67
|
+
def success?; true; end
|
68
|
+
end
|
69
|
+
|
70
|
+
context "with block=false" do
|
71
|
+
it "should not block if not child process available" do
|
72
|
+
|
73
|
+
# stub out Process.waitpid2 to return only 2 processes
|
74
|
+
allow(Process).to receive(:waitpid2).and_return(nil)
|
75
|
+
allow_any_instance_of(AWS::Flow::ForkingExecutor).to receive(:fork).and_return(1, 2, 3)
|
76
|
+
executor = ForkingExecutor.new(max_workers: 3)
|
77
|
+
|
78
|
+
executor.execute { sleep 1 }
|
79
|
+
executor.execute { sleep 1 }
|
80
|
+
executor.execute { sleep 1 }
|
81
|
+
executor.pids.size.should == 3
|
82
|
+
executor.send(:remove_completed_pids, false)
|
83
|
+
# The two processes that are completed will be reaped.
|
84
|
+
executor.pids.size.should == 3
|
85
|
+
end
|
86
|
+
|
87
|
+
it "should reap all completed child processes" do
|
88
|
+
|
89
|
+
allow(Process).to receive(:waitpid2).and_return([1, Status.new], [2, Status.new], [3, Status.new] )
|
90
|
+
allow_any_instance_of(AWS::Flow::ForkingExecutor).to receive(:fork).and_return(1, 2, 3)
|
91
|
+
executor = ForkingExecutor.new(max_workers: 3)
|
92
|
+
|
93
|
+
executor.execute { sleep 1 }
|
94
|
+
executor.execute { sleep 1 }
|
95
|
+
executor.execute { sleep 1 }
|
96
|
+
executor.pids.size.should == 3
|
97
|
+
executor.send(:remove_completed_pids, false)
|
98
|
+
# The two processes that are completed will be reaped.
|
99
|
+
executor.pids.size.should == 0
|
100
|
+
end
|
101
|
+
end
|
102
|
+
context "with block=true" do
|
103
|
+
it "should wait for atleast one child process to become available and then reap as many as possible" do
|
104
|
+
|
105
|
+
# stub out Process.waitpid2 to return only 2 processes
|
106
|
+
allow(Process).to receive(:waitpid2).and_return([1, Status.new], [2, Status.new], nil)
|
107
|
+
allow_any_instance_of(AWS::Flow::ForkingExecutor).to receive(:fork).and_return(1, 2, 3)
|
108
|
+
executor = ForkingExecutor.new(max_workers: 3)
|
109
|
+
|
110
|
+
executor.execute { sleep 1 }
|
111
|
+
executor.execute { sleep 1 }
|
112
|
+
executor.execute { sleep 5 }
|
113
|
+
|
114
|
+
executor.pids.size.should == 3
|
115
|
+
|
116
|
+
executor.send(:remove_completed_pids, true)
|
117
|
+
# It will wait for one of the processes to become available and then
|
118
|
+
# reap as many as possible
|
119
|
+
executor.pids.size.should == 1
|
120
|
+
end
|
121
|
+
end
|
122
|
+
end
|
123
|
+
end
|
@@ -0,0 +1,62 @@
|
|
1
|
+
require_relative 'setup'
|
2
|
+
|
3
|
+
describe FlowConstants do
|
4
|
+
options = {
|
5
|
+
:initial_retry_interval => 1,
|
6
|
+
:backoff_coefficient => 2,
|
7
|
+
:should_jitter => false,
|
8
|
+
:maximum_retry_interval_seconds => 100
|
9
|
+
}
|
10
|
+
options = ExponentialRetryOptions.new(options)
|
11
|
+
|
12
|
+
context "#default_exponential_retry_function" do
|
13
|
+
|
14
|
+
it "will test the default retry function with regular cases" do
|
15
|
+
time = Time.now
|
16
|
+
test_first = [time, time, time]
|
17
|
+
test_time_of_failure = [time, time+10, time+100]
|
18
|
+
test_attempts = [{Exception=>2}, {Exception=>4}, {ActivityTaskTimedOutException=>5, Exception=>2}]
|
19
|
+
test_output = [1, 4, 32]
|
20
|
+
arr = test_first.zip(test_time_of_failure, test_attempts, test_output)
|
21
|
+
arr.each do |first, time_of_failure, attempts, output|
|
22
|
+
result = FlowConstants.exponential_retry_function.call(first, time_of_failure, attempts, options)
|
23
|
+
(result == output).should == true
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
it "will test for exceptions" do
|
28
|
+
expect { FlowConstants.exponential_retry_function.call(-1, nil, {}, options) }.to raise_error(ArgumentError, "first should be an instance of Time")
|
29
|
+
expect { FlowConstants.exponential_retry_function.call(Time.now, 0, {}, options) }.to raise_error(ArgumentError, "time_of_failure should be nil or an instance of Time")
|
30
|
+
expect { FlowConstants.exponential_retry_function.call(Time.now, nil, {Exception=>-1}, options) }.to raise_error(ArgumentError, "number of attempts should be positive")
|
31
|
+
expect { FlowConstants.exponential_retry_function.call(Time.now, nil, {Exception=>-1, ActivityTaskTimedOutException=>-10}, options) }.to raise_error(ArgumentError, "number of attempts should be positive")
|
32
|
+
expect { FlowConstants.exponential_retry_function.call(Time.now, nil, {Exception=>2, ActivityTaskTimedOutException=>-10}, options) }.to raise_error(ArgumentError, "number of attempts should be positive")
|
33
|
+
end
|
34
|
+
|
35
|
+
it "ensures the default retry function will use the user provided options" do
|
36
|
+
first = Time.now
|
37
|
+
time_of_failure = nil
|
38
|
+
attempts = {Exception=>2}
|
39
|
+
options = {
|
40
|
+
:initial_retry_interval => 10,
|
41
|
+
:backoff_coefficient => 2,
|
42
|
+
:should_jitter => false,
|
43
|
+
:maximum_retry_interval_seconds => 5
|
44
|
+
}
|
45
|
+
options = ExponentialRetryOptions.new(options)
|
46
|
+
result = FlowConstants.exponential_retry_function.call(first, time_of_failure, attempts, options)
|
47
|
+
result.should == 5
|
48
|
+
end
|
49
|
+
|
50
|
+
end
|
51
|
+
|
52
|
+
context "#default_jitter_function" do
|
53
|
+
it "ensures that the jitter function checks arguments passed to it" do
|
54
|
+
expect { FlowConstants.jitter_function.call(1, -1) }.to raise_error(
|
55
|
+
ArgumentError, "max_value should be greater than 0")
|
56
|
+
end
|
57
|
+
it "ensures that we get same jitter for a particular execution id" do
|
58
|
+
(FlowConstants.jitter_function.call(1, 100)).should equal(FlowConstants.jitter_function.call(1, 100))
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
@@ -0,0 +1,101 @@
|
|
1
|
+
require_relative 'setup'
|
2
|
+
|
3
|
+
describe "Miscellaneous" do
|
4
|
+
it "ensures with_retry can be called without including AWS::Flow" do
|
5
|
+
|
6
|
+
class TestWorkflow
|
7
|
+
extend AWS::Flow::Workflows
|
8
|
+
workflow (:start) { {:version => "1"} }
|
9
|
+
|
10
|
+
def start
|
11
|
+
AWS::Flow::with_retry do
|
12
|
+
return "This is the entry point"
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
class SynchronousWorkflowTaskPoller < AWS::Flow::WorkflowTaskPoller
|
18
|
+
def get_decision_task
|
19
|
+
workflow_type = FakeWorkflowType.new(nil, "TestWorkflow.start", "1")
|
20
|
+
TestHistoryWrapper.new(workflow_type,
|
21
|
+
[TestHistoryEvent.new("WorkflowExecutionStarted", 1, {:parent_initiated_event_id=>0, :child_policy=>:request_cancel, :execution_start_to_close_timeout=>3600, :task_start_to_close_timeout=>5, :workflow_type=> workflow_type, :task_list=>"TestWorkflow_tasklist"}),
|
22
|
+
TestHistoryEvent.new("DecisionTaskScheduled", 2, {:parent_initiated_event_id=>0, :child_policy=>:request_cancel, :execution_start_to_close_timeout=>3600, :task_start_to_close_timeout=>5, :workflow_type=> workflow_type, :task_list=>"TestWorkflow_tastlist"}),
|
23
|
+
TestHistoryEvent.new("DecisionTaskStarted", 3, {:scheduled_event_id=>2, :identity=>"some_identity"}),
|
24
|
+
])
|
25
|
+
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
workflow_type_object = double("workflow_type", :name => "TestWorkflow.start", :start_execution => "" )
|
30
|
+
domain = FakeDomain.new(workflow_type_object)
|
31
|
+
swf_client = FakeServiceClient.new
|
32
|
+
task_list = "TestWorkflow_tasklist"
|
33
|
+
|
34
|
+
workflow_worker = SynchronousWorkflowWorker.new(swf_client, domain, task_list)
|
35
|
+
workflow_worker.add_workflow_implementation(TestWorkflow)
|
36
|
+
|
37
|
+
workflow_client = AWS::Flow::workflow_client(swf_client, domain) { { from_class: "TestWorkflow" } }
|
38
|
+
workflow_client.start_execution
|
39
|
+
|
40
|
+
workflow_worker.start
|
41
|
+
end
|
42
|
+
|
43
|
+
it "ensures decision_context can be called without including AWS::Flow" do
|
44
|
+
|
45
|
+
class TestWorkflow
|
46
|
+
extend AWS::Flow::Workflows
|
47
|
+
workflow (:start) { {:version => "1"} }
|
48
|
+
|
49
|
+
def start
|
50
|
+
return AWS::Flow::decision_context.workflow_clock.current_time
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
class SynchronousWorkflowTaskPoller < AWS::Flow::WorkflowTaskPoller
|
55
|
+
def get_decision_task
|
56
|
+
workflow_type = FakeWorkflowType.new(nil, "TestWorkflow.start", "1")
|
57
|
+
TestHistoryWrapper.new(workflow_type,
|
58
|
+
[TestHistoryEvent.new("WorkflowExecutionStarted", 1, {:parent_initiated_event_id=>0, :child_policy=>:request_cancel, :execution_start_to_close_timeout=>3600, :task_start_to_close_timeout=>5, :workflow_type=> workflow_type, :task_list=>"TestWorkflow_tasklist"}),
|
59
|
+
TestHistoryEvent.new("DecisionTaskScheduled", 2, {:parent_initiated_event_id=>0, :child_policy=>:request_cancel, :execution_start_to_close_timeout=>3600, :task_start_to_close_timeout=>5, :workflow_type=> workflow_type, :task_list=>"TestWorkflow_tastlist"}),
|
60
|
+
TestHistoryEvent.new("DecisionTaskStarted", 3, {:scheduled_event_id=>2, :identity=>"some_identity"}),
|
61
|
+
])
|
62
|
+
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
workflow_type_object = double("workflow_type", :name => "TestWorkflow.start", :start_execution => "" )
|
67
|
+
domain = FakeDomain.new(workflow_type_object)
|
68
|
+
swf_client = FakeServiceClient.new
|
69
|
+
task_list = "TestWorkflow_tasklist"
|
70
|
+
|
71
|
+
workflow_worker = SynchronousWorkflowWorker.new(swf_client, domain, task_list)
|
72
|
+
workflow_worker.add_workflow_implementation(TestWorkflow)
|
73
|
+
|
74
|
+
workflow_client = AWS::Flow::workflow_client(swf_client, domain) { { from_class: "TestWorkflow" } }
|
75
|
+
workflow_client.start_execution
|
76
|
+
|
77
|
+
workflow_worker.start
|
78
|
+
end
|
79
|
+
|
80
|
+
it "makes sure we can remove depedency on UUIDTools" do
|
81
|
+
class TestWorkflow
|
82
|
+
extend AWS::Flow::Workflows
|
83
|
+
workflow (:start) { { version: "1.0" } }
|
84
|
+
def start; end
|
85
|
+
end
|
86
|
+
|
87
|
+
require "securerandom"
|
88
|
+
# first check if SecureRandom.uuid returns uuid in the right format
|
89
|
+
regex = /[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}/
|
90
|
+
SecureRandom.uuid.should match(regex)
|
91
|
+
|
92
|
+
# Now check if the uuid is correctly set in start_external_workflow method
|
93
|
+
workflow_type = WorkflowType.new(nil, "TestWorkflow.start", "1")
|
94
|
+
client = AWS::Flow::WorkflowClient.new(FakeServiceClient.new, FakeDomain.new(workflow_type), TestWorkflow, WorkflowOptions.new)
|
95
|
+
workflow = client.start_execution
|
96
|
+
workflow.workflow_id.should match(regex)
|
97
|
+
end
|
98
|
+
|
99
|
+
end
|
100
|
+
|
101
|
+
|
@@ -0,0 +1,289 @@
|
|
1
|
+
require_relative 'setup'
|
2
|
+
|
3
|
+
describe AWS::Flow::ActivityRegistrationOptions do
|
4
|
+
context "#get_registration_options" do
|
5
|
+
|
6
|
+
it "should return the default registration options if not value is passed in" do
|
7
|
+
options = AWS::Flow::ActivityRegistrationOptions.new
|
8
|
+
options.get_registration_options.should == {
|
9
|
+
default_task_heartbeat_timeout: "NONE",
|
10
|
+
default_task_schedule_to_close_timeout: "NONE",
|
11
|
+
default_task_schedule_to_start_timeout: "NONE",
|
12
|
+
default_task_start_to_close_timeout: "NONE",
|
13
|
+
default_task_list: "USE_WORKER_TASK_LIST"
|
14
|
+
}
|
15
|
+
end
|
16
|
+
|
17
|
+
it "should return the new registration options if values are passed in" do
|
18
|
+
options = AWS::Flow::ActivityRegistrationOptions.new({
|
19
|
+
default_task_schedule_to_start_timeout: 20,
|
20
|
+
default_task_schedule_to_close_timeout: 50,
|
21
|
+
default_task_start_to_close_timeout: 30,
|
22
|
+
default_task_heartbeat_timeout: 5,
|
23
|
+
default_task_list: "test_tasklist",
|
24
|
+
})
|
25
|
+
options.get_registration_options.should == {
|
26
|
+
default_task_heartbeat_timeout: "5",
|
27
|
+
default_task_schedule_to_close_timeout: "50",
|
28
|
+
default_task_schedule_to_start_timeout: "20",
|
29
|
+
default_task_start_to_close_timeout: "30",
|
30
|
+
default_task_list: "test_tasklist"
|
31
|
+
}
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
context "#get_full_options" do
|
36
|
+
|
37
|
+
it "should contain both registration and regular options" do
|
38
|
+
options = AWS::Flow::ActivityRegistrationOptions.new
|
39
|
+
full_options = options.get_full_options
|
40
|
+
expected = {
|
41
|
+
default_task_heartbeat_timeout: "NONE",
|
42
|
+
default_task_schedule_to_close_timeout: "NONE",
|
43
|
+
default_task_schedule_to_start_timeout: "NONE",
|
44
|
+
default_task_start_to_close_timeout: "NONE",
|
45
|
+
default_task_list: "USE_WORKER_TASK_LIST",
|
46
|
+
data_converter: FlowConstants.default_data_converter
|
47
|
+
}
|
48
|
+
# We first compare and remove the following values because these objects have issues
|
49
|
+
# when we sort the values array below
|
50
|
+
full_options.delete(:data_converter) == expected.delete(:data_converter)
|
51
|
+
full_options.keys.sort.should == expected.keys.sort
|
52
|
+
full_options.values.sort.should == expected.values.sort
|
53
|
+
end
|
54
|
+
|
55
|
+
it "should return the values passed in" do
|
56
|
+
options = AWS::Flow::ActivityRegistrationOptions.new({
|
57
|
+
default_task_schedule_to_start_timeout: 20,
|
58
|
+
default_task_start_to_close_timeout: 30,
|
59
|
+
default_task_heartbeat_timeout: 5,
|
60
|
+
task_list: "test_tasklist",
|
61
|
+
version: "1.0",
|
62
|
+
prefix_name: "FooActivity",
|
63
|
+
manual_completion: true,
|
64
|
+
heartbeat_timeout: 10
|
65
|
+
})
|
66
|
+
full_options = options.get_full_options
|
67
|
+
expected = {
|
68
|
+
default_task_heartbeat_timeout: "5",
|
69
|
+
default_task_schedule_to_close_timeout: "NONE",
|
70
|
+
default_task_schedule_to_start_timeout: "20",
|
71
|
+
default_task_start_to_close_timeout: "30",
|
72
|
+
default_task_list: "USE_WORKER_TASK_LIST",
|
73
|
+
task_list: "test_tasklist",
|
74
|
+
version: "1.0",
|
75
|
+
prefix_name: "FooActivity",
|
76
|
+
manual_completion: true,
|
77
|
+
heartbeat_timeout: "10",
|
78
|
+
data_converter: FlowConstants.default_data_converter
|
79
|
+
}
|
80
|
+
# We first compare and remove the following values because these objects have issues
|
81
|
+
# when we sort the values array below
|
82
|
+
[:data_converter, :manual_completion].each { |x| full_options.delete(x).should == expected.delete(x) }
|
83
|
+
full_options.keys.sort.should == expected.keys.sort
|
84
|
+
full_options.values.sort.should == expected.values.sort
|
85
|
+
end
|
86
|
+
|
87
|
+
end
|
88
|
+
|
89
|
+
end
|
90
|
+
|
91
|
+
describe AWS::Flow::WorkflowRegistrationOptions do
|
92
|
+
|
93
|
+
context "#get_registration_options" do
|
94
|
+
|
95
|
+
it "should return the default registration options if not value is passed in" do
|
96
|
+
options = AWS::Flow::WorkflowRegistrationOptions.new
|
97
|
+
options.get_registration_options.should == {
|
98
|
+
default_task_start_to_close_timeout: "30",
|
99
|
+
default_child_policy: "TERMINATE",
|
100
|
+
default_task_list: "USE_WORKER_TASK_LIST"
|
101
|
+
}
|
102
|
+
end
|
103
|
+
|
104
|
+
it "should return the new registration options if values are passed in" do
|
105
|
+
options = AWS::Flow::WorkflowRegistrationOptions.new({
|
106
|
+
default_task_schedule_to_close_timeout: 30,
|
107
|
+
default_execution_start_to_close_timeout: 600,
|
108
|
+
default_child_policy: "ABANDON",
|
109
|
+
default_task_list: "task_list"
|
110
|
+
})
|
111
|
+
options.get_registration_options.should == {
|
112
|
+
default_task_start_to_close_timeout: "30",
|
113
|
+
default_execution_start_to_close_timeout: "600",
|
114
|
+
default_child_policy: "ABANDON",
|
115
|
+
default_task_list: "task_list"
|
116
|
+
}
|
117
|
+
end
|
118
|
+
|
119
|
+
end
|
120
|
+
|
121
|
+
context "#get_full_options" do
|
122
|
+
|
123
|
+
it "should not contain any registration options" do
|
124
|
+
options = AWS::Flow::WorkflowRegistrationOptions.new
|
125
|
+
full_options = options.get_full_options
|
126
|
+
expected = {
|
127
|
+
default_task_start_to_close_timeout: "30",
|
128
|
+
default_child_policy: "TERMINATE",
|
129
|
+
default_task_list: "USE_WORKER_TASK_LIST",
|
130
|
+
tag_list: [],
|
131
|
+
data_converter: FlowConstants.default_data_converter
|
132
|
+
}
|
133
|
+
# We first compare and remove the following values because these objects have issues
|
134
|
+
# when we sort the values array below
|
135
|
+
[:data_converter, :tag_list].each { |x| full_options.delete(x).should == expected.delete(x) }
|
136
|
+
full_options.keys.sort.should == expected.keys.sort
|
137
|
+
full_options.values.sort.should == expected.values.sort
|
138
|
+
end
|
139
|
+
|
140
|
+
it "should return the values passed in" do
|
141
|
+
options = AWS::Flow::WorkflowRegistrationOptions.new({
|
142
|
+
default_task_start_to_close_timeout: "30",
|
143
|
+
default_child_policy: "TERMINATE",
|
144
|
+
default_task_list: "USE_WORKER_TASK_LIST",
|
145
|
+
task_list: "test_tasklist",
|
146
|
+
version: "1.0",
|
147
|
+
prefix_name: "FooActivity",
|
148
|
+
tag_list: ["tag1", "tag2"]
|
149
|
+
})
|
150
|
+
full_options = options.get_full_options
|
151
|
+
expected = {
|
152
|
+
default_task_start_to_close_timeout: "30",
|
153
|
+
default_child_policy: "TERMINATE",
|
154
|
+
default_task_list: "USE_WORKER_TASK_LIST",
|
155
|
+
task_list: "test_tasklist",
|
156
|
+
version: "1.0",
|
157
|
+
prefix_name: "FooActivity",
|
158
|
+
data_converter: FlowConstants.default_data_converter,
|
159
|
+
tag_list: ["tag1", "tag2"]
|
160
|
+
}
|
161
|
+
# We first compare and remove the following values because these objects have issues
|
162
|
+
# when we sort the values array below
|
163
|
+
[:data_converter, :tag_list].each { |x| full_options.delete(x).should == expected.delete(x) }
|
164
|
+
full_options.keys.sort.should == expected.keys.sort
|
165
|
+
full_options.values.sort.should == expected.values.sort
|
166
|
+
end
|
167
|
+
|
168
|
+
end
|
169
|
+
|
170
|
+
end
|
171
|
+
|
172
|
+
describe AWS::Flow::ActivityOptions do
|
173
|
+
|
174
|
+
context "#get_full_options" do
|
175
|
+
|
176
|
+
it "should only contain the non registration options" do
|
177
|
+
options = AWS::Flow::ActivityOptions.new
|
178
|
+
full_options = options.get_full_options
|
179
|
+
expected = {
|
180
|
+
data_converter: FlowConstants.default_data_converter
|
181
|
+
}
|
182
|
+
# We first compare and remove the following values because these objects have issues
|
183
|
+
# when we sort the values array below
|
184
|
+
full_options.should == expected
|
185
|
+
end
|
186
|
+
|
187
|
+
it "should return the values passed in" do
|
188
|
+
options = AWS::Flow::ActivityOptions.new({
|
189
|
+
task_list: "test_tasklist",
|
190
|
+
version: "1.0",
|
191
|
+
prefix_name: "FooActivity",
|
192
|
+
manual_completion: true,
|
193
|
+
heartbeat_timeout: 10
|
194
|
+
})
|
195
|
+
full_options = options.get_full_options
|
196
|
+
expected = {
|
197
|
+
task_list: "test_tasklist",
|
198
|
+
version: "1.0",
|
199
|
+
prefix_name: "FooActivity",
|
200
|
+
manual_completion: true,
|
201
|
+
heartbeat_timeout: "10",
|
202
|
+
data_converter: FlowConstants.default_data_converter,
|
203
|
+
}
|
204
|
+
# We first compare and remove the following values because these objects have issues
|
205
|
+
# when we sort the values array below
|
206
|
+
[:data_converter, :manual_completion].each { |x| full_options.delete(x).should == expected.delete(x) }
|
207
|
+
full_options.keys.sort.should == expected.keys.sort
|
208
|
+
full_options.values.sort.should == expected.values.sort
|
209
|
+
end
|
210
|
+
|
211
|
+
end
|
212
|
+
|
213
|
+
end
|
214
|
+
describe AWS::Flow::WorkflowOptions do
|
215
|
+
|
216
|
+
context "#get_full_options" do
|
217
|
+
|
218
|
+
it "should not contain any registration options" do
|
219
|
+
options = AWS::Flow::WorkflowOptions.new
|
220
|
+
full_options = options.get_full_options
|
221
|
+
expected = {
|
222
|
+
data_converter: FlowConstants.default_data_converter
|
223
|
+
}
|
224
|
+
# We first compare and remove the following values because these objects have issues
|
225
|
+
# when we sort the values array below
|
226
|
+
full_options.should == expected
|
227
|
+
end
|
228
|
+
|
229
|
+
it "should return the values passed in" do
|
230
|
+
options = AWS::Flow::WorkflowOptions.new({
|
231
|
+
task_list: "test_tasklist",
|
232
|
+
version: "1.0",
|
233
|
+
prefix_name: "FooWorkflow",
|
234
|
+
tag_list: ["tag1", "tag2"]
|
235
|
+
})
|
236
|
+
full_options = options.get_full_options
|
237
|
+
expected = {
|
238
|
+
task_list: "test_tasklist",
|
239
|
+
version: "1.0",
|
240
|
+
prefix_name: "FooWorkflow",
|
241
|
+
tag_list: ["tag1", "tag2"],
|
242
|
+
data_converter: FlowConstants.default_data_converter,
|
243
|
+
}
|
244
|
+
# We first compare and remove the following values because these objects have issues
|
245
|
+
# when we sort the values array below
|
246
|
+
[:data_converter, :tag_list].each { |x| full_options.delete(x).should == expected.delete(x) }
|
247
|
+
full_options.keys.sort.should == expected.keys.sort
|
248
|
+
full_options.values.sort.should == expected.values.sort
|
249
|
+
end
|
250
|
+
|
251
|
+
end
|
252
|
+
|
253
|
+
end
|
254
|
+
|
255
|
+
describe AWS::Flow::WorkflowRegistrationDefaults do
|
256
|
+
|
257
|
+
context "#defaults" do
|
258
|
+
|
259
|
+
it "should return the correct default values" do
|
260
|
+
defaults = AWS::Flow::WorkflowRegistrationDefaults.new
|
261
|
+
defaults.data_converter.should == AWS::Flow::FlowConstants.default_data_converter
|
262
|
+
defaults.default_task_start_to_close_timeout.should == 30
|
263
|
+
defaults.default_child_policy.should == "TERMINATE"
|
264
|
+
defaults.tag_list.should == []
|
265
|
+
defaults.default_task_list.should == AWS::Flow::FlowConstants.use_worker_task_list
|
266
|
+
end
|
267
|
+
|
268
|
+
end
|
269
|
+
|
270
|
+
end
|
271
|
+
|
272
|
+
describe AWS::Flow::ActivityRegistrationDefaults do
|
273
|
+
|
274
|
+
context "#defaults" do
|
275
|
+
|
276
|
+
it "should return the correct default values" do
|
277
|
+
defaults = AWS::Flow::ActivityRegistrationDefaults.new
|
278
|
+
defaults.data_converter.should == AWS::Flow::FlowConstants.default_data_converter
|
279
|
+
defaults.default_task_schedule_to_start_timeout.should == Float::INFINITY
|
280
|
+
defaults.default_task_schedule_to_close_timeout.should == Float::INFINITY
|
281
|
+
defaults.default_task_start_to_close_timeout.should == Float::INFINITY
|
282
|
+
defaults.default_task_heartbeat_timeout.should == Float::INFINITY
|
283
|
+
defaults.default_task_list.should == AWS::Flow::FlowConstants.use_worker_task_list
|
284
|
+
end
|
285
|
+
|
286
|
+
end
|
287
|
+
|
288
|
+
end
|
289
|
+
|