jason-o-matic-deep_test 1.2.2.1
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +47 -0
- data/README.rdoc +228 -0
- data/Rakefile +211 -0
- data/bin/deep_test +15 -0
- data/lib/deep_test.rb +90 -0
- data/lib/deep_test/database/mysql_setup_listener.rb +113 -0
- data/lib/deep_test/database/setup_listener.rb +116 -0
- data/lib/deep_test/deadlock_detector.rb +7 -0
- data/lib/deep_test/distributed/dispatch_controller.rb +53 -0
- data/lib/deep_test/distributed/drb_client_connection_info.rb +15 -0
- data/lib/deep_test/distributed/filename_resolver.rb +40 -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 +111 -0
- data/lib/deep_test/distributed/rsync.rb +37 -0
- data/lib/deep_test/distributed/show_status.rhtml +41 -0
- data/lib/deep_test/distributed/test_server.rb +79 -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/extensions/object_extension.rb +40 -0
- data/lib/deep_test/listener_list.rb +17 -0
- data/lib/deep_test/local_workers.rb +55 -0
- data/lib/deep_test/logger.rb +17 -0
- data/lib/deep_test/marshallable_exception_wrapper.rb +44 -0
- 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_worker_listener.rb +65 -0
- data/lib/deep_test/option.rb +70 -0
- data/lib/deep_test/options.rb +112 -0
- data/lib/deep_test/process_orchestrator.rb +49 -0
- data/lib/deep_test/rake_tasks.rb +11 -0
- data/lib/deep_test/result_reader.rb +36 -0
- data/lib/deep_test/rspec_detector.rb +24 -0
- data/lib/deep_test/server.rb +75 -0
- data/lib/deep_test/spec.rb +12 -0
- data/lib/deep_test/spec/extensions/example_group_methods.rb +64 -0
- data/lib/deep_test/spec/extensions/example_methods.rb +46 -0
- data/lib/deep_test/spec/extensions/options.rb +43 -0
- data/lib/deep_test/spec/extensions/reporter.rb +29 -0
- data/lib/deep_test/spec/extensions/spec_task.rb +20 -0
- data/lib/deep_test/spec/runner.rb +57 -0
- data/lib/deep_test/spec/work_result.rb +33 -0
- data/lib/deep_test/spec/work_unit.rb +59 -0
- data/lib/deep_test/test.rb +10 -0
- data/lib/deep_test/test/extensions/error.rb +14 -0
- data/lib/deep_test/test/runner.rb +24 -0
- data/lib/deep_test/test/supervised_test_suite.rb +49 -0
- data/lib/deep_test/test/work_result.rb +34 -0
- data/lib/deep_test/test/work_unit.rb +40 -0
- data/lib/deep_test/test_task.rb +51 -0
- data/lib/deep_test/ui/console.rb +76 -0
- data/lib/deep_test/ui/null.rb +17 -0
- data/lib/deep_test/warlock.rb +134 -0
- data/lib/deep_test/worker.rb +57 -0
- 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/test/deep_test/database/mysql_setup_listener_test.rb +14 -0
- data/test/deep_test/distributed/dispatch_controller_test.rb +209 -0
- data/test/deep_test/distributed/drb_client_connection_info_test.rb +42 -0
- data/test/deep_test/distributed/filename_resolver_test.rb +52 -0
- 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 +107 -0
- data/test/deep_test/distributed/rsync_test.rb +67 -0
- 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/extensions/object_extension_test.rb +37 -0
- data/test/deep_test/listener_list_test.rb +20 -0
- data/test/deep_test/local_workers_test.rb +22 -0
- data/test/deep_test/logger_test.rb +11 -0
- data/test/deep_test/marshallable_exception_wrapper_test.rb +44 -0
- 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 +128 -0
- data/test/deep_test/server_test.rb +58 -0
- data/test/deep_test/test/extensions/error_test.rb +40 -0
- data/test/deep_test/test/runner_test.rb +7 -0
- data/test/deep_test/test/supervised_test_suite_test.rb +79 -0
- data/test/deep_test/test/work_result_test.rb +81 -0
- data/test/deep_test/test/work_unit_test.rb +61 -0
- data/test/deep_test/test_task_test.rb +43 -0
- data/test/deep_test/ui/console_test.rb +9 -0
- data/test/deep_test/warlock_test.rb +38 -0
- data/test/deep_test/worker_test.rb +94 -0
- data/test/failing.rake +11 -0
- data/test/failing.rb +7 -0
- data/test/fake_deadlock_error.rb +12 -0
- data/test/simple_test_blackboard.rb +45 -0
- data/test/simple_test_blackboard_test.rb +33 -0
- data/test/test_factory.rb +74 -0
- data/test/test_helper.rb +15 -0
- data/test/test_task_test.rb +72 -0
- metadata +160 -0
@@ -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,107 @@
|
|
1
|
+
require File.dirname(__FILE__) + "/../../test_helper"
|
2
|
+
|
3
|
+
unit_tests do
|
4
|
+
test "start_all delegates to worker implementation" do
|
5
|
+
options = DeepTest::Options.new(:libs => [], :requires => [])
|
6
|
+
server = DeepTest::Distributed::RemoteWorkerServer.new("", implementation = mock, options)
|
7
|
+
implementation.expects(:start_all)
|
8
|
+
server.start_all
|
9
|
+
end
|
10
|
+
|
11
|
+
test "stop_all delegates to worker implementation" do
|
12
|
+
options = DeepTest::Options.new(:libs => [], :requires => [])
|
13
|
+
server = DeepTest::Distributed::RemoteWorkerServer.new("", implementation = mock, options)
|
14
|
+
implementation.expects(:stop_all)
|
15
|
+
server.stop_all
|
16
|
+
end
|
17
|
+
|
18
|
+
test "stop_all returns without waiting for stops" do
|
19
|
+
implementation = Object.new.instance_eval do
|
20
|
+
def done?
|
21
|
+
@done == true
|
22
|
+
end
|
23
|
+
|
24
|
+
def stop_all
|
25
|
+
sleep 0.01
|
26
|
+
@done = true
|
27
|
+
end
|
28
|
+
self
|
29
|
+
end
|
30
|
+
options = DeepTest::Options.new(:libs => [], :requires => [])
|
31
|
+
|
32
|
+
server = DeepTest::Distributed::RemoteWorkerServer.new("", implementation, options)
|
33
|
+
server.stop_all
|
34
|
+
assert_equal false, implementation.done?
|
35
|
+
|
36
|
+
until implementation.done?
|
37
|
+
sleep 0.01
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
test "load_files loads each file in list, resolving each filename with resolver" do
|
42
|
+
options = DeepTest::Options.new(:libs => [], :requires => [])
|
43
|
+
DeepTest::Distributed::FilenameResolver.expects(:new).times(2).with("/mirror/dir").
|
44
|
+
returns(resolver = mock)
|
45
|
+
|
46
|
+
server = DeepTest::Distributed::RemoteWorkerServer.new("/mirror/dir", stub_everything, options)
|
47
|
+
|
48
|
+
resolver.expects(:resolve).with("/source/path/my/file.rb").
|
49
|
+
returns("/mirror/dir/my/file.rb")
|
50
|
+
server.expects(:load).with("/mirror/dir/my/file.rb")
|
51
|
+
Dir.expects(:chdir).with("/mirror/dir")
|
52
|
+
|
53
|
+
server.load_files(["/source/path/my/file.rb"])
|
54
|
+
end
|
55
|
+
|
56
|
+
test "service is removed after grace period if workers haven't been started" do
|
57
|
+
options = DeepTest::Options.new(:libs => [], :requires => [])
|
58
|
+
log_level = DeepTest.logger.level
|
59
|
+
begin
|
60
|
+
DeepTest.logger.level = Logger::ERROR
|
61
|
+
DeepTest::Distributed::RemoteWorkerServer.start(
|
62
|
+
"localhost",
|
63
|
+
"base_path",
|
64
|
+
stub_everything,
|
65
|
+
options,
|
66
|
+
0.25
|
67
|
+
)
|
68
|
+
# Have to sleep long enough to warlock to reap dead process
|
69
|
+
sleep 1.0
|
70
|
+
assert_equal 0, DeepTest::Distributed::RemoteWorkerServer.running_server_count
|
71
|
+
ensure
|
72
|
+
begin
|
73
|
+
DeepTest::Distributed::RemoteWorkerServer.stop_all
|
74
|
+
ensure
|
75
|
+
DeepTest.logger.level = log_level
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
test "service is not removed after grace period if workers have been started" do
|
81
|
+
options = DeepTest::Options.new(:libs => [], :requires => [])
|
82
|
+
log_level = DeepTest.logger.level
|
83
|
+
begin
|
84
|
+
DeepTest.logger.level = Logger::ERROR
|
85
|
+
server = nil
|
86
|
+
capture_stdout do
|
87
|
+
server = DeepTest::Distributed::RemoteWorkerServer.start(
|
88
|
+
Socket.gethostname,
|
89
|
+
"",
|
90
|
+
stub_everything,
|
91
|
+
options,
|
92
|
+
0.25
|
93
|
+
)
|
94
|
+
end
|
95
|
+
server.start_all
|
96
|
+
# Have to sleep long enough to warlock to reap dead process
|
97
|
+
sleep 1.0
|
98
|
+
assert_equal 1, DeepTest::Distributed::RemoteWorkerServer.running_server_count
|
99
|
+
ensure
|
100
|
+
begin
|
101
|
+
DeepTest::Distributed::RemoteWorkerServer.stop_all
|
102
|
+
ensure
|
103
|
+
DeepTest.logger.level = log_level
|
104
|
+
end
|
105
|
+
end
|
106
|
+
end
|
107
|
+
end
|
@@ -0,0 +1,67 @@
|
|
1
|
+
require File.dirname(__FILE__) + "/../../test_helper"
|
2
|
+
|
3
|
+
unit_tests do
|
4
|
+
test "executes rsync with source and destination" do
|
5
|
+
options = DeepTest::Options.new(:sync_options => {:source => "source", :local => true})
|
6
|
+
|
7
|
+
DeepTest::Distributed::RSync.expects(:system).
|
8
|
+
with("rsync -az --delete source/ destination").returns(true)
|
9
|
+
|
10
|
+
DeepTest::Distributed::RSync.sync(mock, options, "destination")
|
11
|
+
end
|
12
|
+
|
13
|
+
test "raises error if sync fails" do
|
14
|
+
DeepTest::Distributed::RSync.expects(:system).returns(false)
|
15
|
+
|
16
|
+
assert_raises(RuntimeError) do
|
17
|
+
DeepTest::Distributed::RSync.sync(
|
18
|
+
mock,
|
19
|
+
DeepTest::Options.new(:sync_options => {:source => "a", :local => true}),
|
20
|
+
"destination"
|
21
|
+
)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
test "include rsync_options in command" do
|
26
|
+
options = DeepTest::Options.new(:sync_options => {:source => "source",
|
27
|
+
:local => true,
|
28
|
+
:rsync_options => "opt1 opt2"})
|
29
|
+
|
30
|
+
args = DeepTest::Distributed::RSync::Args.new(mock, options)
|
31
|
+
assert_equal "rsync -az --delete opt1 opt2 source/", args.command("")
|
32
|
+
end
|
33
|
+
|
34
|
+
test "includes host in source_location" do
|
35
|
+
options = DeepTest::Options.new(:sync_options => {:source => "source"})
|
36
|
+
args = DeepTest::Distributed::RSync::Args.new(mock(:address => 'host'),
|
37
|
+
options)
|
38
|
+
|
39
|
+
assert_equal "host:source", args.source_location
|
40
|
+
end
|
41
|
+
|
42
|
+
test "separates host and source with double colon if using daemon" do
|
43
|
+
options = DeepTest::Options.new(
|
44
|
+
:sync_options => {:source => "source", :daemon => true}
|
45
|
+
)
|
46
|
+
args = DeepTest::Distributed::RSync::Args.new(mock(:address => 'host'),
|
47
|
+
options)
|
48
|
+
|
49
|
+
assert_equal "host::source", args.source_location
|
50
|
+
end
|
51
|
+
|
52
|
+
test "includes username in source_location if specified" do
|
53
|
+
options = DeepTest::Options.new(:sync_options => {:source => "source",
|
54
|
+
:username => "user"})
|
55
|
+
args = DeepTest::Distributed::RSync::Args.new(mock(:address => 'host'),
|
56
|
+
options)
|
57
|
+
|
58
|
+
assert_equal "user@host:source", args.source_location
|
59
|
+
end
|
60
|
+
|
61
|
+
test "does not include host in source_location if local is specified" do
|
62
|
+
options = DeepTest::Options.new(:sync_options => {:source => "source", :local => true})
|
63
|
+
args = DeepTest::Distributed::RSync::Args.new(mock, options)
|
64
|
+
|
65
|
+
assert_equal "source", args.source_location
|
66
|
+
end
|
67
|
+
end
|
@@ -0,0 +1,94 @@
|
|
1
|
+
require File.dirname(__FILE__) + "/../../test_helper"
|
2
|
+
|
3
|
+
unit_tests do
|
4
|
+
test "generates a local working copy path based on host and source of request" do
|
5
|
+
DeepTest::Distributed::DRbClientConnectionInfo.expects(:new).
|
6
|
+
returns(:connection_info)
|
7
|
+
|
8
|
+
Socket.stubs(:gethostname).returns("myhost", "serverhost")
|
9
|
+
server = DeepTest::Distributed::TestServer.new(:work_dir => "/tmp")
|
10
|
+
options = DeepTest::Options.new(:sync_options => {:source => "/my/local/dir"})
|
11
|
+
DeepTest::Distributed::RSync.expects(:sync).with(:connection_info,
|
12
|
+
options,
|
13
|
+
"/tmp/myhost_my_local_dir")
|
14
|
+
server.sync(options)
|
15
|
+
end
|
16
|
+
|
17
|
+
test "work_dir can be set from command line" do
|
18
|
+
config = DeepTest::Distributed::TestServer.parse_args(
|
19
|
+
['--work_dir','path']
|
20
|
+
)
|
21
|
+
assert_equal 'path', config[:work_dir]
|
22
|
+
end
|
23
|
+
|
24
|
+
test "uri can be set from command line" do
|
25
|
+
config = DeepTest::Distributed::TestServer.parse_args(['--uri','uri'])
|
26
|
+
assert_equal 'uri', config[:uri]
|
27
|
+
end
|
28
|
+
|
29
|
+
test "number_of_workers can be set from command line" do
|
30
|
+
config = DeepTest::Distributed::TestServer.parse_args(
|
31
|
+
['--number_of_workers','4']
|
32
|
+
)
|
33
|
+
assert_equal 4, config[:number_of_workers]
|
34
|
+
end
|
35
|
+
|
36
|
+
test "default number_of_workers is 2" do
|
37
|
+
assert_equal(
|
38
|
+
2,
|
39
|
+
DeepTest::Distributed::TestServer::DEFAULT_CONFIG[:number_of_workers]
|
40
|
+
)
|
41
|
+
end
|
42
|
+
|
43
|
+
test "uses default options for those not specified" do
|
44
|
+
config = DeepTest::Distributed::TestServer.parse_args([])
|
45
|
+
assert_equal DeepTest::Distributed::TestServer::DEFAULT_CONFIG, config
|
46
|
+
end
|
47
|
+
|
48
|
+
test "spawn_worker_server starts RemoteWorkerServer with TestServerWorkers" do
|
49
|
+
config = {:number_of_workers => 4, :uri => "druby://localhost:4022"}
|
50
|
+
server = DeepTest::Distributed::TestServer.new(config)
|
51
|
+
options = DeepTest::Options.new(:sync_options => {:source => ""})
|
52
|
+
DeepTest::Distributed::DRbClientConnectionInfo.expects(:new).
|
53
|
+
returns(:connection_info)
|
54
|
+
|
55
|
+
DeepTest::Distributed::TestServerWorkers.expects(:new).with(
|
56
|
+
options, config, :connection_info
|
57
|
+
).returns(:workers)
|
58
|
+
|
59
|
+
DeepTest::Distributed::RemoteWorkerServer.expects(:start).with(
|
60
|
+
"localhost", anything, :workers, options
|
61
|
+
)
|
62
|
+
|
63
|
+
server.spawn_worker_server(options)
|
64
|
+
end
|
65
|
+
|
66
|
+
test "connect creates dispatch controller for all servers" do
|
67
|
+
options = DeepTest::Options.new({:ui => "DeepTest::UI::Null"})
|
68
|
+
DRbObject.expects(:new_with_uri).returns(server = mock)
|
69
|
+
server.expects(:servers).returns([s1 = mock, s2 = mock])
|
70
|
+
s1.expects(:sync)
|
71
|
+
s2.expects(:sync)
|
72
|
+
DeepTest::Distributed::TestServer.connect(options).sync(options)
|
73
|
+
end
|
74
|
+
|
75
|
+
test "status.binding_uri is the uri that DRb is bound to" do
|
76
|
+
server = DeepTest::Distributed::TestServer.new(:number_of_workers => 4)
|
77
|
+
DRb.expects(:uri).returns("druby://test")
|
78
|
+
assert_equal "druby://test", server.status.binding_uri
|
79
|
+
end
|
80
|
+
|
81
|
+
test "status.number_of_workers in the configured number of workers" do
|
82
|
+
server = DeepTest::Distributed::TestServer.new(:number_of_workers => 4)
|
83
|
+
DRb.expects(:uri)
|
84
|
+
assert_equal 4, server.status.number_of_workers
|
85
|
+
end
|
86
|
+
|
87
|
+
test "status.remote_worker_server_count is number of servers currently running" do
|
88
|
+
server = DeepTest::Distributed::TestServer.new(:number_of_workers => 4)
|
89
|
+
DRb.expects(:uri)
|
90
|
+
DeepTest::Distributed::RemoteWorkerServer.expects(:running_server_count).
|
91
|
+
returns(3)
|
92
|
+
assert_equal 3, server.status.remote_worker_server_count
|
93
|
+
end
|
94
|
+
end
|