summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaco Guzman <pacoguzmanp@gmail.com>2016-06-23 07:03:24 +0200
committerPaco Guzman <pacoguzmanp@gmail.com>2016-06-23 07:03:24 +0200
commitf893fbaa2cd56b76d12c3f15a1c6848d96f2421b (patch)
treea5a85b79b4d29fe00f3ba8f28177cd2c20b3300d
parentc6f14956d64e726f613c0092587f97444beeebb7 (diff)
downloadgitlab-shell-enqueued_at_for_jobs.tar.gz
Update PostReceive worker to provide enqueued_at timeenqueued_at_for_jobs
-rw-r--r--CHANGELOG3
-rw-r--r--lib/gitlab_post_receive.rb7
-rw-r--r--spec/gitlab_post_receive_spec.rb4
3 files changed, 12 insertions, 2 deletions
diff --git a/CHANGELOG b/CHANGELOG
index 2b41c80..30207dd 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,3 +1,6 @@
+v3.0.1
+ - Update PostReceive worker to provide enqueued_at time.
+
v3.0.0
- Remove rm-tag command (Robert Schilling)
- Remove create-branch and rm-branch commands (Robert Schilling)
diff --git a/lib/gitlab_post_receive.rb b/lib/gitlab_post_receive.rb
index 9f75433..4b80174 100644
--- a/lib/gitlab_post_receive.rb
+++ b/lib/gitlab_post_receive.rb
@@ -73,7 +73,12 @@ class GitlabPostReceive
changes = Base64.encode64(@changes)
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
GitlabNet.new.redis_client.rpush(queue, msg)
diff --git a/spec/gitlab_post_receive_spec.rb b/spec/gitlab_post_receive_spec.rb
index 0392bee..26b1037 100644
--- a/spec/gitlab_post_receive_spec.rb
+++ b/spec/gitlab_post_receive_spec.rb
@@ -13,10 +13,12 @@ describe GitlabPostReceive do
let(:gitlab_post_receive) { GitlabPostReceive.new(repo_path, actor, wrongly_encoded_changes) }
let(:message) { "test " * 10 + "message " * 10 }
let(:redis_client) { double('redis_client') }
+ let(:enqueued_at) { Time.new(2016, 6, 23, 6, 59) }
before do
GitlabConfig.any_instance.stub(repos_path: repository_path)
GitlabNet.any_instance.stub(broadcast_message: { "message" => message })
+ expect(Time).to receive(:now).and_return(enqueued_at)
end
describe "#exec" do
@@ -51,7 +53,7 @@ describe GitlabPostReceive do
it "pushes a Sidekiq job onto the queue" do
expect(redis_client).to receive(:rpush).with(
'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)
gitlab_post_receive.exec