Class: Sfn::Execution

Inherits:
Object
  • Object
show all
Defined in:
lib/sfn/execution.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(state_machine, test_case) ⇒ Execution

Returns a new instance of Execution.



11
12
13
14
15
16
# File 'lib/sfn/execution.rb', line 11

def initialize(state_machine, test_case)
  self.uuid = SecureRandom.uuid
  self.state_machine = state_machine
  self.id = "#{self.state_machine.arn.gsub('stateMachine', 'execution')}:#{uuid}"
  self.test_case = test_case.camelize
end

Instance Attribute Details

#arnObject

Returns the value of attribute arn.



5
6
7
# File 'lib/sfn/execution.rb', line 5

def arn
  @arn
end

#idObject

Returns the value of attribute id.



5
6
7
# File 'lib/sfn/execution.rb', line 5

def id
  @id
end

#outputObject

Returns the value of attribute output.



5
6
7
# File 'lib/sfn/execution.rb', line 5

def output
  @output
end

#profileObject

Returns the value of attribute profile.



5
6
7
# File 'lib/sfn/execution.rb', line 5

def profile
  @profile
end

#start_dateObject

Returns the value of attribute start_date.



5
6
7
# File 'lib/sfn/execution.rb', line 5

def start_date
  @start_date
end

#state_machineObject

Returns the value of attribute state_machine.



5
6
7
# File 'lib/sfn/execution.rb', line 5

def state_machine
  @state_machine
end

#test_caseObject

Returns the value of attribute test_case.



5
6
7
# File 'lib/sfn/execution.rb', line 5

def test_case
  @test_case
end

#uuidObject

Returns the value of attribute uuid.



5
6
7
# File 'lib/sfn/execution.rb', line 5

def uuid
  @uuid
end

Class Method Details

.call(state_machine, test_case, mock_data, input, dry_run = false) ⇒ Object



7
8
9
# File 'lib/sfn/execution.rb', line 7

def self.call(state_machine, test_case, mock_data, input, dry_run = false)
  new(state_machine, test_case).exec(mock_data, input, dry_run)
end

Instance Method Details

#exec(mock_data, input, dry_run = false) ⇒ Object



18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/sfn/execution.rb', line 18

def exec(mock_data, input, dry_run = false)
  MockData.write_context(state_machine.name, test_case, mock_data)
  out = AwsCli.run('stepfunctions', 'start-execution',
                   { name: uuid,
                     'state-machine': "#{state_machine.arn}##{test_case}",
                     input: "'#{input.to_json}'" })
  decoded = JSON.parse(out)
  self.arn = decoded['executionArn']
  self.start_date = decoded['startDate'].gsub('000+00:00', 'Z')
  self.output, self.profile = ExecutionLog.parse(arn, dry_run)
  self
end