Class: Drnbench::RequestResponse::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/drnbench/request-response/configuration.rb

Constant Summary collapse

MIN_DURATION =
1
MIN_WAIT =
0

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

Returns a new instance of Configuration.



32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/drnbench/request-response/configuration.rb', line 32

def initialize
  @duration             = 30
  @wait                 = 0.01
  @interval             = 10
  @start_n_clients      = 0
  @end_n_clients        = 1
  @step                 = 1
  @n_requests           = 1000
  @mode                 = :http
  @n_slow_requests      = 5
  @n_fast_requests      = 5

  @default_hosts        = ["localhost"]
  @default_port         = 80
  @default_path         = "/"
  @default_method       = "GET"
  @default_timeout      = 5.0

  @report_progressively = true
  @output_path          = "/tmp/drnbench-result.csv"

  @last_default_host_index = 0
end

Instance Attribute Details

#default_hostsObject

Returns the value of attribute default_hosts.



25
26
27
# File 'lib/drnbench/request-response/configuration.rb', line 25

def default_hosts
  @default_hosts
end

#default_methodObject

Returns the value of attribute default_method.



26
27
28
# File 'lib/drnbench/request-response/configuration.rb', line 26

def default_method
  @default_method
end

#default_pathObject

Returns the value of attribute default_path.



26
27
28
# File 'lib/drnbench/request-response/configuration.rb', line 26

def default_path
  @default_path
end

#default_portObject

Returns the value of attribute default_port.



26
27
28
# File 'lib/drnbench/request-response/configuration.rb', line 26

def default_port
  @default_port
end

#default_timeoutObject

Returns the value of attribute default_timeout.



26
27
28
# File 'lib/drnbench/request-response/configuration.rb', line 26

def default_timeout
  @default_timeout
end

#durationObject

Returns the value of attribute duration.



21
22
23
# File 'lib/drnbench/request-response/configuration.rb', line 21

def duration
  @duration
end

#end_n_clientsObject

Returns the value of attribute end_n_clients.



22
23
24
# File 'lib/drnbench/request-response/configuration.rb', line 22

def end_n_clients
  @end_n_clients
end

#intervalObject

Returns the value of attribute interval.



21
22
23
# File 'lib/drnbench/request-response/configuration.rb', line 21

def interval
  @interval
end

#modeObject

Returns the value of attribute mode.



24
25
26
# File 'lib/drnbench/request-response/configuration.rb', line 24

def mode
  @mode
end

#n_fast_requestsObject

Returns the value of attribute n_fast_requests.



23
24
25
# File 'lib/drnbench/request-response/configuration.rb', line 23

def n_fast_requests
  @n_fast_requests
end

#n_requestsObject

Returns the value of attribute n_requests.



22
23
24
# File 'lib/drnbench/request-response/configuration.rb', line 22

def n_requests
  @n_requests
end

#n_slow_requestsObject

Returns the value of attribute n_slow_requests.



23
24
25
# File 'lib/drnbench/request-response/configuration.rb', line 23

def n_slow_requests
  @n_slow_requests
end

#output_pathObject

Returns the value of attribute output_path.



27
28
29
# File 'lib/drnbench/request-response/configuration.rb', line 27

def output_path
  @output_path
end

#report_progressivelyObject

Returns the value of attribute report_progressively.



27
28
29
# File 'lib/drnbench/request-response/configuration.rb', line 27

def report_progressively
  @report_progressively
end

#request_patterns_fileObject

Returns the value of attribute request_patterns_file.



21
22
23
# File 'lib/drnbench/request-response/configuration.rb', line 21

def request_patterns_file
  @request_patterns_file
end

#start_n_clientsObject

Returns the value of attribute start_n_clients.



22
23
24
# File 'lib/drnbench/request-response/configuration.rb', line 22

def start_n_clients
  @start_n_clients
end

#stepObject

Returns the value of attribute step.



22
23
24
# File 'lib/drnbench/request-response/configuration.rb', line 22

def step
  @step
end

#waitObject

Returns the value of attribute wait.



21
22
23
# File 'lib/drnbench/request-response/configuration.rb', line 21

def wait
  @wait
end

Instance Method Details

#default_hostObject



86
87
88
89
90
91
92
93
# File 'lib/drnbench/request-response/configuration.rb', line 86

def default_host
  host = @default_hosts[@last_default_host_index]
  @last_default_host_index += 1
  if @last_default_host_index == @default_hosts.size
    @last_default_host_index = 0
  end
  host
end

#request_patternsObject



77
78
79
# File 'lib/drnbench/request-response/configuration.rb', line 77

def request_patterns
  @request_patterns ||= prepare_request_patterns
end

#validateObject



56
57
58
59
60
61
62
63
# File 'lib/drnbench/request-response/configuration.rb', line 56

def validate
  if @duration.nil?
    raise ArgumentError.new("You must specify the test duration.")
  end
  if @request_patterns_file.nil?
    raise ArgumentError.new("You must specify the path to the request patterns JSON file.")
  end
end