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,60 +0,0 @@
|
|
1
|
-
require 'rubygems'
|
2
|
-
require 'test/unit'
|
3
|
-
require 'dust'
|
4
|
-
require 'timeout'
|
5
|
-
|
6
|
-
unit_tests do
|
7
|
-
[:test, :spec].each do |framework|
|
8
|
-
test "#{framework}: DeepTest a failing test results in failure" do
|
9
|
-
result, output = run_rake framework, :failing
|
10
|
-
assert_equal false, result.success?, output
|
11
|
-
end
|
12
|
-
|
13
|
-
test "#{framework}: Distributed DeepTest with failover to local" do
|
14
|
-
result, output = run_rake framework, :failover_to_local
|
15
|
-
assert_equal true, result.success?, output
|
16
|
-
assert_match /RSync Failed!!/, output
|
17
|
-
assert_match /Failing over to local run/, output
|
18
|
-
end
|
19
|
-
|
20
|
-
test "#{framework}: Distributed DeepTest with a host down" do
|
21
|
-
result, output = run_rake framework, :just_one_with_host_down
|
22
|
-
assert_equal true, result.success?, output
|
23
|
-
assert_match /RSync Failed!!/, output
|
24
|
-
assert_no_match /Failing over to local run/, output
|
25
|
-
end
|
26
|
-
|
27
|
-
test "#{framework}: DeepTest with agents that die" do
|
28
|
-
result, output = run_rake framework, :with_agents_dying
|
29
|
-
assert_equal false, result.success?, output
|
30
|
-
assert_match /DeepTest Agents Are Not Running/, output
|
31
|
-
assert_match /DeepTest::IncompleteTestRunError.*100 tests were not run because the DeepTest Agents died/m, output
|
32
|
-
end
|
33
|
-
|
34
|
-
test "#{framework}: DeepTest processes go away after the test run ends" do
|
35
|
-
Timeout.timeout(15) { run_rake framework, :passing }
|
36
|
-
end
|
37
|
-
|
38
|
-
test "#{framework}: DeepTest with work taken and not done" do
|
39
|
-
result, output = run_rake framework, :with_work_taken_and_not_done
|
40
|
-
assert_equal true, result.success?, output
|
41
|
-
end
|
42
|
-
|
43
|
-
test "#{framework}: DeepTest with metrics" do
|
44
|
-
FileUtils.rm_f "negative_acceptance_tests/metrics.data"
|
45
|
-
result, output = run_rake framework, :with_metrics
|
46
|
-
assert_equal true, result.success?, output
|
47
|
-
metrics = File.read("negative_acceptance_tests/metrics.data")
|
48
|
-
assert_match /Metrics Data/, metrics
|
49
|
-
assert_match /Agents Performing Work:/, metrics
|
50
|
-
assert_match /Agents Retrieving Work:/, metrics
|
51
|
-
end
|
52
|
-
end
|
53
|
-
|
54
|
-
def run_rake(framework, task)
|
55
|
-
command = "rake --rakefile #{File.dirname(__FILE__)}/tasks.rake deep_#{framework}_#{task} 2>&1"
|
56
|
-
output = `#{command}`.map {|l| "[rake deep_#{framework}_#{task}] #{l}" }.join
|
57
|
-
return $?, output
|
58
|
-
end
|
59
|
-
|
60
|
-
end
|
@@ -1,175 +0,0 @@
|
|
1
|
-
require File.dirname(__FILE__) + "/../test_helper"
|
2
|
-
|
3
|
-
module DeepTest
|
4
|
-
unit_tests do
|
5
|
-
test "puts result on central_command with acknowledgement of work" do
|
6
|
-
options = Options.new({})
|
7
|
-
central_command = TestCentralCommand.start options
|
8
|
-
central_command.write_work Test::WorkUnit.new(TestFactory.passing_test)
|
9
|
-
central_command.done_with_work
|
10
|
-
|
11
|
-
Agent.new(0, options, stub_everything).execute(StringIO.new, StringIO.new)
|
12
|
-
|
13
|
-
assert_equal [], central_command.switchboard.live_wires.first.unacked_messages
|
14
|
-
assert_kind_of ::Test::Unit::TestResult, central_command.take_result
|
15
|
-
end
|
16
|
-
|
17
|
-
test "puts passing and failing tests on central_command for each test" do
|
18
|
-
options = Options.new({})
|
19
|
-
central_command = TestCentralCommand.start options
|
20
|
-
central_command.write_work Test::WorkUnit.new(TestFactory.passing_test)
|
21
|
-
central_command.write_work Test::WorkUnit.new(TestFactory.failing_test)
|
22
|
-
central_command.done_with_work
|
23
|
-
|
24
|
-
Agent.new(0, options, stub_everything).execute(StringIO.new, StringIO.new)
|
25
|
-
|
26
|
-
result_1 = central_command.take_result
|
27
|
-
result_2 = central_command.take_result
|
28
|
-
|
29
|
-
assert_equal true, (result_1.passed? || result_2.passed?)
|
30
|
-
assert_equal false, (result_1.passed? && result_2.passed?)
|
31
|
-
end
|
32
|
-
|
33
|
-
test "notifies listener that it is starting" do
|
34
|
-
options = Options.new({})
|
35
|
-
central_command = TestCentralCommand.start options
|
36
|
-
central_command.done_with_work
|
37
|
-
listener = stub_everything
|
38
|
-
agent = Agent.new(0, options, listener)
|
39
|
-
listener.expects(:starting).with(agent)
|
40
|
-
agent.execute(StringIO.new, StringIO.new)
|
41
|
-
end
|
42
|
-
|
43
|
-
test "notifies listener that it is about to do work" do
|
44
|
-
options = Options.new({})
|
45
|
-
central_command = TestCentralCommand.start options
|
46
|
-
work_unit = Test::WorkUnit.new(TestFactory.passing_test)
|
47
|
-
central_command.write_work work_unit
|
48
|
-
central_command.done_with_work
|
49
|
-
listener = stub_everything
|
50
|
-
agent = Agent.new(0, options, listener)
|
51
|
-
listener.expects(:starting_work).with(agent, work_unit)
|
52
|
-
agent.execute(StringIO.new, StringIO.new)
|
53
|
-
end
|
54
|
-
|
55
|
-
test "notifies listener that it has done work" do
|
56
|
-
options = Options.new({})
|
57
|
-
central_command = TestCentralCommand.start(options)
|
58
|
-
work_unit = ResultWorkUnit.new(:result)
|
59
|
-
central_command.write_work work_unit
|
60
|
-
central_command.done_with_work
|
61
|
-
listener = stub_everything
|
62
|
-
agent = Agent.new(0, options, listener)
|
63
|
-
listener.expects(:finished_work).with(agent, work_unit, TestResult.new(:result))
|
64
|
-
agent.execute(StringIO.new, StringIO.new)
|
65
|
-
end
|
66
|
-
|
67
|
-
test "connect indicates it has connected" do
|
68
|
-
options = Options.new({})
|
69
|
-
central_command = TestCentralCommand.start(options)
|
70
|
-
agent = Agent.new(0, options, stub_everything)
|
71
|
-
yielded = false
|
72
|
-
agent.connect(io = StringIO.new) do
|
73
|
-
yielded = true
|
74
|
-
assert_equal "Connected\n", io.string
|
75
|
-
assert_equal true, io.closed?
|
76
|
-
end
|
77
|
-
assert yielded, "connect didn't yield"
|
78
|
-
end
|
79
|
-
|
80
|
-
test "connect closes stream even if there is an error" do
|
81
|
-
options = Options.new({})
|
82
|
-
agent = Agent.new(0, options, stub_everything)
|
83
|
-
io = StringIO.new
|
84
|
-
assert_raises(Errno::EADDRNOTAVAIL) { agent.connect io }
|
85
|
-
assert_equal true, io.closed?
|
86
|
-
end
|
87
|
-
|
88
|
-
class ResultWorkUnit
|
89
|
-
attr_reader :result
|
90
|
-
|
91
|
-
def initialize(result)
|
92
|
-
@result = result
|
93
|
-
end
|
94
|
-
|
95
|
-
def run
|
96
|
-
TestResult.new(result)
|
97
|
-
end
|
98
|
-
|
99
|
-
def ==(other)
|
100
|
-
other.class == self.class && other.result == result
|
101
|
-
end
|
102
|
-
end
|
103
|
-
|
104
|
-
class ErrorWorkUnit
|
105
|
-
attr_reader :exception
|
106
|
-
|
107
|
-
def initialize(exception)
|
108
|
-
@exception = exception
|
109
|
-
end
|
110
|
-
|
111
|
-
def run
|
112
|
-
raise @exception
|
113
|
-
end
|
114
|
-
|
115
|
-
def ==(other)
|
116
|
-
other.class == self.class && other.exception == exception
|
117
|
-
end
|
118
|
-
end
|
119
|
-
|
120
|
-
test "exception raised by work unit gives in Agent::Error" do
|
121
|
-
options = Options.new({})
|
122
|
-
central_command = TestCentralCommand.start options
|
123
|
-
work_unit = ErrorWorkUnit.new(exception = TestException.new)
|
124
|
-
central_command.write_work work_unit
|
125
|
-
central_command.done_with_work
|
126
|
-
|
127
|
-
Agent.new(0, options, stub_everything).execute(StringIO.new, StringIO.new)
|
128
|
-
|
129
|
-
assert_equal Agent::Error.new(work_unit, exception), central_command.take_result
|
130
|
-
end
|
131
|
-
|
132
|
-
test "Agent::Error can marshal itself even if the contents are not marshallable" do
|
133
|
-
o = Object.new
|
134
|
-
def o._dump; raise "error"; end
|
135
|
-
|
136
|
-
error = Agent::Error.new o, Exception.new("my error")
|
137
|
-
error_through_marshalling = Marshal.load Marshal.dump(error)
|
138
|
-
assert_equal Exception, error_through_marshalling.error.class
|
139
|
-
assert_equal "my error", error_through_marshalling.error.message
|
140
|
-
assert_equal "<< Undumpable >>", error_through_marshalling.work_unit
|
141
|
-
end
|
142
|
-
|
143
|
-
test "requests work until it finds some" do
|
144
|
-
options = Options.new({})
|
145
|
-
central_command = TestCentralCommand.start(options)
|
146
|
-
|
147
|
-
t = Thread.new { Agent.new(0, options, stub_everything).execute(StringIO.new, StringIO.new) }
|
148
|
-
Thread.pass
|
149
|
-
central_command.write_work stub(:run => TestResult.new(:result))
|
150
|
-
central_command.done_with_work
|
151
|
-
t.join
|
152
|
-
assert_equal TestResult.new(:result), central_command.take_result
|
153
|
-
end
|
154
|
-
|
155
|
-
test "finish running if a connection error is received" do
|
156
|
-
options = Options.new({})
|
157
|
-
central_command = TestCentralCommand.start(options)
|
158
|
-
begin
|
159
|
-
t = Thread.new { Agent.new(0, options, stub_everything).execute(StringIO.new, StringIO.new) }
|
160
|
-
sleep 0.1
|
161
|
-
ensure
|
162
|
-
central_command.stop
|
163
|
-
end
|
164
|
-
t.join
|
165
|
-
end
|
166
|
-
|
167
|
-
test "number is available to indentify agent" do
|
168
|
-
assert_equal 1, Agent.new(1, Options.new({}), nil).number
|
169
|
-
end
|
170
|
-
|
171
|
-
test "does not fork from rake" do
|
172
|
-
assert !defined?($rakefile)
|
173
|
-
end
|
174
|
-
end
|
175
|
-
end
|
@@ -1,147 +0,0 @@
|
|
1
|
-
require File.dirname(__FILE__) + "/../test_helper"
|
2
|
-
|
3
|
-
module DeepTest
|
4
|
-
unit_tests do
|
5
|
-
test "take_work returns result of push_work when it is available" do
|
6
|
-
central_command = CentralCommand.new Options.new({})
|
7
|
-
central_command.write_work :work
|
8
|
-
assert_equal :work, central_command.take_work
|
9
|
-
end
|
10
|
-
|
11
|
-
test "take_work raises error when no work is currently available" do
|
12
|
-
assert_raises(CentralCommand::NoWorkUnitsAvailableError) do
|
13
|
-
CentralCommand.new(Options.new({})).take_work
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
|
-
test "take_work raises error when there is no work left to" do
|
18
|
-
central_command = CentralCommand.new Options.new({})
|
19
|
-
central_command.done_with_work
|
20
|
-
|
21
|
-
assert_raises(CentralCommand::NoWorkUnitsRemainingError) do
|
22
|
-
central_command.take_work
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
test "take_result raises NoAgentsRunningError if agents are connected" do
|
27
|
-
central_command = CentralCommand.start Options.new({})
|
28
|
-
DynamicTeardown.on_teardown { central_command.stop }
|
29
|
-
assert_raises(CentralCommand::NoAgentsRunningError) {central_command.take_result}
|
30
|
-
end
|
31
|
-
|
32
|
-
test "start returns instance of central_command" do
|
33
|
-
central_command = CentralCommand.start Options.new({})
|
34
|
-
DynamicTeardown.on_teardown { central_command.stop }
|
35
|
-
assert_kind_of CentralCommand, central_command
|
36
|
-
end
|
37
|
-
|
38
|
-
test "after starting CentralCommand responds to NeedWork messages by supplying new units of work" do
|
39
|
-
central_command = CentralCommand.start(options = Options.new({}))
|
40
|
-
DynamicTeardown.on_teardown { central_command.stop }
|
41
|
-
central_command.write_work(:a)
|
42
|
-
central_command.write_work(:b)
|
43
|
-
central_command.write_work(:c)
|
44
|
-
|
45
|
-
wire = Telegraph::Wire.connect("localhost", options.server_port)
|
46
|
-
[:a, :b, :c].each do |work_unit|
|
47
|
-
Thread.pass
|
48
|
-
wire.send_message CentralCommand::NeedWork
|
49
|
-
assert_equal work_unit, wire.next_message(:timeout => 2.0).body
|
50
|
-
end
|
51
|
-
end
|
52
|
-
|
53
|
-
test "after starting CentralCommand responds to Result messages adding results to the queue" do
|
54
|
-
central_command = CentralCommand.start(options = Options.new({}))
|
55
|
-
DynamicTeardown.on_teardown { central_command.stop }
|
56
|
-
wire = Telegraph::Wire.connect("localhost", options.server_port)
|
57
|
-
result_1, result_2, result_3 = TestResult.new(1), TestResult.new(2), TestResult.new(3)
|
58
|
-
|
59
|
-
[result_1, result_2, result_3].each do |result|
|
60
|
-
wire.send_message result
|
61
|
-
end
|
62
|
-
|
63
|
-
assert_equal result_1, central_command.take_result
|
64
|
-
assert_equal result_2, central_command.take_result
|
65
|
-
assert_equal result_3, central_command.take_result
|
66
|
-
end
|
67
|
-
|
68
|
-
test "after starting CentralCommand responds to Result by supplying a new unit of work" do
|
69
|
-
central_command = CentralCommand.start(options = Options.new({}))
|
70
|
-
DynamicTeardown.on_teardown { central_command.stop }
|
71
|
-
central_command.write_work(:a)
|
72
|
-
central_command.write_work(:b)
|
73
|
-
central_command.write_work(:c)
|
74
|
-
|
75
|
-
wire = Telegraph::Wire.connect("localhost", options.server_port)
|
76
|
-
result_1, result_2, result_3 = TestResult.new(1), TestResult.new(2), TestResult.new(3)
|
77
|
-
[[result_1, :a], [result_2, :b], [result_3, :c]].each do |result, work_unit|
|
78
|
-
Thread.pass
|
79
|
-
wire.send_message result_1
|
80
|
-
assert_equal work_unit, wire.next_message(:timeout => 2.0).body
|
81
|
-
end
|
82
|
-
end
|
83
|
-
|
84
|
-
test "will add results to queue with a worker waiting for work that is not available" do
|
85
|
-
central_command = CentralCommand.start(options = Options.new({}))
|
86
|
-
DynamicTeardown.on_teardown { central_command.stop }
|
87
|
-
|
88
|
-
Telegraph::Wire.connect("localhost", options.server_port) do |wire|
|
89
|
-
wire.send_message CentralCommand::NeedWork
|
90
|
-
wire.send_message TestResult.new(1)
|
91
|
-
end
|
92
|
-
|
93
|
-
assert_equal TestResult.new(1), central_command.take_result
|
94
|
-
end
|
95
|
-
|
96
|
-
test "will distribute work units that have not received results from dead workers when other work runs out" do
|
97
|
-
central_command = CentralCommand.start(options = Options.new({}))
|
98
|
-
DynamicTeardown.on_teardown { central_command.stop }
|
99
|
-
|
100
|
-
central_command.write_work(:a)
|
101
|
-
|
102
|
-
Telegraph::Wire.connect("localhost", options.server_port) do |wire|
|
103
|
-
wire.send_message CentralCommand::NeedWork
|
104
|
-
assert_equal :a, wire.next_message(:timeout => 1).body
|
105
|
-
end
|
106
|
-
|
107
|
-
Telegraph::Wire.connect("localhost", options.server_port) do |wire|
|
108
|
-
wire.send_message CentralCommand::NeedWork
|
109
|
-
assert_equal :a, wire.next_message(:timeout => 1).body
|
110
|
-
end
|
111
|
-
end
|
112
|
-
|
113
|
-
test "will add measurements to data when received over the wire" do
|
114
|
-
central_command = CentralCommand.start(options = Options.new({}))
|
115
|
-
DynamicTeardown.on_teardown { central_command.stop }
|
116
|
-
|
117
|
-
Telegraph::Wire.connect("localhost", options.server_port) do |wire|
|
118
|
-
wire.send_message Metrics::Measurement.new("category", 1, "units")
|
119
|
-
end
|
120
|
-
|
121
|
-
sleep 0.05
|
122
|
-
|
123
|
-
assert_match /category: 1.0 avg/, central_command.data.summary
|
124
|
-
end
|
125
|
-
|
126
|
-
class SetCalledGlobalToTrue
|
127
|
-
include CentralCommand::Operation
|
128
|
-
def execute; $called = true; end
|
129
|
-
end
|
130
|
-
|
131
|
-
test "will execute Operations read from the wire" do
|
132
|
-
$called = false
|
133
|
-
DynamicTeardown.on_teardown { $called = nil }
|
134
|
-
central_command = CentralCommand.start(options = Options.new({}))
|
135
|
-
DynamicTeardown.on_teardown { central_command.stop }
|
136
|
-
wire = Telegraph::Wire.connect("localhost", options.server_port)
|
137
|
-
wire.send_message SetCalledGlobalToTrue.new
|
138
|
-
|
139
|
-
Timeout.timeout(2) do
|
140
|
-
loop do
|
141
|
-
break if $called
|
142
|
-
sleep 0.25
|
143
|
-
end
|
144
|
-
end
|
145
|
-
end
|
146
|
-
end
|
147
|
-
end
|
@@ -1,33 +0,0 @@
|
|
1
|
-
require File.dirname(__FILE__) + "/../test_helper"
|
2
|
-
|
3
|
-
module DeepTest
|
4
|
-
unit_tests do
|
5
|
-
test "count parses sysctl output on darwin" do
|
6
|
-
cpu_info = CpuInfo.new("foodarwinbar")
|
7
|
-
cpu_info.expects(:`).with("sysctl -n hw.ncpu").returns("2\n")
|
8
|
-
assert_equal 2, cpu_info.count
|
9
|
-
end
|
10
|
-
|
11
|
-
test "count parses /proc/cpuinfo on linux" do
|
12
|
-
cpu_info = CpuInfo.new("foolinuxbar")
|
13
|
-
File.expects(:readlines).with("/proc/cpuinfo").returns [
|
14
|
-
"processor : 0",
|
15
|
-
"vendor_id : GenuineIntel",
|
16
|
-
"cpu family : 6",
|
17
|
-
"",
|
18
|
-
"processor : 1",
|
19
|
-
"vendor_id : GenuineIntel",
|
20
|
-
"cpu family : 6",
|
21
|
-
]
|
22
|
-
assert_equal 2, cpu_info.count
|
23
|
-
end
|
24
|
-
|
25
|
-
test "count returns nil on other platforms" do
|
26
|
-
assert_equal nil, CpuInfo.new("foobar").count
|
27
|
-
end
|
28
|
-
|
29
|
-
test "platform defaults to the current ruby_platform" do
|
30
|
-
assert_equal RUBY_PLATFORM, CpuInfo.new.platform
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|
@@ -1,23 +0,0 @@
|
|
1
|
-
require File.dirname(__FILE__) + '/../test_helper'
|
2
|
-
|
3
|
-
module DeepTest
|
4
|
-
unit_tests do
|
5
|
-
class ProcDemon
|
6
|
-
include Demon
|
7
|
-
def initialize(block); @block = block; end
|
8
|
-
def execute; @block.call; end
|
9
|
-
end
|
10
|
-
|
11
|
-
test "forked redirects output back to central command" do
|
12
|
-
options = Options.new({})
|
13
|
-
operator = TestOperator.listen(options)
|
14
|
-
ProcDemon.new(proc do
|
15
|
-
puts "hello stdout"
|
16
|
-
end).forked("name", options, [])
|
17
|
-
|
18
|
-
assert_equal ProxyIO::Stdout::Output.new("hello stdout"), operator.next_message[0].body
|
19
|
-
assert_equal ProxyIO::Stdout::Output.new("\n"), operator.next_message[0].body
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
@@ -1,67 +0,0 @@
|
|
1
|
-
require File.dirname(__FILE__) + "/../../test_helper"
|
2
|
-
|
3
|
-
module DeepTest
|
4
|
-
module Distributed
|
5
|
-
unit_tests do
|
6
|
-
test "load_files loads each file in list, resolving each filename with resolver" do
|
7
|
-
FilenameResolver.expects(:new).with("/mirror/dir").returns(resolver = mock)
|
8
|
-
|
9
|
-
beachhead = Beachhead.new "/mirror/dir", Options.new({})
|
10
|
-
|
11
|
-
resolver.expects(:resolve).with("/source/path/my/file.rb").returns("/mirror/dir/my/file.rb")
|
12
|
-
beachhead.expects(:load).with("/mirror/dir/my/file.rb")
|
13
|
-
Dir.expects(:chdir).with("/mirror/dir")
|
14
|
-
|
15
|
-
beachhead.load_files(["/source/path/my/file.rb"])
|
16
|
-
end
|
17
|
-
|
18
|
-
test "service is removed after grace period if agents have not been started" do
|
19
|
-
options = Options.new({:number_of_agents => 0})
|
20
|
-
TestCentralCommand.start options
|
21
|
-
begin
|
22
|
-
beachhead = Beachhead.new "", options
|
23
|
-
beachhead.daemonize(0.25)
|
24
|
-
# Have to sleep long enough to warlock to reap dead process
|
25
|
-
sleep 2.0
|
26
|
-
assert_equal 0, beachhead.warlock.demon_count
|
27
|
-
ensure
|
28
|
-
beachhead.warlock.stop_demons
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
test "service is not removed after grace period if agents have been started" do
|
33
|
-
options = Options.new({:number_of_agents => 0})
|
34
|
-
TestCentralCommand.start options
|
35
|
-
begin
|
36
|
-
beachhead = Beachhead.new "", options
|
37
|
-
# Since we're not actually starting agents, we don't want to exit when none are running for this test
|
38
|
-
beachhead.warlock.stubs(:exit_when_none_running)
|
39
|
-
port = beachhead.daemonize(0.25)
|
40
|
-
Telegraph::Wire.connect("localhost", port).send_message Beachhead::DeployAgents
|
41
|
-
# Have to sleep long enough to warlock to reap dead process
|
42
|
-
sleep 1.0
|
43
|
-
assert_equal 1, beachhead.warlock.demon_count
|
44
|
-
ensure
|
45
|
-
beachhead.warlock.stop_demons
|
46
|
-
end
|
47
|
-
end
|
48
|
-
|
49
|
-
test "responds with Done after receiving LoadFiles and DeployAgents" do
|
50
|
-
options = Options.new({:number_of_agents => 0})
|
51
|
-
TestCentralCommand.start options
|
52
|
-
begin
|
53
|
-
beachhead = Beachhead.new File.dirname(__FILE__), options
|
54
|
-
# Since we're not actually starting agents, we don't want to exit when none are running for this test
|
55
|
-
beachhead.warlock.stubs(:exit_when_none_running)
|
56
|
-
port = beachhead.daemonize(0.25)
|
57
|
-
wire = Telegraph::Wire.connect("localhost", port)
|
58
|
-
wire.send_message Beachhead::LoadFiles.new([])
|
59
|
-
wire.send_message Beachhead::DeployAgents
|
60
|
-
assert_equal Beachhead::Done, wire.next_message(:timeout => 1).body
|
61
|
-
ensure
|
62
|
-
beachhead.warlock.stop_demons
|
63
|
-
end
|
64
|
-
end
|
65
|
-
end
|
66
|
-
end
|
67
|
-
end
|