Skip to content

Commit

Permalink
Merge pull request travis-ci#30 from travis-ci/remove_configure_job
Browse files Browse the repository at this point in the history
Remove configure job
  • Loading branch information
joshk committed Apr 27, 2012
2 parents 7e6ed17 + b178387 commit d388e02
Show file tree
Hide file tree
Showing 11 changed files with 35 additions and 138 deletions.
8 changes: 4 additions & 4 deletions lib/travis/worker.rb
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ def open_builds_consumer_channels
end

def open_reporting_channel
@reporting_channel = @broker_connection.create_channel
@reporting_channel = @broker_connection.create_channel
end

def declare_queues
Expand All @@ -133,9 +133,9 @@ def declare_queues
# these are declared here mostly to aid development purposes. Hub is just as involved
# in build log streaming so it may seem more logical to move these declarations to Hub. We may
# do it in the future. MK.
@queue_names.
reject { |name| name =~ /configure$/ }.
map { |name| @reporting_channel.queue("reporting.jobs.#{name}", :durable => true) }
@queue_names.map do |name|
@reporting_channel.queue("reporting.jobs.#{name}", :durable => true)
end
end

def subscribe
Expand Down
2 changes: 1 addition & 1 deletion lib/travis/worker/factory.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def vm
end

def queue_names
%w(builds.configure) + Array(@config[:queues] || @config[:queue] || [])
Array(@config[:queues] || @config[:queue] || [])
end

def config
Expand Down
1 change: 1 addition & 0 deletions lib/travis/worker/virtual_machine/virtual_box.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
# or by adding the user to the group assigned to the file.
#
$: << File.expand_path('../../../../../vendor/virtualbox-4.1.12', __FILE__)

require 'java'
require 'travis/support'

Expand Down
1 change: 0 additions & 1 deletion spec/application_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
app.stubs(:logger).returns(Logger.new(StringIO.new))
end


describe 'start' do
it 'starts the workers with the given names' do
workers.expects(:start).with(['worker-1'])
Expand Down
23 changes: 5 additions & 18 deletions spec/factory_spec.rb
Original file line number Diff line number Diff line change
@@ -1,18 +1,14 @@
require 'spec_helper'

describe Travis::Worker::Factory do
let(:connection) { HotBunnies.connect }
let(:config) { Hashr.new({ :queues => %w(builds.php builds.python builds.perl) }) }
let(:factory) do
Travis::Worker::Factory.new('worker-name', config, connection)
end
include_context "hot_bunnies connection"

let(:config) { Hashr.new({ :queues => %w(builds.php builds.python builds.perl) }) }
let(:factory) { Travis::Worker::Factory.new('worker-name', config, connection) }
let(:worker) { factory.worker }

describe 'worker' do
after :each do
worker.shutdown
connection.close if connection.open?
end
after(:each) { worker.shutdown }

it 'returns a worker' do
worker.should be_a(Travis::Worker)
Expand All @@ -23,15 +19,6 @@
end

describe 'queues' do
after :each do
worker.shutdown
connection.close
end

it 'includes builds.configure' do
worker.queue_names.first.should == 'builds.configure'
end

it 'includes individual build queues that were listed in the configuration' do
worker.queue_names.should include("builds.php")
worker.queue_names.should include("builds.python")
Expand Down
21 changes: 2 additions & 19 deletions spec/pool_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@
require 'stringio'

describe Travis::Worker::Pool do
let(:names) { %w(worker-1 worker-2)}
let(:connection) { HotBunnies.connect }

include_context "hot_bunnies connection"

let(:names) { %w(worker-1 worker-2)}
let(:pool) { Travis::Worker::Pool.new(names, Travis::Worker.config, connection) }
let(:workers) { names.map { |name| stub(name, :name => name, :boot => nil, :start => nil, :stop => nil) } }

Expand All @@ -15,10 +14,6 @@
end

describe 'start' do
after :each do
connection.close
end

describe 'with no worker names given' do
it 'starts the workers' do
workers.each { |worker| worker.expects(:start) }
Expand All @@ -45,21 +40,13 @@

describe 'stop' do
describe 'with no worker names given' do
after :each do
connection.close
end

it 'stops the workers' do
workers.each { |worker| worker.expects(:stop) }
pool.stop([])
end
end

describe 'with a worker name given' do
after :each do
connection.close
end

it 'stops the worker' do
workers.first.expects(:stop)
pool.stop(['worker-1'])
Expand All @@ -76,10 +63,6 @@
end

describe 'with an option :force => true given' do
after :each do
connection.close
end

it 'stops the worker with that option' do
workers.first.expects(:stop).with(:force => true)
pool.stop(['worker-1'], :force => true)
Expand Down
23 changes: 6 additions & 17 deletions spec/reporters/log_streamer_spec.rb
Original file line number Diff line number Diff line change
@@ -1,32 +1,21 @@
require 'spec_helper'

describe Travis::Worker::Reporters::LogStreamer do
let(:connection) { HotBunnies.connect }
let(:channel) { connection.create_channel }
let(:routing_key) do
"reporting.jobs.builds.jvmotp"
end
let(:queue) do
channel.queue(routing_key, :durable => true)
end
let(:reporting_exchange) do
channel.exchange("reporting", :type => :topic, :durable => true)
end
include_context "hot_bunnies connection"

let(:reporter) { described_class.new('staging-1', connection.create_channel, routing_key) }
let(:channel) { connection.create_channel }
let(:routing_key) { "reporting.jobs.builds.jvmotp" }
let(:queue) { channel.queue(routing_key, :durable => true) }
let(:reporting_exchange) { channel.exchange("reporting", :type => :topic, :durable => true) }
let(:reporter) { described_class.new('staging-1', connection.create_channel, routing_key) }

include Travis::Serialization


describe 'notify' do
before :each do
queue.purge

queue.bind(reporting_exchange, :routing_key => routing_key)
end
after :each do
connection.close
end

it "publishes log chunks" do
reporter.notify('build:log', :log => "...")
Expand Down
11 changes: 2 additions & 9 deletions spec/reporters/state_reporter_spec.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
require 'spec_helper'

describe Travis::Worker::Reporters::StateReporter do
let(:connection) { HotBunnies.connect }
include_context "hot_bunnies connection"

let(:reporter) { described_class.new('staging-1', connection.create_channel) }
let(:logger) { stub('logger', :before => nil, :after => nil) }
let(:io) { StringIO.new }
Expand All @@ -11,7 +12,6 @@

include Travis::Serialization


before :each do
Travis.logger = Logger.new(io)
Travis.logger.level = Logger::DEBUG
Expand All @@ -21,9 +21,6 @@
before :each do
queue.purge
end
after :each do
connection.close
end

it "publishes notifications of given type" do
reporter.notify('build:started', :hostname => "giove.local")
Expand All @@ -36,10 +33,6 @@
end

describe 'logging' do
after :each do
connection.close
end

it 'logs before :message is being called' do
reporter.notify('build:started', :foo => "bar")
io.string.should include('about to message')
Expand Down
2 changes: 1 addition & 1 deletion spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
require 'stringio'

FIXTURES = {}
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| load f}
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| load f }

include Mocha::API

Expand Down
4 changes: 4 additions & 0 deletions spec/support/hot_bunnies.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
shared_context "hot_bunnies connection" do
let(:connection) { HotBunnies.connect(:hostname => "127.0.0.1") }
after(:each) { connection.close }
end
77 changes: 9 additions & 68 deletions spec/worker_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@
require "hot_bunnies"

describe Travis::Worker do
include_context "hot_bunnies connection"

let(:vm) { stub('vm', :name => 'vm-name', :shell => nil, :prepare => nil) }
let(:reporter) { stub('reporter', :notify => nil) }
let(:queue_names) { %w(builds.php builds.python builds.perl) }
let(:config) { Hashr.new(:amqp => {}, :queues => queue_names) }

let(:connection) { HotBunnies.connect }
let(:worker) { Travis::Worker.new('worker-1', vm, connection, queue_names, config) }

let(:metadata) { stub('metadata', :ack => nil, :routing_key => "builds.common") }
Expand All @@ -27,10 +28,6 @@
end

describe 'start' do
after :each do
connection.close if connection.open?
end

it 'sets the current state to :starting while it prepares the vm' do
state = nil
vm.stubs(:prepare).with { state = worker.state } # hrmm, mocha doesn't support spies, does it?
Expand Down Expand Up @@ -59,17 +56,9 @@
end
end



describe 'stop' do
after :each do
worker.shutdown
connection.close
end

after :all do
worker.shutdown
connection.close
end

describe 'if the worker is still working' do
Expand Down Expand Up @@ -105,18 +94,10 @@
end
end



describe 'process' do
describe 'without any exception rescued' do
before :each do
worker.state = :ready
end

after :each do
worker.shutdown
connection.close
end
before(:each) { worker.state = :ready }
after(:each) { worker.shutdown }

it 'works' do
worker.expects(:work)
Expand All @@ -134,34 +115,18 @@

after :each do
worker.shutdown
connection.close
end


it 'responds to the error' do
worker.expects(:error).with(exception, metadata)
worker.send(:process, metadata, payload)
end
end
end



describe 'work' do
before :each do
worker.state = :ready
end

after :each do
worker.shutdown
connection.close
end

after :all do
worker.shutdown
connection.close
end

before(:each) { worker.state = :ready }
after(:each) { worker.shutdown }

it 'prepares work' do
worker.expects(:prepare)
Expand All @@ -185,15 +150,7 @@
end

describe 'prepare' do
after :each do
worker.shutdown
connection.close
end

after :all do
worker.shutdown
connection.close
end
after(:each) { worker.shutdown }

it 'sets the current payload' do
worker.send(:prepare, payload)
Expand All @@ -207,15 +164,7 @@
end

describe 'finish' do
after :each do
worker.shutdown
connection.close
end

after :all do
worker.shutdown
connection.close
end
after(:each) { worker.shutdown }

it 'unsets the current payload' do
worker.send(:prepare, '{ "id": 1 }')
Expand All @@ -238,15 +187,7 @@
end

describe 'error' do
after :each do
worker.shutdown
connection.close
end

after :all do
worker.shutdown
connection.close
end
after(:each) { worker.shutdown }

it 'requeues the message' do
metadata.expects(:ack).with(:requeue => true)
Expand Down

0 comments on commit d388e02

Please sign in to comment.