testbot 0.4.6 → 0.4.7
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +6 -0
- data/README.markdown +3 -1
- data/bin/testbot +1 -1
- data/lib/generators/testbot/testbot_generator.rb +1 -1
- data/lib/railtie.rb +0 -2
- data/lib/requester/requester.rb +134 -0
- data/lib/runner/job.rb +52 -33
- data/lib/runner/runner.rb +215 -0
- data/lib/server/build.rb +29 -25
- data/lib/server/db.rb +42 -39
- data/lib/server/group.rb +42 -38
- data/lib/server/job.rb +44 -40
- data/lib/server/runner.rb +37 -33
- data/lib/server/server.rb +74 -0
- data/lib/{adapters → shared/adapters}/adapter.rb +0 -0
- data/lib/{adapters → shared/adapters}/cucumber_adapter.rb +0 -0
- data/lib/{adapters → shared/adapters}/helpers/ruby_env.rb +0 -0
- data/lib/{adapters → shared/adapters}/rspec_adapter.rb +0 -0
- data/lib/{adapters → shared/adapters}/test_unit_adapter.rb +0 -0
- data/lib/shared/testbot.rb +141 -0
- data/lib/tasks/testbot.rake +3 -3
- data/lib/testbot.rb +2 -146
- data/testbot.gemspec +3 -7
- metadata +13 -30
- data/lib/new_runner.rb +0 -30
- data/lib/requester.rb +0 -130
- data/lib/runner.rb +0 -213
- data/lib/server.rb +0 -72
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
@@ -0,0 +1,141 @@
|
|
1
|
+
require File.expand_path(File.join(File.dirname(__FILE__), '/simple_daemonize'))
|
2
|
+
require File.expand_path(File.join(File.dirname(__FILE__), '/adapters/adapter'))
|
3
|
+
require 'fileutils'
|
4
|
+
|
5
|
+
module Testbot
|
6
|
+
require 'railtie' if defined?(Rails)
|
7
|
+
|
8
|
+
# Don't forget to update readme and changelog
|
9
|
+
def self.version
|
10
|
+
version = "0.4.7"
|
11
|
+
dev_version_file = File.join(File.dirname(__FILE__), '..', '..', 'DEV_VERSION')
|
12
|
+
if File.exists?(dev_version_file)
|
13
|
+
version += File.read(dev_version_file)
|
14
|
+
end
|
15
|
+
version
|
16
|
+
end
|
17
|
+
|
18
|
+
if ENV['INTEGRATION_TEST']
|
19
|
+
SERVER_PID = "/tmp/integration_test_testbot_server.pid"
|
20
|
+
RUNNER_PID = "/tmp/integration_test_testbot_runner.pid"
|
21
|
+
else
|
22
|
+
SERVER_PID = "/tmp/testbot_server.pid"
|
23
|
+
RUNNER_PID = "/tmp/testbot_runner.pid"
|
24
|
+
end
|
25
|
+
|
26
|
+
DEFAULT_WORKING_DIR = "/tmp/testbot"
|
27
|
+
DEFAULT_SERVER_PATH = "/tmp/testbot/#{ENV['USER']}"
|
28
|
+
DEFAULT_USER = "testbot"
|
29
|
+
DEFAULT_PROJECT = "project"
|
30
|
+
DEFAULT_RUNNER_USAGE = "100%"
|
31
|
+
SERVER_PORT = ENV['INTEGRATION_TEST'] ? 22880 : 2288
|
32
|
+
|
33
|
+
class CLI
|
34
|
+
|
35
|
+
def self.run(argv)
|
36
|
+
return false if argv == []
|
37
|
+
opts = parse_args(argv)
|
38
|
+
|
39
|
+
if opts[:help]
|
40
|
+
return false
|
41
|
+
elsif opts[:version]
|
42
|
+
puts "Testbot #{Testbot.version}"
|
43
|
+
elsif [ true, 'run', 'start' ].include?(opts[:server])
|
44
|
+
start_server(opts[:server])
|
45
|
+
elsif opts[:server] == 'stop'
|
46
|
+
stop('server', Testbot::SERVER_PID)
|
47
|
+
elsif [ true, 'run', 'start' ].include?(opts[:runner])
|
48
|
+
require File.expand_path(File.join(File.dirname(__FILE__), '/../runner/runner'))
|
49
|
+
return false unless valid_runner_opts?(opts)
|
50
|
+
start_runner(opts)
|
51
|
+
elsif opts[:runner] == 'stop'
|
52
|
+
stop('runner', Testbot::RUNNER_PID)
|
53
|
+
elsif adapter = Adapter.all.find { |adapter| opts[adapter.type.to_sym] }
|
54
|
+
require File.expand_path(File.join(File.dirname(__FILE__), '/../requester/requester'))
|
55
|
+
start_requester(opts, adapter)
|
56
|
+
end
|
57
|
+
|
58
|
+
true
|
59
|
+
end
|
60
|
+
|
61
|
+
def self.parse_args(argv)
|
62
|
+
last_setter = nil
|
63
|
+
hash = {}
|
64
|
+
str = ''
|
65
|
+
argv.each_with_index do |arg, i|
|
66
|
+
if arg.include?('--')
|
67
|
+
str = ''
|
68
|
+
last_setter = arg.split('--').last.to_sym
|
69
|
+
hash[last_setter] = true if (i == argv.size - 1) || argv[i+1].include?('--')
|
70
|
+
else
|
71
|
+
str += ' ' + arg
|
72
|
+
hash[last_setter] = str.strip
|
73
|
+
end
|
74
|
+
end
|
75
|
+
hash
|
76
|
+
end
|
77
|
+
|
78
|
+
def self.start_runner(opts)
|
79
|
+
stop('runner', Testbot::RUNNER_PID)
|
80
|
+
|
81
|
+
proc = lambda {
|
82
|
+
working_dir = opts[:working_dir] || Testbot::DEFAULT_WORKING_DIR
|
83
|
+
FileUtils.mkdir_p(working_dir)
|
84
|
+
Dir.chdir(working_dir)
|
85
|
+
runner = Runner::Runner.new(:server_host => opts[:connect],
|
86
|
+
:auto_update => opts[:auto_update], :max_instances => opts[:cpus],
|
87
|
+
:ssh_tunnel => opts[:ssh_tunnel], :server_user => opts[:user],
|
88
|
+
:max_jruby_instances => opts[:max_jruby_instances],
|
89
|
+
:dev_gem_root => opts[:dev_gem_root],
|
90
|
+
:wait_for_updated_gem => opts[:wait_for_updated_gem],
|
91
|
+
:jruby_opts => opts[:jruby_opts])
|
92
|
+
runner.run!
|
93
|
+
}
|
94
|
+
|
95
|
+
if opts[:runner] == 'run'
|
96
|
+
proc.call
|
97
|
+
else
|
98
|
+
puts "Testbot runner started (pid: #{Process.pid})"
|
99
|
+
SimpleDaemonize.start(proc, Testbot::RUNNER_PID, "testbot (runner)")
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
103
|
+
def self.start_server(type)
|
104
|
+
stop('server', Testbot::SERVER_PID)
|
105
|
+
require File.expand_path(File.join(File.dirname(__FILE__), '/../server/server'))
|
106
|
+
|
107
|
+
if type == 'run'
|
108
|
+
Sinatra::Application.run! :environment => "production"
|
109
|
+
else
|
110
|
+
puts "Testbot server started (pid: #{Process.pid})"
|
111
|
+
SimpleDaemonize.start(lambda {
|
112
|
+
Sinatra::Application.run! :environment => "production"
|
113
|
+
}, Testbot::SERVER_PID, "testbot (server)")
|
114
|
+
end
|
115
|
+
end
|
116
|
+
|
117
|
+
def self.stop(name, pid)
|
118
|
+
puts "Testbot #{name} stopped" if SimpleDaemonize.stop(pid)
|
119
|
+
end
|
120
|
+
|
121
|
+
def self.start_requester(opts, adapter)
|
122
|
+
requester = Requester::Requester.new(:server_host => opts[:connect],
|
123
|
+
:rsync_path => opts[:rsync_path],
|
124
|
+
:rsync_ignores => opts[:rsync_ignores].to_s,
|
125
|
+
:available_runner_usage => nil,
|
126
|
+
:project => opts[:project],
|
127
|
+
:ssh_tunnel => opts[:ssh_tunnel], :server_user => opts[:user])
|
128
|
+
requester.run_tests(adapter, adapter.base_path)
|
129
|
+
end
|
130
|
+
|
131
|
+
def self.valid_runner_opts?(opts)
|
132
|
+
opts[:connect].is_a?(String)
|
133
|
+
end
|
134
|
+
|
135
|
+
def self.lib_path
|
136
|
+
File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib'))
|
137
|
+
end
|
138
|
+
|
139
|
+
end
|
140
|
+
|
141
|
+
end
|
data/lib/tasks/testbot.rake
CHANGED
@@ -1,12 +1,12 @@
|
|
1
|
-
require File.dirname(__FILE__) + '/../adapters/adapter'
|
1
|
+
require File.dirname(__FILE__) + '/../shared/adapters/adapter'
|
2
2
|
|
3
3
|
namespace :testbot do
|
4
4
|
|
5
5
|
def run_and_show_results(adapter, custom_path)
|
6
6
|
Rake::Task["testbot:before_request"].invoke
|
7
7
|
|
8
|
-
require File.join(File.dirname(__FILE__), '..',
|
9
|
-
requester = Requester.create_by_config("#{Rails.root}/config/testbot.yml")
|
8
|
+
require File.expand_path(File.join(File.dirname(__FILE__), '..', 'requester', 'requester.rb'))
|
9
|
+
requester = Testbot::Requester::Requester.create_by_config("#{Rails.root}/config/testbot.yml")
|
10
10
|
|
11
11
|
puts "Running #{adapter.pluralized}..."
|
12
12
|
start_time = Time.now
|
data/lib/testbot.rb
CHANGED
@@ -1,146 +1,2 @@
|
|
1
|
-
#
|
2
|
-
|
3
|
-
require File.join(File.dirname(__FILE__), '/shared/simple_daemonize')
|
4
|
-
require File.join(File.dirname(__FILE__), '/adapters/adapter')
|
5
|
-
require 'fileutils'
|
6
|
-
|
7
|
-
module Testbot
|
8
|
-
require 'railtie' if defined?(Rails)
|
9
|
-
|
10
|
-
# Don't forget to update readme and changelog
|
11
|
-
def self.version
|
12
|
-
version = "0.4.6"
|
13
|
-
dev_version_file = File.join(File.dirname(__FILE__), '..', 'DEV_VERSION')
|
14
|
-
if File.exists?(dev_version_file)
|
15
|
-
version += File.read(dev_version_file)
|
16
|
-
end
|
17
|
-
version
|
18
|
-
end
|
19
|
-
|
20
|
-
if ENV['INTEGRATION_TEST']
|
21
|
-
SERVER_PID = "/tmp/integration_test_testbot_server.pid"
|
22
|
-
RUNNER_PID = "/tmp/integration_test_testbot_runner.pid"
|
23
|
-
else
|
24
|
-
SERVER_PID = "/tmp/testbot_server.pid"
|
25
|
-
RUNNER_PID = "/tmp/testbot_runner.pid"
|
26
|
-
end
|
27
|
-
|
28
|
-
DEFAULT_WORKING_DIR = "/tmp/testbot"
|
29
|
-
DEFAULT_SERVER_PATH = "/tmp/testbot/#{ENV['USER']}"
|
30
|
-
DEFAULT_USER = "testbot"
|
31
|
-
DEFAULT_PROJECT = "project"
|
32
|
-
DEFAULT_RUNNER_USAGE = "100%"
|
33
|
-
SERVER_PORT = ENV['INTEGRATION_TEST'] ? 22880 : 2288
|
34
|
-
|
35
|
-
class CLI
|
36
|
-
|
37
|
-
def self.run(argv)
|
38
|
-
return false if argv == []
|
39
|
-
opts = parse_args(argv)
|
40
|
-
|
41
|
-
if opts[:help]
|
42
|
-
return false
|
43
|
-
elsif opts[:version]
|
44
|
-
puts "Testbot #{Testbot.version}"
|
45
|
-
elsif [ true, 'run', 'start' ].include?(opts[:server])
|
46
|
-
start_server(opts[:server])
|
47
|
-
elsif opts[:server] == 'stop'
|
48
|
-
stop('server', Testbot::SERVER_PID)
|
49
|
-
elsif [ true, 'run', 'start' ].include?(opts[:runner])
|
50
|
-
require File.join(File.dirname(__FILE__), '/runner')
|
51
|
-
return false unless valid_runner_opts?(opts)
|
52
|
-
start_runner(opts)
|
53
|
-
elsif opts[:runner] == 'stop'
|
54
|
-
stop('runner', Testbot::RUNNER_PID)
|
55
|
-
elsif adapter = Adapter.all.find { |adapter| opts[adapter.type.to_sym] }
|
56
|
-
require File.join(File.dirname(__FILE__), '/requester')
|
57
|
-
start_requester(opts, adapter)
|
58
|
-
end
|
59
|
-
|
60
|
-
true
|
61
|
-
end
|
62
|
-
|
63
|
-
def self.parse_args(argv)
|
64
|
-
last_setter = nil
|
65
|
-
hash = {}
|
66
|
-
str = ''
|
67
|
-
argv.each_with_index do |arg, i|
|
68
|
-
if arg.include?('--')
|
69
|
-
str = ''
|
70
|
-
last_setter = arg.split('--').last.to_sym
|
71
|
-
hash[last_setter] = true if (i == argv.size - 1) || argv[i+1].include?('--')
|
72
|
-
else
|
73
|
-
str += ' ' + arg
|
74
|
-
hash[last_setter] = str.strip
|
75
|
-
end
|
76
|
-
end
|
77
|
-
hash
|
78
|
-
end
|
79
|
-
|
80
|
-
def self.start_runner(opts)
|
81
|
-
stop('runner', Testbot::RUNNER_PID)
|
82
|
-
|
83
|
-
proc = lambda {
|
84
|
-
working_dir = opts[:working_dir] || Testbot::DEFAULT_WORKING_DIR
|
85
|
-
FileUtils.mkdir_p(working_dir)
|
86
|
-
Dir.chdir(working_dir)
|
87
|
-
runner = Runner.new(:server_host => opts[:connect],
|
88
|
-
:auto_update => opts[:auto_update], :max_instances => opts[:cpus],
|
89
|
-
:ssh_tunnel => opts[:ssh_tunnel], :server_user => opts[:user],
|
90
|
-
:max_jruby_instances => opts[:max_jruby_instances],
|
91
|
-
:dev_gem_root => opts[:dev_gem_root],
|
92
|
-
:wait_for_updated_gem => opts[:wait_for_updated_gem],
|
93
|
-
:jruby_opts => opts[:jruby_opts])
|
94
|
-
runner.run!
|
95
|
-
}
|
96
|
-
|
97
|
-
if opts[:runner] == 'run'
|
98
|
-
proc.call
|
99
|
-
else
|
100
|
-
puts "Testbot runner started (pid: #{Process.pid})"
|
101
|
-
SimpleDaemonize.start(proc, Testbot::RUNNER_PID, "testbot (runner)")
|
102
|
-
end
|
103
|
-
end
|
104
|
-
|
105
|
-
def self.start_server(type)
|
106
|
-
stop('server', Testbot::SERVER_PID)
|
107
|
-
|
108
|
-
if type == 'run'
|
109
|
-
require File.join(File.dirname(__FILE__), '/server')
|
110
|
-
Sinatra::Application.run! :environment => "production"
|
111
|
-
else
|
112
|
-
puts "Testbot server started (pid: #{Process.pid})"
|
113
|
-
SimpleDaemonize.start(lambda {
|
114
|
-
ENV['DISABLE_LOGGING'] = "true"
|
115
|
-
require File.join(File.dirname(__FILE__), '/server')
|
116
|
-
Sinatra::Application.run! :environment => "production"
|
117
|
-
}, Testbot::SERVER_PID, "testbot (server)")
|
118
|
-
end
|
119
|
-
end
|
120
|
-
|
121
|
-
def self.stop(name, pid)
|
122
|
-
puts "Testbot #{name} stopped" if SimpleDaemonize.stop(pid)
|
123
|
-
end
|
124
|
-
|
125
|
-
def self.start_requester(opts, adapter)
|
126
|
-
requester = Requester.new(:server_host => opts[:connect],
|
127
|
-
:rsync_path => opts[:rsync_path],
|
128
|
-
:rsync_ignores => opts[:rsync_ignores].to_s,
|
129
|
-
:available_runner_usage => nil,
|
130
|
-
:project => opts[:project],
|
131
|
-
:ssh_tunnel => opts[:ssh_tunnel], :server_user => opts[:user])
|
132
|
-
requester.run_tests(adapter, adapter.base_path)
|
133
|
-
end
|
134
|
-
|
135
|
-
def self.valid_runner_opts?(opts)
|
136
|
-
opts[:connect].is_a?(String)
|
137
|
-
end
|
138
|
-
|
139
|
-
def self.lib_path
|
140
|
-
File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib'))
|
141
|
-
end
|
142
|
-
|
143
|
-
end
|
144
|
-
|
145
|
-
end
|
146
|
-
end
|
1
|
+
# Rails plugin hook
|
2
|
+
require File.expand_path(File.join(File.dirname(__FILE__), '/shared/testbot'))
|
data/testbot.gemspec
CHANGED
@@ -1,6 +1,5 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
|
-
|
3
|
-
require File.expand_path("lib/testbot")
|
2
|
+
require File.expand_path(File.dirname(__FILE__) + '/lib/shared/testbot')
|
4
3
|
|
5
4
|
Gem::Specification.new do |s|
|
6
5
|
s.name = "testbot"
|
@@ -20,13 +19,10 @@ Gem::Specification.new do |s|
|
|
20
19
|
s.add_dependency('net-ssh', '>= 2.0.23')
|
21
20
|
s.add_dependency('sequel', '>= 3.16.0')
|
22
21
|
s.add_dependency('json', '>= 1.4.6')
|
23
|
-
s.add_dependency('daemons', '
|
22
|
+
s.add_dependency('daemons', '>= 1.0.10')
|
24
23
|
s.add_dependency('acts_as_rails3_generator')
|
25
24
|
|
26
25
|
# Could work with older versions, but not newer (when deploying on debian)
|
27
26
|
s.add_dependency('sqlite3-ruby', '= 1.2.5')
|
28
|
-
|
29
|
-
# Because sinatra's "disable :logging" does not work with WEBrick.
|
30
|
-
# Also, using a version that builds on ruby 1.9.2.
|
31
|
-
s.add_dependency('mongrel', '1.2.0.pre2')
|
32
27
|
end
|
28
|
+
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: testbot
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 1
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 4
|
9
|
-
-
|
10
|
-
version: 0.4.
|
9
|
+
- 7
|
10
|
+
version: 0.4.7
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- "Joakim Kolsj\xC3\xB6"
|
@@ -120,7 +120,7 @@ dependencies:
|
|
120
120
|
requirement: &id007 !ruby/object:Gem::Requirement
|
121
121
|
none: false
|
122
122
|
requirements:
|
123
|
-
- - "
|
123
|
+
- - ">="
|
124
124
|
- !ruby/object:Gem::Version
|
125
125
|
hash: 3
|
126
126
|
segments:
|
@@ -160,23 +160,6 @@ dependencies:
|
|
160
160
|
version: 1.2.5
|
161
161
|
type: :runtime
|
162
162
|
version_requirements: *id009
|
163
|
-
- !ruby/object:Gem::Dependency
|
164
|
-
name: mongrel
|
165
|
-
prerelease: false
|
166
|
-
requirement: &id010 !ruby/object:Gem::Requirement
|
167
|
-
none: false
|
168
|
-
requirements:
|
169
|
-
- - "="
|
170
|
-
- !ruby/object:Gem::Version
|
171
|
-
hash: -1876988191
|
172
|
-
segments:
|
173
|
-
- 1
|
174
|
-
- 2
|
175
|
-
- 0
|
176
|
-
- pre2
|
177
|
-
version: 1.2.0.pre2
|
178
|
-
type: :runtime
|
179
|
-
version_requirements: *id010
|
180
163
|
description: Testbot is a test distribution tool that works with Rails, RSpec, Test::Unit and Cucumber.
|
181
164
|
email:
|
182
165
|
- joakim.kolsjo@gmail.com
|
@@ -187,27 +170,27 @@ extensions: []
|
|
187
170
|
extra_rdoc_files: []
|
188
171
|
|
189
172
|
files:
|
190
|
-
- lib/adapters/adapter.rb
|
191
|
-
- lib/adapters/cucumber_adapter.rb
|
192
|
-
- lib/adapters/helpers/ruby_env.rb
|
193
|
-
- lib/adapters/rspec_adapter.rb
|
194
|
-
- lib/adapters/test_unit_adapter.rb
|
195
173
|
- lib/generators/testbot/templates/testbot.rake.erb
|
196
174
|
- lib/generators/testbot/templates/testbot.yml.erb
|
197
175
|
- lib/generators/testbot/testbot_generator.rb
|
198
|
-
- lib/new_runner.rb
|
199
176
|
- lib/railtie.rb
|
200
|
-
- lib/requester.rb
|
177
|
+
- lib/requester/requester.rb
|
201
178
|
- lib/runner/job.rb
|
202
|
-
- lib/runner.rb
|
179
|
+
- lib/runner/runner.rb
|
203
180
|
- lib/server/build.rb
|
204
181
|
- lib/server/db.rb
|
205
182
|
- lib/server/group.rb
|
206
183
|
- lib/server/job.rb
|
207
184
|
- lib/server/runner.rb
|
208
|
-
- lib/server.rb
|
185
|
+
- lib/server/server.rb
|
186
|
+
- lib/shared/adapters/adapter.rb
|
187
|
+
- lib/shared/adapters/cucumber_adapter.rb
|
188
|
+
- lib/shared/adapters/helpers/ruby_env.rb
|
189
|
+
- lib/shared/adapters/rspec_adapter.rb
|
190
|
+
- lib/shared/adapters/test_unit_adapter.rb
|
209
191
|
- lib/shared/simple_daemonize.rb
|
210
192
|
- lib/shared/ssh_tunnel.rb
|
193
|
+
- lib/shared/testbot.rb
|
211
194
|
- lib/tasks/testbot.rake
|
212
195
|
- lib/testbot.rb
|
213
196
|
- Gemfile
|
data/lib/new_runner.rb
DELETED
@@ -1,30 +0,0 @@
|
|
1
|
-
require 'rubygems'
|
2
|
-
require 'httparty'
|
3
|
-
|
4
|
-
class Server
|
5
|
-
include HTTParty
|
6
|
-
end
|
7
|
-
|
8
|
-
class NewRunner
|
9
|
-
|
10
|
-
def self.run_jobs
|
11
|
-
next_job = Server.get('/jobs/next') rescue nil
|
12
|
-
return unless next_job
|
13
|
-
id, root, specs = next_job.split(',')
|
14
|
-
result = run_and_return_results("export RAILS_ENV=test; export RSPEC_COLOR=true; rake testbot:before_run; script/spec -O spec/spec.opts #{specs}")
|
15
|
-
Server.put("/jobs/#{id}", :body => { :result => result })
|
16
|
-
end
|
17
|
-
|
18
|
-
def self.load_config
|
19
|
-
host = YAML.load_file("#{ENV['HOME']}/.testbot_runner.yml")[:server_host]
|
20
|
-
Server.base_uri "http://#{host}:2288"
|
21
|
-
end
|
22
|
-
|
23
|
-
private
|
24
|
-
|
25
|
-
# I'd really like to know how to do this better and more testable
|
26
|
-
def self.run_and_return_results(cmd)
|
27
|
-
`#{cmd} 2>&1`
|
28
|
-
end
|
29
|
-
|
30
|
-
end
|