testbot_instructure 0.7.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gemtest +0 -0
- data/CHANGELOG +264 -0
- data/Gemfile +3 -0
- data/README.markdown +141 -0
- data/Rakefile +35 -0
- data/bin/testbot +59 -0
- data/lib/generators/testbot/templates/testbot.rake.erb +35 -0
- data/lib/generators/testbot/templates/testbot.yml.erb +45 -0
- data/lib/generators/testbot/testbot_generator.rb +19 -0
- data/lib/railtie.rb +16 -0
- data/lib/requester/requester.rb +171 -0
- data/lib/runner/job.rb +112 -0
- data/lib/runner/runner.rb +222 -0
- data/lib/runner/safe_result_text.rb +29 -0
- data/lib/server/build.rb +36 -0
- data/lib/server/group.rb +48 -0
- data/lib/server/job.rb +64 -0
- data/lib/server/memory_model.rb +91 -0
- data/lib/server/runner.rb +47 -0
- data/lib/server/server.rb +103 -0
- data/lib/server/status/javascripts/jquery-1.4.4.min.js +167 -0
- data/lib/server/status/status.html +48 -0
- data/lib/server/status/stylesheets/status.css +14 -0
- data/lib/shared/adapters/adapter.rb +27 -0
- data/lib/shared/adapters/cucumber_adapter.rb +91 -0
- data/lib/shared/adapters/helpers/ruby_env.rb +47 -0
- data/lib/shared/adapters/rspec2_adapter.rb +61 -0
- data/lib/shared/adapters/rspec_adapter.rb +79 -0
- data/lib/shared/adapters/test_unit_adapter.rb +44 -0
- data/lib/shared/color.rb +16 -0
- data/lib/shared/simple_daemonize.rb +25 -0
- data/lib/shared/ssh_tunnel.rb +36 -0
- data/lib/shared/testbot.rb +132 -0
- data/lib/shared/version.rb +12 -0
- data/lib/tasks/testbot.rake +30 -0
- data/lib/testbot.rb +2 -0
- data/test/fixtures/local/Rakefile +7 -0
- data/test/fixtures/local/config/testbot.yml +5 -0
- data/test/fixtures/local/log/test.log +0 -0
- data/test/fixtures/local/script/spec +2 -0
- data/test/fixtures/local/spec/models/car_spec.rb +0 -0
- data/test/fixtures/local/spec/models/house_spec.rb +0 -0
- data/test/fixtures/local/spec/spec.opts +0 -0
- data/test/fixtures/local/tmp/restart.txt +0 -0
- data/test/integration_test.rb +55 -0
- data/test/requester/requester_test.rb +407 -0
- data/test/requester/testbot.yml +7 -0
- data/test/requester/testbot_with_erb.yml +2 -0
- data/test/runner/job_test.rb +94 -0
- data/test/runner/safe_result_text_test.rb +20 -0
- data/test/server/group_test.rb +43 -0
- data/test/server/server_test.rb +511 -0
- data/test/shared/adapters/adapter_test.rb +22 -0
- data/test/shared/adapters/cucumber_adapter_test.rb +72 -0
- data/test/shared/adapters/helpers/ruby_env_test.rb +108 -0
- data/test/shared/adapters/rspec_adapter_test.rb +109 -0
- data/test/shared/testbot_test.rb +185 -0
- data/testbot.gemspec +34 -0
- metadata +313 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: e91a209692e050fa35241bdfd5f9b07b244e2cf3
|
4
|
+
data.tar.gz: ddf819aa30078f4dc5615ad80e7038a8ab7eff46
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 48be5c7591e44b08241add8f77ae2a1b770d47bcd13cfb25add5366ef80bbde7b7240b9d55838fdafc93f4b09003616479ae473a926958f5457b7cc559199236
|
7
|
+
data.tar.gz: 2cbf130feb93f11f9915dc81094cedb931303bbbae5bf2cf4d87747ca4924117359a45d016a9994e63c22e17ea7eaf50818979ef6df90ebd84a261ca2f5ac033
|
data/.gemtest
ADDED
File without changes
|
data/CHANGELOG
ADDED
@@ -0,0 +1,264 @@
|
|
1
|
+
0.7.8
|
2
|
+
|
3
|
+
Fix test job bug that caused multiple jobs to use the same TEST_ENV_NUMBER.
|
4
|
+
|
5
|
+
This caused multiple processes to use the same databases, etc.
|
6
|
+
|
7
|
+
If you're seeing database deadlocks in tests, this will probably fix that.
|
8
|
+
|
9
|
+
0.7.7
|
10
|
+
|
11
|
+
Exit when file syncing fails so that you don't run tests for a version of the
|
12
|
+
code you did not expect.
|
13
|
+
|
14
|
+
0.7.5
|
15
|
+
|
16
|
+
Fixed bug where a runner updating without a result would fail.
|
17
|
+
|
18
|
+
Also dropping official support for 1.8 as it's such a hassle to maintain.
|
19
|
+
|
20
|
+
0.7.3
|
21
|
+
|
22
|
+
Increased time between updates to avoid timeouts. Allow timeout when posting
|
23
|
+
incremental build results (but not when posting the final results).
|
24
|
+
|
25
|
+
Should make testbot more stable for some people.
|
26
|
+
|
27
|
+
0.7.2
|
28
|
+
|
29
|
+
Increased timeout on http requests to the server to 10 seconds.
|
30
|
+
|
31
|
+
0.7.1
|
32
|
+
|
33
|
+
Fixed a bug introduced in 0.7.0. The TEST_INSTANCES env-variable are now
|
34
|
+
present again when running before_run scripts.
|
35
|
+
|
36
|
+
0.7.0
|
37
|
+
|
38
|
+
Added per project rvm support. Using this you can run testbot using system ruby
|
39
|
+
while being able to run test processes using the project rvm environment. This
|
40
|
+
is also useful if you have several projects with different rvm rubies and gemsets.
|
41
|
+
|
42
|
+
0.6.9
|
43
|
+
|
44
|
+
Removed dependency on macaddr as that does not work on some platforms.
|
45
|
+
|
46
|
+
0.6.8
|
47
|
+
|
48
|
+
Fixed broken gem lookup in ruby 1.9.
|
49
|
+
|
50
|
+
0.6.6
|
51
|
+
|
52
|
+
The runner will now run config/testbot/before_run.rb if it exists.
|
53
|
+
|
54
|
+
Replaced the old process code with the posix-spawn gem's methods. This fixed
|
55
|
+
process shutdown in my current setup. Hopefully more stable overall.
|
56
|
+
|
57
|
+
The requester will now request that the build is stopped when exiting early (like when killed),
|
58
|
+
and not only on ctrl+c (SIGINT).
|
59
|
+
|
60
|
+
Most of this was based on a fork by https://github.com/Skalar.
|
61
|
+
|
62
|
+
0.6.5
|
63
|
+
|
64
|
+
Fixed test unit require path so that it works with ruby 1.9.
|
65
|
+
|
66
|
+
0.6.4
|
67
|
+
|
68
|
+
Fixed bug with running test unit tests that caused errors like '/bin/ruby:1: Invalid char `\317' in expression`'.
|
69
|
+
|
70
|
+
Now handling errors creating builds.
|
71
|
+
|
72
|
+
Returning 503 and reporting that there are no runners when that is the case.
|
73
|
+
|
74
|
+
0.6.3
|
75
|
+
|
76
|
+
Results are now shown as they happen. It takes care not to break escape codes used for
|
77
|
+
coloring output (only tested with rspec, add a script/spec file containing "rspec --tty $@").
|
78
|
+
|
79
|
+
Also, you can add a "logging: true" option to testbot.yml to see when files are synced, etc.
|
80
|
+
|
81
|
+
0.6.2
|
82
|
+
|
83
|
+
Fixed "invalid byte sequence in UTF-8" errors cased by test output in some cases.
|
84
|
+
|
85
|
+
0.6.1
|
86
|
+
|
87
|
+
Fixed CPU core check for OSX Lion.
|
88
|
+
|
89
|
+
Updated sinatra requirement so that it's a bit less strict
|
90
|
+
(https://github.com/joakimk/testbot/pull/41).
|
91
|
+
|
92
|
+
0.6.0
|
93
|
+
|
94
|
+
Fixed bug that caused the runner to crash and block the server after checking for jobs (issue #34).
|
95
|
+
|
96
|
+
Merged in https://github.com/joakimk/testbot/pull/33 (Bugfix: Run rake task testbot:before_run with bundler if present).
|
97
|
+
|
98
|
+
0.5.9
|
99
|
+
|
100
|
+
When you hit ctrl+c all related test jobs will be stopped (within about 5 seconds). You can
|
101
|
+
now exit, change code and re-run much faster than before.
|
102
|
+
|
103
|
+
It does not stop before_run or code fetch. But no tests will be run after
|
104
|
+
those complete when the build is stopped.
|
105
|
+
|
106
|
+
0.5.8
|
107
|
+
|
108
|
+
Now only running tests from one build on a runner at a time.
|
109
|
+
|
110
|
+
This is mostly usability. Testbot should behave like when you're running your tests locally.
|
111
|
+
|
112
|
+
0.5.7
|
113
|
+
|
114
|
+
Added @meeiw's patch to support ERB in config. Added test result summarization for RSpec and Cucumber.
|
115
|
+
|
116
|
+
0.5.6
|
117
|
+
|
118
|
+
Removed CPU usage check before running jobs (issue #25).
|
119
|
+
|
120
|
+
0.5.5
|
121
|
+
|
122
|
+
Added RSpec2 support. Thanks to Bryan Helmkamp, https://github.com/brynary.
|
123
|
+
|
124
|
+
0.5.4
|
125
|
+
|
126
|
+
Fixed some typos that caused the ruby interpreter to always be "ruby".
|
127
|
+
|
128
|
+
0.5.3
|
129
|
+
|
130
|
+
Added support for rubygems-test and http://gem-testers.org.
|
131
|
+
|
132
|
+
0.5.1
|
133
|
+
|
134
|
+
Fixed a bug that caused exit status to be 1 even if the test run is successful.
|
135
|
+
|
136
|
+
0.5.0
|
137
|
+
|
138
|
+
Made the status page load faster but check less often.
|
139
|
+
|
140
|
+
0.4.9
|
141
|
+
|
142
|
+
There is now a very basic status page at http://testbot_server:2288/status.
|
143
|
+
|
144
|
+
0.4.8
|
145
|
+
|
146
|
+
Removed all remaining native dependencies to make testbot simpler to install.
|
147
|
+
|
148
|
+
0.4.7
|
149
|
+
|
150
|
+
Refactored the code into modules with one directory for each. No longer dependent on mongel, now using webrick.
|
151
|
+
|
152
|
+
0.4.6
|
153
|
+
|
154
|
+
Fixed a bug that caused auto_update not to check for an update after a job had been run.
|
155
|
+
|
156
|
+
0.4.5
|
157
|
+
|
158
|
+
Made auto_update a bit more reliable.
|
159
|
+
|
160
|
+
0.4.4
|
161
|
+
|
162
|
+
Changed to using the deamons gem. Seems to fix some problems with old processes
|
163
|
+
not closing down when using auto_update.
|
164
|
+
|
165
|
+
0.4.2
|
166
|
+
|
167
|
+
Added support for quick deploys when developing testbot.
|
168
|
+
|
169
|
+
0.4.0
|
170
|
+
|
171
|
+
Fixed RSpec 2 compability issue.
|
172
|
+
|
173
|
+
0.3.9
|
174
|
+
|
175
|
+
Added support for running tests with bundler exec.
|
176
|
+
|
177
|
+
0.3.8
|
178
|
+
|
179
|
+
Testbot now uses exit code to determine if the test run has failed.
|
180
|
+
|
181
|
+
0.3.7
|
182
|
+
|
183
|
+
The runner now checks right away for another job if it got one last time around.
|
184
|
+
|
185
|
+
0.3.6
|
186
|
+
|
187
|
+
Added Rails 2 generator support.
|
188
|
+
|
189
|
+
0.3.5
|
190
|
+
|
191
|
+
Fixed ssh_tunnel bug when using a custom user.
|
192
|
+
|
193
|
+
0.3.4
|
194
|
+
|
195
|
+
Bundler support. Testbot now runs "bundle" before "testbot:before_run" if you
|
196
|
+
have "bundle" in path and have a "Gemfile" in the project so that the
|
197
|
+
rails environment can load.
|
198
|
+
|
199
|
+
0.3.3
|
200
|
+
|
201
|
+
Fixed loading issue in rails 2, testbot depended on having rails installed as a gem.
|
202
|
+
|
203
|
+
0.3.0
|
204
|
+
|
205
|
+
Made testbot into a gem. Simplified the design. Added a CLI. Removed git support.
|
206
|
+
|
207
|
+
0.2.3
|
208
|
+
|
209
|
+
Added JRuby support.
|
210
|
+
|
211
|
+
0.2.2
|
212
|
+
|
213
|
+
Replaced runtime optimization code with a simpler file size based method.
|
214
|
+
|
215
|
+
0.2.1
|
216
|
+
|
217
|
+
Added support for Test:Unit and multiple projects.
|
218
|
+
|
219
|
+
0.2.0
|
220
|
+
|
221
|
+
Added "ssh_tunnel" so that you don't have to be able to access the http server directly.
|
222
|
+
|
223
|
+
0.1.9
|
224
|
+
|
225
|
+
The server can now handle if a runner is shutdown in the middle of a test run (it will give the
|
226
|
+
job to another runner).
|
227
|
+
|
228
|
+
0.1.8
|
229
|
+
|
230
|
+
Added cucumber support and failure detection to the client. Added docs. Added code that uses
|
231
|
+
historic test runtimes to reduce test runtime (in theory).
|
232
|
+
|
233
|
+
0.1.7
|
234
|
+
|
235
|
+
Added a basic client so that testbot can be installed as a rails plugin. 'rake testbot:spec'.
|
236
|
+
|
237
|
+
0.1.6
|
238
|
+
|
239
|
+
Now only fetching the code once, and only keeping one copy of it. Less overhead.
|
240
|
+
|
241
|
+
0.1.5
|
242
|
+
|
243
|
+
Added "/runners/total_instances" to be able to balance requesters by knowing how many instances
|
244
|
+
there are in total.
|
245
|
+
|
246
|
+
0.1.4
|
247
|
+
|
248
|
+
Added support for fetching the latest version from git instead of rsync when doing a test run.
|
249
|
+
|
250
|
+
0.1.3
|
251
|
+
|
252
|
+
Added "/runners/available" to see how many runners are available.
|
253
|
+
|
254
|
+
0.1.2
|
255
|
+
|
256
|
+
Added cucumber support.
|
257
|
+
|
258
|
+
0.1.1
|
259
|
+
|
260
|
+
Added a CPU usage check to make sure that the runner does not start a job when the computer is busy.
|
261
|
+
|
262
|
+
0.1
|
263
|
+
|
264
|
+
Added hostname and STDERR to runner results.
|
data/Gemfile
ADDED
data/README.markdown
ADDED
@@ -0,0 +1,141 @@
|
|
1
|
+
Testbot is a test distribution tool that works with Rails, RSpec, RSpec2, Test::Unit and Cucumber. The basic idea is that you let testbot spread the load of running your tests across multiple machines to make the tests run faster.
|
2
|
+
|
3
|
+
Using testbot on 11 machines (25 cores) we got our test suite down to **2 minutes from 30**. [More examples of how testbot is used](http://github.com/joakimk/testbot/wiki/How-testbot-is-used).
|
4
|
+
|
5
|
+
If you intend to use testbot with cloud computing (like EC2), take a look at [TestbotCloud](https://github.com/joakimk/testbot_cloud).
|
6
|
+
|
7
|
+
Installing
|
8
|
+
----
|
9
|
+
|
10
|
+
gem install testbot
|
11
|
+
|
12
|
+
Try it out
|
13
|
+
----
|
14
|
+
|
15
|
+
testbot --server
|
16
|
+
testbot --runner --connect localhost
|
17
|
+
sleep 5 # wait for the runner to register with the server
|
18
|
+
|
19
|
+
mkdir -p testbotdemo/test; cd testbotdemo
|
20
|
+
echo 'require "test/unit"' > test/demo_test.rb
|
21
|
+
echo 'class DemoTest < Test::Unit::TestCase; def test_first; end; end' >> test/demo_test.rb
|
22
|
+
|
23
|
+
testbot --test --connect localhost
|
24
|
+
|
25
|
+
# Cleanup
|
26
|
+
testbot --server stop
|
27
|
+
testbot --runner stop
|
28
|
+
cd ..; rm -rf testbotdemo
|
29
|
+
rm -rf /tmp/testbot
|
30
|
+
|
31
|
+
The project files from the demo project are synced to /tmp/testbot/$USER (default). The runner syncs the files to /tmp/testbot/project (default). The tests are then run and the results returned through the server and displayed.
|
32
|
+
|
33
|
+
How it works
|
34
|
+
----
|
35
|
+
|
36
|
+
Testbot is:
|
37
|
+
|
38
|
+
* A **server** to distribute test jobs.
|
39
|
+
* One or more **runners** to run test jobs and return the results (this is the "worker" process).
|
40
|
+
* One or more **requesters** that tells the server which tests to distribute and displays the results (the client you use to run tests, for example: **rake testbot:spec**).
|
41
|
+
|
42
|
+
<pre>
|
43
|
+
Requester -- (files to run) --> Server -- (files to run) --> (many-)Runner(s)
|
44
|
+
^ | ^ |
|
45
|
+
|---------------------------| |----------------------------------|
|
46
|
+
(results) (results)
|
47
|
+
</pre>
|
48
|
+
|
49
|
+
Example setup
|
50
|
+
----
|
51
|
+
|
52
|
+
Here I make the assumption that you have a user called **testbot** on a server at **192.168.0.100** that every computer [can log into without a password](http://github.com/joakimk/testbot/wiki/SSH-Public-Key-Authentication) and that you have **installed testbot** on each computer.
|
53
|
+
|
54
|
+
ssh testbot@192.168.0.100
|
55
|
+
testbot --server
|
56
|
+
|
57
|
+
On every computer that should share CPU resources run:
|
58
|
+
|
59
|
+
testbot --runner --connect 192.168.0.100
|
60
|
+
|
61
|
+
Running tests:
|
62
|
+
|
63
|
+
testbot --test --connect 192.168.0.100
|
64
|
+
# --test could also be --spec (RSpec), --rspec (RSpec 2) or --features
|
65
|
+
|
66
|
+
Using testbot with Rails 2:
|
67
|
+
|
68
|
+
# Add testbot to your Gemfile if you use bundler. You also need the plugin because
|
69
|
+
# Rails 2 does not load raketasks from gems.
|
70
|
+
ruby script/plugin install git://github.com/joakimk/testbot.git -r 'refs/tags/v0.7.8'
|
71
|
+
script/generate testbot --connect 192.168.0.100
|
72
|
+
|
73
|
+
rake testbot:spec (or :rspec, :test, :features)
|
74
|
+
|
75
|
+
Using testbot with Rails 3:
|
76
|
+
|
77
|
+
rails g testbot --connect 192.168.0.100
|
78
|
+
rake testbot:spec (or :rspec, :test, :features)
|
79
|
+
|
80
|
+
# Gemfile:
|
81
|
+
gem 'testbot'
|
82
|
+
|
83
|
+
You can keep track of the testbots on:
|
84
|
+
|
85
|
+
http://192.168.0.100:2288/status
|
86
|
+
|
87
|
+
Updating testbot
|
88
|
+
----
|
89
|
+
|
90
|
+
To simplify updates there is a **--auto_update** option for the runner. The runner processes that use this option will be automatically updated and restarted when you change the server version.
|
91
|
+
|
92
|
+
This requires testbot to be installed **without sudo** as the update simply runs "gem install testbot -v new_version". I recommend using [RVM](http://rvm.beginrescueend.com/) (it handles paths correctly).
|
93
|
+
|
94
|
+
Example:
|
95
|
+
testbot --runner --connect 192.168.0.100 --auto_update
|
96
|
+
|
97
|
+
More options
|
98
|
+
----
|
99
|
+
|
100
|
+
testbot (or testbot --help)
|
101
|
+
|
102
|
+
Could this readme be better somehow?
|
103
|
+
----
|
104
|
+
|
105
|
+
If there is anything missing or unclear you can create an [issue](http://github.com/joakimk/testbot/issues) (or send me a pull request).
|
106
|
+
|
107
|
+
Features
|
108
|
+
----
|
109
|
+
* You can add and remove computers at any time. Testbot simply gives abandoned jobs to other computers.
|
110
|
+
* Testbot will try to balance the testload so that every computer finishes running the tests at the same time to reduce the time it takes to run the entire test suite. It does a good job, but has potential for further improvement.
|
111
|
+
* You can access your testbot network through SSH by using the built in SSH tunneling code.
|
112
|
+
* You can use the same testbot network with multiple projects.
|
113
|
+
* You can abort a test run with ctrl+c and all remote processes will be stopped.
|
114
|
+
* It shows you the output as it happens.
|
115
|
+
|
116
|
+
Contributing to testbot
|
117
|
+
----
|
118
|
+
|
119
|
+
First, get the tests to run:
|
120
|
+
|
121
|
+
bundle
|
122
|
+
rake
|
123
|
+
|
124
|
+
For development I recommend using guard.
|
125
|
+
|
126
|
+
# OSX needs: gem install rb-fsevent
|
127
|
+
guard
|
128
|
+
|
129
|
+
Make your change (don't forget to write tests) and send me a pull request.
|
130
|
+
|
131
|
+
You can also contribute by adding to the [wiki](http://github.com/joakimk/testbot/wiki).
|
132
|
+
|
133
|
+
How to add support for more test frameworks and/or programming languages
|
134
|
+
----
|
135
|
+
|
136
|
+
Add a **lib/shared/adapters/framework_name_adapter.rb** file and update this readme.
|
137
|
+
|
138
|
+
More
|
139
|
+
----
|
140
|
+
|
141
|
+
* Check the [wiki](http://github.com/joakimk/testbot/wiki) for more info.
|
data/Rakefile
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
require 'bundler'
|
2
|
+
|
3
|
+
Bundler::GemHelper.install_tasks
|
4
|
+
|
5
|
+
task :default => [ :test ] do
|
6
|
+
end
|
7
|
+
|
8
|
+
desc "Run Test::Unit tests"
|
9
|
+
task :test do
|
10
|
+
Dir["test/**/*_test.rb"].each { |test| require(File.expand_path(test)) }
|
11
|
+
end
|
12
|
+
|
13
|
+
|
14
|
+
desc "Used for quickly deploying and testing updates without pusing to rubygems.org"
|
15
|
+
task :deploy do
|
16
|
+
File.open("DEV_VERSION", "w") { |f| f.write(".DEV.#{Time.now.to_i}") }
|
17
|
+
|
18
|
+
gem_file = "testbot-#{Testbot.version}.gem"
|
19
|
+
config = YAML.load_file(".deploy_config.yml")
|
20
|
+
Rake::Task["build"].invoke
|
21
|
+
|
22
|
+
begin
|
23
|
+
system(config["upload_gem"].gsub(/GEM_FILE/, gem_file)) || fail
|
24
|
+
system(config["update_server"].gsub(/GEM_FILE/, gem_file)) || fail
|
25
|
+
system(config["restart_server"]) || fail
|
26
|
+
ensure
|
27
|
+
system("rm DEV_VERSION")
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
desc "Used to restart the server when developing testbot"
|
32
|
+
task :restart do
|
33
|
+
config = YAML.load_file(".deploy_config.yml")
|
34
|
+
system(config["restart_server"]) || fail
|
35
|
+
end
|
data/bin/testbot
ADDED
@@ -0,0 +1,59 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require File.expand_path(File.join(File.dirname(__FILE__), '../lib/shared/testbot.rb'))
|
4
|
+
|
5
|
+
def show_help
|
6
|
+
puts "Testbot #{Testbot.version}"
|
7
|
+
puts
|
8
|
+
puts "Testbot is a test distribution tool that works with Rails, RSpec, Test::Unit and Cucumber."
|
9
|
+
puts
|
10
|
+
puts "More info: http://github.com/joakimk/testbot"
|
11
|
+
puts "Wiki: http://github.com/joakimk/testbot/wiki"
|
12
|
+
puts
|
13
|
+
puts "Examples:"
|
14
|
+
puts " testbot --server"
|
15
|
+
puts " testbot --runner --connect 192.168.0.100"
|
16
|
+
puts " testbot --test --connect 192.168.0.100"
|
17
|
+
puts
|
18
|
+
puts "Types:"
|
19
|
+
puts " --server <start|stop|run>"
|
20
|
+
puts " --runner <start|stop|run>"
|
21
|
+
Adapter.all.each do |adapter|
|
22
|
+
puts " --#{adapter.type}\t\t\t# Run #{adapter.name} tests"
|
23
|
+
end
|
24
|
+
puts
|
25
|
+
puts "Runner options:"
|
26
|
+
puts " --connect <host_or_ip>\t# Which server to use (required)"
|
27
|
+
puts " --working_dir <path>\t\t# Where to store temporary files (default: #{Testbot::DEFAULT_WORKING_DIR})"
|
28
|
+
puts " --cpus <number>\t\t# The number of CPU cores to use (default: use all)"
|
29
|
+
puts " --ssh_tunnel\t\t\t# Use a ssh tunnel"
|
30
|
+
puts " --user <username>\t\t# Use a custom ssh tunnel user (default: testbot)"
|
31
|
+
puts " --auto_update\t\t\t# Keep testbot updated to the same version as the server."
|
32
|
+
puts " --max_jruby_instances <num>\t# To use less instances when running JRuby (as it requires more memory)"
|
33
|
+
puts " --jruby_opts <-J-X...>\t# Options to JRuby."
|
34
|
+
puts
|
35
|
+
puts "Test options:"
|
36
|
+
puts " --connect <host_or_ip>\t# Which server to use (required)"
|
37
|
+
puts " --rsync_ignores <ignores>\t# Files to ignore when syncing (default: include all)"
|
38
|
+
puts " --rsync_path <path>\t\t# Sync path on the server (default: #{Testbot::DEFAULT_SERVER_PATH})"
|
39
|
+
puts " --ssh_tunnel\t\t\t# Use a ssh tunnel"
|
40
|
+
puts " --user <username>\t\t# Use a custom rsync / ssh tunnel user (default: #{Testbot::DEFAULT_USER})"
|
41
|
+
puts " --project <project_name>\t# Use a custom project name (default: #{Testbot::DEFAULT_PROJECT})"
|
42
|
+
puts
|
43
|
+
puts "Other:"
|
44
|
+
puts " --help\t\t\t# Show help (this page)"
|
45
|
+
puts " --version\t\t\t# Show the testbot version"
|
46
|
+
|
47
|
+
# puts " # (when the server gem version is changed,"
|
48
|
+
# puts " # this runs gem install with the same version"
|
49
|
+
# puts " # and restarts the test runner)"
|
50
|
+
|
51
|
+
|
52
|
+
# TODO:
|
53
|
+
# puts " --use_git_ignore # Don't rsync files that are ignored by git"
|
54
|
+
# puts " --status # Show running background processes"
|
55
|
+
# puts " --port <number> # Use a custom port"
|
56
|
+
|
57
|
+
end
|
58
|
+
|
59
|
+
show_help unless Testbot::CLI.run(ARGV)
|
@@ -0,0 +1,35 @@
|
|
1
|
+
namespace :testbot do
|
2
|
+
task :before_request do
|
3
|
+
# This is run after you start a request (ex: rake testbot:spec)
|
4
|
+
end
|
5
|
+
|
6
|
+
task :before_run do
|
7
|
+
# This is run by the runner after files are synced but before tests are run
|
8
|
+
|
9
|
+
# Example: Setting up a test database
|
10
|
+
database_yml = <<-DB_CONFIG
|
11
|
+
test:
|
12
|
+
adapter: mysql
|
13
|
+
encoding: utf8
|
14
|
+
database: <%= options[:project] %>_testbot_test<%%= ENV['TEST_ENV_NUMBER'] %>
|
15
|
+
username: root
|
16
|
+
password:
|
17
|
+
host: localhost
|
18
|
+
DB_CONFIG
|
19
|
+
|
20
|
+
# database_file_path = "config/database.yml"
|
21
|
+
# File.open(database_file_path, 'w') { |f| f.write(database_yml) }
|
22
|
+
#
|
23
|
+
# # Setup databases for all instances
|
24
|
+
# 0.upto(ENV['TEST_INSTANCES'].to_i - 1) do |instance|
|
25
|
+
# test_env_number = (instance == 0) ? '' : instance + 1
|
26
|
+
# system "mysqladmin -u root -f drop <%= options[:project] %>_testbot_test#{test_env_number} > /dev/null 2>&1"
|
27
|
+
# system "mysqladmin -u root -f create <%= options[:project] %>_testbot_test#{test_env_number} > /dev/null 2>&1"
|
28
|
+
# system "export RAILS_ENV=test; export TEST_ENV_NUMBER=#{test_env_number}; rake db:test:load"
|
29
|
+
# end
|
30
|
+
|
31
|
+
# Example: Building gems
|
32
|
+
# system "rm vendor/gems/*/ext/**/*.o > /dev/null 2>&1"
|
33
|
+
# system "rake gems:build:force > /dev/null 2>&1"
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
# You can use ERB here.
|
2
|
+
|
3
|
+
# Which server to use.
|
4
|
+
server_host: <%= options[:connect] %>
|
5
|
+
<%- if options[:user] -%>
|
6
|
+
server_user: <%= options[:user] %>
|
7
|
+
<%- else -%>
|
8
|
+
# server_user: <%= Testbot::DEFAULT_USER %>
|
9
|
+
<%- end -%>
|
10
|
+
|
11
|
+
# Project prefix. Used for prefixing project files
|
12
|
+
# so that you can run multiple projects in the same testbot network.
|
13
|
+
<%- if options[:project] %>
|
14
|
+
project: <%= options[:project] %>
|
15
|
+
<%- else -%>
|
16
|
+
# project: <%= Testbot::DEFAULT_PROJECT %>
|
17
|
+
<%- end -%>
|
18
|
+
|
19
|
+
# RSync settings. The folder where your files are synced to
|
20
|
+
# and then fetched from before running the tests.
|
21
|
+
<%- if options[:rsync_path] -%>
|
22
|
+
rsync_path: <%= options[:rsync_path] %>
|
23
|
+
<%- else -%>
|
24
|
+
# rsync_path: <%= Testbot::DEFAULT_SERVER_PATH %>
|
25
|
+
<%- end -%>
|
26
|
+
<%- if options[:rsync_ignores] -%>
|
27
|
+
rsync_ignores: <%= options[:rsync_ignores] %>
|
28
|
+
<%- else -%>
|
29
|
+
# rsync_ignores:
|
30
|
+
<%- end -%>
|
31
|
+
|
32
|
+
# To tunnel traffic through SSH
|
33
|
+
<%- if options[:ssh_tunnel] -%>
|
34
|
+
ssh_tunnel: true
|
35
|
+
<%- else -%>
|
36
|
+
# ssh_tunnel: true
|
37
|
+
<%- end -%>
|
38
|
+
|
39
|
+
# Runner usage. Set to a lower percentage to not use
|
40
|
+
# every available instance or higher to create more
|
41
|
+
# jobs than there are instances.
|
42
|
+
available_runner_usage: 100%
|
43
|
+
|
44
|
+
# Enable more logging from the requester
|
45
|
+
# logging: true
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + "/../../shared/testbot")
|
2
|
+
require "acts_as_rails3_generator"
|
3
|
+
|
4
|
+
class TestbotGenerator < Rails::Generators::Base
|
5
|
+
source_root File.expand_path('../templates', __FILE__)
|
6
|
+
|
7
|
+
class_option :connect, :type => :string, :required => true, :desc => "Which server to use (required)"
|
8
|
+
class_option :project, :type => :string, :default => nil, :desc => "The name of your project (default: #{Testbot::DEFAULT_PROJECT})"
|
9
|
+
class_option :rsync_path, :type => :string, :default => nil, :desc => "Sync path on the server (default: #{Testbot::DEFAULT_SERVER_PATH})"
|
10
|
+
class_option :rsync_ignores, :type => :string, :default => nil, :desc => "Files to rsync_ignores when syncing (default: include all)"
|
11
|
+
class_option :ssh_tunnel, :type => :boolean, :default => nil, :desc => "Use a ssh tunnel"
|
12
|
+
class_option :user, :type => :string, :default => nil, :desc => "Use a custom rsync / ssh tunnel user (default: #{Testbot::DEFAULT_USER})"
|
13
|
+
|
14
|
+
def generate_config
|
15
|
+
template "testbot.yml.erb", "config/testbot.yml"
|
16
|
+
template "testbot.rake.erb", "lib/tasks/testbot.rake"
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
data/lib/railtie.rb
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
begin
|
2
|
+
require 'rails'
|
3
|
+
@rails_loaded = true
|
4
|
+
rescue LoadError => ex
|
5
|
+
@rails_loaded = false
|
6
|
+
end
|
7
|
+
|
8
|
+
if @rails_loaded
|
9
|
+
module Testbot
|
10
|
+
class Railtie < Rails::Railtie
|
11
|
+
rake_tasks do
|
12
|
+
load File.expand_path(File.join(File.dirname(__FILE__), "tasks/testbot.rake"))
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|