jason-o-matic-deep_test 1.2.2.1
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +47 -0
- data/README.rdoc +228 -0
- data/Rakefile +211 -0
- data/bin/deep_test +15 -0
- data/lib/deep_test.rb +90 -0
- data/lib/deep_test/database/mysql_setup_listener.rb +113 -0
- data/lib/deep_test/database/setup_listener.rb +116 -0
- data/lib/deep_test/deadlock_detector.rb +7 -0
- data/lib/deep_test/distributed/dispatch_controller.rb +53 -0
- data/lib/deep_test/distributed/drb_client_connection_info.rb +15 -0
- data/lib/deep_test/distributed/filename_resolver.rb +40 -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 +111 -0
- data/lib/deep_test/distributed/rsync.rb +37 -0
- data/lib/deep_test/distributed/show_status.rhtml +41 -0
- data/lib/deep_test/distributed/test_server.rb +79 -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/extensions/object_extension.rb +40 -0
- data/lib/deep_test/listener_list.rb +17 -0
- data/lib/deep_test/local_workers.rb +55 -0
- data/lib/deep_test/logger.rb +17 -0
- data/lib/deep_test/marshallable_exception_wrapper.rb +44 -0
- 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_worker_listener.rb +65 -0
- data/lib/deep_test/option.rb +70 -0
- data/lib/deep_test/options.rb +112 -0
- data/lib/deep_test/process_orchestrator.rb +49 -0
- data/lib/deep_test/rake_tasks.rb +11 -0
- data/lib/deep_test/result_reader.rb +36 -0
- data/lib/deep_test/rspec_detector.rb +24 -0
- data/lib/deep_test/server.rb +75 -0
- data/lib/deep_test/spec.rb +12 -0
- data/lib/deep_test/spec/extensions/example_group_methods.rb +64 -0
- data/lib/deep_test/spec/extensions/example_methods.rb +46 -0
- data/lib/deep_test/spec/extensions/options.rb +43 -0
- data/lib/deep_test/spec/extensions/reporter.rb +29 -0
- data/lib/deep_test/spec/extensions/spec_task.rb +20 -0
- data/lib/deep_test/spec/runner.rb +57 -0
- data/lib/deep_test/spec/work_result.rb +33 -0
- data/lib/deep_test/spec/work_unit.rb +59 -0
- data/lib/deep_test/test.rb +10 -0
- data/lib/deep_test/test/extensions/error.rb +14 -0
- data/lib/deep_test/test/runner.rb +24 -0
- data/lib/deep_test/test/supervised_test_suite.rb +49 -0
- data/lib/deep_test/test/work_result.rb +34 -0
- data/lib/deep_test/test/work_unit.rb +40 -0
- data/lib/deep_test/test_task.rb +51 -0
- data/lib/deep_test/ui/console.rb +76 -0
- data/lib/deep_test/ui/null.rb +17 -0
- data/lib/deep_test/warlock.rb +134 -0
- data/lib/deep_test/worker.rb +57 -0
- 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/test/deep_test/database/mysql_setup_listener_test.rb +14 -0
- data/test/deep_test/distributed/dispatch_controller_test.rb +209 -0
- data/test/deep_test/distributed/drb_client_connection_info_test.rb +42 -0
- data/test/deep_test/distributed/filename_resolver_test.rb +52 -0
- 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 +107 -0
- data/test/deep_test/distributed/rsync_test.rb +67 -0
- 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/extensions/object_extension_test.rb +37 -0
- data/test/deep_test/listener_list_test.rb +20 -0
- data/test/deep_test/local_workers_test.rb +22 -0
- data/test/deep_test/logger_test.rb +11 -0
- data/test/deep_test/marshallable_exception_wrapper_test.rb +44 -0
- 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 +128 -0
- data/test/deep_test/server_test.rb +58 -0
- data/test/deep_test/test/extensions/error_test.rb +40 -0
- data/test/deep_test/test/runner_test.rb +7 -0
- data/test/deep_test/test/supervised_test_suite_test.rb +79 -0
- data/test/deep_test/test/work_result_test.rb +81 -0
- data/test/deep_test/test/work_unit_test.rb +61 -0
- data/test/deep_test/test_task_test.rb +43 -0
- data/test/deep_test/ui/console_test.rb +9 -0
- data/test/deep_test/warlock_test.rb +38 -0
- data/test/deep_test/worker_test.rb +94 -0
- data/test/failing.rake +11 -0
- data/test/failing.rb +7 -0
- data/test/fake_deadlock_error.rb +12 -0
- data/test/simple_test_blackboard.rb +45 -0
- data/test/simple_test_blackboard_test.rb +33 -0
- data/test/test_factory.rb +74 -0
- data/test/test_helper.rb +15 -0
- data/test/test_task_test.rb +72 -0
- metadata +160 -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,211 @@
|
|
1
|
+
require 'rake'
|
2
|
+
require 'rake/testtask'
|
3
|
+
require 'rake/rdoctask'
|
4
|
+
require 'rake/gempackagetask'
|
5
|
+
require 'rake/contrib/sshpublisher'
|
6
|
+
require 'yaml'
|
7
|
+
$LOAD_PATH << File.dirname(__FILE__) + "/lib"
|
8
|
+
require "deep_test/rake_tasks"
|
9
|
+
|
10
|
+
task :default => %w[
|
11
|
+
test
|
12
|
+
spec
|
13
|
+
failing_test
|
14
|
+
deep_test
|
15
|
+
deep_spec
|
16
|
+
run_distributed
|
17
|
+
run_distributed_with_worker_down
|
18
|
+
run_distributed_with_failover
|
19
|
+
test_rails_project
|
20
|
+
]
|
21
|
+
|
22
|
+
task :pc => :default
|
23
|
+
|
24
|
+
Rake::TestTask.new do |t|
|
25
|
+
t.pattern = "test/**/*_test.rb"
|
26
|
+
t.libs += ['test', 'lib']
|
27
|
+
end
|
28
|
+
|
29
|
+
DeepTest::TestTask.new :deep_test do |t|
|
30
|
+
t.number_of_workers = 2
|
31
|
+
t.pattern = "test/**/*_test.rb"
|
32
|
+
t.metrics_file = "deep_test.metrics"
|
33
|
+
end
|
34
|
+
|
35
|
+
DeepTest::TestTask.new(:distributed_test) do |t|
|
36
|
+
t.number_of_workers = 2
|
37
|
+
t.pattern = "test/**/*_test.rb"
|
38
|
+
t.distributed_server = "druby://localhost:8000"
|
39
|
+
t.sync_options = {:source => File.dirname(__FILE__),
|
40
|
+
:local => true,
|
41
|
+
:rsync_options => "--exclude=.svn"}
|
42
|
+
end
|
43
|
+
|
44
|
+
def rspec_present?
|
45
|
+
defined?(Spec)
|
46
|
+
end
|
47
|
+
|
48
|
+
if rspec_present?
|
49
|
+
Spec::Rake::SpecTask.new(:spec) do |t|
|
50
|
+
t.spec_files = FileList['spec/**/*_spec.rb']
|
51
|
+
end
|
52
|
+
|
53
|
+
Spec::Rake::SpecTask.new(:deep_spec) do |t|
|
54
|
+
t.spec_files = FileList['spec/**/*_spec.rb']
|
55
|
+
t.deep_test :number_of_workers => 2
|
56
|
+
end
|
57
|
+
|
58
|
+
Spec::Rake::SpecTask.new(:distributed_spec) do |t|
|
59
|
+
t.spec_files = FileList['spec/**/*_spec.rb']
|
60
|
+
t.deep_test :number_of_workers => 2,
|
61
|
+
:distributed_server => "druby://localhost:8000",
|
62
|
+
:sync_options => {:source => File.dirname(__FILE__),
|
63
|
+
:local => true,
|
64
|
+
:rsync_options => "--exclude=.svn"}
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
|
69
|
+
DeepTest::TestTask.new(:distribute_tests_to_minis) do |t|
|
70
|
+
t.number_of_workers = 2
|
71
|
+
t.pattern = "test/**/*_test.rb"
|
72
|
+
t.distributed_server = "druby://alpha.local:8000"
|
73
|
+
t.sync_options = {:source => File.dirname(__FILE__),
|
74
|
+
:username => "tworker",
|
75
|
+
:password => "thought",
|
76
|
+
:rsync_options => "--exclude=.svn"}
|
77
|
+
end
|
78
|
+
|
79
|
+
task :run_distributed do |t|
|
80
|
+
begin
|
81
|
+
FileUtils.mkdir('/tmp/test_1') unless File.exist?('/tmp/test_1')
|
82
|
+
FileUtils.mkdir('/tmp/test_2') unless File.exist?('/tmp/test_2')
|
83
|
+
|
84
|
+
test_1_pid = fork do
|
85
|
+
exec "ruby bin/deep_test test_server --uri drubyall://localhost:8001 --work_dir /tmp/test_1"
|
86
|
+
end
|
87
|
+
|
88
|
+
test_2_pid = fork do
|
89
|
+
exec "ruby bin/deep_test test_server --uri drubyall://localhost:8002 --work_dir /tmp/test_2"
|
90
|
+
end
|
91
|
+
|
92
|
+
master_pid = fork do
|
93
|
+
exec "ruby bin/deep_test master_test_server --uri drubyall://localhost:8000 druby://localhost:8001 druby://localhost:8002"
|
94
|
+
end
|
95
|
+
|
96
|
+
sleep 1
|
97
|
+
|
98
|
+
Rake::Task[:distributed_test].invoke
|
99
|
+
Rake::Task[:distributed_spec].invoke
|
100
|
+
|
101
|
+
sh "ruby bin/deep_test test_throughput druby://localhost:8000 20"
|
102
|
+
ensure
|
103
|
+
Process.kill('TERM', master_pid) if master_pid rescue nil
|
104
|
+
Process.kill('TERM', test_1_pid) if test_1_pid rescue nil
|
105
|
+
Process.kill('TERM', test_2_pid) if test_2_pid rescue nil
|
106
|
+
Process.waitall
|
107
|
+
end
|
108
|
+
|
109
|
+
sleep 1
|
110
|
+
end
|
111
|
+
|
112
|
+
task :run_distributed_with_worker_down do |t|
|
113
|
+
begin
|
114
|
+
FileUtils.mkdir('/tmp/test_1') unless File.exist?('/tmp/test_1')
|
115
|
+
|
116
|
+
test_1_pid = fork do
|
117
|
+
exec "ruby bin/deep_test test_server --uri drubyall://localhost:8001 --work_dir /tmp/test_1"
|
118
|
+
end
|
119
|
+
|
120
|
+
# don't start worker 2
|
121
|
+
|
122
|
+
master_pid = fork do
|
123
|
+
exec "ruby bin/deep_test master_test_server --uri drubyall://localhost:8000 druby://localhost:8001 druby://localhost:8002"
|
124
|
+
end
|
125
|
+
|
126
|
+
sleep 1
|
127
|
+
|
128
|
+
# Use throughput to make sure we can run tests
|
129
|
+
sh "ruby bin/deep_test test_throughput druby://localhost:8000 20"
|
130
|
+
ensure
|
131
|
+
Process.kill('TERM', master_pid) if master_pid rescue nil
|
132
|
+
Process.kill('TERM', test_1_pid) if test_1_pid rescue nil
|
133
|
+
Process.waitall
|
134
|
+
end
|
135
|
+
end
|
136
|
+
|
137
|
+
task :run_distributed_with_failover do |t|
|
138
|
+
puts
|
139
|
+
puts "*** Running distributed with no server - expect a failover message ***"
|
140
|
+
puts
|
141
|
+
Rake::Task[:distributed_spec].execute "dummy arg"
|
142
|
+
end
|
143
|
+
|
144
|
+
task :failing_test do
|
145
|
+
command = "rake --rakefile test/failing.rake 2>&1"
|
146
|
+
puts command
|
147
|
+
`#{command}`
|
148
|
+
if $?.success?
|
149
|
+
puts "F"
|
150
|
+
fail "****\ntest/failing.rake should have failed\n****"
|
151
|
+
else
|
152
|
+
puts "."
|
153
|
+
end
|
154
|
+
end
|
155
|
+
|
156
|
+
Rake::TestTask.new(:test_rails_project) do |t|
|
157
|
+
t.pattern = "sample_rails_project/deep_test.rb"
|
158
|
+
end
|
159
|
+
|
160
|
+
desc "Generate documentation"
|
161
|
+
Rake::RDocTask.new(:rdoc) do |rdoc|
|
162
|
+
rdoc.rdoc_dir = "doc"
|
163
|
+
rdoc.title = "DeepTest"
|
164
|
+
rdoc.options << '--line-numbers'
|
165
|
+
rdoc.rdoc_files.include(
|
166
|
+
'README.rdoc',
|
167
|
+
'CHANGELOG',
|
168
|
+
'lib/deep_test/null_worker_listener.rb',
|
169
|
+
'lib/deep_test/database/*.rb'
|
170
|
+
)
|
171
|
+
end
|
172
|
+
|
173
|
+
desc "Upload RDoc to RubyForge"
|
174
|
+
task :publish_rdoc => [:rerdoc] do
|
175
|
+
rubyforge_config = "#{ENV['HOME']}/.rubyforge/user-config.yml"
|
176
|
+
username = YAML.load_file(rubyforge_config)["username"]
|
177
|
+
sh "chmod -R 775 doc"
|
178
|
+
sh "scp -rqp doc/* #{username}@rubyforge.org:/var/www/gforge-projects/deep-test"
|
179
|
+
end
|
180
|
+
|
181
|
+
Gem::manage_gems
|
182
|
+
|
183
|
+
specification = Gem::Specification.new do |s|
|
184
|
+
s.platform = Gem::Platform::RUBY
|
185
|
+
s.name = "deep_test"
|
186
|
+
s.summary = "DeepTest runs tests in multiple processes."
|
187
|
+
s.version = "1.2.2"
|
188
|
+
s.author = "anonymous z, Dan Manges, David Vollbracht"
|
189
|
+
s.description = s.summary
|
190
|
+
s.email = "daniel.manges@gmail.com"
|
191
|
+
s.homepage = "http://deep-test.rubyforge.org"
|
192
|
+
s.rubyforge_project = "deep-test"
|
193
|
+
s.executables << "deep_test"
|
194
|
+
|
195
|
+
s.has_rdoc = true
|
196
|
+
s.extra_rdoc_files = ['README.rdoc', 'CHANGELOG']
|
197
|
+
s.rdoc_options << '--title' << "DeepTest" << '--main' << 'README.rdoc' << '--line-numbers'
|
198
|
+
|
199
|
+
s.files = FileList['{lib,script,test,bin}/**/*.{rb,rake,rhtml}', 'README.rdoc', 'CHANGELOG', 'Rakefile'].to_a
|
200
|
+
end
|
201
|
+
|
202
|
+
Rake::GemPackageTask.new(specification) do |package|
|
203
|
+
package.need_zip = true
|
204
|
+
package.need_tar = true
|
205
|
+
end
|
206
|
+
|
207
|
+
Rake::Task[:gem].prerequisites.unshift :default
|
208
|
+
|
209
|
+
task :tar do
|
210
|
+
system "tar zcf pkg/deep_test.tar.gz --exclude=.svn --exclude='*.tar.gz' --exclude='*.gem' --directory=.. deep_test"
|
211
|
+
end
|