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
@@ -0,0 +1,66 @@
|
|
1
|
+
require File.dirname(__FILE__) + "/../../test_helper"
|
2
|
+
|
3
|
+
unit_tests do
|
4
|
+
test "section uses block to add measurements when render is called" do
|
5
|
+
i = j = 0
|
6
|
+
section = DeepTest::Metrics::Gatherer::Section.new("my section") do |s|
|
7
|
+
s.measurement("i", i)
|
8
|
+
s.measurement("j", j)
|
9
|
+
end
|
10
|
+
|
11
|
+
i = 1
|
12
|
+
j = 2
|
13
|
+
|
14
|
+
rendered_string = section.render
|
15
|
+
|
16
|
+
assert_match /^i: 1$/, rendered_string
|
17
|
+
assert_match /^j: 2$/, rendered_string
|
18
|
+
end
|
19
|
+
|
20
|
+
test "section starts with title" do
|
21
|
+
section = DeepTest::Metrics::Gatherer::Section.new("my section") {|s|}
|
22
|
+
assert_equal "[my section]\n", section.render
|
23
|
+
end
|
24
|
+
|
25
|
+
test "gatherer renders all sections defined" do
|
26
|
+
gatherer = DeepTest::Metrics::Gatherer.new(DeepTest::Options.new(:metrics_file => "something"))
|
27
|
+
gatherer.section("section 1") {|s|}
|
28
|
+
gatherer.section("section 2") {|s|}
|
29
|
+
|
30
|
+
assert_equal "[section 1]\n\n[section 2]\n", gatherer.render
|
31
|
+
end
|
32
|
+
|
33
|
+
test "no sections are added if not gathering metrics" do
|
34
|
+
gatherer = DeepTest::Metrics::Gatherer.new(DeepTest::Options.new({}))
|
35
|
+
gatherer.section("section 1") {|s|}
|
36
|
+
gatherer.section("section 2") {|s|}
|
37
|
+
|
38
|
+
assert_equal "", gatherer.render
|
39
|
+
end
|
40
|
+
|
41
|
+
test "enabled? is true if metrics_file is specified" do
|
42
|
+
gatherer = DeepTest::Metrics::Gatherer.new(DeepTest::Options.new(:metrics_file => "something"))
|
43
|
+
assert_equal true, gatherer.enabled?
|
44
|
+
end
|
45
|
+
|
46
|
+
test "enabled? is false if metrics_file is not specified" do
|
47
|
+
gatherer = DeepTest::Metrics::Gatherer.new(DeepTest::Options.new({}))
|
48
|
+
assert_equal false, gatherer.enabled?
|
49
|
+
end
|
50
|
+
|
51
|
+
test "write_file writes rendered contents to metrics file" do
|
52
|
+
gatherer = DeepTest::Metrics::Gatherer.new(
|
53
|
+
DeepTest::Options.new(:metrics_file => "a_file")
|
54
|
+
)
|
55
|
+
gatherer.section("section 1") {|s|}
|
56
|
+
File.expects(:open).with("a_file", "w").yields(io = StringIO.new)
|
57
|
+
gatherer.write_file
|
58
|
+
assert_equal gatherer.render, io.string
|
59
|
+
end
|
60
|
+
|
61
|
+
test "write_file does nothing if not enabled" do
|
62
|
+
gatherer = DeepTest::Metrics::Gatherer.new(DeepTest::Options.new({}))
|
63
|
+
File.expects(:open).never
|
64
|
+
gatherer.write_file
|
65
|
+
end
|
66
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
require File.dirname(__FILE__) + "/../test_helper"
|
2
|
+
|
3
|
+
unit_tests do
|
4
|
+
test "shutdown calls done_with_work" do
|
5
|
+
orchestrator = DeepTest::ProcessOrchestrator.new(nil, stub_everything, nil)
|
6
|
+
server = mock
|
7
|
+
server.expects(:done_with_work)
|
8
|
+
|
9
|
+
orchestrator.shutdown(server)
|
10
|
+
end
|
11
|
+
end
|
@@ -1,128 +1,128 @@
|
|
1
1
|
require File.dirname(__FILE__) + "/../test_helper"
|
2
2
|
|
3
|
-
|
4
|
-
unit_tests do
|
5
|
-
class FakeResult
|
6
|
-
attr_reader :identifier
|
7
|
-
def initialize(i) @identifier = i; end
|
8
|
-
def ==(other) identifier == other.identifier; end
|
9
|
-
end
|
3
|
+
unit_tests do
|
10
4
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
assert_equal FakeResult.new(4), central_command.take_result
|
17
|
-
end
|
5
|
+
class FakeResult
|
6
|
+
attr_reader :identifier
|
7
|
+
def initialize(i) @identifier = i; end
|
8
|
+
def ==(other) identifier == other.identifier; end
|
9
|
+
end
|
18
10
|
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
11
|
+
test "reads all as many results as requested" do
|
12
|
+
blackboard = DeepTest::SimpleTestBlackboard.new
|
13
|
+
1.upto(4) {|i| blackboard.write_result FakeResult.new(i)}
|
14
|
+
work_units = {1 => "One", 2 => "Two", 3 => "Three"}
|
15
|
+
DeepTest::ResultReader.new(blackboard).read(work_units) {}
|
16
|
+
assert_equal FakeResult.new(4), blackboard.take_result
|
17
|
+
end
|
26
18
|
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
["Three", FakeResult.new(3)]],
|
36
|
-
results
|
37
|
-
end
|
19
|
+
test "returns unread tests on ResultOverdueError" do
|
20
|
+
blackboard = DeepTest::SimpleTestBlackboard.new
|
21
|
+
blackboard.simulate_result_overdue_error = true
|
22
|
+
work_units = {1 => "One"}
|
23
|
+
DeepTest.logger.expects(:error)
|
24
|
+
DeepTest::ResultReader.new(blackboard).read(work_units) {}
|
25
|
+
assert_equal({1 => "One"}, work_units)
|
26
|
+
end
|
38
27
|
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
28
|
+
test "yields each result" do
|
29
|
+
blackboard = DeepTest::SimpleTestBlackboard.new
|
30
|
+
1.upto(3) {|i| blackboard.write_result FakeResult.new(i)}
|
31
|
+
results = []
|
32
|
+
work_units = {1 => "One", 2 => "Two", 3 => "Three"}
|
33
|
+
DeepTest::ResultReader.new(blackboard).read(work_units) {|r| results << r}
|
34
|
+
assert_equal [["One", FakeResult.new(1)],
|
35
|
+
["Two", FakeResult.new(2)],
|
36
|
+
["Three", FakeResult.new(3)]],
|
37
|
+
results
|
38
|
+
end
|
47
39
|
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
40
|
+
test "keeps attempting to read results when none are available" do
|
41
|
+
blackboard = DeepTest::SimpleTestBlackboard.new
|
42
|
+
work_units = {1 => "One", 2 => "Two", 3 => "Three"}
|
43
|
+
t = Thread.new {DeepTest::ResultReader.new(blackboard).read(work_units) {}}
|
44
|
+
1.upto(4) {|i| blackboard.write_result FakeResult.new(i)}
|
45
|
+
t.join
|
46
|
+
assert_equal FakeResult.new(4), blackboard.take_result
|
47
|
+
end
|
56
48
|
|
57
|
-
|
58
|
-
|
59
|
-
|
49
|
+
test "doesn't yield empty results" do
|
50
|
+
blackboard = DeepTest::SimpleTestBlackboard.new
|
51
|
+
results = []
|
52
|
+
t = Thread.new {DeepTest::ResultReader.new(blackboard).read(1 => "One") {|r| results << r}}
|
53
|
+
blackboard.write_result FakeResult.new(1)
|
54
|
+
t.join
|
55
|
+
assert_equal [["One", FakeResult.new(1)]], results
|
56
|
+
end
|
60
57
|
|
61
|
-
|
62
|
-
|
63
|
-
|
58
|
+
test "prints output if result has output" do
|
59
|
+
blackboard = DeepTest::SimpleTestBlackboard.new
|
60
|
+
blackboard.write_result mock(:output => "output", :identifier => 1)
|
64
61
|
|
65
|
-
|
62
|
+
out = capture_stdout do
|
63
|
+
DeepTest::ResultReader.new(blackboard).read(1 => "One") {}
|
66
64
|
end
|
67
65
|
|
68
|
-
|
69
|
-
|
70
|
-
central_command.write_result mock(:output => nil, :identifier => 1)
|
66
|
+
assert_equal "output", out
|
67
|
+
end
|
71
68
|
|
72
|
-
|
73
|
-
|
74
|
-
|
69
|
+
test "doesn't print any output if output is nil" do
|
70
|
+
blackboard = DeepTest::SimpleTestBlackboard.new
|
71
|
+
blackboard.write_result mock(:output => nil, :identifier => 1)
|
75
72
|
|
76
|
-
|
73
|
+
out = capture_stdout do
|
74
|
+
DeepTest::ResultReader.new(blackboard).read(1 => "One") {}
|
77
75
|
end
|
78
76
|
|
79
|
-
|
80
|
-
|
81
|
-
error.set_backtrace ['a', 'b']
|
77
|
+
assert_equal "", out
|
78
|
+
end
|
82
79
|
|
83
|
-
|
84
|
-
|
80
|
+
test "prints useful error information in case of Worker::Error" do
|
81
|
+
error = RuntimeError.new "message"
|
82
|
+
error.set_backtrace ['a', 'b']
|
85
83
|
|
84
|
+
blackboard = DeepTest::SimpleTestBlackboard.new
|
85
|
+
blackboard.write_result DeepTest::Worker::Error.new("work_unit", error)
|
86
86
|
|
87
|
-
out = capture_stdout do
|
88
|
-
ResultReader.new(central_command).read(1 => "One") {}
|
89
|
-
end
|
90
87
|
|
91
|
-
|
88
|
+
out = capture_stdout do
|
89
|
+
DeepTest::ResultReader.new(blackboard).read(1 => "One") {}
|
92
90
|
end
|
93
91
|
|
94
|
-
|
95
|
-
|
96
|
-
central_command.write_result Agent::Error.new("work_unit", RuntimeError.new)
|
92
|
+
assert_equal "work_unit: message\na\nb\n", out
|
93
|
+
end
|
97
94
|
|
95
|
+
test "doesn't yield Worker::Error results" do
|
96
|
+
blackboard = DeepTest::SimpleTestBlackboard.new
|
97
|
+
blackboard.write_result DeepTest::Worker::Error.new("work_unit", RuntimeError.new)
|
98
98
|
|
99
|
-
results = []
|
100
|
-
capture_stdout do
|
101
|
-
ResultReader.new(central_command).read(1 => "One") {|r| results << r}
|
102
|
-
end
|
103
99
|
|
104
|
-
|
100
|
+
results = []
|
101
|
+
capture_stdout do
|
102
|
+
DeepTest::ResultReader.new(blackboard).read(1 => "One") {|r| results << r}
|
105
103
|
end
|
106
104
|
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
105
|
+
assert_equal [], results
|
106
|
+
end
|
107
|
+
|
108
|
+
test "doesn't modify original work unit hash" do
|
109
|
+
blackboard = DeepTest::SimpleTestBlackboard.new
|
110
|
+
blackboard.write_result FakeResult.new(1)
|
111
|
+
work_units = {1 => "One"}
|
112
|
+
DeepTest::ResultReader.new(blackboard).read(work_units) {}
|
113
|
+
assert_equal({1 => "One"}, work_units)
|
114
|
+
end
|
114
115
|
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
116
|
+
test "returns remaining tests that didn't have errors" do
|
117
|
+
blackboard = DeepTest::SimpleTestBlackboard.new
|
118
|
+
blackboard.write_result FakeResult.new(1)
|
119
|
+
blackboard.write_result DeepTest::Worker::Error.new("work_unit", RuntimeError.new)
|
119
120
|
|
120
|
-
|
121
|
+
work_units = {1 => "One", 2 => "Two"}
|
121
122
|
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
end
|
123
|
+
capture_stdout do
|
124
|
+
missing_work_units = DeepTest::ResultReader.new(blackboard).read(work_units) {}
|
125
|
+
assert_equal({2 => "Two"}, missing_work_units)
|
126
126
|
end
|
127
127
|
end
|
128
128
|
end
|
@@ -0,0 +1,58 @@
|
|
1
|
+
require File.dirname(__FILE__) + "/../test_helper"
|
2
|
+
|
3
|
+
unit_tests do
|
4
|
+
test "take_work returns result of push_work when it is available" do
|
5
|
+
server = DeepTest::Server.new(DeepTest::Options.new({}))
|
6
|
+
server.write_work :work
|
7
|
+
assert_equal :work, server.take_work
|
8
|
+
end
|
9
|
+
|
10
|
+
test "take_work raises error when no work is currently available" do
|
11
|
+
assert_raises(DeepTest::Server::NoWorkUnitsAvailableError) do
|
12
|
+
DeepTest::Server.new(DeepTest::Options.new({})).take_work
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
test "take_work raises error when there is no work left to" do
|
17
|
+
server = DeepTest::Server.new(DeepTest::Options.new({}))
|
18
|
+
server.done_with_work
|
19
|
+
|
20
|
+
assert_raises(DeepTest::Server::NoWorkUnitsRemainingError) do
|
21
|
+
server.take_work
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
test "take_result returns result of push_result when it is available" do
|
26
|
+
server = DeepTest::Server.new(DeepTest::Options.new({}))
|
27
|
+
t = Thread.new {server.take_result}
|
28
|
+
server.write_result :result
|
29
|
+
assert_equal :result, t.value
|
30
|
+
end
|
31
|
+
|
32
|
+
test "take_result timeouts out after configurable number of seconds" do
|
33
|
+
server = DeepTest::Server.new(
|
34
|
+
DeepTest::Options.new(:timeout_in_seconds => 0.01)
|
35
|
+
)
|
36
|
+
Thread.new {sleep 0.1; server.write_result :too_late}
|
37
|
+
assert_raises(DeepTest::Server::ResultOverdueError) {server.take_result}
|
38
|
+
end
|
39
|
+
|
40
|
+
test "write_work returns nil" do
|
41
|
+
server = DeepTest::Server.new(DeepTest::Options.new({}))
|
42
|
+
assert_equal nil, server.write_work(:a)
|
43
|
+
end
|
44
|
+
|
45
|
+
test "write_result returns nil" do
|
46
|
+
server = DeepTest::Server.new(DeepTest::Options.new({}))
|
47
|
+
assert_equal nil, server.write_result(:a)
|
48
|
+
end
|
49
|
+
|
50
|
+
test "start returns instance of server" do
|
51
|
+
DRb.expects(:start_service)
|
52
|
+
DRb.expects(:uri)
|
53
|
+
DeepTest.logger.expects(:info)
|
54
|
+
|
55
|
+
server = DeepTest::Server.start(DeepTest::Options.new({}))
|
56
|
+
assert_kind_of DeepTest::Server, server
|
57
|
+
end
|
58
|
+
end
|
@@ -1,42 +1,40 @@
|
|
1
1
|
require File.dirname(__FILE__) + "/../../../test_helper"
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
assert_equal 'message', error.exception.message
|
40
|
-
end
|
3
|
+
unit_tests do
|
4
|
+
test "make_exception_marshallable wraps exception in a mashallable exception" do
|
5
|
+
error = Test::Unit::Error.new "test_name", Exception.new("message")
|
6
|
+
error.make_exception_marshallable
|
7
|
+
|
8
|
+
assert_kind_of DeepTest::MarshallableExceptionWrapper, error.exception
|
9
|
+
end
|
10
|
+
|
11
|
+
test "calling make_exception_marshallable twice only wraps exception once" do
|
12
|
+
error = Test::Unit::Error.new "test_name", Exception.new("message")
|
13
|
+
error.make_exception_marshallable
|
14
|
+
error.make_exception_marshallable
|
15
|
+
|
16
|
+
assert_kind_of DeepTest::MarshallableExceptionWrapper, error.exception
|
17
|
+
end
|
18
|
+
|
19
|
+
test "error is accessible as normal when it has not been made marshallable" do
|
20
|
+
error = Test::Unit::Error.new "test_name", e = Exception.new("message")
|
21
|
+
assert_equal e, error.exception
|
22
|
+
end
|
23
|
+
|
24
|
+
test "resolve_marshallable_exception restores the original exception" do
|
25
|
+
error = Test::Unit::Error.new "test_name", Exception.new("message")
|
26
|
+
error.make_exception_marshallable
|
27
|
+
error.resolve_marshallable_exception
|
28
|
+
|
29
|
+
assert_kind_of Exception, error.exception
|
30
|
+
assert_equal 'message', error.exception.message
|
31
|
+
end
|
32
|
+
|
33
|
+
test "resolve_marshallable_exception does not fail when exception has not been made marshallable" do
|
34
|
+
error = Test::Unit::Error.new "test_name", Exception.new("message")
|
35
|
+
error.resolve_marshallable_exception
|
36
|
+
|
37
|
+
assert_kind_of Exception, error.exception
|
38
|
+
assert_equal 'message', error.exception.message
|
41
39
|
end
|
42
40
|
end
|
@@ -1,11 +1,7 @@
|
|
1
1
|
require File.dirname(__FILE__) + "/../../test_helper"
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
test "no filters constant has empty filters" do
|
7
|
-
assert_equal [], Runner::NO_FILTERS.filters
|
8
|
-
end
|
9
|
-
end
|
3
|
+
unit_tests do
|
4
|
+
test "no filters constant has empty filters" do
|
5
|
+
assert_equal [], DeepTest::Test::Runner::NO_FILTERS.filters
|
10
6
|
end
|
11
7
|
end
|