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,47 +1,67 @@
|
|
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
|
-
args = RSync::Args.new(mock, {:local => true, :rsync_options => "opt1 opt2"})
|
23
|
-
assert_equal "rsync -az --delete opt1 opt2 #{DeepTest::LIB_ROOT}", args.command("", "")
|
24
|
-
end
|
25
|
-
|
26
|
-
test "includes host in remote_location" do
|
27
|
-
args = RSync::Args.new('host', {})
|
28
|
-
assert_equal "host:dest", args.remote_location('dest')
|
29
|
-
end
|
30
|
-
|
31
|
-
test "separates host and dest with double colon if using daemon" do
|
32
|
-
args = RSync::Args.new('host', {:daemon => true})
|
33
|
-
assert_equal "host::dest", args.remote_location('dest')
|
34
|
-
end
|
35
|
-
|
36
|
-
test "includes username in dest_location if specified" do
|
37
|
-
args = RSync::Args.new('host', {:username => "user"})
|
38
|
-
assert_equal "user@host:dest", args.remote_location('dest')
|
39
|
-
end
|
40
|
-
|
41
|
-
test "does not include host in dest_location if local is specified" do
|
42
|
-
args = RSync::Args.new(mock, {:local => true})
|
43
|
-
assert_equal "dest", args.remote_location('dest')
|
44
|
-
end
|
3
|
+
unit_tests do
|
4
|
+
test "executes rsync with source and destination" do
|
5
|
+
options = DeepTest::Options.new(:sync_options => {:source => "source", :local => true})
|
6
|
+
|
7
|
+
DeepTest::Distributed::RSync.expects(:system).
|
8
|
+
with("rsync -az --delete source/ destination").returns(true)
|
9
|
+
|
10
|
+
DeepTest::Distributed::RSync.sync(mock, options, "destination")
|
11
|
+
end
|
12
|
+
|
13
|
+
test "raises error if sync fails" do
|
14
|
+
DeepTest::Distributed::RSync.expects(:system).returns(false)
|
15
|
+
|
16
|
+
assert_raises(RuntimeError) do
|
17
|
+
DeepTest::Distributed::RSync.sync(
|
18
|
+
mock,
|
19
|
+
DeepTest::Options.new(:sync_options => {:source => "a", :local => true}),
|
20
|
+
"destination"
|
21
|
+
)
|
45
22
|
end
|
46
23
|
end
|
24
|
+
|
25
|
+
test "include rsync_options in command" do
|
26
|
+
options = DeepTest::Options.new(:sync_options => {:source => "source",
|
27
|
+
:local => true,
|
28
|
+
:rsync_options => "opt1 opt2"})
|
29
|
+
|
30
|
+
args = DeepTest::Distributed::RSync::Args.new(mock, options)
|
31
|
+
assert_equal "rsync -az --delete opt1 opt2 source/", args.command("")
|
32
|
+
end
|
33
|
+
|
34
|
+
test "includes host in source_location" do
|
35
|
+
options = DeepTest::Options.new(:sync_options => {:source => "source"})
|
36
|
+
args = DeepTest::Distributed::RSync::Args.new(mock(:address => 'host'),
|
37
|
+
options)
|
38
|
+
|
39
|
+
assert_equal "host:source", args.source_location
|
40
|
+
end
|
41
|
+
|
42
|
+
test "separates host and source with double colon if using daemon" do
|
43
|
+
options = DeepTest::Options.new(
|
44
|
+
:sync_options => {:source => "source", :daemon => true}
|
45
|
+
)
|
46
|
+
args = DeepTest::Distributed::RSync::Args.new(mock(:address => 'host'),
|
47
|
+
options)
|
48
|
+
|
49
|
+
assert_equal "host::source", args.source_location
|
50
|
+
end
|
51
|
+
|
52
|
+
test "includes username in source_location if specified" do
|
53
|
+
options = DeepTest::Options.new(:sync_options => {:source => "source",
|
54
|
+
:username => "user"})
|
55
|
+
args = DeepTest::Distributed::RSync::Args.new(mock(:address => 'host'),
|
56
|
+
options)
|
57
|
+
|
58
|
+
assert_equal "user@host:source", args.source_location
|
59
|
+
end
|
60
|
+
|
61
|
+
test "does not include host in source_location if local is specified" do
|
62
|
+
options = DeepTest::Options.new(:sync_options => {:source => "source", :local => true})
|
63
|
+
args = DeepTest::Distributed::RSync::Args.new(mock, options)
|
64
|
+
|
65
|
+
assert_equal "source", args.source_location
|
66
|
+
end
|
47
67
|
end
|
@@ -0,0 +1,94 @@
|
|
1
|
+
require File.dirname(__FILE__) + "/../../test_helper"
|
2
|
+
|
3
|
+
unit_tests do
|
4
|
+
test "generates a local working copy path based on host and source of request" do
|
5
|
+
DeepTest::Distributed::DRbClientConnectionInfo.expects(:new).
|
6
|
+
returns(:connection_info)
|
7
|
+
|
8
|
+
Socket.stubs(:gethostname).returns("myhost", "serverhost")
|
9
|
+
server = DeepTest::Distributed::TestServer.new(:work_dir => "/tmp")
|
10
|
+
options = DeepTest::Options.new(:sync_options => {:source => "/my/local/dir"})
|
11
|
+
DeepTest::Distributed::RSync.expects(:sync).with(:connection_info,
|
12
|
+
options,
|
13
|
+
"/tmp/myhost_my_local_dir")
|
14
|
+
server.sync(options)
|
15
|
+
end
|
16
|
+
|
17
|
+
test "work_dir can be set from command line" do
|
18
|
+
config = DeepTest::Distributed::TestServer.parse_args(
|
19
|
+
['--work_dir','path']
|
20
|
+
)
|
21
|
+
assert_equal 'path', config[:work_dir]
|
22
|
+
end
|
23
|
+
|
24
|
+
test "uri can be set from command line" do
|
25
|
+
config = DeepTest::Distributed::TestServer.parse_args(['--uri','uri'])
|
26
|
+
assert_equal 'uri', config[:uri]
|
27
|
+
end
|
28
|
+
|
29
|
+
test "number_of_workers can be set from command line" do
|
30
|
+
config = DeepTest::Distributed::TestServer.parse_args(
|
31
|
+
['--number_of_workers','4']
|
32
|
+
)
|
33
|
+
assert_equal 4, config[:number_of_workers]
|
34
|
+
end
|
35
|
+
|
36
|
+
test "default number_of_workers is 2" do
|
37
|
+
assert_equal(
|
38
|
+
2,
|
39
|
+
DeepTest::Distributed::TestServer::DEFAULT_CONFIG[:number_of_workers]
|
40
|
+
)
|
41
|
+
end
|
42
|
+
|
43
|
+
test "uses default options for those not specified" do
|
44
|
+
config = DeepTest::Distributed::TestServer.parse_args([])
|
45
|
+
assert_equal DeepTest::Distributed::TestServer::DEFAULT_CONFIG, config
|
46
|
+
end
|
47
|
+
|
48
|
+
test "spawn_worker_server starts RemoteWorkerServer with TestServerWorkers" do
|
49
|
+
config = {:number_of_workers => 4, :uri => "druby://localhost:4022"}
|
50
|
+
server = DeepTest::Distributed::TestServer.new(config)
|
51
|
+
options = DeepTest::Options.new(:sync_options => {:source => ""})
|
52
|
+
DeepTest::Distributed::DRbClientConnectionInfo.expects(:new).
|
53
|
+
returns(:connection_info)
|
54
|
+
|
55
|
+
DeepTest::Distributed::TestServerWorkers.expects(:new).with(
|
56
|
+
options, config, :connection_info
|
57
|
+
).returns(:workers)
|
58
|
+
|
59
|
+
DeepTest::Distributed::RemoteWorkerServer.expects(:start).with(
|
60
|
+
"localhost", anything, :workers
|
61
|
+
)
|
62
|
+
|
63
|
+
server.spawn_worker_server(options)
|
64
|
+
end
|
65
|
+
|
66
|
+
test "connect creates dispatch controller for all servers" do
|
67
|
+
options = DeepTest::Options.new({:ui => "DeepTest::UI::Null"})
|
68
|
+
DRbObject.expects(:new_with_uri).returns(server = mock)
|
69
|
+
server.expects(:servers).returns([s1 = mock, s2 = mock])
|
70
|
+
s1.expects(:sync)
|
71
|
+
s2.expects(:sync)
|
72
|
+
DeepTest::Distributed::TestServer.connect(options).sync(options)
|
73
|
+
end
|
74
|
+
|
75
|
+
test "status.binding_uri is the uri that DRb is bound to" do
|
76
|
+
server = DeepTest::Distributed::TestServer.new(:number_of_workers => 4)
|
77
|
+
DRb.expects(:uri).returns("druby://test")
|
78
|
+
assert_equal "druby://test", server.status.binding_uri
|
79
|
+
end
|
80
|
+
|
81
|
+
test "status.number_of_workers in the configured number of workers" do
|
82
|
+
server = DeepTest::Distributed::TestServer.new(:number_of_workers => 4)
|
83
|
+
DRb.expects(:uri)
|
84
|
+
assert_equal 4, server.status.number_of_workers
|
85
|
+
end
|
86
|
+
|
87
|
+
test "status.remote_worker_server_count is number of servers currently running" do
|
88
|
+
server = DeepTest::Distributed::TestServer.new(:number_of_workers => 4)
|
89
|
+
DRb.expects(:uri)
|
90
|
+
DeepTest::Distributed::RemoteWorkerServer.expects(:running_server_count).
|
91
|
+
returns(3)
|
92
|
+
assert_equal 3, server.status.remote_worker_server_count
|
93
|
+
end
|
94
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require File.dirname(__FILE__) + "/../../test_helper"
|
2
|
+
|
3
|
+
unit_tests do
|
4
|
+
test "number_of_workers is determined by mirror server options" do
|
5
|
+
workers = DeepTest::Distributed::TestServerWorkers.new(
|
6
|
+
DeepTest::Options.new({}),
|
7
|
+
{:number_of_workers => 4},
|
8
|
+
mock
|
9
|
+
)
|
10
|
+
|
11
|
+
assert_equal 4, workers.number_of_workers
|
12
|
+
end
|
13
|
+
|
14
|
+
test "server is retrieved using client connection information" do
|
15
|
+
workers = DeepTest::Distributed::TestServerWorkers.new(
|
16
|
+
options = DeepTest::Options.new({}),
|
17
|
+
{:number_of_workers => 4},
|
18
|
+
mock(:address => "address")
|
19
|
+
)
|
20
|
+
DeepTest::Server.expects(:remote_reference).
|
21
|
+
with("address", options.server_port).
|
22
|
+
returns(:server_reference)
|
23
|
+
|
24
|
+
assert_equal :server_reference, workers.server
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,68 @@
|
|
1
|
+
require File.dirname(__FILE__) + "/../../test_helper"
|
2
|
+
|
3
|
+
unit_tests do
|
4
|
+
test "runner adds specified number of work units to blackboard" do
|
5
|
+
blackboard = DeepTest::SimpleTestBlackboard.new
|
6
|
+
runner = DeepTest::Distributed::ThroughputRunner.new(
|
7
|
+
DeepTest::Options.new({}),
|
8
|
+
5,
|
9
|
+
blackboard
|
10
|
+
)
|
11
|
+
|
12
|
+
worker = ThreadWorker.new(blackboard, 5)
|
13
|
+
Timeout.timeout(5) do
|
14
|
+
runner.process_work_units
|
15
|
+
end
|
16
|
+
worker.wait_until_done
|
17
|
+
end
|
18
|
+
|
19
|
+
test "runner yields all results from blackboard" do
|
20
|
+
blackboard = DeepTest::SimpleTestBlackboard.new
|
21
|
+
count = 0
|
22
|
+
runner = DeepTest::Distributed::ThroughputRunner.new(
|
23
|
+
DeepTest::Options.new({}),
|
24
|
+
2,
|
25
|
+
blackboard
|
26
|
+
) do |result|
|
27
|
+
assert_equal :null_work_unit_result, result
|
28
|
+
count += 1
|
29
|
+
end
|
30
|
+
|
31
|
+
worker = ThreadWorker.new(blackboard, 2)
|
32
|
+
Timeout.timeout(5) do
|
33
|
+
runner.process_work_units
|
34
|
+
end
|
35
|
+
worker.wait_until_done
|
36
|
+
|
37
|
+
assert_equal 2, count
|
38
|
+
end
|
39
|
+
|
40
|
+
test "statistics are available after run" do
|
41
|
+
blackboard = DeepTest::SimpleTestBlackboard.new
|
42
|
+
runner = DeepTest::Distributed::ThroughputRunner.new(
|
43
|
+
DeepTest::Options.new({}),
|
44
|
+
2,
|
45
|
+
blackboard
|
46
|
+
)
|
47
|
+
|
48
|
+
worker = ThreadWorker.new(blackboard, 2)
|
49
|
+
count = 0
|
50
|
+
Timeout.timeout(5) do
|
51
|
+
runner.process_work_units
|
52
|
+
end
|
53
|
+
worker.wait_until_done
|
54
|
+
|
55
|
+
assert_kind_of DeepTest::Distributed::ThroughputStatistics,
|
56
|
+
runner.statistics
|
57
|
+
end
|
58
|
+
|
59
|
+
test "runner returns true" do
|
60
|
+
runner = DeepTest::Distributed::ThroughputRunner.new(
|
61
|
+
DeepTest::Options.new({}),
|
62
|
+
0,
|
63
|
+
DeepTest::SimpleTestBlackboard.new
|
64
|
+
)
|
65
|
+
|
66
|
+
assert_equal true, runner.process_work_units
|
67
|
+
end
|
68
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require File.dirname(__FILE__) + "/../../test_helper"
|
2
|
+
|
3
|
+
unit_tests do
|
4
|
+
test "start_all starts workers on a new worker server" do
|
5
|
+
client = DeepTest::Distributed::ThroughputWorkerClient.new(
|
6
|
+
options = DeepTest::Options.new({}),
|
7
|
+
test_server = stub_everything
|
8
|
+
)
|
9
|
+
|
10
|
+
test_server.expects(:spawn_worker_server).with(options).
|
11
|
+
returns(worker_server = stub_everything)
|
12
|
+
|
13
|
+
worker_server.expects(:start_all)
|
14
|
+
client.start_all
|
15
|
+
end
|
16
|
+
|
17
|
+
test "stop_all stops workers on worker server that was spawned in start_all" do
|
18
|
+
worker_server = stub_everything
|
19
|
+
client = DeepTest::Distributed::ThroughputWorkerClient.new(
|
20
|
+
DeepTest::Options.new({}),
|
21
|
+
test_server = stub_everything(:spawn_worker_server => worker_server)
|
22
|
+
)
|
23
|
+
|
24
|
+
client.start_all
|
25
|
+
worker_server.expects(:stop_all)
|
26
|
+
client.stop_all
|
27
|
+
end
|
28
|
+
end
|
@@ -1,22 +1,20 @@
|
|
1
1
|
require File.dirname(__FILE__) + "/../test_helper"
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
end
|
3
|
+
unit_tests do
|
4
|
+
test "forwards methods defined in NullWorkerListener to all listeners" do
|
5
|
+
listener_1, listener_2 = mock, mock
|
6
|
+
list = DeepTest::ListenerList.new([listener_1, listener_2])
|
7
|
+
listener_1.expects(:starting).with(:worker)
|
8
|
+
listener_2.expects(:starting).with(:worker)
|
9
|
+
listener_1.expects(:starting_work).with(:worker, :work)
|
10
|
+
listener_2.expects(:starting_work).with(:worker, :work)
|
11
|
+
list.starting(:worker)
|
12
|
+
list.starting_work(:worker, :work)
|
13
|
+
end
|
15
14
|
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
end
|
15
|
+
test "doesn't forward methods not defined in NullWorkerListener" do
|
16
|
+
listener = mock
|
17
|
+
listener.expects(:to_s).never
|
18
|
+
DeepTest::ListenerList.new([listener]).to_s
|
21
19
|
end
|
22
20
|
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require File.dirname(__FILE__) + "/../test_helper"
|
2
|
+
|
3
|
+
unit_tests do
|
4
|
+
test "number_of_workers is determined by options" do
|
5
|
+
workers = DeepTest::LocalWorkers.new(
|
6
|
+
DeepTest::Options.new(:number_of_workers => 4)
|
7
|
+
)
|
8
|
+
|
9
|
+
assert_equal 4, workers.number_of_workers
|
10
|
+
end
|
11
|
+
|
12
|
+
test "load_files simply loads each file provided" do
|
13
|
+
workers = DeepTest::LocalWorkers.new(
|
14
|
+
DeepTest::Options.new(:number_of_workers => 4)
|
15
|
+
)
|
16
|
+
|
17
|
+
workers.expects(:load).with(:file_1)
|
18
|
+
workers.expects(:load).with(:file_2)
|
19
|
+
|
20
|
+
workers.load_files([:file_1, :file_2])
|
21
|
+
end
|
22
|
+
end
|
@@ -1,38 +1,11 @@
|
|
1
1
|
require File.dirname(__FILE__) + "/../test_helper"
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
time = Time.parse("2009-09-22 12:01:33")
|
11
|
-
assert_equal "[DeepTest@#{Socket.gethostname}] 2009-09-22 12:01:33 my_msg\n", DeepTest.logger.formatter.call(nil, time, nil, "my_msg")
|
12
|
-
end
|
13
|
-
|
14
|
-
Logger::Severity.constants.each do |severity|
|
15
|
-
test "#{severity.downcase} can not be called with any arguments" do
|
16
|
-
logger = Logger.new stub_everything
|
17
|
-
assert_raises(ArgumentError) { logger.send severity.downcase, "a" }
|
18
|
-
end
|
19
|
-
|
20
|
-
THE_DATE = '\d{4}-\d\d-\d\d \d\d:\d\d:\d\d' unless defined?(THE_DATE)
|
21
|
-
|
22
|
-
test "#{severity.downcase} can be called with a block" do
|
23
|
-
logger = Logger.new(out = StringIO.new)
|
24
|
-
logger.level = Logger.const_get(severity)
|
25
|
-
logger.send(severity.downcase) { "a" }
|
26
|
-
assert_match /\[DeepTest@#{Socket.gethostname}\] #{THE_DATE} a\n/, out.string
|
27
|
-
end
|
28
|
-
|
29
|
-
test "#{severity.downcase} rescues errors from block and logs them" do
|
30
|
-
logger = Logger.new(out = StringIO.new)
|
31
|
-
logger.level = Logger.const_get(severity)
|
32
|
-
logger.send(severity.downcase) { raise Exception, "e" }
|
33
|
-
assert_match /\[DeepTest@#{Socket.gethostname}\] #{THE_DATE} Exception: e occurred logging on #{__FILE__}:#{__LINE__ - 1}:in `send'\n/,
|
34
|
-
out.string
|
35
|
-
end
|
36
|
-
end
|
3
|
+
unit_tests do
|
4
|
+
test "info log level by default" do
|
5
|
+
assert_equal Logger::INFO, DeepTest.logger.level
|
6
|
+
end
|
7
|
+
|
8
|
+
test "formatter uses msg only" do
|
9
|
+
assert_equal "[DeepTest] my_msg\n", DeepTest.logger.formatter.call(nil, nil, nil, "my_msg")
|
37
10
|
end
|
38
11
|
end
|
@@ -1,46 +1,44 @@
|
|
1
1
|
require File.dirname(__FILE__) + "/../test_helper"
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
original.set_backtrace ['1', '2']
|
3
|
+
unit_tests do
|
4
|
+
test "loading a marshallable exception evals the classname and returns an instance of the original exception" do
|
5
|
+
original = RuntimeError.new "message"
|
6
|
+
original.set_backtrace ['1', '2']
|
8
7
|
|
9
|
-
|
10
|
-
|
11
|
-
|
8
|
+
marshalled = DeepTest::MarshallableExceptionWrapper.new(original)
|
9
|
+
DeepTest::MarshallableExceptionWrapper.any_instance.expects(:eval).
|
10
|
+
with("::RuntimeError").returns(RuntimeError)
|
12
11
|
|
13
|
-
|
12
|
+
loaded = Marshal.load(Marshal.dump(marshalled)).resolve
|
14
13
|
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
14
|
+
assert_equal original.class, loaded.class
|
15
|
+
assert_equal original.message, loaded.message
|
16
|
+
assert_equal original.backtrace, loaded.backtrace
|
17
|
+
end
|
19
18
|
|
20
|
-
|
21
|
-
|
22
|
-
|
19
|
+
test "loading a marshallable exception when class is not available returns an instance of unloadable exception" do
|
20
|
+
original = RuntimeError.new "message"
|
21
|
+
original.set_backtrace ['1', '2']
|
23
22
|
|
24
|
-
|
25
|
-
|
26
|
-
|
23
|
+
marshalled = DeepTest::MarshallableExceptionWrapper.new(original)
|
24
|
+
DeepTest::MarshallableExceptionWrapper.any_instance.expects(:eval).
|
25
|
+
raises("Eval Error")
|
27
26
|
|
28
|
-
|
27
|
+
loaded = Marshal.load(Marshal.dump(marshalled)).resolve
|
29
28
|
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
29
|
+
assert_equal DeepTest::UnloadableException, loaded.class
|
30
|
+
assert_equal "RuntimeError: " + original.message, loaded.message
|
31
|
+
assert_equal original.backtrace, loaded.backtrace
|
32
|
+
end
|
34
33
|
|
35
|
-
|
36
|
-
|
34
|
+
test "loading a marshallable exception when class init throws an error returns an unloadable exception" do
|
35
|
+
original = RuntimeError.new "message"
|
37
36
|
|
38
|
-
|
39
|
-
|
37
|
+
marshalled = DeepTest::MarshallableExceptionWrapper.new(original)
|
38
|
+
RuntimeError.expects(:new).raises(StandardError.new)
|
40
39
|
|
41
|
-
|
40
|
+
loaded = Marshal.load(Marshal.dump(marshalled)).resolve
|
42
41
|
|
43
|
-
|
44
|
-
end
|
42
|
+
assert_equal DeepTest::UnloadableException, loaded.class
|
45
43
|
end
|
46
44
|
end
|