Class: SippyCup::Runner
- Inherits:
-
Object
- Object
- SippyCup::Runner
- Defined in:
- lib/sippy_cup/runner.rb
Instance Attribute Summary collapse
-
#sipp_pid ⇒ Object
Returns the value of attribute sipp_pid.
Instance Method Summary collapse
-
#initialize(scenario, opts = {}) ⇒ Runner
constructor
Create a runner from a scenario.
-
#run ⇒ Object
Runs the loaded scenario using SIPp.
-
#stop ⇒ Object
Tries to stop SIPp by killing the target PID.
-
#wait ⇒ Object
Waits for the runner to finish execution.
Constructor Details
#initialize(scenario, opts = {}) ⇒ Runner
Create a runner from a scenario
21 22 23 24 25 26 27 28 29 30 |
# File 'lib/sippy_cup/runner.rb', line 21 def initialize(scenario, opts = {}) @scenario = scenario @scenario_options = @scenario. defaults = { full_sipp_output: true } @options = defaults.merge(opts) @command = @options[:command] @logger = @options[:logger] || Logger.new(STDOUT) end |
Instance Attribute Details
#sipp_pid ⇒ Object
Returns the value of attribute sipp_pid.
10 11 12 |
# File 'lib/sippy_cup/runner.rb', line 10 def sipp_pid @sipp_pid end |
Instance Method Details
#run ⇒ Object
Runs the loaded scenario using SIPp
35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/sippy_cup/runner.rb', line 35 def run @input_files = @scenario.to_tmpfiles @logger.info "Preparing to run SIPp command: #{command}" execute_with_redirected_streams wait unless @options[:async] ensure cleanup_input_files unless @options[:async] end |
#stop ⇒ Object
Tries to stop SIPp by killing the target PID
53 54 55 |
# File 'lib/sippy_cup/runner.rb', line 53 def stop Process.kill "KILL", @sipp_pid if @sipp_pid end |
#wait ⇒ Object
Waits for the runner to finish execution
69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 |
# File 'lib/sippy_cup/runner.rb', line 69 def wait exit_status = Process.wait2 @sipp_pid.to_i @err_rd.close if @err_rd @stdout_rd.close if @stdout_rd final_result = process_exit_status exit_status, @stderr_buffer if final_result @logger.info "Test completed successfully!" else @logger.info "Test completed successfully but some calls failed." end @logger.info "Statistics logged at #{File. @scenario_options[:stats_file]}" if @scenario_options[:stats_file] final_result ensure cleanup_input_files end |