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,56 +1,52 @@
|
|
1
1
|
require File.dirname(__FILE__) + "/../../test_helper"
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
test "should strip off directories until file exists in base path" do
|
7
|
-
resolver = FilenameResolver.new("base_path")
|
3
|
+
unit_tests do
|
4
|
+
test "should strip off directories until file exists in base path" do
|
5
|
+
resolver = DeepTest::Distributed::FilenameResolver.new("base_path")
|
8
6
|
|
9
|
-
|
10
|
-
|
11
|
-
|
7
|
+
File.expects(:exist?).with("base_path/a/b/c/d.rb").returns(false)
|
8
|
+
File.expects(:exist?).with("base_path/b/c/d.rb").returns(false)
|
9
|
+
File.expects(:exist?).with("base_path/c/d.rb").returns(true)
|
12
10
|
|
13
|
-
|
14
|
-
|
11
|
+
assert_equal "base_path/c/d.rb", resolver.resolve("/a/b/c/d.rb")
|
12
|
+
end
|
15
13
|
|
16
|
-
|
17
|
-
|
14
|
+
test "should resolve relative names starting at first element" do
|
15
|
+
resolver = DeepTest::Distributed::FilenameResolver.new("base_path")
|
18
16
|
|
19
|
-
|
17
|
+
File.expects(:exist?).with("base_path/a/b/c/d.rb").returns(true)
|
20
18
|
|
21
|
-
|
22
|
-
|
19
|
+
assert_equal "base_path/a/b/c/d.rb", resolver.resolve("a/b/c/d.rb")
|
20
|
+
end
|
23
21
|
|
24
|
-
|
25
|
-
|
22
|
+
test "should resolve relative names the same each time" do
|
23
|
+
resolver = DeepTest::Distributed::FilenameResolver.new("base_path")
|
26
24
|
|
27
|
-
|
25
|
+
File.expects(:exist?).with("base_path/a/b/c/d.rb").returns(true)
|
28
26
|
|
29
|
-
|
30
|
-
|
31
|
-
|
27
|
+
assert_equal "base_path/a/b/c/d.rb", resolver.resolve("a/b/c/d.rb")
|
28
|
+
assert_equal "base_path/a/b/c/d.rb", resolver.resolve("a/b/c/d.rb")
|
29
|
+
end
|
32
30
|
|
33
|
-
|
34
|
-
|
31
|
+
test "should raise exception if filename can't be resolved" do
|
32
|
+
resolver = DeepTest::Distributed::FilenameResolver.new("base_path")
|
35
33
|
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
34
|
+
File.expects(:exist?).with("base_path/a/b/c/d.rb").returns(false)
|
35
|
+
File.expects(:exist?).with("base_path/b/c/d.rb").returns(false)
|
36
|
+
File.expects(:exist?).with("base_path/c/d.rb").returns(false)
|
37
|
+
File.expects(:exist?).with("base_path/d.rb").returns(false)
|
40
38
|
|
41
|
-
|
42
|
-
|
39
|
+
assert_raises(RuntimeError) { resolver.resolve("/a/b/c/d.rb") }
|
40
|
+
end
|
43
41
|
|
44
|
-
|
45
|
-
|
42
|
+
test "should remember how many directories to strip off after first resolution" do
|
43
|
+
resolver = DeepTest::Distributed::FilenameResolver.new("base_path")
|
46
44
|
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
45
|
+
File.expects(:exist?).with("base_path/a/b/c/d.rb").returns(false)
|
46
|
+
File.expects(:exist?).with("base_path/b/c/d.rb").returns(true)
|
47
|
+
|
48
|
+
resolver.resolve("/a/b/c/d.rb")
|
51
49
|
|
52
|
-
|
53
|
-
end
|
54
|
-
end
|
50
|
+
assert_equal "base_path/x/y/z.rb", resolver.resolve("/a/x/y/z.rb")
|
55
51
|
end
|
56
52
|
end
|
@@ -0,0 +1,32 @@
|
|
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
|
@@ -0,0 +1,96 @@
|
|
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
|
@@ -0,0 +1,180 @@
|
|
1
|
+
require File.dirname(__FILE__) + "/../../test_helper"
|
2
|
+
|
3
|
+
unit_tests do
|
4
|
+
test "load_files broadcasts before_sync" do
|
5
|
+
class FakeListener; end
|
6
|
+
client = DeepTest::Distributed::RemoteWorkerClient.new(
|
7
|
+
options = DeepTest::Options.new(:worker_listener => FakeListener,
|
8
|
+
:sync_options => {:source => "/tmp"}),
|
9
|
+
test_server = stub_everything(:spawn_worker_server => stub_everything),
|
10
|
+
failover_workers = mock
|
11
|
+
)
|
12
|
+
FakeListener.any_instance.expects(:before_sync)
|
13
|
+
client.expects(:load)
|
14
|
+
client.load_files ["filelist"]
|
15
|
+
|
16
|
+
end
|
17
|
+
|
18
|
+
test "load_files syncs the mirror" do
|
19
|
+
client = DeepTest::Distributed::RemoteWorkerClient.new(
|
20
|
+
options = DeepTest::Options.new(:sync_options => {:source => "/tmp"}),
|
21
|
+
test_server = stub_everything(:spawn_worker_server => stub_everything),
|
22
|
+
failover_workers = mock
|
23
|
+
)
|
24
|
+
|
25
|
+
test_server.expects(:sync).with(options)
|
26
|
+
client.expects(:load)
|
27
|
+
client.load_files ["filelist"]
|
28
|
+
end
|
29
|
+
|
30
|
+
test "load_files loads files on worker server" do
|
31
|
+
worker_server = stub_everything
|
32
|
+
client = DeepTest::Distributed::RemoteWorkerClient.new(
|
33
|
+
DeepTest::Options.new(:sync_options => {:source => "/tmp"}),
|
34
|
+
test_server = stub_everything(:spawn_worker_server => worker_server),
|
35
|
+
failover_workers = mock
|
36
|
+
)
|
37
|
+
|
38
|
+
worker_server.expects(:load_files).with(["filelist"])
|
39
|
+
client.expects(:load)
|
40
|
+
client.load_files ["filelist"]
|
41
|
+
end
|
42
|
+
|
43
|
+
test "load_files loads files locally" do
|
44
|
+
worker_server = stub_everything
|
45
|
+
client = DeepTest::Distributed::RemoteWorkerClient.new(
|
46
|
+
DeepTest::Options.new(:sync_options => {:source => "/tmp"}),
|
47
|
+
test_server = stub_everything(:spawn_worker_server => worker_server),
|
48
|
+
failover_workers = mock
|
49
|
+
)
|
50
|
+
|
51
|
+
client.expects(:load).with("filelist")
|
52
|
+
client.load_files ["filelist"]
|
53
|
+
end
|
54
|
+
|
55
|
+
test "start_all starts workers on worker server" do
|
56
|
+
client = DeepTest::Distributed::RemoteWorkerClient.new(
|
57
|
+
options = DeepTest::Options.new(:sync_options => {:source => "/tmp"}),
|
58
|
+
test_server = stub_everything,
|
59
|
+
failover_workers = mock
|
60
|
+
)
|
61
|
+
|
62
|
+
test_server.expects(:spawn_worker_server).with(options).
|
63
|
+
returns(worker_server = stub_everything)
|
64
|
+
|
65
|
+
client.expects(:load)
|
66
|
+
client.load_files ["filelist"]
|
67
|
+
|
68
|
+
worker_server.expects(:start_all)
|
69
|
+
client.start_all
|
70
|
+
end
|
71
|
+
|
72
|
+
test "stop_all stops workers on worker server that was spawned in load_files" do
|
73
|
+
worker_server = stub_everything
|
74
|
+
client = DeepTest::Distributed::RemoteWorkerClient.new(
|
75
|
+
DeepTest::Options.new(:sync_options => {:source => "/tmp"}),
|
76
|
+
test_server = stub_everything(:spawn_worker_server => worker_server),
|
77
|
+
failover_workers = mock
|
78
|
+
)
|
79
|
+
|
80
|
+
client.expects(:load)
|
81
|
+
client.load_files ["filelist"]
|
82
|
+
|
83
|
+
worker_server.expects(:stop_all)
|
84
|
+
client.stop_all
|
85
|
+
end
|
86
|
+
|
87
|
+
test "exception in start_all causes failover to failover_workers" do
|
88
|
+
client = DeepTest::Distributed::RemoteWorkerClient.new(
|
89
|
+
options = DeepTest::Options.new(:sync_options => {:source => "/tmp"}, :ui => DeepTest::UI::Null),
|
90
|
+
test_server = stub_everything,
|
91
|
+
failover_workers = mock
|
92
|
+
)
|
93
|
+
|
94
|
+
test_server.expects(:spawn_worker_server).with(options).
|
95
|
+
returns(worker_server = mock)
|
96
|
+
|
97
|
+
worker_server.expects(:load_files)
|
98
|
+
client.expects(:load)
|
99
|
+
client.load_files ["filelist"]
|
100
|
+
|
101
|
+
worker_server.expects(:start_all).raises("An Error")
|
102
|
+
|
103
|
+
failover_workers.expects(:start_all)
|
104
|
+
client.start_all
|
105
|
+
|
106
|
+
failover_workers.expects(:stop_all)
|
107
|
+
client.stop_all
|
108
|
+
end
|
109
|
+
|
110
|
+
test "exception in sync causes failover to failover_workers" do
|
111
|
+
client = DeepTest::Distributed::RemoteWorkerClient.new(
|
112
|
+
options = DeepTest::Options.new(:sync_options => {:source => "/tmp"}, :ui => DeepTest::UI::Null),
|
113
|
+
test_server = mock,
|
114
|
+
failover_workers = mock
|
115
|
+
)
|
116
|
+
|
117
|
+
test_server.expects(:sync).raises("An Error")
|
118
|
+
|
119
|
+
client.expects(:load)
|
120
|
+
client.load_files ["filelist"]
|
121
|
+
|
122
|
+
failover_workers.expects(:start_all)
|
123
|
+
client.start_all
|
124
|
+
|
125
|
+
failover_workers.expects(:stop_all)
|
126
|
+
client.stop_all
|
127
|
+
end
|
128
|
+
|
129
|
+
test "exception in load_files causes failover to failover_workers" do
|
130
|
+
client = DeepTest::Distributed::RemoteWorkerClient.new(
|
131
|
+
options = DeepTest::Options.new(:sync_options => {:source => "/tmp"}, :ui => DeepTest::UI::Null),
|
132
|
+
test_server = stub_everything,
|
133
|
+
failover_workers = mock
|
134
|
+
)
|
135
|
+
|
136
|
+
test_server.expects(:spawn_worker_server).with(options).
|
137
|
+
returns(worker_server = Object.new)
|
138
|
+
|
139
|
+
worker_server.instance_eval do
|
140
|
+
def calls() @calls ||= []; end
|
141
|
+
def method_missing(sym, *args) calls << sym; end
|
142
|
+
def load_files(filelist) raise "An Error"; end
|
143
|
+
end
|
144
|
+
|
145
|
+
client.expects(:load)
|
146
|
+
client.load_files ["filelist"]
|
147
|
+
|
148
|
+
failover_workers.expects(:start_all)
|
149
|
+
client.start_all
|
150
|
+
|
151
|
+
failover_workers.expects(:stop_all)
|
152
|
+
client.stop_all
|
153
|
+
|
154
|
+
assert_equal [], worker_server.calls
|
155
|
+
end
|
156
|
+
|
157
|
+
test "exception from start_all of failover_workers is raised" do
|
158
|
+
client = DeepTest::Distributed::RemoteWorkerClient.new(
|
159
|
+
options = DeepTest::Options.new(:sync_options => {:source => "/tmp"}, :ui => DeepTest::UI::Null),
|
160
|
+
test_server = stub_everything,
|
161
|
+
failover_workers = mock
|
162
|
+
)
|
163
|
+
|
164
|
+
test_server.expects(:spawn_worker_server).with(options).
|
165
|
+
returns(worker_server = mock)
|
166
|
+
|
167
|
+
worker_server.expects(:load_files).raises("An Error")
|
168
|
+
client.expects(:load)
|
169
|
+
client.load_files ["filelist"]
|
170
|
+
|
171
|
+
failover_workers.expects(:start_all).raises("Failover Error").then.returns(nil)
|
172
|
+
|
173
|
+
begin
|
174
|
+
client.start_all
|
175
|
+
flunk
|
176
|
+
rescue RuntimeError => e
|
177
|
+
assert_equal "Failover Error", e.message
|
178
|
+
end
|
179
|
+
end
|
180
|
+
end
|
@@ -0,0 +1,99 @@
|
|
1
|
+
require File.dirname(__FILE__) + "/../../test_helper"
|
2
|
+
|
3
|
+
unit_tests do
|
4
|
+
test "start_all delegates to worker implementation" do
|
5
|
+
server = DeepTest::Distributed::RemoteWorkerServer.new("", implementation = mock)
|
6
|
+
implementation.expects(:start_all)
|
7
|
+
server.start_all
|
8
|
+
end
|
9
|
+
|
10
|
+
test "stop_all delegates to worker implementation" do
|
11
|
+
server = DeepTest::Distributed::RemoteWorkerServer.new("", implementation = mock)
|
12
|
+
implementation.expects(:stop_all)
|
13
|
+
server.stop_all.join
|
14
|
+
end
|
15
|
+
|
16
|
+
test "stop_all returns without waiting for stops" do
|
17
|
+
implementation = Object.new.instance_eval do
|
18
|
+
def done?
|
19
|
+
@done == true
|
20
|
+
end
|
21
|
+
|
22
|
+
def stop_all
|
23
|
+
sleep 0.01
|
24
|
+
@done = true
|
25
|
+
end
|
26
|
+
self
|
27
|
+
end
|
28
|
+
|
29
|
+
server = DeepTest::Distributed::RemoteWorkerServer.new("", implementation)
|
30
|
+
server.stop_all
|
31
|
+
assert_equal false, implementation.done?
|
32
|
+
|
33
|
+
until implementation.done?
|
34
|
+
sleep 0.01
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
test "load_files loads each file in list, resolving each filename with resolver" do
|
39
|
+
DeepTest::Distributed::FilenameResolver.expects(:new).with("/mirror/dir").
|
40
|
+
returns(resolver = mock)
|
41
|
+
|
42
|
+
server = DeepTest::Distributed::RemoteWorkerServer.new("/mirror/dir", stub_everything)
|
43
|
+
|
44
|
+
resolver.expects(:resolve).with("/source/path/my/file.rb").
|
45
|
+
returns("/mirror/dir/my/file.rb")
|
46
|
+
server.expects(:load).with("/mirror/dir/my/file.rb")
|
47
|
+
Dir.expects(:chdir).with("/mirror/dir")
|
48
|
+
|
49
|
+
server.load_files(["/source/path/my/file.rb"])
|
50
|
+
end
|
51
|
+
|
52
|
+
test "service is removed after grace period if workers haven't been started" do
|
53
|
+
log_level = DeepTest.logger.level
|
54
|
+
begin
|
55
|
+
DeepTest.logger.level = Logger::ERROR
|
56
|
+
DeepTest::Distributed::RemoteWorkerServer.start(
|
57
|
+
"localhost",
|
58
|
+
"base_path",
|
59
|
+
stub_everything,
|
60
|
+
0.25
|
61
|
+
)
|
62
|
+
# Have to sleep long enough to warlock to reap dead process
|
63
|
+
sleep 1.0
|
64
|
+
assert_equal 0, DeepTest::Distributed::RemoteWorkerServer.running_server_count
|
65
|
+
ensure
|
66
|
+
begin
|
67
|
+
DeepTest::Distributed::RemoteWorkerServer.stop_all
|
68
|
+
ensure
|
69
|
+
DeepTest.logger.level = log_level
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
test "service is not removed after grace period if workers have been started" do
|
75
|
+
log_level = DeepTest.logger.level
|
76
|
+
begin
|
77
|
+
DeepTest.logger.level = Logger::ERROR
|
78
|
+
server = nil
|
79
|
+
capture_stdout do
|
80
|
+
server = DeepTest::Distributed::RemoteWorkerServer.start(
|
81
|
+
Socket.gethostname,
|
82
|
+
"",
|
83
|
+
stub_everything,
|
84
|
+
0.25
|
85
|
+
)
|
86
|
+
end
|
87
|
+
server.start_all
|
88
|
+
# Have to sleep long enough to warlock to reap dead process
|
89
|
+
sleep 1.0
|
90
|
+
assert_equal 1, DeepTest::Distributed::RemoteWorkerServer.running_server_count
|
91
|
+
ensure
|
92
|
+
begin
|
93
|
+
DeepTest::Distributed::RemoteWorkerServer.stop_all
|
94
|
+
ensure
|
95
|
+
DeepTest.logger.level = log_level
|
96
|
+
end
|
97
|
+
end
|
98
|
+
end
|
99
|
+
end
|