add Sidekiq for cancelling build

:
add require sidekiq to the sidekiq.rb

update Gemfile.lock

bump travis-sidekiqs

correct require statement

fix another request

connect to the database

add current user

add current user correctly

add current user correctly

add puts to see were in the condition we are

missing invertted comma

add comments to the worker

I HAVE NO IDEA

Revert "I HAVE NO IDEA"

This reverts commit 8bd1259bf4ea1b479f9391847a4700b7b15efe57.

change the id and source to symbols in the params because siedekiq expects that

add more printout

setup database connection, metrics and notification

correct the test
This commit is contained in:
Tyranja 2015-01-22 15:26:13 +01:00
parent 008111fc67
commit 057e9f0379
6 changed files with 31 additions and 39 deletions

View File

@ -8,7 +8,7 @@ gem 's3', github: 'travis-ci/s3'
gem 'travis-core', github: 'travis-ci/travis-core'
gem 'travis-support', github: 'travis-ci/travis-support'
gem 'travis-config', '~> 0.1.0'
gem 'travis-sidekiqs', github: 'travis-ci/travis-sidekiqs', require: nil, ref: 'cde9741'
gem 'travis-sidekiqs', github: 'travis-ci/travis-sidekiqs', require: nil
gem 'travis-yaml', github: 'travis-ci/travis-yaml'
gem 'sinatra'
gem 'sinatra-contrib', require: nil #github: 'sinatra/sinatra-contrib', require: nil

View File

@ -67,11 +67,10 @@ GIT
GIT
remote: git://github.com/travis-ci/travis-sidekiqs.git
revision: cde9741f8e6811fe3929bdd0dd653b87289c5eef
ref: cde9741
revision: 21a2fee158e25252dd78f5fa31e81b4f6583be23
specs:
travis-sidekiqs (0.0.1)
sidekiq (~> 2.5.0)
sidekiq
GIT
remote: git://github.com/travis-ci/travis-support.git
@ -143,26 +142,13 @@ GEM
backports (2.8.2)
builder (3.0.4)
bunny (0.8.0)
celluloid (0.12.0)
timers (>= 1.0.0)
chunky_png (1.3.3)
celluloid (0.16.0)
timers (~> 4.0.0)
coder (0.4.0)
coderay (1.1.0)
coercible (1.0.0)
descendants_tracker (~> 0.0.1)
compass (1.0.1)
chunky_png (~> 1.2)
compass-core (~> 1.0.1)
compass-import-once (~> 1.0.5)
rb-fsevent (>= 0.9.3)
rb-inotify (>= 0.9)
sass (>= 3.3.13, < 3.5)
compass-core (1.0.1)
multi_json (~> 1.0)
sass (>= 3.3.0, < 3.5)
compass-import-once (1.0.5)
sass (>= 3.2, < 3.5)
connection_pool (0.9.3)
connection_pool (2.1.1)
daemons (1.1.9)
dalli (2.7.2)
data_migrations (0.0.1)
@ -277,16 +263,12 @@ GEM
rspec-expectations (2.99.2)
diff-lcs (>= 1.1.3, < 2.0)
rspec-mocks (2.99.2)
sass (3.4.6)
sidekiq (2.5.0)
celluloid (~> 0.12.0)
compass
connection_pool (~> 0.9.2)
multi_json (~> 1)
redis (~> 3)
redis-namespace
sass
sprockets-sass
sidekiq (3.3.0)
celluloid (>= 0.16.0)
connection_pool (>= 2.0.0)
json
redis (>= 3.0.6)
redis-namespace (>= 1.3.1)
signature (0.1.7)
simple_states (1.0.1)
activesupport
@ -310,9 +292,6 @@ GEM
multi_json (~> 1.0)
rack (~> 1.0)
tilt (~> 1.1, != 1.3.0)
sprockets-sass (1.2.0)
sprockets (~> 2.0)
tilt (~> 1.1)
thin (1.6.3)
daemons (~> 1.0, >= 1.0.9)
eventmachine (~> 1.0)

View File

@ -40,7 +40,7 @@ class Travis::Api::App
else
#service.run
#check syntax of line below
Travis::Sidekiq::BuildCancellation.perform_async(id: params[:id], source: 'api')
Travis::Sidekiq::BuildCancellation.perform_async(id: params[:id], user_id: current_user.id, source: 'api')
Metriks.meter("api.request.cancel_build.success").mark
status 204

View File

@ -10,8 +10,14 @@ module Travis
sidekiq_options queue: :build_cancellations
def perform(data)
Travis.service(:cancel_build, data).run
p "#######################"
p data
user = User.find(data['user_id'])
test = { id: data['id'], source: data['source'] }
p test
Travis.service(:cancel_build, user, { id: data['id'], source: data['source'] }).run
end
end
end
end

View File

@ -1,7 +1,14 @@
$: << './lib'
require 'travis/core'
require 'travis/app/workers/build_cancellation'
require 'sidekiq'
require 'travis'
require 'travis/api/workers/build_cancellation'
require 'travis/support/amqp'
Travis::Database.connect
Travis::Amqp.config = Travis.config.amqp
Travis::Metrics.setup
Travis::Notification.setup
Sidekiq.configure_server do |config|
config.redis = Travis.config.redis.merge(namespace: Travis.config.sidekiq.namespace)
end
end

View File

@ -82,7 +82,7 @@ describe 'Builds' do
end
it 'cancels the build' do
Travis::Sidekiq::BuildCancellation.expects(:perform_async).with(id: build.id.to_s, source: 'api')
Travis::Sidekiq::BuildCancellation.expects(:perform_async).with( id: build.id.to_s, user_id: user.id, source: 'api')
post "/builds/#{build.id}/cancel", {}, headers
end