Commit f893fbaa authored by Paco Guzman's avatar Paco Guzman

Update PostReceive worker to provide enqueued_at time

parent c6f14956
v3.0.1
- Update PostReceive worker to provide enqueued_at time.
v3.0.0 v3.0.0
- Remove rm-tag command (Robert Schilling) - Remove rm-tag command (Robert Schilling)
- Remove create-branch and rm-branch commands (Robert Schilling) - Remove create-branch and rm-branch commands (Robert Schilling)
......
...@@ -73,7 +73,12 @@ class GitlabPostReceive ...@@ -73,7 +73,12 @@ class GitlabPostReceive
changes = Base64.encode64(@changes) changes = Base64.encode64(@changes)
queue = "#{config.redis_namespace}:queue:post_receive" queue = "#{config.redis_namespace}:queue:post_receive"
msg = JSON.dump({ 'class' => 'PostReceive', 'args' => [@repo_path, @actor, changes], 'jid' => @jid }) msg = JSON.dump({
'class' => 'PostReceive',
'args' => [@repo_path, @actor, changes],
'jid' => @jid,
'enqueued_at' => Time.now.to_f
})
begin begin
GitlabNet.new.redis_client.rpush(queue, msg) GitlabNet.new.redis_client.rpush(queue, msg)
......
...@@ -13,10 +13,12 @@ describe GitlabPostReceive do ...@@ -13,10 +13,12 @@ describe GitlabPostReceive do
let(:gitlab_post_receive) { GitlabPostReceive.new(repo_path, actor, wrongly_encoded_changes) } let(:gitlab_post_receive) { GitlabPostReceive.new(repo_path, actor, wrongly_encoded_changes) }
let(:message) { "test " * 10 + "message " * 10 } let(:message) { "test " * 10 + "message " * 10 }
let(:redis_client) { double('redis_client') } let(:redis_client) { double('redis_client') }
let(:enqueued_at) { Time.new(2016, 6, 23, 6, 59) }
before do before do
GitlabConfig.any_instance.stub(repos_path: repository_path) GitlabConfig.any_instance.stub(repos_path: repository_path)
GitlabNet.any_instance.stub(broadcast_message: { "message" => message }) GitlabNet.any_instance.stub(broadcast_message: { "message" => message })
expect(Time).to receive(:now).and_return(enqueued_at)
end end
describe "#exec" do describe "#exec" do
...@@ -51,7 +53,7 @@ describe GitlabPostReceive do ...@@ -51,7 +53,7 @@ describe GitlabPostReceive do
it "pushes a Sidekiq job onto the queue" do it "pushes a Sidekiq job onto the queue" do
expect(redis_client).to receive(:rpush).with( expect(redis_client).to receive(:rpush).with(
'resque:gitlab:queue:post_receive', 'resque:gitlab:queue:post_receive',
%Q/{"class":"PostReceive","args":["#{repo_path}","#{actor}",#{base64_changes.inspect}],"jid":"#{gitlab_post_receive.jid}"}/ %Q/{"class":"PostReceive","args":["#{repo_path}","#{actor}",#{base64_changes.inspect}],"jid":"#{gitlab_post_receive.jid}","enqueued_at":#{enqueued_at.to_f}}/
).and_return(true) ).and_return(true)
gitlab_post_receive.exec gitlab_post_receive.exec
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment