Class: DeepTest::Options
- Inherits:
-
Object
show all
- Defined in:
- lib/deep_test/options.rb
Defined Under Namespace
Classes: InvalidOptionError
Constant Summary
collapse
- VALID_OPTIONS =
[
Option.new(:distributed_hosts, nil),
Option.new(:number_of_agents, nil),
Option.new(:metrics_file, nil),
Option.new(:pattern, nil),
Option.new(:server_port, nil),
Option.new(:sync_options, {}),
Option.new(:ui, "DeepTest::UI::Console"),
Option.new(:listener, "DeepTest::NullListener"),
]
- UI_INSTANCES =
Don’t store UI instances in the options instance, which will need to be dumped over Telegraph since UI instances may not be dumpable.
{}
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
#initialize(hash) ⇒ Options
Returns a new instance of Options.
39
40
41
42
43
44
45
46
|
# File 'lib/deep_test/options.rb', line 39
def initialize(hash)
@origin_hostname = Socket.gethostname
check_option_keys(hash)
VALID_OPTIONS.each do |option|
send("#{option.name}=", hash[option.name] || hash[option.name.to_s] || option.default)
end
self.environment_log_level = ENV['DEEP_TEST_LOG_LEVEL']
end
|
Instance Attribute Details
#environment_log_level ⇒ Object
Returns the value of attribute environment_log_level.
19
20
21
|
# File 'lib/deep_test/options.rb', line 19
def environment_log_level
@environment_log_level
end
|
#ssh_client_connection_info ⇒ Object
Returns the value of attribute ssh_client_connection_info.
19
20
21
|
# File 'lib/deep_test/options.rb', line 19
def ssh_client_connection_info
@ssh_client_connection_info
end
|
Class Method Details
.from_command_line(command_line) ⇒ Object
34
35
36
37
|
# File 'lib/deep_test/options.rb', line 34
def self.from_command_line(command_line)
return new({}) if command_line.nil? || command_line.empty?
Marshal.load Base64.decode64(command_line)
end
|
Instance Method Details
#connect_to_central_command ⇒ Object
63
64
65
66
67
68
|
# File 'lib/deep_test/options.rb', line 63
def connect_to_central_command
address = ssh_client_connection_info ? ssh_client_connection_info.address : "localhost"
Telegraph::Wire.connect(address, server_port) do |wire|
yield wire
end
end
|
#gathering_metrics? ⇒ Boolean
48
49
50
|
# File 'lib/deep_test/options.rb', line 48
def gathering_metrics?
!@metrics_file.nil?
end
|
#listener=(value) ⇒ Object
30
31
32
|
# File 'lib/deep_test/options.rb', line 30
def listener=(value)
@listener = value.to_s
end
|
#mirror_path ⇒ Object
82
83
84
85
86
|
# File 'lib/deep_test/options.rb', line 82
def mirror_path
raise "No source directory specified in sync_options" unless sync_options[:source]
relative_mirror_path = @origin_hostname + sync_options[:source].gsub('/','_')
"#{sync_options[:remote_base_dir] || '/tmp'}/#{relative_mirror_path}"
end
|
#new_landing_fleet ⇒ Object
#new_listener_list ⇒ Object
52
53
54
55
56
57
|
# File 'lib/deep_test/options.rb', line 52
def new_listener_list
listeners = listener.split(',').map do |listener|
eval(listener).new
end
ListenerList.new(listeners)
end
|
#number_of_agents ⇒ Object
21
22
23
24
|
# File 'lib/deep_test/options.rb', line 21
def number_of_agents
return CpuInfo.new.count unless @number_of_agents
@number_of_agents
end
|
#origin_hostname ⇒ Object
59
60
61
|
# File 'lib/deep_test/options.rb', line 59
def origin_hostname
(Socket.gethostname == @origin_hostname) ? 'localhost' : @origin_hostname
end
|
#to_command_line ⇒ Object
78
79
80
|
# File 'lib/deep_test/options.rb', line 78
def to_command_line
Base64.encode64(Marshal.dump(self)).gsub("\n","")
end
|
#ui=(value) ⇒ Object
26
27
28
|
# File 'lib/deep_test/options.rb', line 26
def ui=(value)
@ui = value.to_s
end
|
#ui_instance ⇒ Object
74
75
76
|
# File 'lib/deep_test/options.rb', line 74
def ui_instance
UI_INSTANCES[self] ||= eval(ui).new(self)
end
|