diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-02-26 00:09:23 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-02-26 00:09:23 +0300 |
commit | 32fd4cd5e2134511936899d6bcc4aaf18b9be6fd (patch) | |
tree | 10378ceffed52dd0e160a0d9bcf3c5ab72c18958 /spec/lib/gitlab | |
parent | 951616a26a61e880860ad862c1d45a8e3762b4bc (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/lib/gitlab')
-rw-r--r-- | spec/lib/gitlab/import_export/safe_model_attributes.yml | 1 | ||||
-rw-r--r-- | spec/lib/gitlab/job_waiter_spec.rb | 35 | ||||
-rw-r--r-- | spec/lib/gitlab/tracing_spec.rb | 69 |
3 files changed, 36 insertions, 69 deletions
diff --git a/spec/lib/gitlab/import_export/safe_model_attributes.yml b/spec/lib/gitlab/import_export/safe_model_attributes.yml index 1d652f703b8..7d98f8a0c3e 100644 --- a/spec/lib/gitlab/import_export/safe_model_attributes.yml +++ b/spec/lib/gitlab/import_export/safe_model_attributes.yml @@ -271,6 +271,7 @@ MergeRequest::Metrics: - diff_size - modified_paths_size - commits_count +- first_approved_at Ci::Pipeline: - id - project_id diff --git a/spec/lib/gitlab/job_waiter_spec.rb b/spec/lib/gitlab/job_waiter_spec.rb index efa7fd4b975..da6a6a9149b 100644 --- a/spec/lib/gitlab/job_waiter_spec.rb +++ b/spec/lib/gitlab/job_waiter_spec.rb @@ -37,5 +37,40 @@ describe Gitlab::JobWaiter do expect(result).to contain_exactly('a') end + + context 'when a label is provided' do + let(:waiter) { described_class.new(2, worker_label: 'Foo') } + let(:started_total) { double(:started_total) } + let(:timeouts_total) { double(:timeouts_total) } + + before do + allow(Gitlab::Metrics).to receive(:counter) + .with(described_class::STARTED_METRIC, anything) + .and_return(started_total) + + allow(Gitlab::Metrics).to receive(:counter) + .with(described_class::TIMEOUTS_METRIC, anything) + .and_return(timeouts_total) + end + + it 'increments just job_waiter_started_total when all jobs complete' do + expect(started_total).to receive(:increment).with(worker: 'Foo') + expect(timeouts_total).not_to receive(:increment) + + described_class.notify(waiter.key, 'a') + described_class.notify(waiter.key, 'b') + + result = nil + expect { Timeout.timeout(1) { result = waiter.wait(2) } }.not_to raise_error + end + + it 'increments job_waiter_started_total and job_waiter_timeouts_total when it times out' do + expect(started_total).to receive(:increment).with(worker: 'Foo') + expect(timeouts_total).to receive(:increment).with(worker: 'Foo') + + result = nil + expect { Timeout.timeout(2) { result = waiter.wait(1) } }.not_to raise_error + end + end end end diff --git a/spec/lib/gitlab/tracing_spec.rb b/spec/lib/gitlab/tracing_spec.rb deleted file mode 100644 index e913bb600ec..00000000000 --- a/spec/lib/gitlab/tracing_spec.rb +++ /dev/null @@ -1,69 +0,0 @@ -# frozen_string_literal: true - -require 'fast_spec_helper' -require 'rspec-parameterized' - -describe Gitlab::Tracing do - using RSpec::Parameterized::TableSyntax - - describe '.enabled?' do - where(:connection_string, :enabled_state) do - nil | false - "" | false - "opentracing://jaeger" | true - end - - with_them do - it 'returns the correct state for .enabled?' do - expect(described_class).to receive(:connection_string).and_return(connection_string) - - expect(described_class.enabled?).to eq(enabled_state) - end - end - end - - describe '.tracing_url_enabled?' do - where(:enabled?, :tracing_url_template, :tracing_url_enabled_state) do - false | nil | false - false | "" | false - false | "http://localhost" | false - true | nil | false - true | "" | false - true | "http://localhost" | true - end - - with_them do - it 'returns the correct state for .tracing_url_enabled?' do - expect(described_class).to receive(:enabled?).and_return(enabled?) - allow(described_class).to receive(:tracing_url_template).and_return(tracing_url_template) - - expect(described_class.tracing_url_enabled?).to eq(tracing_url_enabled_state) - end - end - end - - describe '.tracing_url' do - where(:tracing_url_enabled?, :tracing_url_template, :correlation_id, :process_name, :tracing_url) do - false | "https://localhost" | "123" | "web" | nil - true | "https://localhost" | "123" | "web" | "https://localhost" - true | "https://localhost?service={{ service }}" | "123" | "web" | "https://localhost?service=web" - true | "https://localhost?c={{ correlation_id }}" | "123" | "web" | "https://localhost?c=123" - true | "https://localhost?c={{ correlation_id }}&s={{ service }}" | "123" | "web" | "https://localhost?c=123&s=web" - true | "https://localhost?c={{ correlation_id }}" | nil | "web" | "https://localhost?c=" - true | "https://localhost?c={{ correlation_id }}&s=%22{{ service }}%22" | "123" | "web" | "https://localhost?c=123&s=%22web%22" - true | "https://localhost?c={{correlation_id}}&s={{service}}" | "123" | "web" | "https://localhost?c=123&s=web" - true | "https://localhost?c={{correlation_id }}&s={{ service}}" | "123" | "web" | "https://localhost?c=123&s=web" - end - - with_them do - it 'returns the correct state for .tracing_url' do - expect(described_class).to receive(:tracing_url_enabled?).and_return(tracing_url_enabled?) - allow(described_class).to receive(:tracing_url_template).and_return(tracing_url_template) - allow(Labkit::Correlation::CorrelationId).to receive(:current_id).and_return(correlation_id) - allow(Gitlab).to receive(:process_name).and_return(process_name) - - expect(described_class.tracing_url).to eq(tracing_url) - end - end - end -end |