jstorimer-deep-test 0.2.0 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +0 -1
- data/README.rdoc +70 -41
- data/Rakefile +104 -32
- data/TODO +2 -2
- data/VERSION +1 -1
- data/bin/deep_test +15 -0
- data/jstorimer-deep-test-0.1.0.gem +0 -0
- data/jstorimer-deep-test.gemspec +1425 -0
- data/lib/deep_test.rb +40 -28
- data/lib/deep_test/database/mysql_setup_listener.rb +12 -12
- data/lib/deep_test/database/setup_listener.rb +23 -23
- data/lib/deep_test/distributed/dispatch_controller.rb +10 -17
- data/lib/deep_test/distributed/drb_client_connection_info.rb +15 -0
- data/lib/deep_test/distributed/master_test_server.rb +52 -0
- data/lib/deep_test/distributed/multi_test_server_proxy.rb +44 -0
- data/lib/deep_test/distributed/null_work_unit.rb +12 -0
- data/lib/deep_test/distributed/remote_worker_client.rb +54 -0
- data/lib/deep_test/distributed/remote_worker_server.rb +82 -0
- data/lib/deep_test/distributed/rsync.rb +12 -25
- data/lib/deep_test/distributed/show_status.rhtml +41 -0
- data/lib/deep_test/distributed/test_server.rb +78 -0
- data/lib/deep_test/distributed/test_server_status.rb +9 -0
- data/lib/deep_test/distributed/test_server_workers.rb +24 -0
- data/lib/deep_test/distributed/throughput_runner.rb +42 -0
- data/lib/deep_test/distributed/throughput_statistics.rb +26 -0
- data/lib/deep_test/distributed/throughput_worker_client.rb +19 -0
- data/lib/deep_test/extensions/drb_extension.rb +34 -0
- data/lib/deep_test/listener_list.rb +1 -1
- data/lib/deep_test/local_workers.rb +55 -0
- data/lib/deep_test/logger.rb +2 -17
- data/lib/deep_test/marshallable_exception_wrapper.rb +4 -4
- data/lib/deep_test/metrics/gatherer.rb +67 -0
- data/lib/deep_test/metrics/queue_lock_wait_time_measurement.rb +133 -0
- data/lib/deep_test/{null_listener.rb → null_worker_listener.rb} +14 -14
- data/lib/deep_test/option.rb +60 -0
- data/lib/deep_test/options.rb +42 -45
- data/lib/deep_test/process_orchestrator.rb +49 -0
- data/lib/deep_test/rake_tasks.rb +1 -3
- data/lib/deep_test/result_reader.rb +6 -10
- data/lib/deep_test/rspec_detector.rb +1 -1
- data/lib/deep_test/server.rb +75 -0
- data/lib/deep_test/spec.rb +1 -5
- data/lib/deep_test/spec/extensions/example_methods.rb +1 -7
- data/lib/deep_test/spec/extensions/reporter.rb +29 -0
- data/lib/deep_test/spec/extensions/spec_task.rb +2 -3
- data/lib/deep_test/spec/runner.rb +17 -32
- data/lib/deep_test/spec/work_result.rb +0 -2
- data/lib/deep_test/test/runner.rb +2 -2
- data/lib/deep_test/test/supervised_test_suite.rb +10 -9
- data/lib/deep_test/test/work_result.rb +0 -1
- data/lib/deep_test/test_task.rb +1 -1
- data/lib/deep_test/ui/console.rb +11 -9
- data/lib/deep_test/warlock.rb +25 -37
- data/lib/deep_test/worker.rb +57 -0
- data/sample_rails_project/deep_test.rb +0 -4
- data/sample_rails_project/lib/{foreign_host_agent_simulation_listener.rb → foreign_host_worker_simulation_listener.rb} +4 -6
- data/sample_rails_project/lib/tasks/deep_test.rake +4 -13
- data/script/internal/run_test_suite.rb +7 -0
- data/script/public/master_test_server.rb +24 -0
- data/script/public/test_server.rb +18 -0
- data/script/public/test_throughput.rb +29 -0
- data/spec/deep_test/option_spec.rb +33 -0
- data/spec/deep_test/options_spec.rb +59 -80
- data/spec/deep_test/spec/extensions/example_methods_spec.rb +4 -5
- data/spec/deep_test/spec/extensions/spec_task_spec.rb +6 -4
- data/spec/deep_test/spec/runner_spec.rb +32 -59
- data/spec/spec_helper.rb +6 -14
- data/spec/thread_worker.rb +25 -0
- data/test/deep_test/database/mysql_setup_listener_test.rb +9 -13
- data/test/deep_test/distributed/dispatch_controller_test.rb +177 -130
- data/test/deep_test/distributed/drb_client_connection_info_test.rb +42 -0
- data/test/deep_test/distributed/filename_resolver_test.rb +34 -38
- data/test/deep_test/distributed/master_test_server_test.rb +32 -0
- data/test/deep_test/distributed/multi_test_server_proxy_test.rb +96 -0
- data/test/deep_test/distributed/remote_worker_client_test.rb +180 -0
- data/test/deep_test/distributed/remote_worker_server_test.rb +99 -0
- data/test/deep_test/distributed/rsync_test.rb +62 -42
- data/test/deep_test/distributed/test_server_test.rb +94 -0
- data/test/deep_test/distributed/test_server_workers_test.rb +26 -0
- data/test/deep_test/distributed/throughput_runner_test.rb +68 -0
- data/test/deep_test/distributed/throughput_worker_client_test.rb +28 -0
- data/test/deep_test/listener_list_test.rb +15 -17
- data/test/deep_test/local_workers_test.rb +22 -0
- data/test/deep_test/logger_test.rb +7 -34
- data/test/deep_test/marshallable_exception_wrapper_test.rb +29 -31
- data/test/deep_test/metrics/gatherer_test.rb +66 -0
- data/test/deep_test/process_orchestrator_test.rb +11 -0
- data/test/deep_test/result_reader_test.rb +95 -95
- data/test/deep_test/server_test.rb +58 -0
- data/test/deep_test/test/extensions/error_test.rb +36 -38
- data/test/deep_test/test/runner_test.rb +3 -7
- data/test/deep_test/test/supervised_test_suite_test.rb +61 -89
- data/test/deep_test/test/work_result_test.rb +76 -80
- data/test/deep_test/test/work_unit_test.rb +51 -53
- data/test/deep_test/test_task_test.rb +38 -10
- data/test/deep_test/ui/console_test.rb +4 -8
- data/test/deep_test/warlock_test.rb +31 -33
- data/test/deep_test/worker_test.rb +94 -0
- data/test/failing.rake +11 -0
- data/{negative_acceptance_tests/failing_test.rb → test/failing.rb} +1 -3
- data/{infrastructure → test}/fake_deadlock_error.rb +0 -0
- data/test/simple_test_blackboard.rb +45 -0
- data/test/simple_test_blackboard_test.rb +33 -0
- data/{infrastructure → test}/test_factory.rb +0 -0
- data/test/test_helper.rb +5 -20
- data/test/test_task_test.rb +57 -60
- metadata +78 -87
- data/infrastructure/dynamic_teardown.rb +0 -22
- data/infrastructure/load.rb +0 -11
- data/infrastructure/test_central_command.rb +0 -15
- data/infrastructure/test_exception.rb +0 -7
- data/infrastructure/test_logger.rb +0 -11
- data/infrastructure/test_operator.rb +0 -15
- data/infrastructure/test_result.rb +0 -15
- data/infrastructure/thread_agent.rb +0 -21
- data/infrastructure/timewarp/Rakefile +0 -14
- data/infrastructure/timewarp/lib/timewarp.rb +0 -21
- data/infrastructure/timewarp/test/timewarp_test.rb +0 -45
- data/lib/deep_test/agent.rb +0 -108
- data/lib/deep_test/central_command.rb +0 -165
- data/lib/deep_test/cpu_info.rb +0 -22
- data/lib/deep_test/demon.rb +0 -25
- data/lib/deep_test/distributed/beachhead.rb +0 -104
- data/lib/deep_test/distributed/establish_beachhead.rb +0 -19
- data/lib/deep_test/distributed/landing_fleet.rb +0 -30
- data/lib/deep_test/distributed/landing_ship.rb +0 -60
- data/lib/deep_test/distributed/remote_deployment.rb +0 -56
- data/lib/deep_test/distributed/shell_environment.rb +0 -50
- data/lib/deep_test/distributed/ssh_client_connection_info.rb +0 -14
- data/lib/deep_test/failure_message.rb +0 -19
- data/lib/deep_test/lib_root.rb +0 -4
- data/lib/deep_test/local_deployment.rb +0 -46
- data/lib/deep_test/main.rb +0 -41
- data/lib/deep_test/metrics/data.rb +0 -34
- data/lib/deep_test/metrics/measurement.rb +0 -39
- data/lib/deep_test/proxy_io.rb +0 -77
- data/lib/deep_test/test/run_test_suite.rb +0 -5
- data/lib/telegraph.rb +0 -29
- data/lib/telegraph/ack_sequence.rb +0 -14
- data/lib/telegraph/logging.rb +0 -20
- data/lib/telegraph/message.rb +0 -39
- data/lib/telegraph/operator.rb +0 -47
- data/lib/telegraph/switchboard.rb +0 -57
- data/lib/telegraph/wire.rb +0 -73
- data/negative_acceptance_tests/dying_spec.rb +0 -13
- data/negative_acceptance_tests/dying_test.rb +0 -13
- data/negative_acceptance_tests/failing_spec.rb +0 -9
- data/negative_acceptance_tests/kill_agent_one_on_start_work.rb +0 -16
- data/negative_acceptance_tests/passing_spec.rb +0 -10
- data/negative_acceptance_tests/passing_test.rb +0 -12
- data/negative_acceptance_tests/tasks.rake +0 -87
- data/negative_acceptance_tests/tests.rb +0 -60
- data/test/deep_test/agent_test.rb +0 -175
- data/test/deep_test/central_command_test.rb +0 -147
- data/test/deep_test/cpu_info_test.rb +0 -33
- data/test/deep_test/demon_test.rb +0 -23
- data/test/deep_test/distributed/beachhead_test.rb +0 -67
- data/test/deep_test/distributed/landing_fleet_test.rb +0 -55
- data/test/deep_test/distributed/landing_ship_test.rb +0 -48
- data/test/deep_test/distributed/remote_deployment_test.rb +0 -134
- data/test/deep_test/distributed/shell_environment_fixtures/set_bar_to_foo +0 -1
- data/test/deep_test/distributed/shell_environment_fixtures/set_foo_to_bar +0 -1
- data/test/deep_test/distributed/shell_environment_fixtures/set_foo_to_baz +0 -1
- data/test/deep_test/distributed/shell_environment_test.rb +0 -108
- data/test/deep_test/distributed/ssh_client_connection_info_test.rb +0 -34
- data/test/deep_test/local_deployment_test.rb +0 -19
- data/test/deep_test/main_test.rb +0 -12
- data/test/deep_test/metrics/data_test.rb +0 -22
- data/test/deep_test/metrics/measurement_test.rb +0 -18
- data/test/deep_test/proxy_io_test.rb +0 -104
@@ -1,19 +0,0 @@
|
|
1
|
-
require File.dirname(__FILE__) + "/../../deep_test"
|
2
|
-
options = DeepTest::Options.from_command_line(ENV['OPTIONS'])
|
3
|
-
ENV['DEEP_TEST_LOG_LEVEL'] = options.environment_log_level
|
4
|
-
options.ssh_client_connection_info = DeepTest::Distributed::SshClientConnectionInfo.new
|
5
|
-
|
6
|
-
DeepTest.logger.debug { "mirror establish_beachhead for #{options.origin_hostname}" }
|
7
|
-
|
8
|
-
STDIN.close
|
9
|
-
|
10
|
-
beachhead_port = DeepTest::Distributed::Beachhead.new(
|
11
|
-
File.join(options.mirror_path, File.basename(options.sync_options[:source])),
|
12
|
-
options
|
13
|
-
).daemonize
|
14
|
-
|
15
|
-
puts "Beachhead port: #{beachhead_port}"
|
16
|
-
$stdout.flush
|
17
|
-
|
18
|
-
exit!(0)
|
19
|
-
|
@@ -1,30 +0,0 @@
|
|
1
|
-
module DeepTest
|
2
|
-
module Distributed
|
3
|
-
class LandingFleet
|
4
|
-
def initialize(options, slaves)
|
5
|
-
DeepTest.logger.debug { "LandingFleet#initialize #{slaves.length} slaves" }
|
6
|
-
@slave_controller = DispatchController.new(options, slaves)
|
7
|
-
end
|
8
|
-
|
9
|
-
def establish_beachhead(options)
|
10
|
-
DeepTest.logger.debug { "dispatch establish_beachhead for #{options.origin_hostname}" }
|
11
|
-
@slave_controller.dispatch :establish_beachhead, options
|
12
|
-
end
|
13
|
-
|
14
|
-
def push_code(options)
|
15
|
-
DeepTest.logger.debug { "dispatch push_code for #{options.origin_hostname}" }
|
16
|
-
@slave_controller.dispatch :push_code, options
|
17
|
-
end
|
18
|
-
|
19
|
-
def load_files(files)
|
20
|
-
DeepTest.logger.debug { "dispatch load_files" }
|
21
|
-
@slave_controller.dispatch :load_files, files
|
22
|
-
end
|
23
|
-
|
24
|
-
def deploy_agents
|
25
|
-
DeepTest.logger.debug { "dispatch deploy_agents" }
|
26
|
-
@slave_controller.dispatch :deploy_agents
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
@@ -1,60 +0,0 @@
|
|
1
|
-
module DeepTest
|
2
|
-
module Distributed
|
3
|
-
class LandingShip
|
4
|
-
def initialize(config)
|
5
|
-
@config = config
|
6
|
-
end
|
7
|
-
|
8
|
-
def push_code(options)
|
9
|
-
RSync.push(@config[:address], options.sync_options, options.mirror_path)
|
10
|
-
end
|
11
|
-
|
12
|
-
def establish_beachhead(options)
|
13
|
-
command = "#{ssh_command(options)} '#{spawn_command(options)}' 2>&1"
|
14
|
-
DeepTest.logger.debug { "Establishing Beachhead: #{command}" }
|
15
|
-
|
16
|
-
output = `#{command}`
|
17
|
-
output.each do |line|
|
18
|
-
if DeepTest.logger.level == Logger::DEBUG
|
19
|
-
puts output
|
20
|
-
end
|
21
|
-
if line =~ /Beachhead port: (.+)/
|
22
|
-
@wire = Telegraph::Wire.connect(@config[:address], $1.to_i)
|
23
|
-
end
|
24
|
-
end
|
25
|
-
raise "LandingShip unable to establish Beachhead. Output from #{@config[:address]} was:\n#{output}" unless @wire
|
26
|
-
end
|
27
|
-
|
28
|
-
def load_files(files)
|
29
|
-
@wire.send_message Beachhead::LoadFiles.new(files)
|
30
|
-
end
|
31
|
-
|
32
|
-
def deploy_agents
|
33
|
-
@wire.send_message Beachhead::DeployAgents
|
34
|
-
begin
|
35
|
-
message = @wire.next_message :timeout => 1
|
36
|
-
raise "Unexpected message from Beachhead: #{message.inspect}" unless message.body == Beachhead::Done
|
37
|
-
rescue Telegraph::NoMessageAvailable
|
38
|
-
retry
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
def ssh_command(options)
|
43
|
-
username_option = if options.sync_options[:username]
|
44
|
-
" -l #{options.sync_options[:username]}"
|
45
|
-
else
|
46
|
-
""
|
47
|
-
end
|
48
|
-
|
49
|
-
"ssh -4 #{@config[:address]}#{username_option}"
|
50
|
-
end
|
51
|
-
|
52
|
-
def spawn_command(options)
|
53
|
-
"#{ShellEnvironment.like_login} && " +
|
54
|
-
"cd #{options.mirror_path} && " +
|
55
|
-
"OPTIONS=#{options.to_command_line} " +
|
56
|
-
"ruby lib/deep_test/distributed/establish_beachhead.rb"
|
57
|
-
end
|
58
|
-
end
|
59
|
-
end
|
60
|
-
end
|
@@ -1,56 +0,0 @@
|
|
1
|
-
module DeepTest
|
2
|
-
module Distributed
|
3
|
-
class RemoteDeployment
|
4
|
-
def initialize(options, landing_fleet, failover_deployment)
|
5
|
-
@failover_deployment = failover_deployment
|
6
|
-
@options = options
|
7
|
-
@landing_fleet = landing_fleet
|
8
|
-
end
|
9
|
-
|
10
|
-
def load_files(filelist)
|
11
|
-
# load one file before calling listeners to make sure environment has
|
12
|
-
# been initialized as expected
|
13
|
-
#
|
14
|
-
load filelist.first
|
15
|
-
@options.new_listener_list.before_sync
|
16
|
-
|
17
|
-
t = Thread.new do
|
18
|
-
@landing_fleet.push_code(@options)
|
19
|
-
@landing_fleet.establish_beachhead(@options)
|
20
|
-
@landing_fleet.load_files filelist
|
21
|
-
end
|
22
|
-
|
23
|
-
filelist[1..-1].each {|f| load f}
|
24
|
-
|
25
|
-
begin
|
26
|
-
t.join
|
27
|
-
rescue => e
|
28
|
-
# The failover here doesn't invoke load_files on the failover_deployment
|
29
|
-
# because it will be a LocalDeployment, which forks from the current
|
30
|
-
# process. The fact that we depend in this here is damp...
|
31
|
-
#
|
32
|
-
fail_over("load_files", e)
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
def deploy_agents
|
37
|
-
DeepTest.logger.debug { "RemoteDeployment deploying agents with #{@landing_fleet}" }
|
38
|
-
@landing_fleet.deploy_agents
|
39
|
-
rescue => e
|
40
|
-
raise if failed_over?
|
41
|
-
fail_over("deploy_agents", e)
|
42
|
-
retry
|
43
|
-
end
|
44
|
-
|
45
|
-
def fail_over(method, exception)
|
46
|
-
DeepTest.logger.debug { "RemoteDeployment failing over on #{method}." }
|
47
|
-
@options.ui_instance.distributed_failover_to_local(method, exception)
|
48
|
-
@landing_fleet = @failover_deployment
|
49
|
-
end
|
50
|
-
|
51
|
-
def failed_over?
|
52
|
-
@landing_fleet == @failover_deployment
|
53
|
-
end
|
54
|
-
end
|
55
|
-
end
|
56
|
-
end
|
@@ -1,50 +0,0 @@
|
|
1
|
-
module DeepTest
|
2
|
-
module Distributed
|
3
|
-
class ShellEnvironment
|
4
|
-
def self.like_login
|
5
|
-
login_env = new
|
6
|
-
login_env.include_first '/etc/profile'
|
7
|
-
login_env.include_first '~/.profile', '~/.bash_profile', '~/.bashrc'
|
8
|
-
login_env
|
9
|
-
end
|
10
|
-
|
11
|
-
def initialize
|
12
|
-
@source_file_lists = []
|
13
|
-
end
|
14
|
-
|
15
|
-
def include_first(*filenames)
|
16
|
-
source_file_lists << SourceFileList.new(filenames)
|
17
|
-
end
|
18
|
-
|
19
|
-
def to_s
|
20
|
-
source_file_lists.join(" && ")
|
21
|
-
end
|
22
|
-
|
23
|
-
def ==(other)
|
24
|
-
source_file_lists == other.source_file_lists
|
25
|
-
end
|
26
|
-
|
27
|
-
attr_reader :source_file_lists
|
28
|
-
protected :source_file_lists
|
29
|
-
|
30
|
-
class SourceFileList
|
31
|
-
def initialize(filenames)
|
32
|
-
@filenames = filenames
|
33
|
-
end
|
34
|
-
|
35
|
-
def to_s
|
36
|
-
"if" +
|
37
|
-
filenames.map {|f| " [[ -f #{f} ]]; then . #{f}; "}.join("elif") +
|
38
|
-
"fi"
|
39
|
-
end
|
40
|
-
|
41
|
-
def ==(other)
|
42
|
-
filenames == other.filenames
|
43
|
-
end
|
44
|
-
|
45
|
-
attr_reader :filenames
|
46
|
-
protected :filenames
|
47
|
-
end
|
48
|
-
end
|
49
|
-
end
|
50
|
-
end
|
@@ -1,14 +0,0 @@
|
|
1
|
-
module DeepTest
|
2
|
-
module Distributed
|
3
|
-
class SshClientConnectionInfo
|
4
|
-
attr_reader :address
|
5
|
-
|
6
|
-
def initialize
|
7
|
-
raise "SSH_CLIENT environment variable not set" unless ENV['SSH_CLIENT']
|
8
|
-
ENV['SSH_CLIENT'] =~ /^(.+) \d+ \d+$/
|
9
|
-
raise "Unable to extract address from SSH_CLIENT (#{ENV['SSH_CLIENT']})" unless $1
|
10
|
-
@address = $1
|
11
|
-
end
|
12
|
-
end
|
13
|
-
end
|
14
|
-
end
|
@@ -1,19 +0,0 @@
|
|
1
|
-
module DeepTest
|
2
|
-
module FailureMessage
|
3
|
-
def self.show(title, message, width = 70)
|
4
|
-
lines = [" #{title} ".center(width, '*')]
|
5
|
-
message.each do |line|
|
6
|
-
lines << "* #{line.strip}".ljust(width - 1) + "*"
|
7
|
-
end
|
8
|
-
lines << "*" * width
|
9
|
-
string = lines.join("\n")
|
10
|
-
begin
|
11
|
-
puts string
|
12
|
-
rescue
|
13
|
-
IO.new(2) do |err|
|
14
|
-
err.puts string
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
data/lib/deep_test/lib_root.rb
DELETED
@@ -1,46 +0,0 @@
|
|
1
|
-
module DeepTest
|
2
|
-
class LocalDeployment
|
3
|
-
attr_reader :warlock
|
4
|
-
|
5
|
-
def initialize(options, agent_class = DeepTest::Agent)
|
6
|
-
@options = options
|
7
|
-
@agent_class = agent_class
|
8
|
-
end
|
9
|
-
|
10
|
-
def warlock
|
11
|
-
@warlock ||= Warlock.new @options
|
12
|
-
end
|
13
|
-
|
14
|
-
def load_files(files)
|
15
|
-
files.each {|f| load f}
|
16
|
-
end
|
17
|
-
|
18
|
-
def deploy_agents
|
19
|
-
DeepTest.logger.debug { "Deploying #{number_of_agents} #{@agent_class}s" }
|
20
|
-
wait_for_connect_threads = []
|
21
|
-
each_agent do |agent_num|
|
22
|
-
stream_from_child_process, stream_to_parent_process = IO.pipe
|
23
|
-
warlock.start "agent #{agent_num}", @agent_class.new(agent_num, @options, @options.new_listener_list),
|
24
|
-
stream_from_child_process, stream_to_parent_process
|
25
|
-
wait_for_connect_threads << Thread.new do
|
26
|
-
stream_to_parent_process.close
|
27
|
-
message = stream_from_child_process.read
|
28
|
-
stream_from_child_process.close
|
29
|
-
raise "Agent was not able to connect: #{message}" unless message == "Connected\n"
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
wait_for_connect_threads.each { |t| t.join }
|
34
|
-
end
|
35
|
-
|
36
|
-
def number_of_agents
|
37
|
-
@options.number_of_agents
|
38
|
-
end
|
39
|
-
|
40
|
-
private
|
41
|
-
|
42
|
-
def each_agent
|
43
|
-
number_of_agents.to_i.times { |agent_num| yield agent_num }
|
44
|
-
end
|
45
|
-
end
|
46
|
-
end
|
data/lib/deep_test/main.rb
DELETED
@@ -1,41 +0,0 @@
|
|
1
|
-
module DeepTest
|
2
|
-
class Main
|
3
|
-
attr_reader :central_command
|
4
|
-
|
5
|
-
def initialize(options, deployment, runner, central_command = nil)
|
6
|
-
@options = options
|
7
|
-
@deployment = deployment
|
8
|
-
@runner = runner
|
9
|
-
@central_command = central_command || CentralCommand.start(options)
|
10
|
-
end
|
11
|
-
|
12
|
-
def load_files(files)
|
13
|
-
@deployment.load_files files
|
14
|
-
end
|
15
|
-
|
16
|
-
def run(exit_when_done = true)
|
17
|
-
passed = false
|
18
|
-
|
19
|
-
begin
|
20
|
-
@options.new_listener_list.before_starting_agents
|
21
|
-
@deployment.deploy_agents
|
22
|
-
begin
|
23
|
-
DeepTest.logger.debug { "Main: About to process work units (#{$$})" }
|
24
|
-
passed = @runner.process_work_units(central_command)
|
25
|
-
ensure
|
26
|
-
shutdown
|
27
|
-
end
|
28
|
-
ensure
|
29
|
-
DeepTest.logger.debug { "Main: Stopping CentralCommand" }
|
30
|
-
@central_command.stop
|
31
|
-
end
|
32
|
-
|
33
|
-
Kernel.exit(passed ? 0 : 1) if exit_when_done
|
34
|
-
end
|
35
|
-
|
36
|
-
def shutdown
|
37
|
-
DeepTest.logger.debug { "Main: Shutting Down" }
|
38
|
-
@central_command.done_with_work
|
39
|
-
end
|
40
|
-
end
|
41
|
-
end
|
@@ -1,34 +0,0 @@
|
|
1
|
-
module DeepTest
|
2
|
-
module Metrics
|
3
|
-
class Data
|
4
|
-
def initialize
|
5
|
-
@measurements_by_category = {}
|
6
|
-
end
|
7
|
-
|
8
|
-
def add(measurement)
|
9
|
-
categories = @measurements_by_category[measurement.category] ||= []
|
10
|
-
categories << measurement
|
11
|
-
end
|
12
|
-
|
13
|
-
def summary
|
14
|
-
summary = []
|
15
|
-
summary << "Metrics Data\n"
|
16
|
-
summary << "------------\n"
|
17
|
-
|
18
|
-
@measurements_by_category.keys.sort.map do |category|
|
19
|
-
measurements = @measurements_by_category[category]
|
20
|
-
units = measurements.first.units
|
21
|
-
summary << "#{category}: #{Measurement.average(measurements)} avg / #{Measurement.total(measurements)} total #{units}\n"
|
22
|
-
end
|
23
|
-
|
24
|
-
summary.join
|
25
|
-
end
|
26
|
-
|
27
|
-
def save(file)
|
28
|
-
File.open(file, "w") do |f|
|
29
|
-
f << summary
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|
@@ -1,39 +0,0 @@
|
|
1
|
-
module DeepTest
|
2
|
-
module Metrics
|
3
|
-
class Measurement
|
4
|
-
attr_reader :category, :value, :units
|
5
|
-
|
6
|
-
def initialize(category, value, units)
|
7
|
-
@category = category
|
8
|
-
@value = value
|
9
|
-
@units = units
|
10
|
-
end
|
11
|
-
|
12
|
-
def self.average(measurements)
|
13
|
-
total(measurements).to_f / measurements.size
|
14
|
-
end
|
15
|
-
|
16
|
-
def self.total(measurements)
|
17
|
-
measurements.inject(0) { |sum, m| sum + m.value }
|
18
|
-
end
|
19
|
-
|
20
|
-
def self.of_time_taken(category)
|
21
|
-
start = Time.now
|
22
|
-
yield
|
23
|
-
Measurement.new category, Time.now - start, "seconds"
|
24
|
-
end
|
25
|
-
|
26
|
-
def self.send_home(category, wire, options)
|
27
|
-
result = nil
|
28
|
-
measurement = of_time_taken(category) { result = yield }
|
29
|
-
if options.gathering_metrics?
|
30
|
-
begin
|
31
|
-
wire.send_message measurement
|
32
|
-
rescue Telegraph::LineDead
|
33
|
-
end
|
34
|
-
end
|
35
|
-
result
|
36
|
-
end
|
37
|
-
end
|
38
|
-
end
|
39
|
-
end
|
data/lib/deep_test/proxy_io.rb
DELETED
@@ -1,77 +0,0 @@
|
|
1
|
-
module DeepTest
|
2
|
-
class ProxyIO < StringIO
|
3
|
-
def initialize(output_module, wire)
|
4
|
-
@output_module = output_module
|
5
|
-
@wire = wire
|
6
|
-
super("")
|
7
|
-
end
|
8
|
-
|
9
|
-
def write(*args)
|
10
|
-
super
|
11
|
-
@wire.send_message @output_module::Output.new(string)
|
12
|
-
self.string = ""
|
13
|
-
end
|
14
|
-
|
15
|
-
def flush
|
16
|
-
@wire.send_message @output_module::Flush.new
|
17
|
-
end
|
18
|
-
|
19
|
-
def self.replace_stdout_stderr!(wire)
|
20
|
-
old_stdout_const, old_stdout_global = STDOUT, $stdout
|
21
|
-
old_stderr_const, old_stderr_global = STDERR, $stderr
|
22
|
-
|
23
|
-
supress_warnings { Object.const_set :STDOUT, ProxyIO.new(Stdout, wire) }
|
24
|
-
$stdout = STDOUT
|
25
|
-
|
26
|
-
supress_warnings { Object.const_set :STDERR, ProxyIO.new(Stderr, wire) }
|
27
|
-
$stderr = STDERR
|
28
|
-
|
29
|
-
DeepTest.logger = nil
|
30
|
-
|
31
|
-
yield
|
32
|
-
ensure
|
33
|
-
$stdout = old_stdout_global
|
34
|
-
supress_warnings { Object.const_set :STDOUT, old_stdout_const }
|
35
|
-
|
36
|
-
$stderr = old_stderr_global
|
37
|
-
supress_warnings { Object.const_set :STDERR, old_stderr_const }
|
38
|
-
end
|
39
|
-
|
40
|
-
def self.supress_warnings
|
41
|
-
old_verbose, $VERBOSE = $VERBOSE, nil
|
42
|
-
yield
|
43
|
-
ensure
|
44
|
-
$VERBOSE = old_verbose
|
45
|
-
end
|
46
|
-
|
47
|
-
class AbstractOutput
|
48
|
-
include CentralCommand::Operation
|
49
|
-
attr_reader :s
|
50
|
-
def initialize(s); @s = s; end
|
51
|
-
def execute; stream.write s; end
|
52
|
-
def ==(other); self.class == other.class && s == other.s; end
|
53
|
-
end
|
54
|
-
|
55
|
-
module Stdout
|
56
|
-
class Output < AbstractOutput
|
57
|
-
def stream; $stdout; end
|
58
|
-
end
|
59
|
-
|
60
|
-
class Flush
|
61
|
-
include CentralCommand::Operation
|
62
|
-
def execute; $stdout.flush; end
|
63
|
-
end
|
64
|
-
end
|
65
|
-
|
66
|
-
module Stderr
|
67
|
-
class Output < AbstractOutput
|
68
|
-
def stream; $stderr; end
|
69
|
-
end
|
70
|
-
|
71
|
-
class Flush
|
72
|
-
include CentralCommand::Operation
|
73
|
-
def execute; $stderr.flush; end
|
74
|
-
end
|
75
|
-
end
|
76
|
-
end
|
77
|
-
end
|