Class representing an execution of a single step in scenario
Information about timings, collected automatically
Output of the execution, to be filled by execution step
Information about timings, collected automatically
One of :pending, :running, :success, :fail, :skipped
Step performed as part of the execution
# File lib/foreman_maintain/runner/execution.rb, line 23 def initialize(step, reporter, options = {}) options.validate_options!(:whitelisted, :storage, :force) @step = step @reporter = reporter @status = :pending @output = '' @whitelisted = options[:whitelisted] @storage = options[:storage] @force = options[:force] end
# File lib/foreman_maintain/runner/execution.rb, line 50 def aborted? @status == :abort end
# File lib/foreman_maintain/runner/execution.rb, line 46 def fail? @status == :fail end
# File lib/foreman_maintain/runner/execution.rb, line 34 def name @step.description end
# File lib/foreman_maintain/runner/execution.rb, line 71 def run @reporter.before_execution_starts(self) if skip? @status = :already_run return end @status = whitelisted? ? :skipped : :running with_metadata_calculation do capture_errors do step.__run__(self) end end # change the state only when not modified @status = :success if @status == :running ensure @reporter.after_execution_finishes(self) end
# File lib/foreman_maintain/runner/execution.rb, line 58 def skip? !@force && step.run_once? && step.executed? && step.success? end
# File lib/foreman_maintain/runner/execution.rb, line 54 def skipped? @status == :skipped end
yaml storage to preserve key/value pairs between runs.
# File lib/foreman_maintain/runner/execution.rb, line 67 def storage @storage || ForemanMaintain.storage(:default) end
# File lib/foreman_maintain/runner/execution.rb, line 42 def success? [:success, :already_run, :skipped].include?(@status) end
# File lib/foreman_maintain/runner/execution.rb, line 93 def update(line) @reporter.on_execution_update(self, line) end
# File lib/foreman_maintain/runner/execution.rb, line 62 def warning? @status == :warning end
# File lib/foreman_maintain/runner/execution.rb, line 38 def whitelisted? @whitelisted end
# File lib/foreman_maintain/runner/execution.rb, line 106 def capture_errors yield rescue StandardError => e @status = :fail @output << e.message logger.error(e) end
# File lib/foreman_maintain/runner/execution.rb, line 99 def with_metadata_calculation @started_at = Time.now yield ensure @ended_at = Time.now end