Class: PerformanceTester::Runner
- Inherits:
-
Object
- Object
- PerformanceTester::Runner
- Defined in:
- lib/performance_tester/runner.rb
Overview
Executes a scenario, then creates and logs outcomes
Defined Under Namespace
Classes: Context
Instance Attribute Summary collapse
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Instance Method Summary collapse
- #browser ⇒ Object
- #build_context ⇒ Object
- #clock ⇒ Object
- #create_outcome(period, context) ⇒ Object
- #driver ⇒ Object
- #hosts ⇒ Object
-
#initialize(options = {}) ⇒ Runner
constructor
A new instance of Runner.
- #initialize_browser ⇒ Object
- #load_images? ⇒ Boolean
- #log_outcome(outcome) ⇒ Object
- #loggers ⇒ Object
- #outcome ⇒ Object
- #params ⇒ Object
- #run(scenario) ⇒ Object
- #run_name ⇒ Object
- #time_now ⇒ Object
- #timeout ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Runner
Returns a new instance of Runner.
12 13 14 15 |
# File 'lib/performance_tester/runner.rb', line 12 def initialize( = {}) @options = initialize_browser end |
Instance Attribute Details
#options ⇒ Object (readonly)
Returns the value of attribute options.
10 11 12 |
# File 'lib/performance_tester/runner.rb', line 10 def @options end |
Instance Method Details
#browser ⇒ Object
96 97 98 |
# File 'lib/performance_tester/runner.rb', line 96 def browser .fetch(:browser) { Capybara } end |
#build_context ⇒ Object
56 57 58 |
# File 'lib/performance_tester/runner.rb', line 56 def build_context Context.new(params, hosts) end |
#clock ⇒ Object
92 93 94 |
# File 'lib/performance_tester/runner.rb', line 92 def clock .fetch(:clock) { Time } end |
#create_outcome(period, context) ⇒ Object
45 46 47 |
# File 'lib/performance_tester/runner.rb', line 45 def create_outcome(period, context) outcome.new(context.network_traffic, period, hosts, context.error) end |
#driver ⇒ Object
100 101 102 |
# File 'lib/performance_tester/runner.rb', line 100 def driver .fetch(:driver) { Capybara::Poltergeist::Driver } end |
#hosts ⇒ Object
72 73 74 |
# File 'lib/performance_tester/runner.rb', line 72 def hosts .fetch(:hosts) { {} } end |
#initialize_browser ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/performance_tester/runner.rb', line 28 def initialize_browser browser.run_server = false browser.current_driver = :poltergeist browser.register_driver :poltergeist do |app| = [] unless load_images? << "--load-images=no" end = { :debug => false, :timeout => timeout, :phantomjs_options => } driver.new(app, ) end end |
#load_images? ⇒ Boolean
80 81 82 |
# File 'lib/performance_tester/runner.rb', line 80 def load_images? .fetch(:load_images) { true } end |
#log_outcome(outcome) ⇒ Object
49 50 51 52 53 54 |
# File 'lib/performance_tester/runner.rb', line 49 def log_outcome(outcome) loggers.each do |logger_name, | logger = PerformanceTester.registered_logger(logger_name) logger.new(run_name, outcome, ).log end end |
#loggers ⇒ Object
76 77 78 |
# File 'lib/performance_tester/runner.rb', line 76 def loggers .fetch(:loggers) { {} } end |
#outcome ⇒ Object
88 89 90 |
# File 'lib/performance_tester/runner.rb', line 88 def outcome .fetch(:outcome) { Outcome } end |
#params ⇒ Object
68 69 70 |
# File 'lib/performance_tester/runner.rb', line 68 def params .fetch(:params) { {} } end |
#run(scenario) ⇒ Object
17 18 19 20 21 22 23 24 25 26 |
# File 'lib/performance_tester/runner.rb', line 17 def run(scenario) context = build_context start = time_now context.execute(scenario) stop = time_now period = (start .. stop) outcome = create_outcome(period, context) log_outcome(outcome) outcome end |
#run_name ⇒ Object
64 65 66 |
# File 'lib/performance_tester/runner.rb', line 64 def run_name .fetch(:name) { '' } end |
#time_now ⇒ Object
60 61 62 |
# File 'lib/performance_tester/runner.rb', line 60 def time_now clock.now end |
#timeout ⇒ Object
84 85 86 |
# File 'lib/performance_tester/runner.rb', line 84 def timeout .fetch(:timeout) { 30 } end |