jstorimer-deep-test 1.4.0 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +1 -0
- data/README.rdoc +41 -70
- data/Rakefile +47 -119
- data/TODO +2 -2
- data/VERSION +1 -1
- data/infrastructure/dynamic_teardown.rb +22 -0
- data/{test → infrastructure}/fake_deadlock_error.rb +0 -0
- data/infrastructure/load.rb +11 -0
- data/infrastructure/test_central_command.rb +15 -0
- data/infrastructure/test_exception.rb +7 -0
- data/{test → infrastructure}/test_factory.rb +0 -0
- data/infrastructure/test_logger.rb +11 -0
- data/infrastructure/test_operator.rb +15 -0
- data/infrastructure/test_result.rb +15 -0
- data/infrastructure/thread_agent.rb +21 -0
- data/infrastructure/timewarp/Rakefile +14 -0
- data/infrastructure/timewarp/lib/timewarp.rb +21 -0
- data/infrastructure/timewarp/test/timewarp_test.rb +45 -0
- data/lib/deep_test.rb +28 -40
- data/lib/deep_test/agent.rb +108 -0
- data/lib/deep_test/central_command.rb +165 -0
- data/lib/deep_test/cpu_info.rb +22 -0
- data/lib/deep_test/database/mysql_setup_listener.rb +11 -12
- data/lib/deep_test/database/setup_listener.rb +23 -23
- data/lib/deep_test/demon.rb +25 -0
- data/lib/deep_test/distributed/beachhead.rb +104 -0
- data/lib/deep_test/distributed/dispatch_controller.rb +17 -10
- data/lib/deep_test/distributed/establish_beachhead.rb +19 -0
- data/lib/deep_test/distributed/landing_fleet.rb +30 -0
- data/lib/deep_test/distributed/landing_ship.rb +60 -0
- data/lib/deep_test/distributed/remote_deployment.rb +56 -0
- data/lib/deep_test/distributed/rsync.rb +25 -12
- data/lib/deep_test/distributed/shell_environment.rb +50 -0
- data/lib/deep_test/distributed/ssh_client_connection_info.rb +14 -0
- data/lib/deep_test/failure_message.rb +19 -0
- data/lib/deep_test/lib_root.rb +4 -0
- data/lib/deep_test/listener_list.rb +1 -1
- data/lib/deep_test/local_deployment.rb +46 -0
- data/lib/deep_test/logger.rb +17 -2
- data/lib/deep_test/main.rb +41 -0
- data/lib/deep_test/marshallable_exception_wrapper.rb +4 -4
- data/lib/deep_test/metrics/data.rb +34 -0
- data/lib/deep_test/metrics/measurement.rb +39 -0
- data/lib/deep_test/{null_worker_listener.rb → null_listener.rb} +14 -14
- data/lib/deep_test/options.rb +41 -56
- data/lib/deep_test/proxy_io.rb +77 -0
- data/lib/deep_test/rake_tasks.rb +3 -1
- data/lib/deep_test/result_reader.rb +10 -6
- data/lib/deep_test/rspec_detector.rb +1 -1
- data/lib/deep_test/spec.rb +5 -1
- data/lib/deep_test/spec/extensions/example_methods.rb +7 -1
- data/lib/deep_test/spec/extensions/spec_task.rb +3 -2
- data/lib/deep_test/spec/runner.rb +32 -17
- data/lib/deep_test/spec/work_result.rb +2 -0
- data/lib/deep_test/test/run_test_suite.rb +5 -0
- data/lib/deep_test/test/runner.rb +2 -2
- data/lib/deep_test/test/supervised_test_suite.rb +9 -10
- data/lib/deep_test/test/work_result.rb +1 -0
- data/lib/deep_test/test_task.rb +1 -1
- data/lib/deep_test/ui/console.rb +9 -11
- data/lib/deep_test/warlock.rb +37 -25
- data/lib/telegraph.rb +29 -0
- data/lib/telegraph/ack_sequence.rb +14 -0
- data/lib/telegraph/logging.rb +20 -0
- data/lib/telegraph/message.rb +39 -0
- data/lib/telegraph/operator.rb +47 -0
- data/lib/telegraph/switchboard.rb +57 -0
- data/lib/telegraph/wire.rb +73 -0
- data/negative_acceptance_tests/dying_spec.rb +13 -0
- data/negative_acceptance_tests/dying_test.rb +13 -0
- data/negative_acceptance_tests/failing_spec.rb +9 -0
- data/{test/failing.rb → negative_acceptance_tests/failing_test.rb} +3 -1
- data/negative_acceptance_tests/kill_agent_one_on_start_work.rb +16 -0
- data/negative_acceptance_tests/passing_spec.rb +10 -0
- data/negative_acceptance_tests/passing_test.rb +12 -0
- data/negative_acceptance_tests/tasks.rake +87 -0
- data/negative_acceptance_tests/tests.rb +60 -0
- data/sample_rails_project/deep_test.rb +4 -0
- data/sample_rails_project/lib/{foreign_host_worker_simulation_listener.rb → foreign_host_agent_simulation_listener.rb} +6 -4
- data/sample_rails_project/lib/tasks/deep_test.rake +13 -4
- data/spec/deep_test/options_spec.rb +80 -59
- data/spec/deep_test/spec/extensions/example_methods_spec.rb +5 -4
- data/spec/deep_test/spec/extensions/spec_task_spec.rb +4 -6
- data/spec/deep_test/spec/runner_spec.rb +59 -32
- data/spec/spec_helper.rb +14 -6
- data/test/deep_test/agent_test.rb +175 -0
- data/test/deep_test/central_command_test.rb +147 -0
- data/test/deep_test/cpu_info_test.rb +33 -0
- data/test/deep_test/database/mysql_setup_listener_test.rb +13 -9
- data/test/deep_test/demon_test.rb +23 -0
- data/test/deep_test/distributed/beachhead_test.rb +67 -0
- data/test/deep_test/distributed/dispatch_controller_test.rb +130 -177
- data/test/deep_test/distributed/filename_resolver_test.rb +38 -34
- data/test/deep_test/distributed/landing_fleet_test.rb +55 -0
- data/test/deep_test/distributed/landing_ship_test.rb +48 -0
- data/test/deep_test/distributed/remote_deployment_test.rb +134 -0
- data/test/deep_test/distributed/rsync_test.rb +42 -62
- data/test/deep_test/distributed/shell_environment_fixtures/set_bar_to_foo +1 -0
- data/test/deep_test/distributed/shell_environment_fixtures/set_foo_to_bar +1 -0
- data/test/deep_test/distributed/shell_environment_fixtures/set_foo_to_baz +1 -0
- data/test/deep_test/distributed/shell_environment_test.rb +108 -0
- data/test/deep_test/distributed/ssh_client_connection_info_test.rb +34 -0
- data/test/deep_test/listener_list_test.rb +17 -15
- data/test/deep_test/local_deployment_test.rb +19 -0
- data/test/deep_test/logger_test.rb +34 -7
- data/test/deep_test/main_test.rb +12 -0
- data/test/deep_test/marshallable_exception_wrapper_test.rb +31 -29
- data/test/deep_test/metrics/data_test.rb +22 -0
- data/test/deep_test/metrics/measurement_test.rb +18 -0
- data/test/deep_test/proxy_io_test.rb +104 -0
- data/test/deep_test/result_reader_test.rb +95 -95
- data/test/deep_test/test/extensions/error_test.rb +38 -36
- data/test/deep_test/test/runner_test.rb +7 -3
- data/test/deep_test/test/supervised_test_suite_test.rb +89 -61
- data/test/deep_test/test/work_result_test.rb +80 -76
- data/test/deep_test/test/work_unit_test.rb +53 -51
- data/test/deep_test/test_task_test.rb +10 -38
- data/test/deep_test/ui/console_test.rb +8 -4
- data/test/deep_test/warlock_test.rb +33 -31
- data/test/test_helper.rb +20 -5
- data/test/test_task_test.rb +60 -57
- metadata +94 -84
- data/bin/deep_test +0 -15
- data/jstorimer-deep-test-0.1.0.gem +0 -0
- data/jstorimer-deep-test.gemspec +0 -1425
- data/lib/deep_test/distributed/drb_client_connection_info.rb +0 -15
- data/lib/deep_test/distributed/master_test_server.rb +0 -52
- data/lib/deep_test/distributed/multi_test_server_proxy.rb +0 -44
- data/lib/deep_test/distributed/null_work_unit.rb +0 -12
- data/lib/deep_test/distributed/remote_worker_client.rb +0 -54
- data/lib/deep_test/distributed/remote_worker_server.rb +0 -82
- data/lib/deep_test/distributed/show_status.rhtml +0 -41
- data/lib/deep_test/distributed/test_server.rb +0 -78
- data/lib/deep_test/distributed/test_server_status.rb +0 -9
- data/lib/deep_test/distributed/test_server_workers.rb +0 -24
- data/lib/deep_test/distributed/throughput_runner.rb +0 -42
- data/lib/deep_test/distributed/throughput_statistics.rb +0 -26
- data/lib/deep_test/distributed/throughput_worker_client.rb +0 -19
- data/lib/deep_test/extensions/drb_extension.rb +0 -34
- data/lib/deep_test/local_workers.rb +0 -55
- data/lib/deep_test/metrics/gatherer.rb +0 -67
- data/lib/deep_test/metrics/queue_lock_wait_time_measurement.rb +0 -133
- data/lib/deep_test/option.rb +0 -60
- data/lib/deep_test/process_orchestrator.rb +0 -49
- data/lib/deep_test/server.rb +0 -75
- data/lib/deep_test/spec/extensions/reporter.rb +0 -29
- data/lib/deep_test/worker.rb +0 -57
- data/script/internal/run_test_suite.rb +0 -7
- data/script/public/master_test_server.rb +0 -24
- data/script/public/test_server.rb +0 -18
- data/script/public/test_throughput.rb +0 -29
- data/spec/deep_test/option_spec.rb +0 -33
- data/spec/thread_worker.rb +0 -25
- data/test/deep_test/distributed/drb_client_connection_info_test.rb +0 -42
- data/test/deep_test/distributed/master_test_server_test.rb +0 -32
- data/test/deep_test/distributed/multi_test_server_proxy_test.rb +0 -96
- data/test/deep_test/distributed/remote_worker_client_test.rb +0 -180
- data/test/deep_test/distributed/remote_worker_server_test.rb +0 -99
- data/test/deep_test/distributed/test_server_test.rb +0 -94
- data/test/deep_test/distributed/test_server_workers_test.rb +0 -26
- data/test/deep_test/distributed/throughput_runner_test.rb +0 -68
- data/test/deep_test/distributed/throughput_worker_client_test.rb +0 -28
- data/test/deep_test/local_workers_test.rb +0 -22
- data/test/deep_test/metrics/gatherer_test.rb +0 -66
- data/test/deep_test/process_orchestrator_test.rb +0 -11
- data/test/deep_test/server_test.rb +0 -58
- data/test/deep_test/worker_test.rb +0 -94
- data/test/failing.rake +0 -11
- data/test/simple_test_blackboard.rb +0 -45
- data/test/simple_test_blackboard_test.rb +0 -33
@@ -0,0 +1,41 @@
|
|
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
|
@@ -19,8 +19,8 @@ module DeepTest
|
|
19
19
|
klass = eval("::" + classname)
|
20
20
|
resolved_message = message
|
21
21
|
rescue => e
|
22
|
-
DeepTest.logger.debug
|
23
|
-
DeepTest.logger.debug
|
22
|
+
DeepTest.logger.debug { "Unable to load exception class: #{classname}: #{e.message}" }
|
23
|
+
DeepTest.logger.debug { e.backtrace.join("\n") }
|
24
24
|
|
25
25
|
klass = UnloadableException
|
26
26
|
resolved_message = "#{classname}: #{message}"
|
@@ -29,8 +29,8 @@ module DeepTest
|
|
29
29
|
begin
|
30
30
|
resolved_exception = klass.new resolved_message
|
31
31
|
rescue => e
|
32
|
-
DeepTest.logger.debug
|
33
|
-
DeepTest.logger.debug
|
32
|
+
DeepTest.logger.debug { "Unable to instantiation exception class: #{classname}: #{e.message}" }
|
33
|
+
DeepTest.logger.debug { e.backtrace.join("\n") }
|
34
34
|
|
35
35
|
resolved_exception = UnloadableException.new resolved_message
|
36
36
|
end
|
@@ -0,0 +1,34 @@
|
|
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
|
@@ -0,0 +1,39 @@
|
|
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
|
@@ -2,7 +2,7 @@ module DeepTest
|
|
2
2
|
#
|
3
3
|
# Listener that implements no-ops for all callbacks that DeepTest supports.
|
4
4
|
#
|
5
|
-
class
|
5
|
+
class NullListener
|
6
6
|
#
|
7
7
|
# Before DeepTest synchronizes any code during a distributed run,
|
8
8
|
# before_sync is called. If DeepTest is not running distributed,
|
@@ -12,51 +12,51 @@ module DeepTest
|
|
12
12
|
end
|
13
13
|
|
14
14
|
#
|
15
|
-
# Before DeepTest starts any
|
15
|
+
# Before DeepTest starts any agents, it instantiates a listener and
|
16
16
|
# invokes this method. No other callbacks are made to the listener
|
17
17
|
# instance receiving this message.
|
18
18
|
#
|
19
|
-
def
|
19
|
+
def before_starting_agents
|
20
20
|
end
|
21
21
|
|
22
22
|
#
|
23
|
-
# A separate listener instance is created in each
|
24
|
-
# notified that the
|
25
|
-
# provided for the listener to use. If you are using 3
|
23
|
+
# A separate listener instance is created in each agent process and
|
24
|
+
# notified that the agent is starting. The agent for the process is
|
25
|
+
# provided for the listener to use. If you are using 3 agents, this
|
26
26
|
# method is invoked 3 times on 3 distinct instances. These instances
|
27
27
|
# will also receive the starting_work and finished_work callbacks for
|
28
|
-
# the
|
28
|
+
# the agent provided.
|
29
29
|
#
|
30
|
-
def starting(
|
30
|
+
def starting(agent)
|
31
31
|
end
|
32
32
|
|
33
33
|
#
|
34
|
-
# Each time a
|
34
|
+
# Each time a agent takes a work unit, it calls this method before
|
35
35
|
# doing the work. In total, this method will be called as many times
|
36
36
|
# as there are work units. The listener instance that received the
|
37
|
-
# starting callback with the
|
37
|
+
# starting callback with the agent provided here is the same instance
|
38
38
|
# that receives this message.
|
39
39
|
#
|
40
40
|
# Because each work processes work units in a serial fashion, the
|
41
41
|
# listener will receive a finished_work message before another
|
42
42
|
# starting_work message.
|
43
43
|
#
|
44
|
-
def starting_work(
|
44
|
+
def starting_work(agent, work_unit)
|
45
45
|
end
|
46
46
|
|
47
47
|
#
|
48
|
-
# Each time a
|
48
|
+
# Each time a agent finishes computing a result for a work unit,
|
49
49
|
# it calls this method before sending that result back to the server.
|
50
50
|
# In total, this method will be called as many times
|
51
51
|
# as there are work units. The listener instance that received the
|
52
|
-
# starting callback with the
|
52
|
+
# starting callback with the agent provided here is the same instance
|
53
53
|
# that receives this message.
|
54
54
|
#
|
55
55
|
# Because each work processes work units in a serial fashion, the
|
56
56
|
# listener will receive a starting_work message before another
|
57
57
|
# finished_work message.
|
58
58
|
#
|
59
|
-
def finished_work(
|
59
|
+
def finished_work(agent, work_unit, result)
|
60
60
|
end
|
61
61
|
end
|
62
62
|
end
|
data/lib/deep_test/options.rb
CHANGED
@@ -1,23 +1,25 @@
|
|
1
1
|
module DeepTest
|
2
|
+
Option = Struct.new :name, :default unless defined?(Option)
|
3
|
+
|
2
4
|
class Options
|
3
5
|
unless defined?(VALID_OPTIONS)
|
4
6
|
VALID_OPTIONS = [
|
5
|
-
Option.new(:
|
6
|
-
Option.new(:
|
7
|
-
Option.new(:metrics_file,
|
8
|
-
Option.new(:pattern,
|
9
|
-
Option.new(:server_port,
|
10
|
-
Option.new(:sync_options,
|
11
|
-
Option.new(:
|
12
|
-
Option.new(:
|
13
|
-
Option.new(:worker_listener, Option::String, "DeepTest::NullWorkerListener"),
|
7
|
+
Option.new(:distributed_hosts, nil),
|
8
|
+
Option.new(:number_of_agents, nil),
|
9
|
+
Option.new(:metrics_file, nil),
|
10
|
+
Option.new(:pattern, nil),
|
11
|
+
Option.new(:server_port, nil),
|
12
|
+
Option.new(:sync_options, {}),
|
13
|
+
Option.new(:ui, "DeepTest::UI::Console"),
|
14
|
+
Option.new(:listener, "DeepTest::NullListener"),
|
14
15
|
]
|
15
16
|
end
|
16
17
|
|
17
18
|
attr_accessor *VALID_OPTIONS.map {|o| o.name}
|
18
|
-
|
19
|
+
attr_accessor :ssh_client_connection_info, :environment_log_level
|
20
|
+
|
19
21
|
def number_of_agents
|
20
|
-
|
22
|
+
return CpuInfo.new.count unless @number_of_agents
|
21
23
|
@number_of_agents
|
22
24
|
end
|
23
25
|
|
@@ -25,24 +27,22 @@ module DeepTest
|
|
25
27
|
@ui = value.to_s
|
26
28
|
end
|
27
29
|
|
28
|
-
def
|
29
|
-
@
|
30
|
+
def listener=(value)
|
31
|
+
@listener = value.to_s
|
30
32
|
end
|
31
33
|
|
32
34
|
def self.from_command_line(command_line)
|
33
|
-
|
34
|
-
|
35
|
-
hash[option.name] = option.from_command_line(command_line)
|
36
|
-
end
|
37
|
-
new(hash)
|
35
|
+
return new({}) if command_line.nil? || command_line.empty?
|
36
|
+
Marshal.load Base64.decode64(command_line)
|
38
37
|
end
|
39
38
|
|
40
39
|
def initialize(hash)
|
41
40
|
@origin_hostname = Socket.gethostname
|
42
41
|
check_option_keys(hash)
|
43
42
|
VALID_OPTIONS.each do |option|
|
44
|
-
send("#{option.name}=", hash[option.name] || option.default)
|
43
|
+
send("#{option.name}=", hash[option.name] || hash[option.name.to_s] || option.default)
|
45
44
|
end
|
45
|
+
self.environment_log_level = ENV['DEEP_TEST_LOG_LEVEL']
|
46
46
|
end
|
47
47
|
|
48
48
|
def gathering_metrics?
|
@@ -50,7 +50,7 @@ module DeepTest
|
|
50
50
|
end
|
51
51
|
|
52
52
|
def new_listener_list
|
53
|
-
listeners =
|
53
|
+
listeners = listener.split(',').map do |listener|
|
54
54
|
eval(listener).new
|
55
55
|
end
|
56
56
|
ListenerList.new(listeners)
|
@@ -60,9 +60,15 @@ module DeepTest
|
|
60
60
|
(Socket.gethostname == @origin_hostname) ? 'localhost' : @origin_hostname
|
61
61
|
end
|
62
62
|
|
63
|
+
def connect_to_central_command
|
64
|
+
address = ssh_client_connection_info ? ssh_client_connection_info.address : "localhost"
|
65
|
+
Telegraph::Wire.connect(address, server_port) do |wire|
|
66
|
+
yield wire
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
63
70
|
# Don't store UI instances in the options instance, which will
|
64
|
-
# need to be dumped over
|
65
|
-
# and we don't want to have to start yet another DRb Server
|
71
|
+
# need to be dumped over Telegraph since UI instances may not be dumpable.
|
66
72
|
#
|
67
73
|
UI_INSTANCES = {} unless defined?(UI_INSTANCES)
|
68
74
|
def ui_instance
|
@@ -70,56 +76,35 @@ module DeepTest
|
|
70
76
|
end
|
71
77
|
|
72
78
|
def to_command_line
|
73
|
-
|
74
|
-
VALID_OPTIONS.each do |option|
|
75
|
-
value = send(option.name)
|
76
|
-
command_line << option.to_command_line(value)
|
77
|
-
end
|
78
|
-
command_line.compact.join(' ')
|
79
|
+
Base64.encode64(Marshal.dump(self)).gsub("\n","")
|
79
80
|
end
|
80
81
|
|
81
|
-
def mirror_path
|
82
|
+
def mirror_path
|
82
83
|
raise "No source directory specified in sync_options" unless sync_options[:source]
|
83
|
-
relative_mirror_path = origin_hostname + sync_options[:source].gsub('/','_')
|
84
|
-
"#{
|
84
|
+
relative_mirror_path = @origin_hostname + sync_options[:source].gsub('/','_')
|
85
|
+
"#{sync_options[:remote_base_dir] || '/tmp'}/#{relative_mirror_path}"
|
85
86
|
end
|
86
87
|
|
87
|
-
def
|
88
|
-
if
|
89
|
-
|
88
|
+
def new_deployment
|
89
|
+
if distributed_hosts.nil?
|
90
|
+
LocalDeployment.new self
|
90
91
|
else
|
91
|
-
|
92
|
-
server = Distributed::TestServer.connect(self)
|
93
|
-
Distributed::RemoteWorkerClient.new(self, server, LocalWorkers.new(self))
|
94
|
-
rescue => e
|
95
|
-
ui_instance.distributed_failover_to_local("connect", e)
|
96
|
-
LocalWorkers.new self
|
97
|
-
end
|
92
|
+
Distributed::RemoteDeployment.new self, new_landing_fleet, LocalDeployment.new(self)
|
98
93
|
end
|
99
94
|
end
|
100
95
|
|
101
|
-
def
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
def cpu_count
|
106
|
-
case RUBY_PLATFORM
|
107
|
-
when /darwin/
|
108
|
-
output = `sysctl -n hw.ncpu`
|
109
|
-
output.strip.to_i
|
110
|
-
when /linux/
|
111
|
-
File.readlines("/proc/cpuinfo").inject(0) do |count, line|
|
112
|
-
next count + 1 if line =~ /processor\s*:\s*\d+/
|
113
|
-
count
|
114
|
-
end
|
96
|
+
def new_landing_fleet
|
97
|
+
landing_ships = distributed_hosts.map do |host|
|
98
|
+
Distributed::LandingShip.new :address => host
|
115
99
|
end
|
100
|
+
Distributed::LandingFleet.new self, landing_ships
|
116
101
|
end
|
117
102
|
|
118
103
|
protected
|
119
104
|
|
120
105
|
def check_option_keys(hash)
|
121
106
|
hash.keys.each do |key|
|
122
|
-
raise InvalidOptionError.new(key) unless VALID_OPTIONS.any? {|o| o.name == key.to_sym}
|
107
|
+
raise InvalidOptionError.new("#{key} is not a valid option") unless VALID_OPTIONS.any? {|o| o.name == key.to_sym}
|
123
108
|
end
|
124
109
|
end
|
125
110
|
|
@@ -0,0 +1,77 @@
|
|
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
|