Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2019-10-28 18:05:58 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2019-10-28 18:05:58 +0300
commita77db6bc47d8cdd9edae2ec22f640821d0794404 (patch)
tree15861a5f1ec29e07c2012102e463402bb7dc8c2d /spec/lib/gitlab/instrumentation_helper_spec.rb
parent6cf6996f183bdff46e73431c07bfb723066a8222 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/lib/gitlab/instrumentation_helper_spec.rb')
-rw-r--r--spec/lib/gitlab/instrumentation_helper_spec.rb37
1 files changed, 37 insertions, 0 deletions
diff --git a/spec/lib/gitlab/instrumentation_helper_spec.rb b/spec/lib/gitlab/instrumentation_helper_spec.rb
new file mode 100644
index 00000000000..c2674638743
--- /dev/null
+++ b/spec/lib/gitlab/instrumentation_helper_spec.rb
@@ -0,0 +1,37 @@
+# frozen_string_literal: true
+
+require 'fast_spec_helper'
+require 'rspec-parameterized'
+
+describe Gitlab::InstrumentationHelper do
+ using RSpec::Parameterized::TableSyntax
+
+ describe '.queue_duration_for_job' do
+ where(:enqueued_at, :created_at, :time_now, :expected_duration) do
+ "2019-06-01T00:00:00.000+0000" | nil | "2019-06-01T02:00:00.000+0000" | 2.hours.to_f
+ "2019-06-01T02:00:00.000+0000" | nil | "2019-06-01T02:00:00.001+0000" | 0.001
+ "2019-06-01T02:00:00.000+0000" | "2019-05-01T02:00:00.000+0000" | "2019-06-01T02:00:01.000+0000" | 1
+ nil | "2019-06-01T02:00:00.000+0000" | "2019-06-01T02:00:00.001+0000" | 0.001
+ nil | nil | "2019-06-01T02:00:00.001+0000" | nil
+ "2019-06-01T02:00:00.000+0200" | nil | "2019-06-01T02:00:00.000-0200" | 4.hours.to_f
+ 1571825569.998168 | nil | "2019-10-23T12:13:16.000+0200" | 26.001832
+ 1571825569 | nil | "2019-10-23T12:13:16.000+0200" | 27
+ "invalid_date" | nil | "2019-10-23T12:13:16.000+0200" | nil
+ "" | nil | "2019-10-23T12:13:16.000+0200" | nil
+ 0 | nil | "2019-10-23T12:13:16.000+0200" | nil
+ -1 | nil | "2019-10-23T12:13:16.000+0200" | nil
+ "2019-06-01T02:00:00.000+0000" | nil | "2019-06-01T00:00:00.000+0000" | 0
+ Time.at(1571999233) | nil | "2019-10-25T12:29:16.000+0200" | 123
+ end
+
+ with_them do
+ let(:job) { { 'enqueued_at' => enqueued_at, 'created_at' => created_at } }
+
+ it "returns the correct duration" do
+ Timecop.freeze(Time.iso8601(time_now)) do
+ expect(described_class.queue_duration_for_job(job)).to eq(expected_duration)
+ end
+ end
+ end
+ end
+end