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.
Files changed (170) hide show
  1. data/.gitignore +0 -1
  2. data/README.rdoc +70 -41
  3. data/Rakefile +104 -32
  4. data/TODO +2 -2
  5. data/VERSION +1 -1
  6. data/bin/deep_test +15 -0
  7. data/jstorimer-deep-test-0.1.0.gem +0 -0
  8. data/jstorimer-deep-test.gemspec +1425 -0
  9. data/lib/deep_test.rb +40 -28
  10. data/lib/deep_test/database/mysql_setup_listener.rb +12 -12
  11. data/lib/deep_test/database/setup_listener.rb +23 -23
  12. data/lib/deep_test/distributed/dispatch_controller.rb +10 -17
  13. data/lib/deep_test/distributed/drb_client_connection_info.rb +15 -0
  14. data/lib/deep_test/distributed/master_test_server.rb +52 -0
  15. data/lib/deep_test/distributed/multi_test_server_proxy.rb +44 -0
  16. data/lib/deep_test/distributed/null_work_unit.rb +12 -0
  17. data/lib/deep_test/distributed/remote_worker_client.rb +54 -0
  18. data/lib/deep_test/distributed/remote_worker_server.rb +82 -0
  19. data/lib/deep_test/distributed/rsync.rb +12 -25
  20. data/lib/deep_test/distributed/show_status.rhtml +41 -0
  21. data/lib/deep_test/distributed/test_server.rb +78 -0
  22. data/lib/deep_test/distributed/test_server_status.rb +9 -0
  23. data/lib/deep_test/distributed/test_server_workers.rb +24 -0
  24. data/lib/deep_test/distributed/throughput_runner.rb +42 -0
  25. data/lib/deep_test/distributed/throughput_statistics.rb +26 -0
  26. data/lib/deep_test/distributed/throughput_worker_client.rb +19 -0
  27. data/lib/deep_test/extensions/drb_extension.rb +34 -0
  28. data/lib/deep_test/listener_list.rb +1 -1
  29. data/lib/deep_test/local_workers.rb +55 -0
  30. data/lib/deep_test/logger.rb +2 -17
  31. data/lib/deep_test/marshallable_exception_wrapper.rb +4 -4
  32. data/lib/deep_test/metrics/gatherer.rb +67 -0
  33. data/lib/deep_test/metrics/queue_lock_wait_time_measurement.rb +133 -0
  34. data/lib/deep_test/{null_listener.rb → null_worker_listener.rb} +14 -14
  35. data/lib/deep_test/option.rb +60 -0
  36. data/lib/deep_test/options.rb +42 -45
  37. data/lib/deep_test/process_orchestrator.rb +49 -0
  38. data/lib/deep_test/rake_tasks.rb +1 -3
  39. data/lib/deep_test/result_reader.rb +6 -10
  40. data/lib/deep_test/rspec_detector.rb +1 -1
  41. data/lib/deep_test/server.rb +75 -0
  42. data/lib/deep_test/spec.rb +1 -5
  43. data/lib/deep_test/spec/extensions/example_methods.rb +1 -7
  44. data/lib/deep_test/spec/extensions/reporter.rb +29 -0
  45. data/lib/deep_test/spec/extensions/spec_task.rb +2 -3
  46. data/lib/deep_test/spec/runner.rb +17 -32
  47. data/lib/deep_test/spec/work_result.rb +0 -2
  48. data/lib/deep_test/test/runner.rb +2 -2
  49. data/lib/deep_test/test/supervised_test_suite.rb +10 -9
  50. data/lib/deep_test/test/work_result.rb +0 -1
  51. data/lib/deep_test/test_task.rb +1 -1
  52. data/lib/deep_test/ui/console.rb +11 -9
  53. data/lib/deep_test/warlock.rb +25 -37
  54. data/lib/deep_test/worker.rb +57 -0
  55. data/sample_rails_project/deep_test.rb +0 -4
  56. data/sample_rails_project/lib/{foreign_host_agent_simulation_listener.rb → foreign_host_worker_simulation_listener.rb} +4 -6
  57. data/sample_rails_project/lib/tasks/deep_test.rake +4 -13
  58. data/script/internal/run_test_suite.rb +7 -0
  59. data/script/public/master_test_server.rb +24 -0
  60. data/script/public/test_server.rb +18 -0
  61. data/script/public/test_throughput.rb +29 -0
  62. data/spec/deep_test/option_spec.rb +33 -0
  63. data/spec/deep_test/options_spec.rb +59 -80
  64. data/spec/deep_test/spec/extensions/example_methods_spec.rb +4 -5
  65. data/spec/deep_test/spec/extensions/spec_task_spec.rb +6 -4
  66. data/spec/deep_test/spec/runner_spec.rb +32 -59
  67. data/spec/spec_helper.rb +6 -14
  68. data/spec/thread_worker.rb +25 -0
  69. data/test/deep_test/database/mysql_setup_listener_test.rb +9 -13
  70. data/test/deep_test/distributed/dispatch_controller_test.rb +177 -130
  71. data/test/deep_test/distributed/drb_client_connection_info_test.rb +42 -0
  72. data/test/deep_test/distributed/filename_resolver_test.rb +34 -38
  73. data/test/deep_test/distributed/master_test_server_test.rb +32 -0
  74. data/test/deep_test/distributed/multi_test_server_proxy_test.rb +96 -0
  75. data/test/deep_test/distributed/remote_worker_client_test.rb +180 -0
  76. data/test/deep_test/distributed/remote_worker_server_test.rb +99 -0
  77. data/test/deep_test/distributed/rsync_test.rb +62 -42
  78. data/test/deep_test/distributed/test_server_test.rb +94 -0
  79. data/test/deep_test/distributed/test_server_workers_test.rb +26 -0
  80. data/test/deep_test/distributed/throughput_runner_test.rb +68 -0
  81. data/test/deep_test/distributed/throughput_worker_client_test.rb +28 -0
  82. data/test/deep_test/listener_list_test.rb +15 -17
  83. data/test/deep_test/local_workers_test.rb +22 -0
  84. data/test/deep_test/logger_test.rb +7 -34
  85. data/test/deep_test/marshallable_exception_wrapper_test.rb +29 -31
  86. data/test/deep_test/metrics/gatherer_test.rb +66 -0
  87. data/test/deep_test/process_orchestrator_test.rb +11 -0
  88. data/test/deep_test/result_reader_test.rb +95 -95
  89. data/test/deep_test/server_test.rb +58 -0
  90. data/test/deep_test/test/extensions/error_test.rb +36 -38
  91. data/test/deep_test/test/runner_test.rb +3 -7
  92. data/test/deep_test/test/supervised_test_suite_test.rb +61 -89
  93. data/test/deep_test/test/work_result_test.rb +76 -80
  94. data/test/deep_test/test/work_unit_test.rb +51 -53
  95. data/test/deep_test/test_task_test.rb +38 -10
  96. data/test/deep_test/ui/console_test.rb +4 -8
  97. data/test/deep_test/warlock_test.rb +31 -33
  98. data/test/deep_test/worker_test.rb +94 -0
  99. data/test/failing.rake +11 -0
  100. data/{negative_acceptance_tests/failing_test.rb → test/failing.rb} +1 -3
  101. data/{infrastructure → test}/fake_deadlock_error.rb +0 -0
  102. data/test/simple_test_blackboard.rb +45 -0
  103. data/test/simple_test_blackboard_test.rb +33 -0
  104. data/{infrastructure → test}/test_factory.rb +0 -0
  105. data/test/test_helper.rb +5 -20
  106. data/test/test_task_test.rb +57 -60
  107. metadata +78 -87
  108. data/infrastructure/dynamic_teardown.rb +0 -22
  109. data/infrastructure/load.rb +0 -11
  110. data/infrastructure/test_central_command.rb +0 -15
  111. data/infrastructure/test_exception.rb +0 -7
  112. data/infrastructure/test_logger.rb +0 -11
  113. data/infrastructure/test_operator.rb +0 -15
  114. data/infrastructure/test_result.rb +0 -15
  115. data/infrastructure/thread_agent.rb +0 -21
  116. data/infrastructure/timewarp/Rakefile +0 -14
  117. data/infrastructure/timewarp/lib/timewarp.rb +0 -21
  118. data/infrastructure/timewarp/test/timewarp_test.rb +0 -45
  119. data/lib/deep_test/agent.rb +0 -108
  120. data/lib/deep_test/central_command.rb +0 -165
  121. data/lib/deep_test/cpu_info.rb +0 -22
  122. data/lib/deep_test/demon.rb +0 -25
  123. data/lib/deep_test/distributed/beachhead.rb +0 -104
  124. data/lib/deep_test/distributed/establish_beachhead.rb +0 -19
  125. data/lib/deep_test/distributed/landing_fleet.rb +0 -30
  126. data/lib/deep_test/distributed/landing_ship.rb +0 -60
  127. data/lib/deep_test/distributed/remote_deployment.rb +0 -56
  128. data/lib/deep_test/distributed/shell_environment.rb +0 -50
  129. data/lib/deep_test/distributed/ssh_client_connection_info.rb +0 -14
  130. data/lib/deep_test/failure_message.rb +0 -19
  131. data/lib/deep_test/lib_root.rb +0 -4
  132. data/lib/deep_test/local_deployment.rb +0 -46
  133. data/lib/deep_test/main.rb +0 -41
  134. data/lib/deep_test/metrics/data.rb +0 -34
  135. data/lib/deep_test/metrics/measurement.rb +0 -39
  136. data/lib/deep_test/proxy_io.rb +0 -77
  137. data/lib/deep_test/test/run_test_suite.rb +0 -5
  138. data/lib/telegraph.rb +0 -29
  139. data/lib/telegraph/ack_sequence.rb +0 -14
  140. data/lib/telegraph/logging.rb +0 -20
  141. data/lib/telegraph/message.rb +0 -39
  142. data/lib/telegraph/operator.rb +0 -47
  143. data/lib/telegraph/switchboard.rb +0 -57
  144. data/lib/telegraph/wire.rb +0 -73
  145. data/negative_acceptance_tests/dying_spec.rb +0 -13
  146. data/negative_acceptance_tests/dying_test.rb +0 -13
  147. data/negative_acceptance_tests/failing_spec.rb +0 -9
  148. data/negative_acceptance_tests/kill_agent_one_on_start_work.rb +0 -16
  149. data/negative_acceptance_tests/passing_spec.rb +0 -10
  150. data/negative_acceptance_tests/passing_test.rb +0 -12
  151. data/negative_acceptance_tests/tasks.rake +0 -87
  152. data/negative_acceptance_tests/tests.rb +0 -60
  153. data/test/deep_test/agent_test.rb +0 -175
  154. data/test/deep_test/central_command_test.rb +0 -147
  155. data/test/deep_test/cpu_info_test.rb +0 -33
  156. data/test/deep_test/demon_test.rb +0 -23
  157. data/test/deep_test/distributed/beachhead_test.rb +0 -67
  158. data/test/deep_test/distributed/landing_fleet_test.rb +0 -55
  159. data/test/deep_test/distributed/landing_ship_test.rb +0 -48
  160. data/test/deep_test/distributed/remote_deployment_test.rb +0 -134
  161. data/test/deep_test/distributed/shell_environment_fixtures/set_bar_to_foo +0 -1
  162. data/test/deep_test/distributed/shell_environment_fixtures/set_foo_to_bar +0 -1
  163. data/test/deep_test/distributed/shell_environment_fixtures/set_foo_to_baz +0 -1
  164. data/test/deep_test/distributed/shell_environment_test.rb +0 -108
  165. data/test/deep_test/distributed/ssh_client_connection_info_test.rb +0 -34
  166. data/test/deep_test/local_deployment_test.rb +0 -19
  167. data/test/deep_test/main_test.rb +0 -12
  168. data/test/deep_test/metrics/data_test.rb +0 -22
  169. data/test/deep_test/metrics/measurement_test.rb +0 -18
  170. data/test/deep_test/proxy_io_test.rb +0 -104
data/lib/deep_test.rb CHANGED
@@ -3,15 +3,27 @@ module DeepTest
3
3
  def logger
4
4
  @logger ||= DeepTest::Logger.new($stdout)
5
5
  end
6
-
7
- def logger=(logger)
8
- @logger = logger
9
- end
10
6
  end
11
7
 
12
- class IncompleteTestRunError < StandardError
13
- def initialize(count)
14
- super "#{count} tests were not run because the DeepTest Agents died"
8
+ # Fork in a separate thread. If we fork from a DRb thread
9
+ # (a thread handling a method call invoked over drb),
10
+ # DRb still thinks the current object is the DRb Front Object,
11
+ # and reports its uri as the same as in the parent process, even
12
+ # if you restart DRb service.
13
+ #
14
+ def self.drb_safe_fork(&block)
15
+ Thread.new {Process.fork(&block)}.value
16
+ end
17
+
18
+ def self.init(options)
19
+ return if @initialized
20
+ @initialized = true
21
+ Metrics::Gatherer.setup(options)
22
+ end
23
+
24
+ class WorkUnitNeverReceivedError < StandardError
25
+ def initialize
26
+ super "DeepTest result never received. Maybe an error was printed above?"
15
27
  end
16
28
 
17
29
  def backtrace
@@ -21,52 +33,53 @@ module DeepTest
21
33
  end
22
34
 
23
35
  require "logger"
36
+ require "drb"
24
37
  require "timeout"
25
38
  require "thread"
26
39
  require "socket"
27
40
  require "webrick"
28
41
  require "timeout"
29
- require "base64"
30
42
 
31
- require File.dirname(__FILE__) + "/telegraph"
32
- require File.dirname(__FILE__) + "/deep_test/lib_root"
33
43
  require File.dirname(__FILE__) + "/deep_test/extensions/object_extension"
44
+ require File.dirname(__FILE__) + "/deep_test/extensions/drb_extension"
34
45
 
35
- require File.dirname(__FILE__) + "/deep_test/demon"
36
46
  require File.dirname(__FILE__) + "/deep_test/deadlock_detector"
37
- require File.dirname(__FILE__) + "/deep_test/local_deployment"
47
+ require File.dirname(__FILE__) + "/deep_test/local_workers"
38
48
  require File.dirname(__FILE__) + "/deep_test/logger"
39
49
 
40
50
  require File.dirname(__FILE__) + "/deep_test/marshallable_exception_wrapper"
41
- require File.dirname(__FILE__) + "/deep_test/null_listener"
51
+ require File.dirname(__FILE__) + "/deep_test/null_worker_listener"
42
52
  require File.dirname(__FILE__) + "/deep_test/listener_list"
43
- require File.dirname(__FILE__) + "/deep_test/cpu_info"
44
- require File.dirname(__FILE__) + "/deep_test/failure_message"
53
+ require File.dirname(__FILE__) + "/deep_test/option"
45
54
  require File.dirname(__FILE__) + "/deep_test/options"
46
- require File.dirname(__FILE__) + "/deep_test/main"
55
+ require File.dirname(__FILE__) + "/deep_test/process_orchestrator"
47
56
  require File.dirname(__FILE__) + "/deep_test/result_reader"
48
57
  require File.dirname(__FILE__) + "/deep_test/rspec_detector"
49
- require File.dirname(__FILE__) + "/deep_test/central_command"
50
- require File.dirname(__FILE__) + "/deep_test/proxy_io"
58
+ require File.dirname(__FILE__) + "/deep_test/server"
51
59
  require File.dirname(__FILE__) + "/deep_test/test_task"
52
- require File.dirname(__FILE__) + "/deep_test/agent"
60
+ require File.dirname(__FILE__) + "/deep_test/worker"
53
61
  require File.dirname(__FILE__) + "/deep_test/warlock"
54
62
 
55
63
  require File.dirname(__FILE__) + "/deep_test/database/setup_listener"
56
64
  require File.dirname(__FILE__) + "/deep_test/database/mysql_setup_listener"
57
65
 
58
- require File.dirname(__FILE__) + "/deep_test/distributed/shell_environment"
59
- require File.dirname(__FILE__) + "/deep_test/distributed/landing_ship"
60
66
  require File.dirname(__FILE__) + "/deep_test/distributed/dispatch_controller"
61
- require File.dirname(__FILE__) + "/deep_test/distributed/ssh_client_connection_info"
67
+ require File.dirname(__FILE__) + "/deep_test/distributed/drb_client_connection_info"
62
68
  require File.dirname(__FILE__) + "/deep_test/distributed/filename_resolver"
63
- require File.dirname(__FILE__) + "/deep_test/distributed/landing_fleet"
64
- require File.dirname(__FILE__) + "/deep_test/distributed/remote_deployment"
65
- require File.dirname(__FILE__) + "/deep_test/distributed/beachhead"
69
+ require File.dirname(__FILE__) + "/deep_test/distributed/master_test_server"
70
+ require File.dirname(__FILE__) + "/deep_test/distributed/test_server"
71
+ require File.dirname(__FILE__) + "/deep_test/distributed/test_server_status"
72
+ require File.dirname(__FILE__) + "/deep_test/distributed/test_server_workers"
73
+ require File.dirname(__FILE__) + "/deep_test/distributed/multi_test_server_proxy"
74
+ require File.dirname(__FILE__) + "/deep_test/distributed/null_work_unit"
75
+ require File.dirname(__FILE__) + "/deep_test/distributed/remote_worker_client"
76
+ require File.dirname(__FILE__) + "/deep_test/distributed/remote_worker_server"
66
77
  require File.dirname(__FILE__) + "/deep_test/distributed/rsync"
78
+ require File.dirname(__FILE__) + "/deep_test/distributed/throughput_runner"
79
+ require File.dirname(__FILE__) + "/deep_test/distributed/throughput_statistics"
80
+ require File.dirname(__FILE__) + "/deep_test/distributed/throughput_worker_client"
67
81
 
68
- require File.dirname(__FILE__) + "/deep_test/metrics/data"
69
- require File.dirname(__FILE__) + "/deep_test/metrics/measurement"
82
+ require File.dirname(__FILE__) + "/deep_test/metrics/gatherer"
70
83
 
71
84
  DeepTest::RSpecDetector.if_rspec_available do
72
85
  require File.dirname(__FILE__) + "/deep_test/spec"
@@ -75,4 +88,3 @@ require File.dirname(__FILE__) + "/deep_test/test"
75
88
 
76
89
  require File.dirname(__FILE__) + "/deep_test/ui/console"
77
90
  require File.dirname(__FILE__) + "/deep_test/ui/null"
78
-
@@ -26,26 +26,26 @@ module DeepTest
26
26
  #
27
27
  def create_database
28
28
  admin_connection do |connection|
29
- connection.create_database agent_database
29
+ connection.create_database worker_database
30
30
  grant_privileges connection
31
31
  end
32
32
  end
33
33
 
34
34
  #
35
- # Grants 'all' privilege on agent database to username and password
36
- # specified by agent database config. If your application has
35
+ # Grants 'all' privilege on worker database to username and password
36
+ # specified by worker database config. If your application has
37
37
  # special database privilege needs beyond 'all', you should override
38
38
  # this method and grant them.
39
39
  #
40
40
  def grant_privileges(connection)
41
- puts "==== #{agent_database_config[:password].inspect}"
42
- identified_by = if agent_database_config[:password]
43
- %{identified by %s} % connection.quote(agent_database_config[:password])
41
+ puts "==== #{worker_database_config[:password].inspect}"
42
+ identified_by = if worker_database_config[:password]
43
+ %{identified by %s} % connection.quote(worker_database_config[:password])
44
44
  else
45
45
  ""
46
46
  end
47
- sql = %{grant all on #{agent_database}.* to %s@'localhost' #{identified_by} ; } %
48
- connection.quote(agent_database_config[:username])
47
+ sql = %{grant all on #{worker_database}.* to %s@'localhost' #{identified_by} ; } %
48
+ connection.quote(worker_database_config[:username])
49
49
 
50
50
  connection.execute sql
51
51
  end
@@ -55,7 +55,7 @@ module DeepTest
55
55
  #
56
56
  def drop_database
57
57
  admin_connection do |connection|
58
- connection.drop_database agent_database
58
+ connection.drop_database worker_database
59
59
  end
60
60
  end
61
61
 
@@ -69,10 +69,10 @@ module DeepTest
69
69
  end
70
70
 
71
71
  #
72
- # Loads dumpfile into agent database using mysql command
72
+ # Loads dumpfile into worker database using mysql command
73
73
  #
74
74
  def load_schema
75
- config = command_line_config(agent_database_config)
75
+ config = command_line_config(worker_database_config)
76
76
  system "mysql #{config} < #{dump_file_name}"
77
77
  raise "Error Loading schema" unless $?.success?
78
78
  end
@@ -87,7 +87,7 @@ module DeepTest
87
87
  end
88
88
 
89
89
  def system(command) # :nodoc:
90
- DeepTest.logger.info { command }
90
+ DeepTest.logger.info command
91
91
  super command
92
92
  end
93
93
 
@@ -2,18 +2,18 @@ module DeepTest
2
2
  module Database
3
3
  #
4
4
  # Skeleton Listener to help with setting up a separate database
5
- # for each agent. Calls +dump_schema+, +load_schema+, +create_database+,
5
+ # for each worker. Calls +dump_schema+, +load_schema+, +create_database+,
6
6
  # and +drop_database+ hooks provided by subclasses that implement database
7
7
  # setup strategies for particular database flavors.
8
8
  #
9
- class SetupListener < NullListener
9
+ class SetupListener < NullWorkerListener
10
10
  DUMPED_SCHEMAS = [] unless defined?(DUMPED_SCHEMAS)
11
11
 
12
12
  def before_sync # :nodoc:
13
13
  dump_schema_once
14
14
  end
15
15
 
16
- def before_starting_agents # :nodoc:
16
+ def before_starting_workers # :nodoc:
17
17
  dump_schema_once
18
18
  end
19
19
 
@@ -23,11 +23,11 @@ module DeepTest
23
23
  DUMPED_SCHEMAS << schema_name
24
24
  end
25
25
 
26
- def starting(agent) # :nodoc:
27
- @agent = agent
26
+ def starting(worker) # :nodoc:
27
+ @worker = worker
28
28
 
29
29
  at_exit do
30
- DeepTest.logger.debug { "dropping database #{agent_database}" }
30
+ DeepTest.logger.debug("dropping database #{worker_database}")
31
31
  drop_database
32
32
  end
33
33
 
@@ -38,26 +38,26 @@ module DeepTest
38
38
  end
39
39
 
40
40
  #
41
- # Called on each agent after creating database and before loading
41
+ # Called on each worker after creating database and before loading
42
42
  # schema to initialize connections
43
43
  #
44
44
  def connect_to_database
45
- ActiveRecord::Base.establish_connection(agent_database_config)
45
+ ActiveRecord::Base.establish_connection(worker_database_config)
46
46
  end
47
47
 
48
48
  #
49
- # Called in each agent to create the database named by
50
- # +agent_database+.
49
+ # Called in each worker to create the database named by
50
+ # +worker_database+.
51
51
  #
52
52
  def create_database
53
53
  raise "Subclass must implement"
54
54
  end
55
55
 
56
56
  #
57
- # Called in each agent to drop the database created by
57
+ # Called in each worker to drop the database created by
58
58
  # +create_database+. This method is called twice, once before
59
59
  # +create_database+ to ensure that no database exists and once
60
- # at exit to clean as the agent process exits. This method
60
+ # at exit to clean as the worker process exits. This method
61
61
  # must not fail if the database does not exist when it is called.
62
62
  #
63
63
  def drop_database
@@ -65,12 +65,12 @@ module DeepTest
65
65
  end
66
66
 
67
67
  #
68
- # Called before any agents are spawned to dump the schema that
68
+ # Called before any workers are spawned to dump the schema that
69
69
  # will be used for testing. When running distributed, this method
70
70
  # is called on the local machine providing the tests to run.
71
71
  #
72
72
  # For distributed testing to work, the schema must be dumped in
73
- # location accessible by all agent machines. The easiest way to
73
+ # location accessible by all worker machines. The easiest way to
74
74
  # accomplish this is to dump it to a location within the working copy.
75
75
  #
76
76
  def dump_schema
@@ -79,21 +79,21 @@ module DeepTest
79
79
 
80
80
 
81
81
  #
82
- # Called once in each agent as it is starting to load the schema
82
+ # Called once in each worker as it is starting to load the schema
83
83
  # dumped from dump_schema. Subclasses should load the schema definition
84
- # into the +agent_database+
84
+ # into the +worker_database+
85
85
  #
86
86
  def load_schema
87
87
  raise "Subclass must implement"
88
88
  end
89
89
 
90
90
  #
91
- # ActiveRecord configuration for the agent database. By default,
91
+ # ActiveRecord configuration for the worker database. By default,
92
92
  # the same as +master_database_config+, except that points to
93
- # +agent_database+ instead of the database named in the master config.
93
+ # +worker_database+ instead of the database named in the master config.
94
94
  #
95
- def agent_database_config
96
- master_database_config.merge(:database => agent_database)
95
+ def worker_database_config
96
+ master_database_config.merge(:database => worker_database)
97
97
  end
98
98
 
99
99
  #
@@ -106,10 +106,10 @@ module DeepTest
106
106
  end
107
107
 
108
108
  #
109
- # Unique name for database on machine that agent is running on.
109
+ # Unique name for database on machine that worker is running on.
110
110
  #
111
- def agent_database
112
- "deep_test_agent_#{@agent.number}_pid_#{Process.pid}"
111
+ def worker_database
112
+ "deep_test_worker_#{@worker.number}_pid_#{Process.pid}"
113
113
  end
114
114
  end
115
115
  end
@@ -17,12 +17,9 @@ module DeepTest
17
17
 
18
18
  threads = @receivers.map do |r|
19
19
  Thread.new do
20
- begin
21
- Thread.current[:receiver] = r
20
+ Thread.current[:receiver] = r
21
+ Timeout.timeout(@options.timeout_in_seconds) do
22
22
  r.send method_name, *args
23
- rescue Exception => e
24
- Thread.current[:original_exception] = e
25
- raise
26
23
  end
27
24
  end
28
25
  end
@@ -33,14 +30,15 @@ module DeepTest
33
30
  results << t.value
34
31
  rescue Timeout::Error
35
32
  @receivers.delete t[:receiver]
36
- DeepTest.logger.error { "Timeout dispatching #{method_name} to #{description t[:receiver]}" }
37
- rescue Exception => this_exception
33
+ DeepTest.logger.error "Timeout dispatching #{method_name} to #{t[:receiver].__drburi}"
34
+ rescue DRb::DRbConnError
38
35
  @receivers.delete t[:receiver]
39
- DeepTest.logger.error { "Exception while dispatching #{method_name} to #{description t[:receiver]}:" }
40
-
41
- e = t[:original_exception] || this_exception
42
- DeepTest.logger.error { "#{e.class}: #{e.message}" }
43
- e.backtrace.each {|l| DeepTest.logger.error { l } }
36
+ unless options[:ignore_connection_error]
37
+ DeepTest.logger.error "Connection Refused dispatching #{method_name} to #{t[:receiver].__drburi}"
38
+ end
39
+ rescue Exception => e
40
+ @receivers.delete t[:receiver]
41
+ DeepTest.logger.error "Exception while dispatching #{method_name} to #{t[:receiver].__drburi} #{e.message}"
44
42
  end
45
43
  end
46
44
 
@@ -48,11 +46,6 @@ module DeepTest
48
46
  ensure
49
47
  @options.ui_instance.dispatch_finished(method_name)
50
48
  end
51
-
52
- def description(receiver)
53
- receiver.inspect
54
- end
55
-
56
49
  end
57
50
 
58
51
  class NoDispatchReceiversError < StandardError; end
@@ -0,0 +1,15 @@
1
+ module DeepTest
2
+ module Distributed
3
+ class DRbClientConnectionInfo
4
+ attr_reader :address
5
+
6
+ def initialize
7
+ info = Thread.current['DRb']
8
+ raise "No DRb client found" unless info && info['client']
9
+ peeraddr = info['client'].peeraddr
10
+ DeepTest.logger.debug("DRbClientConnection info: #{peeraddr.inspect}")
11
+ @address = peeraddr[3]
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,52 @@
1
+ module DeepTest
2
+ module Distributed
3
+ class MasterTestServer
4
+ include ERB::Util
5
+
6
+ STATUS_PORT = 4020 unless defined?(STATUS_PORT)
7
+
8
+ attr_reader :servers
9
+
10
+ def initialize(servers)
11
+ @servers = servers
12
+ end
13
+
14
+ def show_status(req, res)
15
+ template = File.read(File.dirname(__FILE__) + "/show_status.rhtml")
16
+ res.body = ERB.new(template).result(binding)
17
+ end
18
+
19
+ def test_server_statuses
20
+ @servers.map do |s|
21
+ status = begin
22
+ s.status
23
+ rescue Exception => e
24
+ e
25
+ end
26
+
27
+ [s.__drburi, status]
28
+ end
29
+ end
30
+
31
+ def self.start(uri, server_uris)
32
+ master = start_drb(uri, server_uris)
33
+ start_http(master)
34
+ DeepTest.logger.info "MasterTestServer listening at #{DRb.uri}"
35
+ DRb.thread.join
36
+ end
37
+
38
+ def self.start_drb(uri, server_uris)
39
+ servers = server_uris.map {|server_uri| DRbObject.new_with_uri server_uri}
40
+ master = DeepTest::Distributed::MasterTestServer.new(servers)
41
+ DRb.start_service(uri, master)
42
+ master
43
+ end
44
+
45
+ def self.start_http(master)
46
+ s = WEBrick::HTTPServer.new :Port => STATUS_PORT
47
+ s.mount_proc("/", &master.method(:show_status))
48
+ Thread.new {s.start}
49
+ end
50
+ end
51
+ end
52
+ end
@@ -0,0 +1,44 @@
1
+ module DeepTest
2
+ module Distributed
3
+ class MultiTestServerProxy
4
+ def initialize(options, slaves)
5
+ DeepTest.logger.debug "MultiTestServerProxy#initialize #{slaves.length} slaves"
6
+ @slave_controller = DispatchController.new(options, slaves)
7
+ end
8
+
9
+ def spawn_worker_server(options)
10
+ DeepTest.logger.debug "dispatch spawn_worker_server for #{options.origin_hostname}"
11
+ WorkerServerProxy.new options,
12
+ @slave_controller.dispatch(:spawn_worker_server,
13
+ options)
14
+ end
15
+
16
+ def sync(options)
17
+ DeepTest.logger.debug "dispatch sync for #{options.origin_hostname}"
18
+ @slave_controller.dispatch(:sync, options)
19
+ end
20
+
21
+ class WorkerServerProxy
22
+ def initialize(options, slaves)
23
+ DeepTest.logger.debug "WorkerServerProxy#initialize #{slaves.inspect}"
24
+ @slave_controller = DispatchController.new(options, slaves)
25
+ end
26
+
27
+ def load_files(files)
28
+ DeepTest.logger.debug "dispatch load_files"
29
+ @slave_controller.dispatch(:load_files, files)
30
+ end
31
+
32
+ def start_all
33
+ DeepTest.logger.debug "dispatch start_all"
34
+ @slave_controller.dispatch(:start_all)
35
+ end
36
+
37
+ def stop_all
38
+ DeepTest.logger.debug "dispatch stop_all"
39
+ @slave_controller.dispatch_with_options(:stop_all, :ignore_connection_error => true)
40
+ end
41
+ end
42
+ end
43
+ end
44
+ end