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
@@ -1,209 +1,162 @@
|
|
1
1
|
require File.dirname(__FILE__) + "/../../test_helper"
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
3
|
+
module DeepTest
|
4
|
+
module Distributed
|
5
|
+
unit_tests do
|
6
|
+
test "dispatch invokes each receiver once" do
|
7
|
+
receiver_1, receiver_2 = mock, mock
|
6
8
|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
9
|
+
controller = DispatchController.new(
|
10
|
+
Options.new({:ui => "UI::Null"}),
|
11
|
+
[receiver_1, receiver_2]
|
12
|
+
)
|
11
13
|
|
12
|
-
|
13
|
-
|
14
|
+
receiver_1.expects(:a_method).with(:args)
|
15
|
+
receiver_2.expects(:a_method).with(:args)
|
14
16
|
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
test "dispatch returns array of all results" do
|
19
|
-
receiver_1, receiver_2 = mock, mock
|
20
|
-
|
21
|
-
controller = DeepTest::Distributed::DispatchController.new(
|
22
|
-
DeepTest::Options.new({:ui => "DeepTest::UI::Null"}),
|
23
|
-
[receiver_1, receiver_2]
|
24
|
-
)
|
25
|
-
|
26
|
-
receiver_1.expects(:a_method).returns(:result_1)
|
27
|
-
receiver_2.expects(:a_method).returns(:result_2)
|
28
|
-
|
29
|
-
results = controller.dispatch(:a_method)
|
30
|
-
assert_equal 2, results.size
|
31
|
-
assert_equal [:result_1, :result_2].to_set, results.to_set
|
32
|
-
end
|
33
|
-
|
34
|
-
test "dispatch calls all receivers in parallel" do
|
35
|
-
options = DeepTest::Options.new({:ui => "DeepTest::UI::Null"})
|
36
|
-
waiter = Waiter.new(tracker = Tracker.new)
|
37
|
-
|
38
|
-
Timeout.timeout(1) do
|
39
|
-
DeepTest::Distributed::DispatchController.new(options,[tracker, waiter]).
|
40
|
-
dispatch(:tracked_method)
|
41
|
-
end
|
42
|
-
|
43
|
-
waiter = Waiter.new(tracker = Tracker.new)
|
44
|
-
|
45
|
-
Timeout.timeout(1) do
|
46
|
-
DeepTest::Distributed::DispatchController.new(options,[waiter, tracker]).
|
47
|
-
dispatch(:tracked_method)
|
48
|
-
end
|
49
|
-
end
|
50
|
-
|
51
|
-
test "dispatch omits results that are taking too long" do
|
52
|
-
receiver = Object.new
|
53
|
-
def receiver.__drburi; ""; end
|
54
|
-
def receiver.sleep_100_millis
|
55
|
-
sleep 0.1
|
56
|
-
end
|
57
|
-
|
58
|
-
controller = DeepTest::Distributed::DispatchController.new(
|
59
|
-
DeepTest::Options.new({:ui => "DeepTest::UI::Null", :timeout_in_seconds => 0.05}),
|
60
|
-
[receiver]
|
61
|
-
)
|
62
|
-
|
63
|
-
DeepTest.logger.expects(:error)
|
64
|
-
|
65
|
-
assert_equal [], controller.dispatch(:sleep_100_millis)
|
66
|
-
end
|
17
|
+
controller.dispatch(:a_method, :args)
|
18
|
+
end
|
67
19
|
|
68
|
-
|
69
|
-
|
70
|
-
receiver_1.expects(:method_call_1).raises(Timeout::Error.new("message"))
|
71
|
-
receiver_1.expects(:method_call_2).never
|
20
|
+
test "dispatch returns array of all results" do
|
21
|
+
receiver_1, receiver_2 = mock, mock
|
72
22
|
|
73
|
-
|
74
|
-
|
23
|
+
controller = DispatchController.new(
|
24
|
+
Options.new({:ui => "UI::Null"}),
|
25
|
+
[receiver_1, receiver_2]
|
26
|
+
)
|
75
27
|
|
76
|
-
|
77
|
-
|
78
|
-
[receiver_1, receiver_2]
|
79
|
-
)
|
28
|
+
receiver_1.expects(:a_method).returns(:result_1)
|
29
|
+
receiver_2.expects(:a_method).returns(:result_2)
|
80
30
|
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
end
|
86
|
-
|
87
|
-
test "receiver is dropped when connection is refused" do
|
88
|
-
receiver_1, receiver_2 = mock(:__drburi => ""), mock
|
89
|
-
receiver_1.expects(:method_call_1).raises(DRb::DRbConnError)
|
90
|
-
receiver_1.expects(:method_call_2).never
|
31
|
+
results = controller.dispatch(:a_method)
|
32
|
+
assert_equal 2, results.size
|
33
|
+
assert_equal [:result_1, :result_2].to_set, results.to_set
|
34
|
+
end
|
91
35
|
|
92
|
-
|
93
|
-
|
36
|
+
test "dispatch calls all receivers in parallel" do
|
37
|
+
options = Options.new({:ui => "UI::Null"})
|
38
|
+
waiter = Waiter.new(tracker = Tracker.new)
|
94
39
|
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
40
|
+
Timeout.timeout(1) do
|
41
|
+
DispatchController.new(options,[tracker, waiter]).
|
42
|
+
dispatch(:tracked_method)
|
43
|
+
end
|
99
44
|
|
100
|
-
|
101
|
-
|
102
|
-
assert_equal [:value], controller.dispatch(:method_call_1)
|
45
|
+
waiter = Waiter.new(tracker = Tracker.new)
|
103
46
|
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
receiver.expects(:method_call).raises(Exception)
|
110
|
-
|
111
|
-
controller = DeepTest::Distributed::DispatchController.new(
|
112
|
-
DeepTest::Options.new({:ui => "DeepTest::UI::Null", :timeout_in_seconds => 0.05}),
|
113
|
-
[receiver]
|
114
|
-
)
|
115
|
-
|
116
|
-
DeepTest.logger.expects(:error)
|
117
|
-
|
118
|
-
controller.dispatch(:method_call)
|
119
|
-
assert_raises(DeepTest::Distributed::NoDispatchReceiversError) {controller.dispatch(:another_call)}
|
120
|
-
end
|
47
|
+
Timeout.timeout(1) do
|
48
|
+
DispatchController.new(options,[waiter, tracker]).
|
49
|
+
dispatch(:tracked_method)
|
50
|
+
end
|
51
|
+
end
|
121
52
|
|
122
|
-
|
123
|
-
|
124
|
-
|
53
|
+
test "receiver is dropped when any exception occurs" do
|
54
|
+
receiver = mock
|
55
|
+
receiver.expects(:method_call).raises(Exception)
|
125
56
|
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
57
|
+
controller = DispatchController.new(
|
58
|
+
Options.new({:ui => "UI::Null"}),
|
59
|
+
[receiver]
|
60
|
+
)
|
130
61
|
|
131
|
-
|
62
|
+
controller.dispatch(:method_call)
|
63
|
+
assert_raises(NoDispatchReceiversError) {controller.dispatch(:another_call)}
|
64
|
+
end
|
132
65
|
|
133
|
-
|
134
|
-
|
66
|
+
test "error is printed with backtrace when it occurrs" do
|
67
|
+
e = Exception.new("message")
|
68
|
+
e.set_backtrace %w[file1:1 file2:2]
|
69
|
+
receiver = mock
|
70
|
+
receiver.expects(:method_call).raises(e)
|
71
|
+
|
72
|
+
controller = DispatchController.new(
|
73
|
+
Options.new({:ui => "UI::Null"}),
|
74
|
+
[receiver]
|
75
|
+
)
|
76
|
+
|
77
|
+
Timewarp.freeze("2009-09-22 12:01:33") do
|
78
|
+
controller.dispatch(:method_call)
|
79
|
+
assert_equal <<-end_log, DeepTest.logger.logged_output
|
80
|
+
[DeepTest@#{Socket.gethostname}] 2009-09-22 12:01:33 Exception while dispatching method_call to #{receiver.inspect}:
|
81
|
+
[DeepTest@#{Socket.gethostname}] 2009-09-22 12:01:33 Exception: message
|
82
|
+
[DeepTest@#{Socket.gethostname}] 2009-09-22 12:01:33 file1:1
|
83
|
+
[DeepTest@#{Socket.gethostname}] 2009-09-22 12:01:33 file2:2
|
84
|
+
end_log
|
85
|
+
end
|
86
|
+
end
|
135
87
|
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
88
|
+
test "dispatch calls notifies ui of start and stop of dispatch" do
|
89
|
+
options = Options.new({:ui => "UI::Null"})
|
90
|
+
controller = DispatchController.new(
|
91
|
+
options, [stub_everything]
|
92
|
+
)
|
141
93
|
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
94
|
+
options.ui_instance.expects(:dispatch_starting).with(:method_name)
|
95
|
+
options.ui_instance.expects(:dispatch_finished).with(:method_name)
|
96
|
+
|
97
|
+
controller.dispatch(:method_name)
|
98
|
+
end
|
147
99
|
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
end
|
100
|
+
test "dispatch calls notifies ui dispatch end in case of an error" do
|
101
|
+
options = Options.new({:ui => "UI::Null"})
|
102
|
+
controller = DispatchController.new(
|
103
|
+
options, [receiver = mock]
|
104
|
+
)
|
105
|
+
receiver.expects(:method_name).raises("An Error")
|
106
|
+
|
107
|
+
options.ui_instance.expects(:dispatch_starting).with(:method_name)
|
108
|
+
options.ui_instance.expects(:dispatch_finished).with(:method_name)
|
109
|
+
|
110
|
+
begin
|
111
|
+
controller.dispatch(:method_name)
|
112
|
+
rescue RuntimeError => e
|
113
|
+
raise unless e.message == "An Error"
|
114
|
+
end
|
115
|
+
end
|
165
116
|
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
117
|
+
test "error is raised if dispatch to no receivers in attempted" do
|
118
|
+
options = Options.new({:ui => "UI::Null"})
|
119
|
+
controller = DispatchController.new(
|
120
|
+
options, []
|
121
|
+
)
|
171
122
|
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
123
|
+
assert_raises(NoDispatchReceiversError) do
|
124
|
+
controller.dispatch(:any_method)
|
125
|
+
end
|
126
|
+
end
|
176
127
|
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
128
|
+
class Tracker
|
129
|
+
def initialize
|
130
|
+
@mutex = Mutex.new
|
131
|
+
@condvar = ConditionVariable.new
|
132
|
+
end
|
182
133
|
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
134
|
+
def tracked_method
|
135
|
+
@mutex.synchronize do
|
136
|
+
@tracked_method_called = true
|
137
|
+
@condvar.broadcast
|
138
|
+
end
|
139
|
+
end
|
189
140
|
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
141
|
+
def wait_for_tracked_method
|
142
|
+
@mutex.synchronize do
|
143
|
+
loop do
|
144
|
+
return if @tracked_method_called
|
145
|
+
@condvar.wait(@mutex)
|
146
|
+
end
|
147
|
+
end
|
195
148
|
end
|
196
149
|
end
|
197
|
-
end
|
198
|
-
end
|
199
150
|
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
151
|
+
class Waiter
|
152
|
+
def initialize(tracker)
|
153
|
+
@tracker = tracker
|
154
|
+
end
|
204
155
|
|
205
|
-
|
206
|
-
|
156
|
+
def tracked_method
|
157
|
+
@tracker.wait_for_tracked_method
|
158
|
+
end
|
159
|
+
end
|
207
160
|
end
|
208
161
|
end
|
209
162
|
end
|
@@ -1,52 +1,56 @@
|
|
1
1
|
require File.dirname(__FILE__) + "/../../test_helper"
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
3
|
+
module DeepTest
|
4
|
+
module Distributed
|
5
|
+
unit_tests do
|
6
|
+
test "should strip off directories until file exists in base path" do
|
7
|
+
resolver = FilenameResolver.new("base_path")
|
6
8
|
|
7
|
-
|
8
|
-
|
9
|
-
|
9
|
+
File.expects(:exist?).with("base_path/a/b/c/d.rb").returns(false)
|
10
|
+
File.expects(:exist?).with("base_path/b/c/d.rb").returns(false)
|
11
|
+
File.expects(:exist?).with("base_path/c/d.rb").returns(true)
|
10
12
|
|
11
|
-
|
12
|
-
|
13
|
+
assert_equal "base_path/c/d.rb", resolver.resolve("/a/b/c/d.rb")
|
14
|
+
end
|
13
15
|
|
14
|
-
|
15
|
-
|
16
|
+
test "should resolve relative names starting at first element" do
|
17
|
+
resolver = FilenameResolver.new("base_path")
|
16
18
|
|
17
|
-
|
19
|
+
File.expects(:exist?).with("base_path/a/b/c/d.rb").returns(true)
|
18
20
|
|
19
|
-
|
20
|
-
|
21
|
+
assert_equal "base_path/a/b/c/d.rb", resolver.resolve("a/b/c/d.rb")
|
22
|
+
end
|
21
23
|
|
22
|
-
|
23
|
-
|
24
|
+
test "should resolve relative names the same each time" do
|
25
|
+
resolver = FilenameResolver.new("base_path")
|
24
26
|
|
25
|
-
|
27
|
+
File.expects(:exist?).with("base_path/a/b/c/d.rb").returns(true)
|
26
28
|
|
27
|
-
|
28
|
-
|
29
|
-
|
29
|
+
assert_equal "base_path/a/b/c/d.rb", resolver.resolve("a/b/c/d.rb")
|
30
|
+
assert_equal "base_path/a/b/c/d.rb", resolver.resolve("a/b/c/d.rb")
|
31
|
+
end
|
30
32
|
|
31
|
-
|
32
|
-
|
33
|
+
test "should raise exception if filename can't be resolved" do
|
34
|
+
resolver = FilenameResolver.new("base_path")
|
33
35
|
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
36
|
+
File.expects(:exist?).with("base_path/a/b/c/d.rb").returns(false)
|
37
|
+
File.expects(:exist?).with("base_path/b/c/d.rb").returns(false)
|
38
|
+
File.expects(:exist?).with("base_path/c/d.rb").returns(false)
|
39
|
+
File.expects(:exist?).with("base_path/d.rb").returns(false)
|
38
40
|
|
39
|
-
|
40
|
-
|
41
|
+
assert_raises(RuntimeError) { resolver.resolve("/a/b/c/d.rb") }
|
42
|
+
end
|
41
43
|
|
42
|
-
|
43
|
-
|
44
|
+
test "should remember how many directories to strip off after first resolution" do
|
45
|
+
resolver = FilenameResolver.new("base_path")
|
44
46
|
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
47
|
+
File.expects(:exist?).with("base_path/a/b/c/d.rb").returns(false)
|
48
|
+
File.expects(:exist?).with("base_path/b/c/d.rb").returns(true)
|
49
|
+
|
50
|
+
resolver.resolve("/a/b/c/d.rb")
|
49
51
|
|
50
|
-
|
52
|
+
assert_equal "base_path/x/y/z.rb", resolver.resolve("/a/x/y/z.rb")
|
53
|
+
end
|
54
|
+
end
|
51
55
|
end
|
52
56
|
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
require File.dirname(__FILE__) + "/../../test_helper"
|
2
|
+
|
3
|
+
module DeepTest
|
4
|
+
module Distributed
|
5
|
+
unit_tests do
|
6
|
+
test "push_code is invoked on all servers" do
|
7
|
+
server_1, server_2 = mock, mock
|
8
|
+
options = Options.new({:ui => "UI::Null"})
|
9
|
+
|
10
|
+
fleet = LandingFleet.new(options, [server_1, server_2])
|
11
|
+
|
12
|
+
server_1.expects(:push_code).with(options)
|
13
|
+
server_2.expects(:push_code).with(options)
|
14
|
+
|
15
|
+
fleet.push_code(options)
|
16
|
+
end
|
17
|
+
|
18
|
+
test "establish_beachhead is invoked on all server" do
|
19
|
+
server_1, server_2 = mock, mock
|
20
|
+
options = Options.new({:ui => "UI::Null"})
|
21
|
+
|
22
|
+
fleet = LandingFleet.new(options, [server_1, server_2])
|
23
|
+
|
24
|
+
server_1.expects(:establish_beachhead).with(options)
|
25
|
+
server_2.expects(:establish_beachhead).with(options)
|
26
|
+
|
27
|
+
fleet.establish_beachhead(options)
|
28
|
+
end
|
29
|
+
|
30
|
+
test "load_files is invoked on all server" do
|
31
|
+
server_1, server_2 = mock, mock
|
32
|
+
options = Options.new({:ui => "UI::Null"})
|
33
|
+
|
34
|
+
fleet = LandingFleet.new(options, [server_1, server_2])
|
35
|
+
|
36
|
+
server_1.expects(:load_files).with(['a'])
|
37
|
+
server_2.expects(:load_files).with(['a'])
|
38
|
+
|
39
|
+
fleet.load_files(['a'])
|
40
|
+
end
|
41
|
+
|
42
|
+
test "deploy_agents is invoked on all server" do
|
43
|
+
server_1, server_2 = mock, mock
|
44
|
+
options = Options.new({:ui => "UI::Null"})
|
45
|
+
|
46
|
+
fleet = LandingFleet.new(options, [server_1, server_2])
|
47
|
+
|
48
|
+
server_1.expects(:deploy_agents)
|
49
|
+
server_2.expects(:deploy_agents)
|
50
|
+
|
51
|
+
fleet.deploy_agents
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|