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.
Files changed (170) hide show
  1. data/.gitignore +1 -0
  2. data/README.rdoc +41 -70
  3. data/Rakefile +47 -119
  4. data/TODO +2 -2
  5. data/VERSION +1 -1
  6. data/infrastructure/dynamic_teardown.rb +22 -0
  7. data/{test → infrastructure}/fake_deadlock_error.rb +0 -0
  8. data/infrastructure/load.rb +11 -0
  9. data/infrastructure/test_central_command.rb +15 -0
  10. data/infrastructure/test_exception.rb +7 -0
  11. data/{test → infrastructure}/test_factory.rb +0 -0
  12. data/infrastructure/test_logger.rb +11 -0
  13. data/infrastructure/test_operator.rb +15 -0
  14. data/infrastructure/test_result.rb +15 -0
  15. data/infrastructure/thread_agent.rb +21 -0
  16. data/infrastructure/timewarp/Rakefile +14 -0
  17. data/infrastructure/timewarp/lib/timewarp.rb +21 -0
  18. data/infrastructure/timewarp/test/timewarp_test.rb +45 -0
  19. data/lib/deep_test.rb +28 -40
  20. data/lib/deep_test/agent.rb +108 -0
  21. data/lib/deep_test/central_command.rb +165 -0
  22. data/lib/deep_test/cpu_info.rb +22 -0
  23. data/lib/deep_test/database/mysql_setup_listener.rb +11 -12
  24. data/lib/deep_test/database/setup_listener.rb +23 -23
  25. data/lib/deep_test/demon.rb +25 -0
  26. data/lib/deep_test/distributed/beachhead.rb +104 -0
  27. data/lib/deep_test/distributed/dispatch_controller.rb +17 -10
  28. data/lib/deep_test/distributed/establish_beachhead.rb +19 -0
  29. data/lib/deep_test/distributed/landing_fleet.rb +30 -0
  30. data/lib/deep_test/distributed/landing_ship.rb +60 -0
  31. data/lib/deep_test/distributed/remote_deployment.rb +56 -0
  32. data/lib/deep_test/distributed/rsync.rb +25 -12
  33. data/lib/deep_test/distributed/shell_environment.rb +50 -0
  34. data/lib/deep_test/distributed/ssh_client_connection_info.rb +14 -0
  35. data/lib/deep_test/failure_message.rb +19 -0
  36. data/lib/deep_test/lib_root.rb +4 -0
  37. data/lib/deep_test/listener_list.rb +1 -1
  38. data/lib/deep_test/local_deployment.rb +46 -0
  39. data/lib/deep_test/logger.rb +17 -2
  40. data/lib/deep_test/main.rb +41 -0
  41. data/lib/deep_test/marshallable_exception_wrapper.rb +4 -4
  42. data/lib/deep_test/metrics/data.rb +34 -0
  43. data/lib/deep_test/metrics/measurement.rb +39 -0
  44. data/lib/deep_test/{null_worker_listener.rb → null_listener.rb} +14 -14
  45. data/lib/deep_test/options.rb +41 -56
  46. data/lib/deep_test/proxy_io.rb +77 -0
  47. data/lib/deep_test/rake_tasks.rb +3 -1
  48. data/lib/deep_test/result_reader.rb +10 -6
  49. data/lib/deep_test/rspec_detector.rb +1 -1
  50. data/lib/deep_test/spec.rb +5 -1
  51. data/lib/deep_test/spec/extensions/example_methods.rb +7 -1
  52. data/lib/deep_test/spec/extensions/spec_task.rb +3 -2
  53. data/lib/deep_test/spec/runner.rb +32 -17
  54. data/lib/deep_test/spec/work_result.rb +2 -0
  55. data/lib/deep_test/test/run_test_suite.rb +5 -0
  56. data/lib/deep_test/test/runner.rb +2 -2
  57. data/lib/deep_test/test/supervised_test_suite.rb +9 -10
  58. data/lib/deep_test/test/work_result.rb +1 -0
  59. data/lib/deep_test/test_task.rb +1 -1
  60. data/lib/deep_test/ui/console.rb +9 -11
  61. data/lib/deep_test/warlock.rb +37 -25
  62. data/lib/telegraph.rb +29 -0
  63. data/lib/telegraph/ack_sequence.rb +14 -0
  64. data/lib/telegraph/logging.rb +20 -0
  65. data/lib/telegraph/message.rb +39 -0
  66. data/lib/telegraph/operator.rb +47 -0
  67. data/lib/telegraph/switchboard.rb +57 -0
  68. data/lib/telegraph/wire.rb +73 -0
  69. data/negative_acceptance_tests/dying_spec.rb +13 -0
  70. data/negative_acceptance_tests/dying_test.rb +13 -0
  71. data/negative_acceptance_tests/failing_spec.rb +9 -0
  72. data/{test/failing.rb → negative_acceptance_tests/failing_test.rb} +3 -1
  73. data/negative_acceptance_tests/kill_agent_one_on_start_work.rb +16 -0
  74. data/negative_acceptance_tests/passing_spec.rb +10 -0
  75. data/negative_acceptance_tests/passing_test.rb +12 -0
  76. data/negative_acceptance_tests/tasks.rake +87 -0
  77. data/negative_acceptance_tests/tests.rb +60 -0
  78. data/sample_rails_project/deep_test.rb +4 -0
  79. data/sample_rails_project/lib/{foreign_host_worker_simulation_listener.rb → foreign_host_agent_simulation_listener.rb} +6 -4
  80. data/sample_rails_project/lib/tasks/deep_test.rake +13 -4
  81. data/spec/deep_test/options_spec.rb +80 -59
  82. data/spec/deep_test/spec/extensions/example_methods_spec.rb +5 -4
  83. data/spec/deep_test/spec/extensions/spec_task_spec.rb +4 -6
  84. data/spec/deep_test/spec/runner_spec.rb +59 -32
  85. data/spec/spec_helper.rb +14 -6
  86. data/test/deep_test/agent_test.rb +175 -0
  87. data/test/deep_test/central_command_test.rb +147 -0
  88. data/test/deep_test/cpu_info_test.rb +33 -0
  89. data/test/deep_test/database/mysql_setup_listener_test.rb +13 -9
  90. data/test/deep_test/demon_test.rb +23 -0
  91. data/test/deep_test/distributed/beachhead_test.rb +67 -0
  92. data/test/deep_test/distributed/dispatch_controller_test.rb +130 -177
  93. data/test/deep_test/distributed/filename_resolver_test.rb +38 -34
  94. data/test/deep_test/distributed/landing_fleet_test.rb +55 -0
  95. data/test/deep_test/distributed/landing_ship_test.rb +48 -0
  96. data/test/deep_test/distributed/remote_deployment_test.rb +134 -0
  97. data/test/deep_test/distributed/rsync_test.rb +42 -62
  98. data/test/deep_test/distributed/shell_environment_fixtures/set_bar_to_foo +1 -0
  99. data/test/deep_test/distributed/shell_environment_fixtures/set_foo_to_bar +1 -0
  100. data/test/deep_test/distributed/shell_environment_fixtures/set_foo_to_baz +1 -0
  101. data/test/deep_test/distributed/shell_environment_test.rb +108 -0
  102. data/test/deep_test/distributed/ssh_client_connection_info_test.rb +34 -0
  103. data/test/deep_test/listener_list_test.rb +17 -15
  104. data/test/deep_test/local_deployment_test.rb +19 -0
  105. data/test/deep_test/logger_test.rb +34 -7
  106. data/test/deep_test/main_test.rb +12 -0
  107. data/test/deep_test/marshallable_exception_wrapper_test.rb +31 -29
  108. data/test/deep_test/metrics/data_test.rb +22 -0
  109. data/test/deep_test/metrics/measurement_test.rb +18 -0
  110. data/test/deep_test/proxy_io_test.rb +104 -0
  111. data/test/deep_test/result_reader_test.rb +95 -95
  112. data/test/deep_test/test/extensions/error_test.rb +38 -36
  113. data/test/deep_test/test/runner_test.rb +7 -3
  114. data/test/deep_test/test/supervised_test_suite_test.rb +89 -61
  115. data/test/deep_test/test/work_result_test.rb +80 -76
  116. data/test/deep_test/test/work_unit_test.rb +53 -51
  117. data/test/deep_test/test_task_test.rb +10 -38
  118. data/test/deep_test/ui/console_test.rb +8 -4
  119. data/test/deep_test/warlock_test.rb +33 -31
  120. data/test/test_helper.rb +20 -5
  121. data/test/test_task_test.rb +60 -57
  122. metadata +94 -84
  123. data/bin/deep_test +0 -15
  124. data/jstorimer-deep-test-0.1.0.gem +0 -0
  125. data/jstorimer-deep-test.gemspec +0 -1425
  126. data/lib/deep_test/distributed/drb_client_connection_info.rb +0 -15
  127. data/lib/deep_test/distributed/master_test_server.rb +0 -52
  128. data/lib/deep_test/distributed/multi_test_server_proxy.rb +0 -44
  129. data/lib/deep_test/distributed/null_work_unit.rb +0 -12
  130. data/lib/deep_test/distributed/remote_worker_client.rb +0 -54
  131. data/lib/deep_test/distributed/remote_worker_server.rb +0 -82
  132. data/lib/deep_test/distributed/show_status.rhtml +0 -41
  133. data/lib/deep_test/distributed/test_server.rb +0 -78
  134. data/lib/deep_test/distributed/test_server_status.rb +0 -9
  135. data/lib/deep_test/distributed/test_server_workers.rb +0 -24
  136. data/lib/deep_test/distributed/throughput_runner.rb +0 -42
  137. data/lib/deep_test/distributed/throughput_statistics.rb +0 -26
  138. data/lib/deep_test/distributed/throughput_worker_client.rb +0 -19
  139. data/lib/deep_test/extensions/drb_extension.rb +0 -34
  140. data/lib/deep_test/local_workers.rb +0 -55
  141. data/lib/deep_test/metrics/gatherer.rb +0 -67
  142. data/lib/deep_test/metrics/queue_lock_wait_time_measurement.rb +0 -133
  143. data/lib/deep_test/option.rb +0 -60
  144. data/lib/deep_test/process_orchestrator.rb +0 -49
  145. data/lib/deep_test/server.rb +0 -75
  146. data/lib/deep_test/spec/extensions/reporter.rb +0 -29
  147. data/lib/deep_test/worker.rb +0 -57
  148. data/script/internal/run_test_suite.rb +0 -7
  149. data/script/public/master_test_server.rb +0 -24
  150. data/script/public/test_server.rb +0 -18
  151. data/script/public/test_throughput.rb +0 -29
  152. data/spec/deep_test/option_spec.rb +0 -33
  153. data/spec/thread_worker.rb +0 -25
  154. data/test/deep_test/distributed/drb_client_connection_info_test.rb +0 -42
  155. data/test/deep_test/distributed/master_test_server_test.rb +0 -32
  156. data/test/deep_test/distributed/multi_test_server_proxy_test.rb +0 -96
  157. data/test/deep_test/distributed/remote_worker_client_test.rb +0 -180
  158. data/test/deep_test/distributed/remote_worker_server_test.rb +0 -99
  159. data/test/deep_test/distributed/test_server_test.rb +0 -94
  160. data/test/deep_test/distributed/test_server_workers_test.rb +0 -26
  161. data/test/deep_test/distributed/throughput_runner_test.rb +0 -68
  162. data/test/deep_test/distributed/throughput_worker_client_test.rb +0 -28
  163. data/test/deep_test/local_workers_test.rb +0 -22
  164. data/test/deep_test/metrics/gatherer_test.rb +0 -66
  165. data/test/deep_test/process_orchestrator_test.rb +0 -11
  166. data/test/deep_test/server_test.rb +0 -58
  167. data/test/deep_test/worker_test.rb +0 -94
  168. data/test/failing.rake +0 -11
  169. data/test/simple_test_blackboard.rb +0 -45
  170. data/test/simple_test_blackboard_test.rb +0 -33
@@ -1,209 +1,162 @@
1
1
  require File.dirname(__FILE__) + "/../../test_helper"
2
2
 
3
- unit_tests do
4
- test "dispatch invokes each receiver once" do
5
- receiver_1, receiver_2 = mock, mock
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
- controller = DeepTest::Distributed::DispatchController.new(
8
- DeepTest::Options.new({:ui => "DeepTest::UI::Null"}),
9
- [receiver_1, receiver_2]
10
- )
9
+ controller = DispatchController.new(
10
+ Options.new({:ui => "UI::Null"}),
11
+ [receiver_1, receiver_2]
12
+ )
11
13
 
12
- receiver_1.expects(:a_method).with(:args)
13
- receiver_2.expects(:a_method).with(:args)
14
+ receiver_1.expects(:a_method).with(:args)
15
+ receiver_2.expects(:a_method).with(:args)
14
16
 
15
- controller.dispatch(:a_method, :args)
16
- end
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
- test "after timeout, no further calls are sent to that receiver" do
69
- receiver_1, receiver_2 = mock(:__drburi => ""), mock
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
- receiver_2.expects(:method_call_1)
74
- receiver_2.expects(:method_call_2)
23
+ controller = DispatchController.new(
24
+ Options.new({:ui => "UI::Null"}),
25
+ [receiver_1, receiver_2]
26
+ )
75
27
 
76
- controller = DeepTest::Distributed::DispatchController.new(
77
- DeepTest::Options.new({:ui => "DeepTest::UI::Null", :timeout_in_seconds => 0.05}),
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
- DeepTest.logger.expects(:error)
82
-
83
- controller.dispatch(:method_call_1)
84
- controller.dispatch(:method_call_2)
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
- receiver_2.expects(:method_call_1).returns(:value)
93
- receiver_2.expects(:method_call_2)
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
- controller = DeepTest::Distributed::DispatchController.new(
96
- DeepTest::Options.new({:ui => "DeepTest::UI::Null", :timeout_in_seconds => 0.05}),
97
- [receiver_1, receiver_2]
98
- )
40
+ Timeout.timeout(1) do
41
+ DispatchController.new(options,[tracker, waiter]).
42
+ dispatch(:tracked_method)
43
+ end
99
44
 
100
- DeepTest.logger.expects(:error)
101
-
102
- assert_equal [:value], controller.dispatch(:method_call_1)
45
+ waiter = Waiter.new(tracker = Tracker.new)
103
46
 
104
- controller.dispatch(:method_call_2)
105
- end
106
-
107
- test "receiver is dropped when any exception occurs" do
108
- receiver = mock(:__drburi => "")
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
- test "no error is printed if dispatching without error" do
123
- receiver_1 = mock
124
- receiver_1.expects(:method_call_1).raises(DRb::DRbConnError)
53
+ test "receiver is dropped when any exception occurs" do
54
+ receiver = mock
55
+ receiver.expects(:method_call).raises(Exception)
125
56
 
126
- controller = DeepTest::Distributed::DispatchController.new(
127
- DeepTest::Options.new({:ui => "DeepTest::UI::Null", :timeout_in_seconds => 0.05}),
128
- [receiver_1]
129
- )
57
+ controller = DispatchController.new(
58
+ Options.new({:ui => "UI::Null"}),
59
+ [receiver]
60
+ )
130
61
 
131
- DeepTest.logger.expects(:error).never
62
+ controller.dispatch(:method_call)
63
+ assert_raises(NoDispatchReceiversError) {controller.dispatch(:another_call)}
64
+ end
132
65
 
133
- controller.dispatch_with_options(:method_call_1, :ignore_connection_error => true)
134
- end
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
- test "dispatch calls notifies ui of start and stop of dispatch" do
137
- options = DeepTest::Options.new({:ui => "DeepTest::UI::Null"})
138
- controller = DeepTest::Distributed::DispatchController.new(
139
- options, [stub_everything]
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
- options.ui_instance.expects(:dispatch_starting).with(:method_name)
143
- options.ui_instance.expects(:dispatch_finished).with(:method_name)
144
-
145
- controller.dispatch(:method_name)
146
- end
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
- test "dispatch calls notifies ui dispatch end in case of an error" do
149
- options = DeepTest::Options.new({:ui => "DeepTest::UI::Null"})
150
- controller = DeepTest::Distributed::DispatchController.new(
151
- options, [receiver = mock(:__drburi => '')]
152
- )
153
- receiver.expects(:method_name).raises("An Error")
154
- DeepTest.logger.expects(:error)
155
-
156
- options.ui_instance.expects(:dispatch_starting).with(:method_name)
157
- options.ui_instance.expects(:dispatch_finished).with(:method_name)
158
-
159
- begin
160
- controller.dispatch(:method_name)
161
- rescue RuntimeError => e
162
- raise unless e.message == "An Error"
163
- end
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
- test "error is raised if dispatch to no receivers in attempted" do
167
- options = DeepTest::Options.new({:ui => "DeepTest::UI::Null"})
168
- controller = DeepTest::Distributed::DispatchController.new(
169
- options, []
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
- assert_raises(DeepTest::Distributed::NoDispatchReceiversError) do
173
- controller.dispatch(:any_method)
174
- end
175
- end
123
+ assert_raises(NoDispatchReceiversError) do
124
+ controller.dispatch(:any_method)
125
+ end
126
+ end
176
127
 
177
- class Tracker
178
- def initialize
179
- @mutex = Mutex.new
180
- @condvar = ConditionVariable.new
181
- end
128
+ class Tracker
129
+ def initialize
130
+ @mutex = Mutex.new
131
+ @condvar = ConditionVariable.new
132
+ end
182
133
 
183
- def tracked_method
184
- @mutex.synchronize do
185
- @tracked_method_called = true
186
- @condvar.broadcast
187
- end
188
- end
134
+ def tracked_method
135
+ @mutex.synchronize do
136
+ @tracked_method_called = true
137
+ @condvar.broadcast
138
+ end
139
+ end
189
140
 
190
- def wait_for_tracked_method
191
- @mutex.synchronize do
192
- loop do
193
- return if @tracked_method_called
194
- @condvar.wait(@mutex)
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
- class Waiter
201
- def initialize(tracker)
202
- @tracker = tracker
203
- end
151
+ class Waiter
152
+ def initialize(tracker)
153
+ @tracker = tracker
154
+ end
204
155
 
205
- def tracked_method
206
- @tracker.wait_for_tracked_method
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
- unit_tests do
4
- test "should strip off directories until file exists in base path" do
5
- resolver = DeepTest::Distributed::FilenameResolver.new("base_path")
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
- 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)
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
- assert_equal "base_path/c/d.rb", resolver.resolve("/a/b/c/d.rb")
12
- end
13
+ assert_equal "base_path/c/d.rb", resolver.resolve("/a/b/c/d.rb")
14
+ end
13
15
 
14
- test "should resolve relative names starting at first element" do
15
- resolver = DeepTest::Distributed::FilenameResolver.new("base_path")
16
+ test "should resolve relative names starting at first element" do
17
+ resolver = FilenameResolver.new("base_path")
16
18
 
17
- File.expects(:exist?).with("base_path/a/b/c/d.rb").returns(true)
19
+ File.expects(:exist?).with("base_path/a/b/c/d.rb").returns(true)
18
20
 
19
- assert_equal "base_path/a/b/c/d.rb", resolver.resolve("a/b/c/d.rb")
20
- end
21
+ assert_equal "base_path/a/b/c/d.rb", resolver.resolve("a/b/c/d.rb")
22
+ end
21
23
 
22
- test "should resolve relative names the same each time" do
23
- resolver = DeepTest::Distributed::FilenameResolver.new("base_path")
24
+ test "should resolve relative names the same each time" do
25
+ resolver = FilenameResolver.new("base_path")
24
26
 
25
- File.expects(:exist?).with("base_path/a/b/c/d.rb").returns(true)
27
+ File.expects(:exist?).with("base_path/a/b/c/d.rb").returns(true)
26
28
 
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
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
- test "should raise exception if filename can't be resolved" do
32
- resolver = DeepTest::Distributed::FilenameResolver.new("base_path")
33
+ test "should raise exception if filename can't be resolved" do
34
+ resolver = FilenameResolver.new("base_path")
33
35
 
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)
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
- assert_raises(RuntimeError) { resolver.resolve("/a/b/c/d.rb") }
40
- end
41
+ assert_raises(RuntimeError) { resolver.resolve("/a/b/c/d.rb") }
42
+ end
41
43
 
42
- test "should remember how many directories to strip off after first resolution" do
43
- resolver = DeepTest::Distributed::FilenameResolver.new("base_path")
44
+ test "should remember how many directories to strip off after first resolution" do
45
+ resolver = FilenameResolver.new("base_path")
44
46
 
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")
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
- assert_equal "base_path/x/y/z.rb", resolver.resolve("/a/x/y/z.rb")
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