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>2020-03-24 21:07:55 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2020-03-24 21:07:55 +0300
commit603c7d4cac5e28bc1c75e50c23ed2cbe56f1aafc (patch)
tree907f5b8ee1b6f5aad396e95e3327a08400b9e8ea /spec/lib/gitlab
parent120f4aaedc8fe830a3f572491d240d8ee6addefb (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/lib/gitlab')
-rw-r--r--spec/lib/gitlab/ci/config/entry/reports_spec.rb1
-rw-r--r--spec/lib/gitlab/grape_logging/loggers/perf_logger_spec.rb28
-rw-r--r--spec/lib/gitlab/instrumentation_helper_spec.rb42
-rw-r--r--spec/lib/gitlab/sidekiq_logging/structured_logger_spec.rb16
4 files changed, 80 insertions, 7 deletions
diff --git a/spec/lib/gitlab/ci/config/entry/reports_spec.rb b/spec/lib/gitlab/ci/config/entry/reports_spec.rb
index 2c8f76c8f34..9bba3eb2b77 100644
--- a/spec/lib/gitlab/ci/config/entry/reports_spec.rb
+++ b/spec/lib/gitlab/ci/config/entry/reports_spec.rb
@@ -46,6 +46,7 @@ describe Gitlab::Ci::Config::Entry::Reports do
:lsif | 'lsif.json'
:dotenv | 'build.dotenv'
:cobertura | 'cobertura-coverage.xml'
+ :terraform | 'tfplan.json'
end
with_them do
diff --git a/spec/lib/gitlab/grape_logging/loggers/perf_logger_spec.rb b/spec/lib/gitlab/grape_logging/loggers/perf_logger_spec.rb
new file mode 100644
index 00000000000..6f20b8877e0
--- /dev/null
+++ b/spec/lib/gitlab/grape_logging/loggers/perf_logger_spec.rb
@@ -0,0 +1,28 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+
+describe Gitlab::GrapeLogging::Loggers::PerfLogger do
+ subject { described_class.new }
+
+ describe ".parameters" do
+ let(:mock_request) { OpenStruct.new(env: {}) }
+
+ describe 'when no performance datais are present' do
+ it 'returns an empty Hash' do
+ expect(subject.parameters(mock_request, nil)).to eq({})
+ end
+ end
+
+ describe 'when Redis calls are present', :request_store do
+ it 'returns a Hash with Redis information' do
+ Gitlab::Redis::SharedState.with { |redis| redis.get('perf-logger-test') }
+
+ payload = subject.parameters(mock_request, nil)
+
+ expect(payload[:redis_calls]).to eq(1)
+ expect(payload[:redis_duration_ms]).to be >= 0
+ end
+ end
+ end
+end
diff --git a/spec/lib/gitlab/instrumentation_helper_spec.rb b/spec/lib/gitlab/instrumentation_helper_spec.rb
index c2674638743..9788c9f4a3c 100644
--- a/spec/lib/gitlab/instrumentation_helper_spec.rb
+++ b/spec/lib/gitlab/instrumentation_helper_spec.rb
@@ -1,11 +1,51 @@
# frozen_string_literal: true
-require 'fast_spec_helper'
+require 'spec_helper'
require 'rspec-parameterized'
describe Gitlab::InstrumentationHelper do
using RSpec::Parameterized::TableSyntax
+ describe '.add_instrumentation_data', :request_store do
+ let(:payload) { {} }
+
+ subject { described_class.add_instrumentation_data(payload) }
+
+ it 'adds nothing' do
+ subject
+
+ expect(payload).to eq({})
+ end
+
+ context 'when Gitaly calls are made' do
+ it 'adds Gitaly data and omits Redis data' do
+ project = create(:project)
+ RequestStore.clear!
+ project.repository.exists?
+
+ subject
+
+ expect(payload[:gitaly_calls]).to eq(1)
+ expect(payload[:gitaly_duration]).to be >= 0
+ expect(payload[:redis_calls]).to be_nil
+ expect(payload[:redis_duration_ms]).to be_nil
+ end
+ end
+
+ context 'when Redis calls are made' do
+ it 'adds Redis data and omits Gitaly data' do
+ Gitlab::Redis::Cache.with { |redis| redis.get('test-instrumentation') }
+
+ subject
+
+ expect(payload[:redis_calls]).to eq(1)
+ expect(payload[:redis_duration_ms]).to be >= 0
+ expect(payload[:gitaly_calls]).to be_nil
+ expect(payload[:gitaly_duration]).to be_nil
+ end
+ end
+ end
+
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
diff --git a/spec/lib/gitlab/sidekiq_logging/structured_logger_spec.rb b/spec/lib/gitlab/sidekiq_logging/structured_logger_spec.rb
index bd04d30f85f..aab63ba88ad 100644
--- a/spec/lib/gitlab/sidekiq_logging/structured_logger_spec.rb
+++ b/spec/lib/gitlab/sidekiq_logging/structured_logger_spec.rb
@@ -175,26 +175,30 @@ describe Gitlab::SidekiqLogging::StructuredLogger do
end
end
- context 'with Gitaly and Rugged calls' do
+ context 'with Gitaly, Rugged, and Redis calls' do
let(:timing_data) do
{
gitaly_calls: 10,
gitaly_duration: 10000,
rugged_calls: 1,
- rugged_duration_ms: 5000
+ rugged_duration_ms: 5000,
+ redis_calls: 3,
+ redis_duration_ms: 1234
}
end
- before do
- job.merge!(timing_data)
+ let(:expected_end_payload) do
+ end_payload.except('args').merge(timing_data)
end
it 'logs with Gitaly and Rugged timing data' do
Timecop.freeze(timestamp) do
expect(logger).to receive(:info).with(start_payload.except('args')).ordered
- expect(logger).to receive(:info).with(end_payload.except('args')).ordered
+ expect(logger).to receive(:info).with(expected_end_payload).ordered
- subject.call(job, 'test_queue') { }
+ subject.call(job, 'test_queue') do
+ job.merge!(timing_data)
+ end
end
end
end