jperkins-deep_test 1.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (117) hide show
  1. data/CHANGELOG +47 -0
  2. data/README.rdoc +228 -0
  3. data/Rakefile +247 -0
  4. data/bin/deep_test +15 -0
  5. data/lib/deep_test.rb +91 -0
  6. data/lib/deep_test/database/mysql_setup_listener.rb +112 -0
  7. data/lib/deep_test/database/postgresql_setup_listener.rb +116 -0
  8. data/lib/deep_test/database/setup_listener.rb +125 -0
  9. data/lib/deep_test/deadlock_detector.rb +7 -0
  10. data/lib/deep_test/distributed/dispatch_controller.rb +53 -0
  11. data/lib/deep_test/distributed/drb_client_connection_info.rb +15 -0
  12. data/lib/deep_test/distributed/filename_resolver.rb +40 -0
  13. data/lib/deep_test/distributed/master_test_server.rb +52 -0
  14. data/lib/deep_test/distributed/multi_test_server_proxy.rb +44 -0
  15. data/lib/deep_test/distributed/null_work_unit.rb +12 -0
  16. data/lib/deep_test/distributed/remote_worker_client.rb +54 -0
  17. data/lib/deep_test/distributed/remote_worker_server.rb +82 -0
  18. data/lib/deep_test/distributed/rsync.rb +37 -0
  19. data/lib/deep_test/distributed/show_status.rhtml +41 -0
  20. data/lib/deep_test/distributed/test_server.rb +78 -0
  21. data/lib/deep_test/distributed/test_server_status.rb +9 -0
  22. data/lib/deep_test/distributed/test_server_workers.rb +24 -0
  23. data/lib/deep_test/distributed/throughput_runner.rb +42 -0
  24. data/lib/deep_test/distributed/throughput_statistics.rb +26 -0
  25. data/lib/deep_test/distributed/throughput_worker_client.rb +19 -0
  26. data/lib/deep_test/extensions/drb_extension.rb +34 -0
  27. data/lib/deep_test/extensions/object_extension.rb +40 -0
  28. data/lib/deep_test/listener_list.rb +17 -0
  29. data/lib/deep_test/local_workers.rb +55 -0
  30. data/lib/deep_test/logger.rb +17 -0
  31. data/lib/deep_test/marshallable_exception_wrapper.rb +44 -0
  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_worker_listener.rb +62 -0
  35. data/lib/deep_test/option.rb +60 -0
  36. data/lib/deep_test/options.rb +110 -0
  37. data/lib/deep_test/process_orchestrator.rb +49 -0
  38. data/lib/deep_test/rake_tasks.rb +11 -0
  39. data/lib/deep_test/result_reader.rb +36 -0
  40. data/lib/deep_test/rspec_detector.rb +21 -0
  41. data/lib/deep_test/server.rb +75 -0
  42. data/lib/deep_test/spec.rb +13 -0
  43. data/lib/deep_test/spec/extensions/example_group_methods.rb +64 -0
  44. data/lib/deep_test/spec/extensions/example_methods.rb +46 -0
  45. data/lib/deep_test/spec/extensions/options.rb +43 -0
  46. data/lib/deep_test/spec/extensions/reporter.rb +29 -0
  47. data/lib/deep_test/spec/extensions/spec_task.rb +20 -0
  48. data/lib/deep_test/spec/runner.rb +57 -0
  49. data/lib/deep_test/spec/work_result.rb +33 -0
  50. data/lib/deep_test/spec/work_unit.rb +59 -0
  51. data/lib/deep_test/test.rb +10 -0
  52. data/lib/deep_test/test/extensions/error.rb +14 -0
  53. data/lib/deep_test/test/runner.rb +24 -0
  54. data/lib/deep_test/test/supervised_test_suite.rb +49 -0
  55. data/lib/deep_test/test/work_result.rb +34 -0
  56. data/lib/deep_test/test/work_unit.rb +40 -0
  57. data/lib/deep_test/test_task.rb +47 -0
  58. data/lib/deep_test/ui/console.rb +76 -0
  59. data/lib/deep_test/ui/null.rb +17 -0
  60. data/lib/deep_test/warlock.rb +134 -0
  61. data/lib/deep_test/worker.rb +57 -0
  62. data/script/internal/run_test_suite.rb +7 -0
  63. data/script/public/master_test_server.rb +24 -0
  64. data/script/public/test_server.rb +18 -0
  65. data/script/public/test_throughput.rb +29 -0
  66. data/spec/deep_test/option_spec.rb +33 -0
  67. data/spec/deep_test/options_spec.rb +183 -0
  68. data/spec/deep_test/spec/extensions/example_group_methods_spec.rb +48 -0
  69. data/spec/deep_test/spec/extensions/example_methods_spec.rb +61 -0
  70. data/spec/deep_test/spec/extensions/options_spec.rb +23 -0
  71. data/spec/deep_test/spec/extensions/reporter_spec.rb +28 -0
  72. data/spec/deep_test/spec/extensions/spec_task_spec.rb +36 -0
  73. data/spec/deep_test/spec/runner_spec.rb +106 -0
  74. data/spec/deep_test/spec/work_result_spec.rb +14 -0
  75. data/spec/deep_test/spec/work_unit_spec.rb +78 -0
  76. data/spec/spec_helper.rb +59 -0
  77. data/spec/thread_worker.rb +25 -0
  78. data/test/deep_test/database/mysql_setup_listener_test.rb +14 -0
  79. data/test/deep_test/distributed/dispatch_controller_test.rb +209 -0
  80. data/test/deep_test/distributed/drb_client_connection_info_test.rb +42 -0
  81. data/test/deep_test/distributed/filename_resolver_test.rb +52 -0
  82. data/test/deep_test/distributed/master_test_server_test.rb +32 -0
  83. data/test/deep_test/distributed/multi_test_server_proxy_test.rb +96 -0
  84. data/test/deep_test/distributed/remote_worker_client_test.rb +180 -0
  85. data/test/deep_test/distributed/remote_worker_server_test.rb +99 -0
  86. data/test/deep_test/distributed/rsync_test.rb +67 -0
  87. data/test/deep_test/distributed/test_server_test.rb +94 -0
  88. data/test/deep_test/distributed/test_server_workers_test.rb +26 -0
  89. data/test/deep_test/distributed/throughput_runner_test.rb +68 -0
  90. data/test/deep_test/distributed/throughput_worker_client_test.rb +28 -0
  91. data/test/deep_test/extensions/object_extension_test.rb +37 -0
  92. data/test/deep_test/listener_list_test.rb +20 -0
  93. data/test/deep_test/local_workers_test.rb +22 -0
  94. data/test/deep_test/logger_test.rb +11 -0
  95. data/test/deep_test/marshallable_exception_wrapper_test.rb +44 -0
  96. data/test/deep_test/metrics/gatherer_test.rb +66 -0
  97. data/test/deep_test/process_orchestrator_test.rb +11 -0
  98. data/test/deep_test/result_reader_test.rb +128 -0
  99. data/test/deep_test/server_test.rb +58 -0
  100. data/test/deep_test/test/extensions/error_test.rb +40 -0
  101. data/test/deep_test/test/runner_test.rb +7 -0
  102. data/test/deep_test/test/supervised_test_suite_test.rb +79 -0
  103. data/test/deep_test/test/work_result_test.rb +81 -0
  104. data/test/deep_test/test/work_unit_test.rb +61 -0
  105. data/test/deep_test/test_task_test.rb +43 -0
  106. data/test/deep_test/ui/console_test.rb +9 -0
  107. data/test/deep_test/warlock_test.rb +38 -0
  108. data/test/deep_test/worker_test.rb +94 -0
  109. data/test/failing.rake +11 -0
  110. data/test/failing.rb +7 -0
  111. data/test/fake_deadlock_error.rb +12 -0
  112. data/test/simple_test_blackboard.rb +45 -0
  113. data/test/simple_test_blackboard_test.rb +33 -0
  114. data/test/test_factory.rb +74 -0
  115. data/test/test_helper.rb +15 -0
  116. data/test/test_task_test.rb +72 -0
  117. metadata +214 -0
data/CHANGELOG ADDED
@@ -0,0 +1,47 @@
1
+ 1.2.2 (October 11, 2008)
2
+
3
+ * Added libs option to DeepTest::TestTask for Rails 2.1 compatibility
4
+ * RSpec 1.1.8 compatibility
5
+ * Require RSpec 1.1.8
6
+
7
+ 1.2.1 (September 25, 2008)
8
+
9
+ * rspec 1.1.4 compatibility
10
+ * Requires rspec 1.1.4
11
+
12
+ 1.2.0 (March 28, 2008)
13
+
14
+ * Added capability to run distributed
15
+ * Changed to use straight DRb instead of Rinda (performance)
16
+ * Changed error raised on before/after(:all) to warning
17
+ * Added worker listener to setup mysql database for each worker
18
+ * Run test server in same process
19
+ * Check rspec version when loading rspec support
20
+ * Add support for multiple worker listeners
21
+
22
+ 1.1.4 (March 11, 2008)
23
+
24
+ * Fixed 2 RSpec pending example bugs
25
+ * Fixed setting spec_opts with DeepTest bug
26
+ * Raise an error if before or after all is defined
27
+ * Added server_port to configuration options
28
+ * Wait for signal from server indicating it is ready on startup
29
+
30
+ 1.1.3 (March 10, 2008)
31
+
32
+ * Added Support for RSpec
33
+ * Added DeepTest::TestTask#timeout_in_seconds to configure Rinda IO timeouts
34
+ * Added worker_listener to configuration options
35
+
36
+ 1.1.2 (February 9, 2008)
37
+
38
+ * Fix bug with run_test_suite script not exiting with correct exit code.
39
+
40
+ 1.1.1 (February 9, 2008)
41
+
42
+ * No longer fork from Rake process.
43
+
44
+ 1.1.0 (December 23, 2007)
45
+
46
+ * DeepTest::TestTask#processes= is now DeepTest::TestTask#number_of_workers=
47
+ * No longer depend on the Daemons gem, use DeepTest::Warlock instead.
data/README.rdoc ADDED
@@ -0,0 +1,228 @@
1
+ = DeepTest
2
+
3
+ DeepTest enables tests to run in parallel using multiple processes. Processes
4
+ may spawned locally to take advantage of multiple processors on a single
5
+ machine or distributed across many machines to take advantage of distributed
6
+ processing.
7
+
8
+ == Usage
9
+
10
+ In your Rakefile:
11
+
12
+ require "rubygems"
13
+ require "deep_test/rake_tasks"
14
+
15
+ # sample DeepTest task
16
+
17
+ DeepTest::TestTask.new "task_name" do |t|
18
+ t.number_of_workers = 2 # optional, defaults to 2
19
+ t.timeout_in_seconds = 30 # optional, defaults to 30
20
+ t.server_port = 6969 # optional, defaults to 6969
21
+ t.pattern = "test/**/*_test.rb"
22
+ t.libs << "test" # may be necessary for Rails >= 2.1.x
23
+ end
24
+
25
+ # sample SpecTask using DeepTest
26
+
27
+ Spec::Rake::SpecTask.new(:deep_spec) do |t|
28
+ t.spec_files = FileList['spec/**/*_spec.rb']
29
+ t.deep_test :number_of_workers => 2, # optional, defaults to 2
30
+ :timeout_in_seconds => 30, # optional, defaults to 30
31
+ :server_port => 6969 # optional, defaults to 6969
32
+ end
33
+
34
+
35
+ === Specifying a Listener to be Notified of Events
36
+
37
+ In my_worker_listener.rb
38
+ class MyWorkerListener
39
+ def before_sync
40
+ end
41
+
42
+ def before_starting_workers
43
+ end
44
+
45
+ def starting(worker)
46
+ end
47
+
48
+ def starting_work(worker, work_unit)
49
+ end
50
+
51
+ def finished_work(worker, work_unit, result)
52
+ end
53
+ end
54
+
55
+ In your Rakefile
56
+
57
+ DeepTest::TestTask.new "task_name" do |t|
58
+ ...
59
+ t.worker_listener = "MyWorkerListener"
60
+ end
61
+
62
+ An instance of MyWorkerListener will be created for each worker that is
63
+ started, and will receive events from that worker. However, you must ensure
64
+ that the MyWorkerListener class is loaded at the time that the test files are
65
+ loaded, so it is available to be instantiated. You can specify multiple
66
+ listener classes by separating them with a comma. For more information about
67
+ when events are triggered, see the documentation at
68
+ DeepTest::NullWorkerListener.
69
+
70
+
71
+ === Setting Up A New Database For Each Worker
72
+
73
+ By default, DeepTest will reinitialize ActiveRecord connections if ActiveRecord
74
+ is loaded when the workers are started. This means all workers are running
75
+ against the same database. You may want each worker to use a database
76
+ decidicated to it. To facilitate this, DeepTest provides a worker listener to
77
+ help you. If you're using Rails with Mysql, simply configure DeepTest as
78
+ follows in your Rakefile:
79
+
80
+ DeepTest::TestTask.new "task_name" do |t|
81
+ ...
82
+ t.worker_listener = "DeepTest::Database::MysqlSetupListener"
83
+ end
84
+
85
+
86
+ Before spawning workers, DeepTest will dump the schema of the database for the
87
+ current Rails environment (usually test). As each worker starts up, the
88
+ listener will create a database dedicated to that worker and load the schema
89
+ into it. The database will be dropped when the worker process exits.
90
+
91
+ If you're using Mysql but not using Rails, you'll have to create a subclass of
92
+ MysqlSetupListener and override +master_database_config+ and +dump_file_name+,
93
+ as the default implementations of these methods are Rails specific.
94
+
95
+
96
+ If you're using a database other than Mysql, read the documentation for
97
+ DeepTest::Database::SetupListener and create a new subclass for your database
98
+ type. If you do this, please consider contributing your subclass back to the
99
+ project so that it can be included in later releases of DeepTest.
100
+
101
+ === Distributing Tests Across Multiple Machines
102
+
103
+ In addition to running your tests in parallel, DeepTest can also distribute
104
+ them across multiple machines. It does this by first mirroring the local
105
+ working copy that launched the tests on each machine that will be running tests.
106
+ Then workers are launched on each of the machines and consume tests in the same
107
+ fashion as when DeepTest is running locally.
108
+
109
+ ==== Requirements
110
+
111
+ Before you can distribute tests, you must ensure that all the machines involved
112
+ (including the machine with the local working copy) have rsync installed for
113
+ mirroring working copies. You must also have either SSH or an RSync daemon
114
+ exposing your local working copy running on the local development machine. For
115
+ more information about rsync, visit the rsync
116
+ webpage[http://www.samba.org/rsync/]. Currently only passwordless access is
117
+ supported, so you must either setup your RSync daemon to be accessible without
118
+ a password or enable passwordless SSH access from the test machines to the
119
+ local development machine. DeepTest must also be installed as a gem on each
120
+ test machine and available either as a gem or in your project on the local
121
+ machine.
122
+
123
+ ==== Starting a Test Server
124
+
125
+ On each test machine, execute the following:
126
+ > deep_test test_server
127
+
128
+ This will launch a server providing mirroring and worker services. By default,
129
+ 2 workers will be launched for each set of tests run. If you wish to change
130
+ the number of workers, simply specify the --number_of_workers option. For
131
+ information about what options are available, use -h. The test_server will
132
+ print out the uri it is bound to, druby://<hostname>:4022 by default.
133
+
134
+ ==== Starting a Master Test Server
135
+
136
+ On a single machine (probably one of the test machines), execute this:
137
+ > deep_test master_test_server <uris of test servers>
138
+
139
+ The master_test_server will also print it's binding uri,
140
+ druby://<hostname>:4021 by default. It will also provide a webserver bound
141
+ to port 4020 that provides a status page summarizing the state of all the
142
+ test servers.
143
+
144
+ ==== Overriding the DRb uri for the Test Server or Master Test Server
145
+
146
+ The DRb url that the Test Server or Master Test Server should bind to can be
147
+ specified when the process is started. Use the --uri option followed by the
148
+ DRb url that you would like DRb to bind to and return to clients. By default,
149
+ DRb does not provide any capability to bind to all addresses but return a
150
+ specific IP or hostname as part of the DRb url for clients. DeepTest provides
151
+ a special DRb protocol to enable this, drubyall. If you wish your test server
152
+ to listen on all addresses (which you probably do), start the server
153
+ with a command like this (where deeptest1.local is the hostname of the machine):
154
+ > deep_test test_server --uri drubyall://deeptest1.local/
155
+
156
+ The server will report that it is listening on druby://deeptest1.local as the
157
+ public DRb url, but it will actually accept connections on all addresses to
158
+ server requests.
159
+
160
+
161
+ ==== Configuring Your Project
162
+
163
+ If you're using rsync over ssh, create a DeepTest test task similar to that
164
+ below in your Rakefile.
165
+
166
+ DeepTest::TestTask.new "deep_test_distributed" do |t|
167
+ t.pattern = "test/**/*_test.rb" # whatever is appropriate for your project
168
+ t.distributed_server = <drb uri of master_test_server>
169
+ t.sync_options = {
170
+ :source => <absolute path of project root on machine>,
171
+ :username => "username"
172
+ }
173
+ end
174
+
175
+ The :source entry in sync_options can be easily calculated based on the value
176
+ of \_\_FILE__ when defining the task. :username will be used by rsync to ssh
177
+ back to the local machine and mirror the working copy.
178
+
179
+ If you have an rsync daemon running in your local machine, configure the
180
+ rake task as follows.
181
+
182
+ DeepTest::TestTask.new "deep_test_distributed" do |t|
183
+ t.pattern = "test/**/*_test.rb" # whatever is appropriate for your project
184
+ t.distributed_server = <drb uri of master_test_server>
185
+ t.sync_options = {
186
+ :source => <name of rsync module from daemon configuration>,
187
+ :daemon => true,
188
+ :username => "username"
189
+ }
190
+ end
191
+
192
+
193
+ Username is optional in both cases. You'll need to either setup passwordless
194
+ ssh access or run an rsync daemon that doesn't require passwords.
195
+
196
+ There may be other options you'd like to pass to rsync in your particular
197
+ scenario. This can be done by adding an :rsync_options entry to sync_options.
198
+ For example, if you're working on a Rails project you'll probably want to at
199
+ least have something like this:
200
+
201
+ DeepTest::TestTask.new "deep_test_distributed" do |t|
202
+ ...
203
+ excludes = %w[.svn tmp/** log/**]
204
+ t.sync_options = {
205
+ ...
206
+ :rsync_options => excludes.map {|s| "'--exclude=#{s}'"}.join(' ')
207
+ }
208
+ end
209
+
210
+ That way you can avoid spending any time mirroring tmp and log files that don't
211
+ have any effect on the tests. If you are running distributed tests against a
212
+ database, consult the section above about creating a new database for each
213
+ worker to see how to configure DeepTest for your project.
214
+
215
+ Any number of projects can be run using the same test servers, as long as
216
+ they're all using the same version of Ruby and DeepTest.
217
+
218
+ == Contributors
219
+
220
+ * anonymous z
221
+ * Alex Chaffee
222
+ * Dan[http://www.dcmanges.com/blog] Manges[http://www.dcmanges.com/blog]
223
+ * David[http://davidvollbracht.com/] Vollbracht[http://davidvollbracht.com/]
224
+ * Scott Taylor
225
+
226
+ == License
227
+
228
+ DeepTest Released under Ruby's[http://www.ruby-lang.org/en/LICENSE.txt] license[http://www.ruby-lang.org/en/LICENSE.txt]
data/Rakefile ADDED
@@ -0,0 +1,247 @@
1
+ require 'rake'
2
+ require 'rake/testtask'
3
+ require 'rake/rdoctask'
4
+ require 'rake/gempackagetask'
5
+ require 'rake/contrib/sshpublisher'
6
+ require 'yaml'
7
+
8
+ require 'rubygems'
9
+ gem 'rspec', '=1.1.8'
10
+ require 'spec/rake/spectask'
11
+
12
+ $LOAD_PATH << File.dirname(__FILE__) + "/lib"
13
+ require "deep_test/rake_tasks"
14
+
15
+
16
+ # ----------------------------------------------------------------------
17
+ # jeweler tasks
18
+ # ----------------------------------------------------------------------
19
+
20
+ begin
21
+ require 'jeweler'
22
+ Jeweler::Tasks.new do |gem|
23
+ gem.name = "deep_test"
24
+ gem.summary = "DeepTest runs tests in multiple processes."
25
+ gem.description = gem.summary
26
+ gem.email = "daniel.manges@gmail.com"
27
+ gem.homepage = "http://deep-test.rubyforge.org"
28
+ gem.authors = ["anonymous z", "Dan Manges", "David Vollbracht"]
29
+ gem.rubyforge_project = "deep-test"
30
+ gem.executables << "deep_test"
31
+
32
+ gem.has_rdoc = true
33
+ gem.extra_rdoc_files = ['README.rdoc', 'CHANGELOG']
34
+ gem.rdoc_options << '--title' << "DeepTest" << '--main' << 'README.rdoc' << '--line-numbers'
35
+
36
+ gem.files = FileList['{lib,script,test,bin}/**/*.{rb,rake,rhtml}', 'README.rdoc', 'CHANGELOG', 'Rakefile'].to_a
37
+ end
38
+
39
+ rescue LoadError
40
+ puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler"
41
+ end
42
+
43
+ # ----------------------------------------------------------------------
44
+ # default task
45
+ # ----------------------------------------------------------------------
46
+
47
+ task :default => %w[
48
+ test
49
+ spec
50
+ failing_test
51
+ deep_test
52
+ deep_spec
53
+ run_distributed
54
+ run_distributed_with_worker_down
55
+ run_distributed_with_failover
56
+ test_rails_project
57
+ ]
58
+
59
+ task :pc => :default
60
+
61
+ # ----------------------------------------------------------------------
62
+ # test tasks
63
+ # ----------------------------------------------------------------------
64
+
65
+ Rake::TestTask.new do |t|
66
+ t.pattern = "test/**/*_test.rb"
67
+ t.libs += ['test', 'lib']
68
+ end
69
+
70
+ DeepTest::TestTask.new :deep_test do |t|
71
+ t.number_of_workers = 2
72
+ t.pattern = "test/**/*_test.rb"
73
+ t.metrics_file = "deep_test.metrics"
74
+ end
75
+
76
+ DeepTest::TestTask.new(:distributed_test) do |t|
77
+ t.number_of_workers = 2
78
+ t.pattern = "test/**/*_test.rb"
79
+ t.distributed_server = "druby://localhost:8000"
80
+ t.sync_options = {:source => File.dirname(__FILE__),
81
+ :local => true,
82
+ :rsync_options => "--exclude=.svn"}
83
+ end
84
+
85
+
86
+ # ----------------------------------------------------------------------
87
+ # spec tasks
88
+ # ----------------------------------------------------------------------
89
+
90
+ Spec::Rake::SpecTask.new(:spec) do |t|
91
+ t.spec_files = FileList['spec/**/*_spec.rb']
92
+ end
93
+
94
+ Spec::Rake::SpecTask.new(:deep_spec) do |t|
95
+ t.spec_files = FileList['spec/**/*_spec.rb']
96
+ t.deep_test :number_of_workers => 2
97
+ end
98
+
99
+ Spec::Rake::SpecTask.new(:distributed_spec) do |t|
100
+ t.spec_files = FileList['spec/**/*_spec.rb']
101
+ t.deep_test :number_of_workers => 2,
102
+ :distributed_server => "druby://localhost:8000",
103
+ :sync_options => {:source => File.dirname(__FILE__),
104
+ :local => true,
105
+ :rsync_options => "--exclude=.svn"}
106
+ end
107
+
108
+ DeepTest::TestTask.new(:distribute_tests_to_minis) do |t|
109
+ t.number_of_workers = 2
110
+ t.pattern = "test/**/*_test.rb"
111
+ t.distributed_server = "druby://alpha.local:8000"
112
+ t.sync_options = {:source => File.dirname(__FILE__),
113
+ :username => "tworker",
114
+ :password => "thought",
115
+ :rsync_options => "--exclude=.svn"}
116
+ end
117
+
118
+
119
+ # ----------------------------------------------------------------------
120
+ # distributed test tasks
121
+ # ----------------------------------------------------------------------
122
+
123
+ task :run_distributed do |t|
124
+ begin
125
+ FileUtils.mkdir('/tmp/test_1') unless File.exist?('/tmp/test_1')
126
+ FileUtils.mkdir('/tmp/test_2') unless File.exist?('/tmp/test_2')
127
+
128
+ test_1_pid = fork do
129
+ exec "ruby bin/deep_test test_server --uri drubyall://localhost:8001 --work_dir /tmp/test_1"
130
+ end
131
+
132
+ test_2_pid = fork do
133
+ exec "ruby bin/deep_test test_server --uri drubyall://localhost:8002 --work_dir /tmp/test_2"
134
+ end
135
+
136
+ master_pid = fork do
137
+ exec "ruby bin/deep_test master_test_server --uri drubyall://localhost:8000 druby://localhost:8001 druby://localhost:8002"
138
+ end
139
+
140
+ sleep 1
141
+
142
+ Rake::Task[:distributed_test].invoke
143
+ Rake::Task[:distributed_spec].invoke
144
+
145
+ sh "ruby bin/deep_test test_throughput druby://localhost:8000 20"
146
+ ensure
147
+ Process.kill('TERM', master_pid) if master_pid rescue nil
148
+ Process.kill('TERM', test_1_pid) if test_1_pid rescue nil
149
+ Process.kill('TERM', test_2_pid) if test_2_pid rescue nil
150
+ Process.waitall
151
+ end
152
+
153
+ sleep 1
154
+ end
155
+
156
+ task :run_distributed_with_worker_down do |t|
157
+ begin
158
+ FileUtils.mkdir('/tmp/test_1') unless File.exist?('/tmp/test_1')
159
+
160
+ test_1_pid = fork do
161
+ exec "ruby bin/deep_test test_server --uri drubyall://localhost:8001 --work_dir /tmp/test_1"
162
+ end
163
+
164
+ # don't start worker 2
165
+
166
+ master_pid = fork do
167
+ exec "ruby bin/deep_test master_test_server --uri drubyall://localhost:8000 druby://localhost:8001 druby://localhost:8002"
168
+ end
169
+
170
+ sleep 1
171
+
172
+ # Use throughput to make sure we can run tests
173
+ sh "ruby bin/deep_test test_throughput druby://localhost:8000 20"
174
+ ensure
175
+ Process.kill('TERM', master_pid) if master_pid rescue nil
176
+ Process.kill('TERM', test_1_pid) if test_1_pid rescue nil
177
+ Process.waitall
178
+ end
179
+ end
180
+
181
+ task :run_distributed_with_failover do |t|
182
+ puts
183
+ puts "*** Running distributed with no server - expect a failover message ***"
184
+ puts
185
+ Rake::Task[:distributed_spec].execute "dummy arg"
186
+ end
187
+
188
+ task :failing_test do
189
+ command = "rake --rakefile test/failing.rake 2>&1"
190
+ puts command
191
+ `#{command}`
192
+ if $?.success?
193
+ puts "F"
194
+ fail "****\ntest/failing.rake should have failed\n****"
195
+ else
196
+ puts "."
197
+ end
198
+ end
199
+
200
+ # ----------------------------------------------------------------------
201
+ # sample app test task
202
+ # ----------------------------------------------------------------------
203
+
204
+ Rake::TestTask.new(:test_rails_project) do |t|
205
+ t.pattern = "sample_rails_project/deep_test.rb"
206
+ end
207
+
208
+
209
+ # ----------------------------------------------------------------------
210
+ # documentation tasks
211
+ # ----------------------------------------------------------------------
212
+
213
+ desc "Generate documentation"
214
+ Rake::RDocTask.new(:rdoc) do |rdoc|
215
+ rdoc.rdoc_dir = "doc"
216
+ rdoc.title = "DeepTest"
217
+ rdoc.options << '--line-numbers'
218
+ rdoc.rdoc_files.include(
219
+ 'README.rdoc',
220
+ 'CHANGELOG',
221
+ 'lib/deep_test/null_worker_listener.rb',
222
+ 'lib/deep_test/database/*.rb'
223
+ )
224
+ end
225
+
226
+ desc "Upload RDoc to RubyForge"
227
+ task :publish_rdoc => [:rerdoc] do
228
+ rubyforge_config = "#{ENV['HOME']}/.rubyforge/user-config.yml"
229
+ username = YAML.load_file(rubyforge_config)["username"]
230
+ sh "chmod -R 775 doc"
231
+ sh "scp -rqp doc/* #{username}@rubyforge.org:/var/www/gforge-projects/deep-test"
232
+ end
233
+
234
+ # ----------------------------------------------------------------------
235
+ # gem tasks
236
+ # ----------------------------------------------------------------------
237
+
238
+ # Rake::GemPackageTask.new(specification) do |package|
239
+ # package.need_zip = true
240
+ # package.need_tar = true
241
+ # end
242
+
243
+ # Rake::Task[:gem].prerequisites.unshift :default
244
+
245
+ # task :tar do
246
+ # system "tar zcf pkg/deep_test.tar.gz --exclude=.svn --exclude='*.tar.gz' --exclude='*.gem' --directory=.. deep_test"
247
+ # end