ruby-sfn-local 0.1.26 → 0.1.28
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/sfn/execution.rb +6 -7
- data/lib/sfn/execution_log.rb +6 -4
- data/lib/sfn/mock_macros.rb +1 -1
- data/lib/sfn/state_machine.rb +14 -10
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a1ded192dbca449ce9c35a0fdac5a33cff11a5d6e7c60bf2780de51e93463896
|
4
|
+
data.tar.gz: 0d3ccddbbded015d1bae65ca6459f68e19581121063d3d9a93e4c31d5402fbba
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e18a67928a60e687dbe05e0ee1947feedfa16c4ecad21f45f2c483bd5efbf2391785b010031d16592ba8b2e7043b8f9a41621d99473721cfb0ef23404c0c70a8
|
7
|
+
data.tar.gz: 60e1b4cfdfb3497e767dfc1a2ac6afdfad190df3c97141c538500085170858a863f10166a63ec451b04f1387b637b4fe9c4dc90195a05abcc48bda1c6a18d701
|
data/lib/sfn/execution.rb
CHANGED
@@ -11,20 +11,19 @@ module Sfn
|
|
11
11
|
def initialize(state_machine, test_case)
|
12
12
|
self.uuid = SecureRandom.uuid
|
13
13
|
self.state_machine = state_machine
|
14
|
-
self.id = "#{self.state_machine.arn.gsub(
|
14
|
+
self.id = "#{self.state_machine.arn.gsub('stateMachine', 'execution')}:#{uuid}"
|
15
15
|
self.test_case = test_case.camelize
|
16
16
|
end
|
17
17
|
|
18
18
|
def exec(mock_data, input, dry_run = false)
|
19
19
|
MockData.write_context(state_machine.name, test_case, mock_data)
|
20
20
|
out = AwsCli.run('stepfunctions', 'start-execution',
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
})
|
21
|
+
{ name: uuid,
|
22
|
+
'state-machine': "#{state_machine.arn}##{test_case}",
|
23
|
+
input: "'#{input.to_json}'" })
|
25
24
|
decoded = JSON.parse(out)
|
26
|
-
self.arn = decoded[
|
27
|
-
self.start_date = decoded[
|
25
|
+
self.arn = decoded['executionArn']
|
26
|
+
self.start_date = decoded['startDate'].gsub('000+00:00', 'Z')
|
28
27
|
self.output, self.profile = ExecutionLog.parse(arn, dry_run)
|
29
28
|
self
|
30
29
|
end
|
data/lib/sfn/execution_log.rb
CHANGED
@@ -60,10 +60,12 @@ module Sfn
|
|
60
60
|
def error(events_json = '{}', dry_run = false)
|
61
61
|
return if event['executionFailedEventDetails'].nil?
|
62
62
|
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
63
|
+
unless dry_run
|
64
|
+
raise ExecutionError.new(event['executionFailedEventDetails']['cause'],
|
65
|
+
event['executionFailedEventDetails']['error'],
|
66
|
+
events_json)
|
67
|
+
end
|
68
|
+
|
67
69
|
event['executionFailedEventDetails']
|
68
70
|
end
|
69
71
|
|
data/lib/sfn/mock_macros.rb
CHANGED
data/lib/sfn/state_machine.rb
CHANGED
@@ -9,10 +9,10 @@ module Sfn
|
|
9
9
|
class StateMachine
|
10
10
|
ROLE = 'arn:aws:iam::123456789012:role/DummyRole'
|
11
11
|
|
12
|
-
attr_accessor :name, :path, :definition, :arn, :executions, :execution_arn
|
12
|
+
attr_accessor :name, :path, :definition, :arn, :variables, :executions, :execution_arn
|
13
13
|
|
14
14
|
def self.all
|
15
|
-
Collection.instance.all.map { |sf| new(sf['name'], sf['stateMachineArn']) }
|
15
|
+
Collection.instance.all.map { |sf| new(sf['name'], nil, sf['stateMachineArn']) }
|
16
16
|
end
|
17
17
|
|
18
18
|
def self.destroy_all
|
@@ -27,9 +27,10 @@ module Sfn
|
|
27
27
|
all.find { |sf| sf.arn == arn }
|
28
28
|
end
|
29
29
|
|
30
|
-
def initialize(name, arn = nil)
|
30
|
+
def initialize(name, variables = {}, arn = nil)
|
31
31
|
self.path = "#{Sfn.configuration.definition_path}/#{name}.json"
|
32
32
|
self.name = name.split('/').last
|
33
|
+
self.variables = variables
|
33
34
|
self.arn = arn || self.class.find_by_name(self.name)&.arn || create_state_machine
|
34
35
|
self.executions = {}
|
35
36
|
end
|
@@ -43,7 +44,7 @@ module Sfn
|
|
43
44
|
def dry_run(mock_data = {}, input = {}, test_name = nil)
|
44
45
|
execution = run(mock_data, input, test_name, true)
|
45
46
|
end
|
46
|
-
|
47
|
+
|
47
48
|
def run(mock_data = {}, input = {}, test_name = nil, dry_run = false)
|
48
49
|
test_name ||= OpenSSL::Digest::SHA512.digest(mock_data.merge({ input: input }).to_json)
|
49
50
|
executions[test_name] ||= Execution.call(self, test_name, mock_data, input, dry_run)
|
@@ -74,13 +75,16 @@ module Sfn
|
|
74
75
|
local_definition = local_definition.gsub(/"Type": "Wait"/, '"Type": "Pass"')
|
75
76
|
local_definition = local_definition.gsub(/"Seconds": [0-9]+,*/, '')
|
76
77
|
local_definition = local_definition.gsub(/"Timestamp": "[0-9\-T:+]+",*/, '')
|
77
|
-
local_definition = local_definition.gsub(/"TimestampPath": "[
|
78
|
-
local_definition = local_definition.gsub(
|
79
|
-
local_definition = local_definition.gsub(
|
80
|
-
local_definition = local_definition.gsub(/"ProcessorConfig":\s*{[\s"[A-Za-z:,]]+},*/,
|
81
|
-
local_definition = local_definition.gsub(/"Label": "[A-Za-z]+",*/,
|
78
|
+
local_definition = local_definition.gsub(/"TimestampPath": "[^"]+",*/, '')
|
79
|
+
local_definition = local_definition.gsub('ItemProcessor', 'Iterator')
|
80
|
+
local_definition = local_definition.gsub('ItemSelector', 'Parameters')
|
81
|
+
local_definition = local_definition.gsub(/"ProcessorConfig":\s*{[\s"[A-Za-z:,]]+},*/, '')
|
82
|
+
local_definition = local_definition.gsub(/"Label": "[A-Za-z]+",*/, '')
|
82
83
|
local_definition = local_definition.gsub(/,[\s\n]+\}/, "\n}")
|
83
|
-
|
84
|
+
local_definition = local_definition.gsub(/(\${[a-z_]+})/) do |variable|
|
85
|
+
key = variable.gsub(/[${}]/, '')
|
86
|
+
variables[key].to_s || variable
|
87
|
+
end
|
84
88
|
File.open(local_definition_path, 'w') { |file| file.puts local_definition }
|
85
89
|
"file://#{local_definition_path}"
|
86
90
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruby-sfn-local
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.28
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gianni Mazza
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-02
|
11
|
+
date: 2023-05-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake-release
|