Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Quick development deploy support.

  • Loading branch information...
commit 9677ce140ab97eef97e1e9afbbb197d4e6e70115 1 parent 73cd8b9
@joakimk authored
View
1  .gitignore
@@ -1,3 +1,4 @@
+.deploy_config.yml
*.db
pkg
todo.txt
View
4 CHANGELOG
@@ -1,3 +1,7 @@
+0.4.1
+
+Added support for quicker and more automated updates when developing testbot.
+
0.4.0
Fixed RSpec 2 compability issue.
View
2  README.markdown
@@ -68,7 +68,7 @@ Using testbot with Rails 3:
Using testbot with Rails 2:
- ruby script/plugin install git://github.com/joakimk/testbot.git -r 'refs/tags/v0.4.0'
+ ruby script/plugin install git://github.com/joakimk/testbot.git -r 'refs/tags/v0.4.1'
script/generate testbot --connect 192.168.0.100
rake testbot:spec (or :test, :features)
View
12 Rakefile
@@ -14,6 +14,18 @@ task :test do
Dir["test/**/test_*.rb"].each { |test| require(File.expand_path(test)) }
end
+desc "Used for quickly deploying and testing updates without pusing to rubygems.org"
+task :deploy do
+ ENV['TESTBOT_DEV_DEPLOY'] = '1'
+
+ gem_file = "testbot-#{Testbot.version}.gem"
+ config = YAML.load_file(".deploy_config.yml")
+ Rake::Task["build"].invoke
+
+ system(config["upload_gem"].gsub(/GEM_FILE/, gem_file)) || fail
+ system(config["update_and_restart_server"].gsub(/GEM_FILE/, gem_file)) || fail
+end
+
Cucumber::Rake::Task.new(:features) do |t|
t.cucumber_opts = "features --format progress"
end
View
2  bin/testbot
@@ -3,7 +3,7 @@
require File.expand_path(File.join(File.dirname(__FILE__), '../lib/testbot.rb'))
def show_help
- puts "Testbot #{Testbot::VERSION}"
+ puts "Testbot #{Testbot.version}"
puts
puts "Testbot is a test distribution tool that works with Rails, RSpec, Test::Unit and Cucumber."
puts
View
12 lib/runner.rb
@@ -189,10 +189,14 @@ def time_for_update?
def check_for_update
return unless @config.auto_update
- version = Server.get('/version') rescue Testbot::VERSION
- return unless version != Testbot::VERSION
+ version = Server.get('/version') rescue Testbot.version
+ return unless version != Testbot.version
- successful_install = system "gem install testbot -v #{version}"
+ if version.include?(".DEV.")
+ successful_install = system "gem install #{@config.dev_gem_root}/testbot-#{version}.gem"
+ else
+ successful_install = system "gem install testbot -v #{version}"
+ end
if successful_install
File.open("/tmp/update_testbot.sh", "w") { |file| file.write("#!/bin/sh\nsleep 5\ntestbot #{ARGV.join(' ')}") }
@@ -208,7 +212,7 @@ def ping_params
end
def base_params
- { :version => Testbot::VERSION, :uid => @uid }
+ { :version => Testbot.version, :uid => @uid }
end
def max_instances_running?
View
4 lib/server.rb
@@ -18,7 +18,7 @@
class Server
def self.valid_version?(runner_version)
- Testbot::VERSION == runner_version
+ Testbot.version == runner_version
end
end
@@ -68,5 +68,5 @@ def self.valid_version?(runner_version)
end
get '/version' do
- Testbot::VERSION
+ Testbot.version
end
View
4 lib/server/runner.rb
@@ -19,11 +19,11 @@ def self.timeout
end
def self.find_all_outdated
- DB[:runners].filter("version != ? OR version IS NULL", Testbot::VERSION)
+ DB[:runners].filter("version != ? OR version IS NULL", Testbot.version)
end
def self.find_all_available
- DB[:runners].filter("version = ? AND last_seen_at > ?", Testbot::VERSION, Time.now - Runner.timeout)
+ DB[:runners].filter("version = ? AND last_seen_at > ?", Testbot.version, Time.now - Runner.timeout)
end
def self.available_instances
View
9 lib/testbot.rb
@@ -8,7 +8,11 @@ module Testbot
require 'railtie' if defined?(Rails)
# Don't forget to update readme and changelog
- VERSION = "0.4.0"
+ def self.version
+ version = "0.4.1"
+ version += ".DEV.#{Time.now.to_i}" if ENV['TESTBOT_DEV_DEPLOY']
+ version
+ end
if ENV['INTEGRATION_TEST']
SERVER_PID = "/tmp/integration_test_testbot_server.pid"
@@ -34,7 +38,7 @@ def self.run(argv)
if opts[:help]
return false
elsif opts[:version]
- puts "Testbot #{Testbot::VERSION}"
+ puts "Testbot #{Testbot.version}"
elsif [ true, 'run', 'start' ].include?(opts[:server])
start_server(opts[:server])
elsif opts[:server] == 'stop'
@@ -81,6 +85,7 @@ def self.start_runner(opts)
:auto_update => opts[:auto_update], :max_instances => opts[:cpus],
:ssh_tunnel => opts[:ssh_tunnel], :server_user => opts[:user],
:max_jruby_instances => opts[:max_jruby_instances],
+ :dev_gem_root => opts[:dev_gem_root],
:jruby_opts => opts[:jruby_opts])
runner.run!
}
View
74 test/test_server.rb
@@ -102,7 +102,7 @@ def app
should "be able to return a job and mark it as taken" do
job1 = Job.create :files => 'spec/models/car_spec.rb', :root => 'server:/project', :type => 'spec', :requester_mac => "bb:bb:bb:bb:bb:bb", :project => 'things', :jruby => 1
- get '/jobs/next', :version => Testbot::VERSION
+ get '/jobs/next', :version => Testbot.version
assert last_response.ok?
assert_equal [ job1[:id], "bb:bb:bb:bb:bb:bb", "things", "server:/project", "spec", "jruby", "spec/models/car_spec.rb" ].join(','), last_response.body
@@ -112,28 +112,28 @@ def app
should "not return a job that has already been taken" do
job1 = Job.create :files => 'spec/models/car_spec.rb', :taken_at => Time.now, :type => 'spec'
job2 = Job.create :files => 'spec/models/house_spec.rb', :root => 'server:/project', :type => 'spec', :requester_mac => "aa:aa:aa:aa:aa:aa", :project => 'things', :jruby => 0
- get '/jobs/next', :version => Testbot::VERSION
+ get '/jobs/next', :version => Testbot.version
assert last_response.ok?
assert_equal [ job2[:id], "aa:aa:aa:aa:aa:aa", "things", "server:/project", "spec", "ruby", "spec/models/house_spec.rb" ].join(','), last_response.body
assert job2.reload[:taken_at] != nil
end
should "not return a job if there isnt any" do
- get '/jobs/next', :version => Testbot::VERSION
+ get '/jobs/next', :version => Testbot.version
assert last_response.ok?
assert_equal '', last_response.body
end
should "save which runner takes a job" do
job = Job.create :files => 'spec/models/house_spec.rb', :root => 'server:/project', :type => 'spec', :requester_mac => "aa:aa:aa:aa:aa:aa"
- get '/jobs/next', :version => Testbot::VERSION
+ get '/jobs/next', :version => Testbot.version
assert_equal Runner.first.id, job.reload.taken_by_id
end
should "save information about the runners" do
- get '/jobs/next', :version => Testbot::VERSION, :hostname => 'macmini.local', :uid => "00:01:...", :idle_instances => 2, :max_instances => 4
+ get '/jobs/next', :version => Testbot.version, :hostname => 'macmini.local', :uid => "00:01:...", :idle_instances => 2, :max_instances => 4
runner = DB[:runners].first
- assert_equal Testbot::VERSION, runner[:version]
+ assert_equal Testbot.version, runner[:version]
assert_equal '127.0.0.1', runner[:ip]
assert_equal 'macmini.local', runner[:hostname]
assert_equal '00:01:...', runner[:uid]
@@ -144,8 +144,8 @@ def app
end
should "only create one record for the same mac" do
- get '/jobs/next', :version => Testbot::VERSION, :uid => "00:01:..."
- get '/jobs/next', :version => Testbot::VERSION, :uid => "00:01:..."
+ get '/jobs/next', :version => Testbot.version, :uid => "00:01:..."
+ get '/jobs/next', :version => Testbot.version, :uid => "00:01:..."
assert_equal 1, Runner.count
end
@@ -158,11 +158,11 @@ def app
should "only give jobs from the same source to a runner" do
job1 = Job.create :files => 'spec/models/car_spec.rb', :type => 'spec', :requester_mac => "bb:bb:bb:bb:bb:bb"
- get '/jobs/next', :version => Testbot::VERSION, :uid => "00:..."
+ get '/jobs/next', :version => Testbot.version, :uid => "00:..."
# Creating the second job here because of the random lookup.
job2 = Job.create :files => 'spec/models/house_spec.rb', :root => 'server:/project', :type => 'spec', :requester_mac => "aa:aa:aa:aa:aa:aa"
- get '/jobs/next', :version => Testbot::VERSION, :uid => "00:...", :requester_mac => "bb:bb:bb:bb:bb:bb"
+ get '/jobs/next', :version => Testbot.version, :uid => "00:...", :requester_mac => "bb:bb:bb:bb:bb:bb"
assert last_response.ok?
assert_equal '', last_response.body
@@ -170,11 +170,11 @@ def app
should "not give more jruby jobs to an instance that can't take more" do
job1 = Job.create :files => 'spec/models/car_spec.rb', :type => 'spec', :requester_mac => "bb:bb:bb:bb:bb:bb", :jruby => 1
- get '/jobs/next', :version => Testbot::VERSION, :uid => "00:..."
+ get '/jobs/next', :version => Testbot.version, :uid => "00:..."
# Creating the second job here because of the random lookup.
job2 = Job.create :files => 'spec/models/house_spec.rb', :root => 'server:/project', :type => 'spec', :jruby => 1
- get '/jobs/next', :version => Testbot::VERSION, :uid => "00:...", :no_jruby => "true"
+ get '/jobs/next', :version => Testbot.version, :uid => "00:...", :no_jruby => "true"
assert last_response.ok?
assert_equal '', last_response.body
@@ -182,11 +182,11 @@ def app
should "still return other jobs when the runner cant take more jruby jobs" do
job1 = Job.create :files => 'spec/models/car_spec.rb', :type => 'spec', :requester_mac => "bb:bb:bb:bb:bb:bb", :jruby => 1
- get '/jobs/next', :version => Testbot::VERSION, :uid => "00:..."
+ get '/jobs/next', :version => Testbot.version, :uid => "00:..."
# Creating the second job here because of the random lookup.
job2 = Job.create :files => 'spec/models/house_spec.rb', :root => 'server:/project', :type => 'spec', :jruby => 0
- get '/jobs/next', :version => Testbot::VERSION, :uid => "00:...", :no_jruby => "true"
+ get '/jobs/next', :version => Testbot.version, :uid => "00:...", :no_jruby => "true"
assert last_response.ok?
assert_equal job2.id.to_s, last_response.body.split(',')[0]
@@ -198,7 +198,7 @@ def app
20.times { Job.create :files => 'spec/models/house_spec.rb', :root => 'server:/project', :type => 'spec', :requester_mac => "aa:aa:aa:aa:aa:aa" }
macs = (0...10).map {
- get '/jobs/next', :version => Testbot::VERSION, :uid => "00:..."
+ get '/jobs/next', :version => Testbot.version, :uid => "00:..."
last_response.body.split(',')[1]
}
@@ -212,7 +212,7 @@ def app
20.times { Job.create :files => 'spec/models/car_spec.rb', :root => 'server:/project', :type => 'spec', :requester_mac => "bb:bb:bb:bb:bb:bb" }
files = (0...10).map {
- get '/jobs/next', :version => Testbot::VERSION, :uid => "00:...", :requester_mac => "bb:bb:bb:bb:bb:bb"
+ get '/jobs/next', :version => Testbot.version, :uid => "00:...", :requester_mac => "bb:bb:bb:bb:bb:bb"
last_response.body.split(',').last
}
@@ -225,7 +225,7 @@ def app
old_taken_job = Job.create :files => 'spec/models/house_spec.rb', :root => 'server:/project', :type => 'spec', :requester_mac => "aa:aa:aa:aa:aa:aa", :taken_by_id => missing_runner.id, :taken_at => Time.now - 30, :project => 'things'
new_runner = Runner.create(:uid => "00:01")
- get '/jobs/next', :version => Testbot::VERSION, :uid => "00:01"
+ get '/jobs/next', :version => Testbot.version, :uid => "00:01"
assert_equal new_runner.id, old_taken_job.reload.taken_by_id
assert last_response.ok?
@@ -240,7 +240,7 @@ def app
get '/jobs/next', :version => "1", :hostname => 'macmini1.local', :uid => "00:01"
get '/jobs/next', :version => "1", :hostname => 'macmini2.local', :uid => "00:02"
get '/jobs/next'
- get '/jobs/next', :version => Testbot::VERSION.to_s, :hostname => 'macmini3.local', :uid => "00:03"
+ get '/jobs/next', :version => Testbot.version.to_s, :hostname => 'macmini3.local', :uid => "00:03"
assert_equal 4, Runner.count
get '/runners/outdated'
assert last_response.ok?
@@ -252,16 +252,16 @@ def app
context "GET /runners/available_runners" do
should "return a list of available runners" do
- get '/jobs/next', :version => Testbot::VERSION, :hostname => 'macmini1.local', :uid => "00:01", :idle_instances => 2, :username => 'user1'
- get '/jobs/next', :version => Testbot::VERSION, :hostname => 'macmini2.local', :uid => "00:02", :idle_instances => 4, :username => 'user2'
+ get '/jobs/next', :version => Testbot.version, :hostname => 'macmini1.local', :uid => "00:01", :idle_instances => 2, :username => 'user1'
+ get '/jobs/next', :version => Testbot.version, :hostname => 'macmini2.local', :uid => "00:02", :idle_instances => 4, :username => 'user2'
get '/runners/available'
assert last_response.ok?
assert_equal "127.0.0.1 macmini1.local 00:01 user1 2\n127.0.0.1 macmini2.local 00:02 user2 4", last_response.body
end
should "not return runners as available when not seen the last 10 seconds" do
- get '/jobs/next', :version => Testbot::VERSION, :hostname => 'macmini1.local', :uid => "00:01", :idle_instances => 2, :username => "user1"
- get '/jobs/next', :version => Testbot::VERSION, :hostname => 'macmini2.local', :uid => "00:02", :idle_instances => 4
+ get '/jobs/next', :version => Testbot.version, :hostname => 'macmini1.local', :uid => "00:01", :idle_instances => 2, :username => "user1"
+ get '/jobs/next', :version => Testbot.version, :hostname => 'macmini2.local', :uid => "00:02", :idle_instances => 4
Runner.find(:uid => "00:02").update(:last_seen_at => Time.now - 10)
get '/runners/available'
assert_equal "127.0.0.1 macmini1.local 00:01 user1 2", last_response.body
@@ -272,16 +272,16 @@ def app
context "GET /runners/available_instances" do
should "return the number of available runner instances" do
- get '/jobs/next', :version => Testbot::VERSION, :hostname => 'macmini1.local', :uid => "00:01", :idle_instances => 2
- get '/jobs/next', :version => Testbot::VERSION, :hostname => 'macmini2.local', :uid => "00:02", :idle_instances => 4
+ get '/jobs/next', :version => Testbot.version, :hostname => 'macmini1.local', :uid => "00:01", :idle_instances => 2
+ get '/jobs/next', :version => Testbot.version, :hostname => 'macmini2.local', :uid => "00:02", :idle_instances => 4
get '/runners/available_instances'
assert last_response.ok?
assert_equal "6", last_response.body
end
should "not return instances as available when not seen the last 10 seconds" do
- get '/jobs/next', :version => Testbot::VERSION, :hostname => 'macmini1.local', :uid => "00:01", :idle_instances => 2
- get '/jobs/next', :version => Testbot::VERSION, :hostname => 'macmini2.local', :uid => "00:02", :idle_instances => 4
+ get '/jobs/next', :version => Testbot.version, :hostname => 'macmini1.local', :uid => "00:01", :idle_instances => 2
+ get '/jobs/next', :version => Testbot.version, :hostname => 'macmini2.local', :uid => "00:02", :idle_instances => 4
Runner.find(:uid => "00:02").update(:last_seen_at => Time.now - 10)
get '/runners/available_instances'
assert last_response.ok?
@@ -293,16 +293,16 @@ def app
context "GET /runners/total_instances" do
should "return the number of available runner instances" do
- get '/jobs/next', :version => Testbot::VERSION, :hostname => 'macmini1.local', :uid => "00:01", :max_instances => 2
- get '/jobs/next', :version => Testbot::VERSION, :hostname => 'macmini2.local', :uid => "00:02", :max_instances => 4
+ get '/jobs/next', :version => Testbot.version, :hostname => 'macmini1.local', :uid => "00:01", :max_instances => 2
+ get '/jobs/next', :version => Testbot.version, :hostname => 'macmini2.local', :uid => "00:02", :max_instances => 4
get '/runners/total_instances'
assert last_response.ok?
assert_equal "6", last_response.body
end
should "not return instances as available when not seen the last 10 seconds" do
- get '/jobs/next', :version => Testbot::VERSION, :hostname => 'macmini1.local', :uid => "00:01", :max_instances => 2
- get '/jobs/next', :version => Testbot::VERSION, :hostname => 'macmini2.local', :uid => "00:02", :max_instances => 4
+ get '/jobs/next', :version => Testbot.version, :hostname => 'macmini1.local', :uid => "00:01", :max_instances => 2
+ get '/jobs/next', :version => Testbot.version, :hostname => 'macmini2.local', :uid => "00:02", :max_instances => 4
Runner.find(:uid => "00:02").update(:last_seen_at => Time.now - 10)
get '/runners/total_instances'
assert last_response.ok?
@@ -315,7 +315,7 @@ def app
should "update last_seen_at for the runner" do
runner = Runner.create(:uid => 'aa:aa:aa:aa:aa:aa')
- get "/runners/ping", :uid => 'aa:aa:aa:aa:aa:aa', :version => Testbot::VERSION
+ get "/runners/ping", :uid => 'aa:aa:aa:aa:aa:aa', :version => Testbot.version
runner.reload
assert last_response.ok?
assert (Time.now - 5) < runner[:last_seen_at]
@@ -324,26 +324,26 @@ def app
should "update data on the runner" do
runner = Runner.create(:uid => 'aa:aa:..')
- get "/runners/ping", :uid => 'aa:aa:..', :max_instances => 4, :idle_instances => 2, :hostname => "hostname1", :version => Testbot::VERSION, :username => 'jocke'
+ get "/runners/ping", :uid => 'aa:aa:..', :max_instances => 4, :idle_instances => 2, :hostname => "hostname1", :version => Testbot.version, :username => 'jocke'
runner.reload
assert last_response.ok?
assert_equal 'aa:aa:..', runner.uid
assert_equal 4, runner.max_instances
assert_equal 2, runner.idle_instances
assert_equal 'hostname1', runner.hostname
- assert_equal Testbot::VERSION, runner.version
+ assert_equal Testbot.version, runner.version
assert_equal 'jocke', runner.username
end
should "do nothing if the version does not match" do
- runner = Runner.create(:uid => 'aa:aa:..', :version => Testbot::VERSION)
+ runner = Runner.create(:uid => 'aa:aa:..', :version => Testbot.version)
get "/runners/ping", :uid => 'aa:aa:..', :version => "OLD"
assert last_response.ok?
- assert_equal Testbot::VERSION, runner.reload.version
+ assert_equal Testbot.version, runner.reload.version
end
should "do nothing if the runners isnt known yet found" do
- get "/runners/ping", :uid => 'aa:aa:aa:aa:aa:aa', :version => Testbot::VERSION
+ get "/runners/ping", :uid => 'aa:aa:aa:aa:aa:aa', :version => Testbot.version
assert last_response.ok?
end
@@ -394,7 +394,7 @@ def app
should "return its version" do
get '/version'
assert last_response.ok?
- assert_equal Testbot::VERSION.to_s, last_response.body
+ assert_equal Testbot.version.to_s, last_response.body
end
end
View
2  test/test_testbot.rb
@@ -38,7 +38,7 @@ class CLITest < Test::Unit::TestCase
context "with --version" do
should "print version and return true" do
- flexmock(CLI).should_receive(:puts).once.with("Testbot #{Testbot::VERSION}")
+ flexmock(CLI).should_receive(:puts).once.with("Testbot #{Testbot.version}")
assert_equal true, CLI.run([ '--version' ])
end
end
View
2  testbot.gemspec
@@ -4,7 +4,7 @@ require File.expand_path("lib/testbot")
Gem::Specification.new do |s|
s.name = "testbot"
- s.version = Testbot::VERSION
+ s.version = Testbot.version
s.authors = ["Joakim Kolsjö"]
s.email = ["joakim.kolsjo@gmail.com"]
s.homepage = "http://github.com/joakimk/testbot"
Please sign in to comment.
Something went wrong with that request. Please try again.