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
data/lib/deep_test/server.rb
DELETED
@@ -1,75 +0,0 @@
|
|
1
|
-
module DeepTest
|
2
|
-
class Server
|
3
|
-
def self.start(options)
|
4
|
-
server = new(options)
|
5
|
-
DRb.start_service("druby://0.0.0.0:#{options.server_port}", server)
|
6
|
-
DeepTest.logger.info "Started DeepTest service at #{DRb.uri}"
|
7
|
-
server
|
8
|
-
end
|
9
|
-
|
10
|
-
def self.stop
|
11
|
-
DRb.stop_service
|
12
|
-
end
|
13
|
-
|
14
|
-
def self.remote_reference(address, port)
|
15
|
-
DRb.start_service
|
16
|
-
blackboard = DRbObject.new_with_uri("druby://#{address}:#{port}")
|
17
|
-
DeepTest.logger.debug "Connecting to DeepTest server at #{blackboard.__drburi}"
|
18
|
-
blackboard
|
19
|
-
end
|
20
|
-
|
21
|
-
def initialize(options)
|
22
|
-
@options = options
|
23
|
-
@work_queue = Queue.new
|
24
|
-
@result_queue = Queue.new
|
25
|
-
|
26
|
-
if Metrics::Gatherer.enabled?
|
27
|
-
require File.dirname(__FILE__) + "/metrics/queue_lock_wait_time_measurement"
|
28
|
-
@work_queue.extend Metrics::QueueLockWaitTimeMeasurement
|
29
|
-
@result_queue.extend Metrics::QueueLockWaitTimeMeasurement
|
30
|
-
Metrics::Gatherer.section("server queue lock wait times") do |s|
|
31
|
-
s.measurement("work queue total pop wait time", @work_queue.total_pop_time)
|
32
|
-
s.measurement("work queue total push wait time", @work_queue.total_push_time)
|
33
|
-
s.measurement("result queue total pop wait time", @result_queue.total_pop_time)
|
34
|
-
s.measurement("result queue total push wait time", @result_queue.total_push_time)
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
def done_with_work
|
40
|
-
@done_with_work = true
|
41
|
-
end
|
42
|
-
|
43
|
-
def take_result
|
44
|
-
Timeout.timeout(@options.timeout_in_seconds, ResultOverdueError) do
|
45
|
-
@result_queue.pop
|
46
|
-
end
|
47
|
-
end
|
48
|
-
|
49
|
-
def take_work
|
50
|
-
raise NoWorkUnitsRemainingError if @done_with_work
|
51
|
-
|
52
|
-
@work_queue.pop(true)
|
53
|
-
rescue ThreadError => e
|
54
|
-
if e.message == "queue empty"
|
55
|
-
raise NoWorkUnitsAvailableError
|
56
|
-
else
|
57
|
-
raise
|
58
|
-
end
|
59
|
-
end
|
60
|
-
|
61
|
-
def write_result(result)
|
62
|
-
@result_queue.push result
|
63
|
-
nil
|
64
|
-
end
|
65
|
-
|
66
|
-
def write_work(work_unit)
|
67
|
-
@work_queue.push work_unit
|
68
|
-
nil
|
69
|
-
end
|
70
|
-
|
71
|
-
class NoWorkUnitsAvailableError < StandardError; end
|
72
|
-
class NoWorkUnitsRemainingError < StandardError; end
|
73
|
-
class ResultOverdueError < StandardError; end
|
74
|
-
end
|
75
|
-
end
|
@@ -1,29 +0,0 @@
|
|
1
|
-
require 'spec/runner/reporter'
|
2
|
-
module Spec
|
3
|
-
module Runner
|
4
|
-
class Reporter
|
5
|
-
def example_finished(example, error=nil)
|
6
|
-
@examples << example
|
7
|
-
|
8
|
-
if error.nil?
|
9
|
-
example_passed(example)
|
10
|
-
elsif Spec::Example::ExamplePendingError === error
|
11
|
-
example_pending(example, error.message)
|
12
|
-
else
|
13
|
-
example_failed(example, error)
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
|
-
def failure(example, error)
|
18
|
-
backtrace_tweaker.tweak_backtrace(error)
|
19
|
-
example_name = "#{example.class.description} #{example.description}"
|
20
|
-
failure = Failure.new(example, error)
|
21
|
-
@failures << failure
|
22
|
-
formatters.each do |f|
|
23
|
-
f.example_failed(example, @failures.length, failure)
|
24
|
-
end
|
25
|
-
end
|
26
|
-
alias_method :example_failed, :failure
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
data/lib/deep_test/worker.rb
DELETED
@@ -1,57 +0,0 @@
|
|
1
|
-
module DeepTest
|
2
|
-
class Worker
|
3
|
-
attr_reader :number
|
4
|
-
|
5
|
-
def initialize(number, blackboard, worker_listener)
|
6
|
-
@number = number
|
7
|
-
@blackboard = blackboard
|
8
|
-
@listener = worker_listener
|
9
|
-
end
|
10
|
-
|
11
|
-
def run
|
12
|
-
@listener.starting(self)
|
13
|
-
while work_unit = next_work_unit
|
14
|
-
@listener.starting_work(self, work_unit)
|
15
|
-
|
16
|
-
result = begin
|
17
|
-
work_unit.run
|
18
|
-
rescue Exception => error
|
19
|
-
Error.new(work_unit, error)
|
20
|
-
end
|
21
|
-
|
22
|
-
@listener.finished_work(self, work_unit, result)
|
23
|
-
@blackboard.write_result result
|
24
|
-
if ENV['DEEP_TEST_SHOW_WORKER_DOTS'] == 'yes'
|
25
|
-
$stdout.print '.'
|
26
|
-
$stdout.flush
|
27
|
-
end
|
28
|
-
end
|
29
|
-
rescue Server::NoWorkUnitsRemainingError
|
30
|
-
DeepTest.logger.debug("Worker #{number}: no more work to do")
|
31
|
-
end
|
32
|
-
|
33
|
-
def next_work_unit
|
34
|
-
@blackboard.take_work
|
35
|
-
rescue Server::NoWorkUnitsAvailableError
|
36
|
-
sleep 0.02
|
37
|
-
retry
|
38
|
-
end
|
39
|
-
|
40
|
-
class Error
|
41
|
-
attr_accessor :work_unit, :error
|
42
|
-
|
43
|
-
def initialize(work_unit, error)
|
44
|
-
@work_unit, @error = work_unit, error
|
45
|
-
end
|
46
|
-
|
47
|
-
def ==(other)
|
48
|
-
work_unit == other.work_unit &&
|
49
|
-
error == other.error
|
50
|
-
end
|
51
|
-
|
52
|
-
def to_s
|
53
|
-
"#{@work_unit}: #{@error}\n" + (@error.backtrace || []).join("\n")
|
54
|
-
end
|
55
|
-
end
|
56
|
-
end
|
57
|
-
end
|
@@ -1,7 +0,0 @@
|
|
1
|
-
require File.dirname(__FILE__) + "/../../lib/deep_test"
|
2
|
-
options = DeepTest::Options.from_command_line(ARGV[0])
|
3
|
-
DeepTest.init(options)
|
4
|
-
runner = DeepTest::Test::Runner.new(options)
|
5
|
-
workers = options.new_workers
|
6
|
-
workers.load_files Dir.glob(options.pattern)
|
7
|
-
DeepTest::ProcessOrchestrator.run(options, workers, runner)
|
@@ -1,24 +0,0 @@
|
|
1
|
-
require File.dirname(__FILE__) + "/../../lib/deep_test"
|
2
|
-
require 'drb/drb'
|
3
|
-
require 'optparse'
|
4
|
-
|
5
|
-
uri = "drubyall://:4021"
|
6
|
-
slave_uris = OptionParser.new do |opts|
|
7
|
-
opts.banner = "Usage: deep_test master_test_server [options] <test_server_uris>"
|
8
|
-
|
9
|
-
opts.on("--uri URI", "DRb URI to bind server to") do |v|
|
10
|
-
uri = v
|
11
|
-
end
|
12
|
-
|
13
|
-
opts.on_tail("-h", "--help", "Show this message") do
|
14
|
-
puts opts
|
15
|
-
exit
|
16
|
-
end
|
17
|
-
end.parse(ARGV)
|
18
|
-
|
19
|
-
begin
|
20
|
-
DeepTest::Distributed::MasterTestServer.start(uri, slave_uris)
|
21
|
-
rescue Interrupt
|
22
|
-
DeepTest.logger.info "Exiting due to Interrupt"
|
23
|
-
end
|
24
|
-
|
@@ -1,18 +0,0 @@
|
|
1
|
-
require File.dirname(__FILE__) + "/../../lib/deep_test"
|
2
|
-
require 'drb/drb'
|
3
|
-
require 'optparse'
|
4
|
-
|
5
|
-
config = DeepTest::Distributed::TestServer.parse_args(ARGV)
|
6
|
-
|
7
|
-
#
|
8
|
-
# Clear args so they won't be processed in any forked processes.
|
9
|
-
# - When specs are loaded by the RemoteWorkerServer, RSpec
|
10
|
-
# attempts to parse ARGV
|
11
|
-
#
|
12
|
-
ARGV.clear
|
13
|
-
|
14
|
-
begin
|
15
|
-
DeepTest::Distributed::TestServer.start(config)
|
16
|
-
rescue Interrupt
|
17
|
-
DeepTest.logger.info "Exiting due to Interrupt"
|
18
|
-
end
|
@@ -1,29 +0,0 @@
|
|
1
|
-
require File.dirname(__FILE__) + '/../../lib/deep_test'
|
2
|
-
|
3
|
-
unless ARGV.length == 2
|
4
|
-
puts "Usage: deep_test test_throughput <server uri> <test_count>"
|
5
|
-
exit(1)
|
6
|
-
end
|
7
|
-
|
8
|
-
uri = ARGV[0]
|
9
|
-
test_count = ARGV[1].to_i
|
10
|
-
|
11
|
-
options = DeepTest::Options.new(:distributed_server => uri,
|
12
|
-
:sync_options => {:source => ""})
|
13
|
-
server = DeepTest::Distributed::TestServer.connect options
|
14
|
-
workers = DeepTest::Distributed::ThroughputWorkerClient.new(options, server)
|
15
|
-
runner = DeepTest::Distributed::ThroughputRunner.new(options, test_count) do |result|
|
16
|
-
$stdout.print "."
|
17
|
-
$stdout.flush
|
18
|
-
end
|
19
|
-
|
20
|
-
start_time = Time.now
|
21
|
-
DeepTest::ProcessOrchestrator.new(options, workers, runner).run(false)
|
22
|
-
end_time = Time.now
|
23
|
-
|
24
|
-
puts
|
25
|
-
puts runner.statistics.summary
|
26
|
-
|
27
|
-
run_time = end_time.to_f - start_time.to_f
|
28
|
-
puts "Total Run Time: #{run_time} seconds"
|
29
|
-
puts "Run Time Not Spent On Tests: #{run_time - runner.statistics.timespan_in_seconds}"
|
@@ -1,33 +0,0 @@
|
|
1
|
-
require File.dirname(__FILE__) + "/../spec_helper"
|
2
|
-
|
3
|
-
module DeepTest
|
4
|
-
describe Option do
|
5
|
-
it "should have hash conversion" do
|
6
|
-
option = Option.new(:name, Option::Hash, {})
|
7
|
-
string = option.to_command_line({:a => "1", :b => "a"})
|
8
|
-
string.should be_instance_of(String)
|
9
|
-
option.from_command_line(string).should == {:a => "1", :b => "a"}
|
10
|
-
end
|
11
|
-
|
12
|
-
it "should support booleans in hash" do
|
13
|
-
option = Option.new(:name, Option::Hash, {})
|
14
|
-
string = option.to_command_line({:a => true})
|
15
|
-
string.should be_instance_of(String)
|
16
|
-
option.from_command_line(string).should == {:a => true}
|
17
|
-
end
|
18
|
-
|
19
|
-
it "should handle hash values with spaces" do
|
20
|
-
option = Option.new(:name, Option::Hash, {})
|
21
|
-
|
22
|
-
string = option.to_command_line(
|
23
|
-
{:a => "has a space", :b => "has more spaces"}
|
24
|
-
)
|
25
|
-
|
26
|
-
string.should be_instance_of(String)
|
27
|
-
|
28
|
-
option.from_command_line(string).should ==
|
29
|
-
{:a => "has a space", :b => "has more spaces"}
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
data/spec/thread_worker.rb
DELETED
@@ -1,25 +0,0 @@
|
|
1
|
-
class ThreadWorker
|
2
|
-
attr_reader :work_done
|
3
|
-
|
4
|
-
def initialize(blackboard, expected_work)
|
5
|
-
@blackboard, @expected_work = blackboard, expected_work
|
6
|
-
@thread = Thread.new {run}
|
7
|
-
end
|
8
|
-
|
9
|
-
def wait_until_done
|
10
|
-
Timeout.timeout(5) {@thread.join}
|
11
|
-
@thread.kill if @thread.alive?
|
12
|
-
end
|
13
|
-
|
14
|
-
def run
|
15
|
-
@work_done = 0
|
16
|
-
until @work_done >= @expected_work
|
17
|
-
Thread.pass
|
18
|
-
work = @blackboard.take_work
|
19
|
-
if work
|
20
|
-
@blackboard.write_result work.run
|
21
|
-
@work_done += 1
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
@@ -1,42 +0,0 @@
|
|
1
|
-
require File.dirname(__FILE__) + "/../../test_helper"
|
2
|
-
|
3
|
-
unit_tests do
|
4
|
-
test "returns ipaddress from peeraddr as address" do
|
5
|
-
info = Thread.current['DRb']
|
6
|
-
begin
|
7
|
-
Thread.current['DRb'] = {
|
8
|
-
'client' => mock(:peeraddr => [nil, nil, nil, "ip"])
|
9
|
-
}
|
10
|
-
|
11
|
-
info = DeepTest::Distributed::DRbClientConnectionInfo.new
|
12
|
-
ensure
|
13
|
-
Thread.current['DRb'] = info
|
14
|
-
end
|
15
|
-
|
16
|
-
assert_equal "ip", info.address
|
17
|
-
end
|
18
|
-
|
19
|
-
test "raises an error if no drb client is found" do
|
20
|
-
info = Thread.current['DRb']
|
21
|
-
begin
|
22
|
-
Thread.current['DRb'] = {}
|
23
|
-
assert_raises(RuntimeError) do
|
24
|
-
DeepTest::Distributed::DRbClientConnectionInfo.new
|
25
|
-
end
|
26
|
-
ensure
|
27
|
-
Thread.current['DRb'] = info
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
test "raises an error if no drb info is found" do
|
32
|
-
info = Thread.current['DRb']
|
33
|
-
begin
|
34
|
-
Thread.current['DRb'] = nil
|
35
|
-
assert_raises(RuntimeError) do
|
36
|
-
DeepTest::Distributed::DRbClientConnectionInfo.new
|
37
|
-
end
|
38
|
-
ensure
|
39
|
-
Thread.current['DRb'] = info
|
40
|
-
end
|
41
|
-
end
|
42
|
-
end
|
@@ -1,32 +0,0 @@
|
|
1
|
-
require File.dirname(__FILE__) + "/../../test_helper"
|
2
|
-
|
3
|
-
unit_tests do
|
4
|
-
test "show_status renders status of all servers as html" do
|
5
|
-
status = DeepTest::Distributed::TestServerStatus.new(
|
6
|
-
"binding_uri",
|
7
|
-
5,
|
8
|
-
3
|
9
|
-
)
|
10
|
-
|
11
|
-
test_server = mock(:__drburi => "drburi_1", :status => status)
|
12
|
-
server = DeepTest::Distributed::MasterTestServer.new([test_server])
|
13
|
-
res = WEBrick::HTTPResponse.new(WEBrick::Config::HTTP)
|
14
|
-
server.show_status(:req, res)
|
15
|
-
|
16
|
-
assert_match "<td>binding_uri</td>", res.body
|
17
|
-
assert_match "<td>5</td>", res.body
|
18
|
-
assert_match "<td>3</td>", res.body
|
19
|
-
end
|
20
|
-
|
21
|
-
test "show_status display error message if exception occurs" do
|
22
|
-
test_server = mock(:__drburi => "drburi_1")
|
23
|
-
test_server.expects(:status).raises("An Error")
|
24
|
-
|
25
|
-
server = DeepTest::Distributed::MasterTestServer.new([test_server])
|
26
|
-
|
27
|
-
res = WEBrick::HTTPResponse.new(WEBrick::Config::HTTP)
|
28
|
-
server.show_status(:req, res)
|
29
|
-
|
30
|
-
assert_match /<td.*?>An Error<\/td>/, res.body
|
31
|
-
end
|
32
|
-
end
|
@@ -1,96 +0,0 @@
|
|
1
|
-
require File.dirname(__FILE__) + "/../../test_helper"
|
2
|
-
|
3
|
-
unit_tests do
|
4
|
-
test "sync is invoked on all servers" do
|
5
|
-
server_1, server_2 = mock, mock
|
6
|
-
options = DeepTest::Options.new({:ui => "DeepTest::UI::Null"})
|
7
|
-
|
8
|
-
master = DeepTest::Distributed::MultiTestServerProxy.new(options, [server_1, server_2])
|
9
|
-
|
10
|
-
server_1.expects(:sync).with(options)
|
11
|
-
server_2.expects(:sync).with(options)
|
12
|
-
|
13
|
-
master.sync(options)
|
14
|
-
end
|
15
|
-
|
16
|
-
test "spawn_worker_server is invoked on all server" do
|
17
|
-
server_1, server_2 = mock, mock
|
18
|
-
options = DeepTest::Options.new({:ui => "DeepTest::UI::Null"})
|
19
|
-
|
20
|
-
master = DeepTest::Distributed::MultiTestServerProxy.new(options, [server_1, server_2])
|
21
|
-
|
22
|
-
server_1.expects(:spawn_worker_server).with(options)
|
23
|
-
server_2.expects(:spawn_worker_server).with(options)
|
24
|
-
|
25
|
-
master.spawn_worker_server(options)
|
26
|
-
end
|
27
|
-
|
28
|
-
test "spawn_worker_server returns WorkerServerProxy with each worker" do
|
29
|
-
server_1 = mock(:spawn_worker_server => :worker_server_1)
|
30
|
-
server_2 = mock(:spawn_worker_server => :worker_server_2)
|
31
|
-
options = DeepTest::Options.new({:ui => "DeepTest::UI::Null"})
|
32
|
-
|
33
|
-
master = DeepTest::Distributed::MultiTestServerProxy.new(options, [server_1, server_2])
|
34
|
-
|
35
|
-
DeepTest::Distributed::MultiTestServerProxy::WorkerServerProxy.
|
36
|
-
expects(:new).with(options, [:worker_server_1, :worker_server_2])
|
37
|
-
|
38
|
-
master.spawn_worker_server(options)
|
39
|
-
end
|
40
|
-
|
41
|
-
test "WorkerServerProxy dispatches start_all" do
|
42
|
-
server_1, server_2 = mock, mock
|
43
|
-
|
44
|
-
master = DeepTest::Distributed::MultiTestServerProxy::WorkerServerProxy.new(
|
45
|
-
DeepTest::Options.new({:ui => "DeepTest::UI::Null"}),
|
46
|
-
[server_1, server_2]
|
47
|
-
)
|
48
|
-
|
49
|
-
server_1.expects(:start_all)
|
50
|
-
server_2.expects(:start_all)
|
51
|
-
|
52
|
-
master.start_all
|
53
|
-
end
|
54
|
-
|
55
|
-
test "WorkerServerProxy dispatches stop_all" do
|
56
|
-
server_1, server_2 = mock, mock
|
57
|
-
|
58
|
-
master = DeepTest::Distributed::MultiTestServerProxy::WorkerServerProxy.new(
|
59
|
-
DeepTest::Options.new({:ui => "DeepTest::UI::Null"}),
|
60
|
-
[server_1, server_2]
|
61
|
-
)
|
62
|
-
|
63
|
-
server_1.expects(:stop_all)
|
64
|
-
server_2.expects(:stop_all)
|
65
|
-
|
66
|
-
master.stop_all
|
67
|
-
end
|
68
|
-
|
69
|
-
test "WorkerServerProxy stop_all ignores connection errors" do
|
70
|
-
server_1 = mock
|
71
|
-
|
72
|
-
master = DeepTest::Distributed::MultiTestServerProxy::WorkerServerProxy.new(
|
73
|
-
DeepTest::Options.new({:ui => "DeepTest::UI::Null"}),
|
74
|
-
[server_1]
|
75
|
-
)
|
76
|
-
|
77
|
-
server_1.expects(:__drburi).never
|
78
|
-
server_1.expects(:stop_all).raises(DRb::DRbConnError)
|
79
|
-
|
80
|
-
master.stop_all
|
81
|
-
end
|
82
|
-
|
83
|
-
test "WorkerServerProxy dispatches load_files" do
|
84
|
-
server_1, server_2 = mock, mock
|
85
|
-
|
86
|
-
master = DeepTest::Distributed::MultiTestServerProxy::WorkerServerProxy.new(
|
87
|
-
DeepTest::Options.new({:ui => "DeepTest::UI::Null"}),
|
88
|
-
[server_1, server_2]
|
89
|
-
)
|
90
|
-
|
91
|
-
server_1.expects(:load_files).with(:filelist)
|
92
|
-
server_2.expects(:load_files).with(:filelist)
|
93
|
-
|
94
|
-
master.load_files :filelist
|
95
|
-
end
|
96
|
-
end
|