Module: Stella::Engine::Functional

Extended by:
Base, Functional
Included in:
Functional
Defined in:
lib/stella/engine/functional.rb

Instance Method Summary collapse

Methods included from Base

update

Instance Method Details

#run(plan, opts = {}) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/stella/engine/functional.rb', line 7

def run(plan, opts={})
  opts = {
    :hosts        => [],
    :benchmark    => false,
    :repetitions  => 1
  }.merge! opts
  Stella.ld "OPTIONS: #{opts.inspect}"
  Stella.li2 "Hosts: " << opts[:hosts].join(', ') if !opts[:hosts].empty?
  Stella.li plan.pretty
  
  client = Stella::Client.new opts[:hosts].first
  client.add_observer(self)

  client.enable_benchmark_mode if opts[:benchmark]
  
  Stella.li $/, "Starting test...", $/
  Stella.lflush
  sleep 0.3
  
  plan.usecases.each_with_index do |uc,i|
    desc = (uc.desc || "Usecase ##{i+1}")
    Stella.li ' %-65s '.att(:reverse).bright % [desc]
    Stella.rescue { client.execute uc }
  end
  
  
  #p client.benelux_at(:execute_start).first.name
  
  #p client.benelux_between(:execute_start, :execute_end)
  
  #p client.benelux_duration(:execute)
  
  !plan.errors?
end

#update_error_execute_response_handler(client_id, ex, req, container) ⇒ Object



68
69
70
71
# File 'lib/stella/engine/functional.rb', line 68

def update_error_execute_response_handler(client_id, ex, req, container)
  Stella.le ex.message
  Stella.ld ex.backtrace
end

#update_execute_response_handler(client_id, req, container) ⇒ Object



65
66
# File 'lib/stella/engine/functional.rb', line 65

def update_execute_response_handler(client_id, req, container)
end

#update_prepare_request(client_id, usecase, req, counter) ⇒ Object



43
44
45
46
# File 'lib/stella/engine/functional.rb', line 43

def update_prepare_request(client_id, usecase, req, counter)
  notice = "repeat: #{counter-1}" if counter > 1
  Stella.li2 ' ' << " %-46s %16s ".att(:reverse) % [req.desc, notice]
end

#update_receive_response(client_id, usecase, uri, req, params, container) ⇒ Object



52
53
54
55
56
57
58
59
60
61
62
63
# File 'lib/stella/engine/functional.rb', line 52

def update_receive_response(client_id, usecase, uri, req, params, container)
  Stella.li '  %-59s %3d' % [uri, container.status]
  Stella.li2 "  Method: " << req.http_method
  Stella.li2 "  Params: " << params.inspect
  Stella.li3 $/, "  Headers:"
  container.headers.all.each do |pair|
    Stella.li3 "    %s: %s" % pair
  end
  Stella.li4 $/, "  Content:"
  Stella.li4 container.body.empty? ? '    [empty]' : container.body
  Stella.li2 $/
end

#update_request_error(client_id, usecase, uri, req, params, ex) ⇒ Object



73
74
75
76
77
# File 'lib/stella/engine/functional.rb', line 73

def update_request_error(client_id, usecase, uri, req, params, ex)
  desc = "#{usecase.desc} > #{req.desc}"
  Stella.le '  Client%-3s %-45s %s' % [client_id, desc, ex.message]
  Stella.ld ex.backtrace
end

#update_send_request(client_id, usecase, uri, req, params, counter) ⇒ Object



48
49
50
# File 'lib/stella/engine/functional.rb', line 48

def update_send_request(client_id, usecase, uri, req, params, counter)

end