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
@@ -0,0 +1,60 @@
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
@@ -12,6 +12,10 @@ unit_tests do
12
12
  assert_successful "rake deep_test"
13
13
  end
14
14
 
15
+ test "distributed_test" do
16
+ assert_successful "rake distributed_test"
17
+ end
18
+
15
19
  test "spec" do
16
20
  assert_successful "rake spec"
17
21
  end
@@ -1,11 +1,13 @@
1
- class ForeignHostWorkerSimulationListener < DeepTest::NullWorkerListener
2
- def starting(worker)
1
+ require File.dirname(__FILE__) + '/../vendor/gems/deep_test/lib/deep_test'
2
+
3
+ class ForeignHostAgentSimulationListener < DeepTest::NullListener
4
+ def starting(agent)
3
5
  # On a foreign host, there won't necessarily be a database for tests
4
6
  # to run against. We simulate that by dropping them here.
5
7
  #
6
- # It's important that this happens as the first thing when the workers
8
+ # It's important that this happens as the first thing when the agents
7
9
  # are started, since this is the first listener event that would be
8
- # invoked on a foreign host. before_starting_workers would be invoked
10
+ # invoked on a foreign host. before_starting_agents would be invoked
9
11
  # on the local host, which should have databases available as usual.
10
12
  #
11
13
  system "mysqladmin -u root -f drop sample_rails_project_development > /dev/null"
@@ -1,18 +1,27 @@
1
1
  require 'rubygems'
2
2
  gem 'rspec', '=1.1.8'
3
3
  require 'spec/rake/spectask'
4
- $LOAD_PATH << File.dirname(__FILE__) + "/../../../lib"
4
+ $LOAD_PATH << File.dirname(__FILE__) + "/../../vendor/gems/deep_test/lib"
5
5
  require 'deep_test/rake_tasks'
6
6
 
7
7
  DeepTest::TestTask.new(:deep_test) do |t|
8
- t.number_of_workers = 1
8
+ t.number_of_agents = 1
9
9
  t.pattern = "test/unit/**/*_test.rb"
10
- t.worker_listener = "ForeignHostWorkerSimulationListener,DeepTest::Database::MysqlSetupListener"
10
+ t.listener = "ForeignHostAgentSimulationListener,DeepTest::Database::MysqlSetupListener"
11
11
  end
12
12
  Rake::Task[:deep_test].enhance ["db:test:prepare"]
13
13
 
14
14
  Spec::Rake::SpecTask.new(:deep_spec) do |t|
15
15
  t.spec_files = FileList['spec/**/*_spec.rb']
16
- t.deep_test :number_of_workers => 2
16
+ t.deep_test :number_of_agents => 2
17
17
  end
18
18
  Rake::Task[:deep_spec].enhance ["db:test:prepare"]
19
+
20
+ DeepTest::TestTask.new(:distributed_test => %w[db:test:prepare]) do |t|
21
+ t.number_of_agents = 1
22
+ t.distributed_hosts = %w[localhost]
23
+ t.requires = File.dirname(__FILE__) + "/../foreign_host_agent_simulation_listener"
24
+ t.listener = "ForeignHostAgentSimulationListener,DeepTest::Database::MysqlSetupListener"
25
+ t.sync_options = {:source => File.expand_path(File.dirname(__FILE__) + "/../.."),
26
+ :rsync_options => "--exclude=.svn --copy-dirlinks"}
27
+ end
@@ -2,59 +2,55 @@ require File.dirname(__FILE__) + "/../spec_helper"
2
2
 
3
3
  module DeepTest
4
4
  describe Options do
5
- it "should support number_of_workers" do
6
- Options.new(:number_of_workers => 3).number_of_workers.should == 3
5
+ it "should support number_of_agents" do
6
+ Options.new(:number_of_agents => 3).number_of_agents.should == 3
7
+ end
8
+
9
+ it "should default to number_of_agents based on cpu info at time of call" do
10
+ options = Options.new({})
11
+ CpuInfo.should_receive(:new).and_return stub("cpu_info", :count => 4)
12
+ options.number_of_agents.should == 4
7
13
  end
8
14
 
9
15
  it "should have reasonable defaults" do
10
16
  options = Options.new({})
11
- options.number_of_workers.should == 2
12
- options.timeout_in_seconds.should == 30
13
- options.server_port.should == 6969
14
17
  options.pattern.should == nil
15
18
  options.metrics_file.should == nil
16
19
  end
17
20
 
18
- it "should support timeout_in_seconds" do
19
- Options.new(:timeout_in_seconds => 2).timeout_in_seconds.should == 2
20
- end
21
-
22
21
  it "should support pattern" do
23
22
  Options.new(:pattern => '*').pattern.should == '*'
24
23
  end
25
24
 
26
- it "should support distributed_server" do
27
- Options.new(:distributed_server => "uri").distributed_server.should == "uri"
28
- end
29
-
30
- it "should support server_port" do
31
- Options.new(:server_port => 10).server_port.should == 10
25
+ it "should support distributed_hosts" do
26
+ Options.new(:distributed_hosts => %w[host1 host2]).
27
+ distributed_hosts.should == %w[host1 host2]
32
28
  end
33
29
 
34
30
  it "should support sync_options" do
35
31
  Options.new(:sync_options => {:options => 1}).sync_options.should == {:options => 1}
36
32
  end
37
33
 
38
- it "should support worker_listener" do
39
- Options.new(:worker_listener => "AListener").
40
- worker_listener.should == "AListener"
34
+ it "should support listener" do
35
+ Options.new(:listener => "AListener").
36
+ listener.should == "AListener"
41
37
  end
42
38
 
43
- it "should use DeepTest::NullWorkerListener as the default listener" do
44
- Options.new({}).worker_listener.should == "DeepTest::NullWorkerListener"
39
+ it "should use DeepTest::NullListener as the default listener" do
40
+ Options.new({}).listener.should == "DeepTest::NullListener"
45
41
  end
46
42
 
47
- it "should allow worker_listener to be set with class" do
43
+ it "should allow listener to be set with class" do
48
44
  class FakeListener; end
49
- Options.new(:worker_listener => FakeListener).
50
- worker_listener.should == "DeepTest::FakeListener"
45
+ Options.new(:listener => FakeListener).
46
+ listener.should == "DeepTest::FakeListener"
51
47
  end
52
48
 
53
- it "should allow multiple workers to be specified" do
49
+ it "should allow multiple listeners to be specified" do
54
50
  class FakeListener1; end
55
51
  class FakeListener2; end
56
52
  options = Options.new(
57
- :worker_listener => "DeepTest::FakeListener1,DeepTest::FakeListener2"
53
+ :listener => "DeepTest::FakeListener1,DeepTest::FakeListener2"
58
54
  )
59
55
  listener = options.new_listener_list
60
56
  listener.should be_instance_of(DeepTest::ListenerList)
@@ -63,7 +59,7 @@ module DeepTest
63
59
  listener.listeners.last.should be_instance_of(FakeListener2)
64
60
  end
65
61
 
66
- it "should create a list of worker listeners upon request" do
62
+ it "should create a list of agent listeners upon request" do
67
63
  Options.new({}).new_listener_list.should be_instance_of(DeepTest::ListenerList)
68
64
  end
69
65
 
@@ -92,7 +88,7 @@ module DeepTest
92
88
  end
93
89
 
94
90
  it "should support strings as well as symbols" do
95
- Options.new("number_of_workers" => 2).number_of_workers.should == 2
91
+ Options.new("server_port" => 2).server_port.should == 2
96
92
  end
97
93
 
98
94
  it "should raise error when invalid option is specifed" do
@@ -102,42 +98,50 @@ module DeepTest
102
98
  end
103
99
 
104
100
  it "should convert to command line option string" do
105
- options = Options.new(:number_of_workers => 1, :timeout_in_seconds => 3)
106
- options.to_command_line.should ==
107
- "--number_of_workers 1 --timeout_in_seconds 3"
101
+ options = Options.new(:number_of_agents => 1)
102
+ options.to_command_line.should == Base64.encode64(Marshal.dump(options)).gsub("\n","")
108
103
  end
109
104
 
110
105
  it "should parse from command line option string" do
111
- options = Options.from_command_line(
112
- "--number_of_workers 2 --timeout_in_seconds 3 --pattern *")
113
- options.number_of_workers.should == 2
114
- options.timeout_in_seconds.should == 3
115
- options.pattern.should == '*'
106
+ options = Options.new(:number_of_agents => 2, :pattern => '*')
107
+ parsed_options = Options.from_command_line(options.to_command_line)
108
+ parsed_options.number_of_agents.should == 2
109
+ parsed_options.pattern.should == '*'
116
110
  end
117
111
 
118
112
  it "should use default option value when no command line option is present" do
119
- options = Options.from_command_line("")
120
- options.number_of_workers.should == 2
113
+ ["", nil].each do |blank_value|
114
+ options = Options.from_command_line(blank_value)
115
+ options.ui == "DeepTest::UI::Console"
116
+ end
121
117
  end
122
118
 
123
- it "should create local workers by default" do
119
+ it "should create local deployment by default" do
124
120
  options = Options.new({})
125
- options.new_workers.should be_instance_of(LocalWorkers)
121
+ options.new_deployment.should be_instance_of(LocalDeployment)
126
122
  end
127
123
 
128
- it "should create remote worker client when distributed server is specified" do
129
- options = Options.new(:distributed_server => "uri", :sync_options => {:source => "root"})
130
- Distributed::TestServer.should_receive(:connect).with(options).and_return(:server_instance)
131
- Distributed::RemoteWorkerClient.should_receive(:new).with(options, :server_instance, be_instance_of(LocalWorkers))
132
- options.new_workers
124
+ it "should create remote deployment when distributed hosts are specified" do
125
+ options = Options.new(:distributed_hosts => %w[hosts], :sync_options => {:source => "root"})
126
+ Distributed::RemoteDeployment.should_receive(:new).with(options,
127
+ be_instance_of(Distributed::LandingFleet),
128
+ be_instance_of(LocalDeployment))
129
+ options.new_deployment
133
130
  end
134
131
 
135
- it "should create local workers when connect fails" do
136
- options = Options.new(:distributed_server => "uri", :sync_options => {:source => "root"}, :ui => "DeepTest::UI::Null")
137
- Distributed::TestServer.should_receive(:connect).and_raise("An error")
138
- options.new_workers.should be_instance_of(LocalWorkers)
132
+ it "should create a landing fleet with a ship for each host" do
133
+ Socket.should_receive(:gethostname).and_return("myhost")
134
+ options = Options.new(:ui => "DeepTest::UI::Null",
135
+ :sync_options => {:source => "/my/local/dir"},
136
+ :distributed_hosts => %w[host1 host2])
137
+
138
+ Distributed::RSync.should_receive(:push).with("host1", options.sync_options, "/tmp/myhost_my_local_dir")
139
+ Distributed::RSync.should_receive(:push).with("host2", options.sync_options, "/tmp/myhost_my_local_dir")
140
+
141
+ options.new_landing_fleet.push_code(options)
139
142
  end
140
143
 
144
+
141
145
  it "should return localhost as origin_hostname current hostname is same as when created" do
142
146
  options = Options.new({})
143
147
  options.origin_hostname.should == 'localhost'
@@ -150,24 +154,41 @@ module DeepTest
150
154
  options.origin_hostname.should == local_hostname
151
155
  end
152
156
 
153
- it "should be able to calculate mirror_path based on base an sync_options" do
154
- Socket.should_receive(:gethostname).and_return("hostname", "server_hostname")
155
- options = Options.new(:sync_options => {:source => "/my/source/path"})
156
- options.mirror_path("/mirror/base/path").should ==
157
- "/mirror/base/path/hostname_my_source_path"
157
+ it "should connect_to_central_command on localhost when there is no SSH info" do
158
+ Telegraph::Wire.should_receive(:connect).with("localhost", 9999).and_yield(:wire)
159
+ yielded_wire = nil
160
+ Options.new(:server_port => 9999).connect_to_central_command { |yielded_wire| }
161
+ yielded_wire.should == :wire
162
+ end
163
+
164
+ it "should connect_to_central_command on remote address where there is SSH info" do
165
+ Telegraph::Wire.should_receive(:connect).with("remote_address", 9999).and_yield(:wire)
166
+ yielded_wire = nil
167
+
168
+ options = Options.new(:server_port => 9999)
169
+ options.ssh_client_connection_info = mock("connection_info", :address => "remote_address")
170
+ options.connect_to_central_command { |yielded_wire| }
171
+
172
+ yielded_wire.should == :wire
173
+ end
174
+
175
+ it "should be able to calculate mirror_path based on sync_options" do
176
+ Socket.should_receive(:gethostname).and_return("hostname")
177
+ options = Options.new(:sync_options => {:source => "/my/source/path", :remote_base_dir => "/mirror/base/path"})
178
+ options.mirror_path.should == "/mirror/base/path/hostname_my_source_path"
158
179
  end
159
180
 
160
181
  it "should raise a useful error if no source is specified" do
161
- options = DeepTest::Options.new(:sync_options => {})
182
+ options = DeepTest::Options.new(:sync_options => {:remote_base_dir => "/mirror/base/path/"})
162
183
  lambda {
163
- options.mirror_path("base")
184
+ options.mirror_path
164
185
  }.should raise_error("No source directory specified in sync_options")
165
186
  end
166
187
 
167
- it "should create drb object to connect to server" do
168
- options = DeepTest::Options.new({})
169
- server = options.server
170
- server.__drburi.should == "druby://#{options.origin_hostname}:#{options.server_port}"
188
+ it "should default to /tmp if no remote_base_dir is specified in sync_options" do
189
+ Socket.should_receive(:gethostname).and_return("hostname")
190
+ options = DeepTest::Options.new(:sync_options => {:source => "/my/source/path"})
191
+ options.mirror_path.should == "/tmp/hostname_my_source_path"
171
192
  end
172
193
 
173
194
  it "should be gathering metrics if metrics file is set" do
@@ -14,8 +14,9 @@ module Spec
14
14
  example_1 = group.examples.first
15
15
  example_2 = group.examples.last
16
16
 
17
- example_1.identifier.locate([group]).should == example_1
18
- example_2.identifier.locate([group]).should == example_2
17
+
18
+ (example_1.identifier.locate([group]) == example_1).should == true # as of rspec 1.1.12 should is redefined on examples to behave differently
19
+ (example_2.identifier.locate([group]) == example_2).should == true
19
20
  end
20
21
 
21
22
  it "should have identifier that can locate the example by name" do
@@ -28,8 +29,8 @@ module Spec
28
29
  example_1 = group.examples.first
29
30
  example_2 = group.examples.last
30
31
 
31
- example_1.identifier.locate([group]).should == example_1
32
- example_2.identifier.locate([group]).should == example_2
32
+ (example_1.identifier.locate([group]) == example_1).should == true
33
+ (example_2.identifier.locate([group]) == example_2).should == true
33
34
  end
34
35
 
35
36
  describe ExampleMethods::Identifier do
@@ -3,12 +3,11 @@ require File.dirname(__FILE__) + "/../../../spec_helper"
3
3
  describe Spec::Rake::SpecTask do
4
4
  it "should allow deep_test configuration" do
5
5
  t = Spec::Rake::SpecTask.new do |t|
6
- t.deep_test :number_of_workers => 2
6
+ t.deep_test :number_of_agents => 2
7
7
  end
8
8
 
9
- deep_test_path = File.expand_path(File.dirname(__FILE__) +
10
- '/../../../../lib/deep_test')
11
- options = DeepTest::Options.new(:number_of_workers => 2)
9
+ deep_test_path = File.expand_path(DeepTest::LIB_ROOT + "/deep_test")
10
+ options = DeepTest::Options.new(:number_of_agents => 2)
12
11
  t.spec_opts.should == ["--require #{deep_test_path}",
13
12
  "--runner 'DeepTest::Spec::Runner:#{options.to_command_line}'"]
14
13
  end
@@ -19,8 +18,7 @@ describe Spec::Rake::SpecTask do
19
18
  t.spec_opts = ["anoption"]
20
19
  end
21
20
 
22
- deep_test_path = File.expand_path(File.dirname(__FILE__) +
23
- '/../../../../lib/deep_test')
21
+ deep_test_path = File.expand_path(DeepTest::LIB_ROOT + "/deep_test")
24
22
  options = DeepTest::Options.new({})
25
23
  t.spec_opts.should == ["--require #{deep_test_path}",
26
24
  "--runner 'DeepTest::Spec::Runner:#{options.to_command_line}'",
@@ -5,100 +5,127 @@ module DeepTest
5
5
  describe Runner do
6
6
  it_should_behave_like 'sandboxed rspec_options'
7
7
 
8
- it "should run each test using blackboard" do
9
- blackboard = SimpleTestBlackboard.new
10
- runner = Runner.new(options, Options.new({}), blackboard)
8
+ it "should run each test using central_command" do
9
+ deep_test_options = Options.new({})
10
+ central_command = TestCentralCommand.start deep_test_options
11
+ runner = Runner.new(options, deep_test_options.to_command_line)
11
12
 
12
13
  describe("test") do
13
14
  it("passes1") {}
14
15
  it("passes2") {}
15
16
  end
16
17
 
17
- worker = ThreadWorker.new(blackboard, 2)
18
+ agent = ThreadAgent.new deep_test_options
18
19
  Timeout.timeout(5) do
19
- runner.process_work_units.should == true
20
+ runner.process_work_units(central_command).should == true
20
21
  end
21
- worker.wait_until_done
22
+ central_command.done_with_work
23
+ agent.wait_until_done
22
24
 
23
- worker.work_done.should == 2
25
+ agent.work_done.should == 2
24
26
  options.reporter.number_of_examples.should == 2
25
- blackboard.take_result.should be_nil
27
+ central_command.remaining_result_count.should == 0
26
28
  options.reporter.examples_finished.should == ['passes1','passes2']
27
29
  options.reporter.should be_ended
28
30
  end
29
31
 
30
32
  it "should return failure when a spec fails" do
31
- blackboard = SimpleTestBlackboard.new
32
- runner = Runner.new(options, Options.new({}), blackboard)
33
+ deep_test_options = Options.new({})
34
+ central_command = TestCentralCommand.start deep_test_options
35
+ runner = Runner.new(options, deep_test_options.to_command_line)
33
36
 
34
37
  describe("test") do
35
38
  it("passes") {};
36
39
  it("fails") {1.should == 2};
37
40
  end
38
41
 
39
- worker = ThreadWorker.new(blackboard, 2)
42
+ agent = ThreadAgent.new(deep_test_options)
40
43
  Timeout.timeout(5) do
41
- runner.process_work_units.should == false
44
+ runner.process_work_units(central_command).should == false
42
45
  end
43
- worker.wait_until_done
46
+ central_command.done_with_work
47
+ agent.wait_until_done
44
48
  end
45
49
 
46
50
  it "should return success when there are pending examples" do
47
- blackboard = SimpleTestBlackboard.new
48
- runner = Runner.new(options, Options.new({}), blackboard)
51
+ deep_test_options = Options.new({})
52
+ central_command = TestCentralCommand.start deep_test_options
53
+ runner = Runner.new(options, deep_test_options.to_command_line)
49
54
 
50
55
  describe("test") do
51
56
  it("pending") {pending {1.should == 2}};
52
57
  end
53
58
 
54
- worker = ThreadWorker.new(blackboard, 1)
59
+ agent = ThreadAgent.new deep_test_options
55
60
  Timeout.timeout(5) do
56
- runner.process_work_units.should == true
61
+ runner.process_work_units(central_command).should == true
57
62
  end
58
- worker.wait_until_done
63
+ central_command.done_with_work
64
+ agent.wait_until_done
59
65
  end
60
66
 
61
67
  it "should return failure when a pending example passes" do
62
- blackboard = SimpleTestBlackboard.new
63
- runner = Runner.new(options, Options.new({}), blackboard)
68
+ deep_test_options = Options.new({})
69
+ central_command = TestCentralCommand.start deep_test_options
70
+ runner = Runner.new(options, deep_test_options.to_command_line)
64
71
 
65
72
  describe("test") do
66
73
  it("pending") {pending {1.should == 1}};
67
74
  end
68
75
 
69
- worker = ThreadWorker.new(blackboard, 1)
76
+ agent = ThreadAgent.new deep_test_options
70
77
  Timeout.timeout(5) do
71
- runner.process_work_units.should == false
78
+ runner.process_work_units(central_command).should == false
72
79
  end
73
- worker.wait_until_done
80
+ central_command.done_with_work
81
+ agent.wait_until_done
74
82
  end
75
83
 
76
- it "should return failure when a worker error occurs" do
77
- blackboard = SimpleTestBlackboard.new
78
- runner = Runner.new(options, Options.new({}), blackboard)
84
+ it "should return failure when a agent error occurs" do
85
+ deep_test_options = Options.new({})
86
+ central_command = TestCentralCommand.start deep_test_options
87
+ runner = Runner.new(options, deep_test_options.to_command_line)
88
+
89
+ describe("test") { it("does") {} }
90
+
91
+ central_command.write_result Agent::Error.new("example", RuntimeError.new)
92
+ capture_stdout do
93
+ runner.process_work_units(central_command).should == false
94
+ end
95
+
96
+ options.reporter.number_of_errors.should == 1
97
+ end
98
+
99
+ it "should return a singl efailure when multiple agent error occurs" do
100
+ deep_test_options = Options.new({})
101
+ central_command = TestCentralCommand.start deep_test_options
102
+ runner = Runner.new(options, deep_test_options.to_command_line)
79
103
 
80
104
  describe("test") do
81
- it("pending") {pending {1.should == 1}};
105
+ it("does a") {}
106
+ it("does b") {}
82
107
  end
83
108
 
84
- blackboard.write_result Worker::Error.new("example", RuntimeError.new)
109
+ central_command.write_result Agent::Error.new("example 1", RuntimeError.new)
110
+ central_command.write_result Agent::Error.new("example 2", RuntimeError.new)
85
111
  capture_stdout do
86
- runner.process_work_units.should == false
112
+ runner.process_work_units(central_command).should == false
87
113
  end
88
114
 
89
115
  options.reporter.number_of_errors.should == 1
90
116
  end
91
117
 
92
118
  it "should raise error if duplicate spec is found" do
93
- blackboard = SimpleTestBlackboard.new
94
- runner = Runner.new(options, Options.new({}), blackboard)
119
+ deep_test_options = Options.new({})
120
+ central_command = TestCentralCommand.start deep_test_options
121
+ runner = Runner.new(options, deep_test_options.to_command_line)
95
122
 
96
123
  describe("test") do
97
124
  2.times {it("example") {}};
98
125
  end
99
126
 
100
127
  lambda {
101
- runner.process_work_units
128
+ runner.process_work_units(central_command)
102
129
  }.should raise_error
103
130
  end
104
131
  end