Skip to content
Snippets Groups Projects
Commit 69d6d3ca authored by GitLab Bot's avatar GitLab Bot
Browse files

Add latest changes from gitlab-org/gitlab@master

parent 01fdcf49
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -206,21 +206,19 @@ describe Clusters::Applications::Prometheus do
end
end
 
describe '#upgrade_command' do
describe '#patch_command' do
subject(:patch_command) { prometheus.patch_command(values) }
let(:prometheus) { build(:clusters_applications_prometheus) }
let(:values) { prometheus.values }
 
it 'returns an instance of Gitlab::Kubernetes::Helm::InstallCommand' do
expect(prometheus.upgrade_command(values)).to be_an_instance_of(::Gitlab::Kubernetes::Helm::InstallCommand)
end
it { is_expected.to be_an_instance_of(::Gitlab::Kubernetes::Helm::PatchCommand) }
 
it 'is initialized with 3 arguments' do
command = prometheus.upgrade_command(values)
expect(command.name).to eq('prometheus')
expect(command.chart).to eq('stable/prometheus')
expect(command.version).to eq('6.7.3')
expect(command.files).to eq(prometheus.files)
expect(patch_command.name).to eq('prometheus')
expect(patch_command.chart).to eq('stable/prometheus')
expect(patch_command.version).to eq('6.7.3')
expect(patch_command.files).to eq(prometheus.files)
end
end
 
Loading
Loading
Loading
Loading
@@ -36,8 +36,16 @@ describe DiffsMetadataEntity do
 
describe 'diff_files' do
it 'returns diff files metadata' do
payload =
DiffFileMetadataEntity.represent(merge_request_diff.diffs.diff_files).as_json
raw_diff_files = merge_request_diff.diffs.raw_diff_files
expect_next_instance_of(Gitlab::Diff::FileCollection::MergeRequestDiff) do |instance|
# Use lightweight version instead. Several methods delegate to it, so putting a 5
# calls limit.
expect(instance).to receive(:raw_diff_files).at_most(5).times.and_call_original
expect(instance).not_to receive(:diff_files)
end
payload = DiffFileMetadataEntity.represent(raw_diff_files).as_json
 
expect(subject[:diff_files]).to eq(payload)
end
Loading
Loading
# frozen_string_literal: true
require 'spec_helper'
describe Metrics::SampleMetricsService do
describe 'query' do
subject { described_class.new(identifier).query }
context 'when the file is not found' do
let(:identifier) { nil }
it { is_expected.to be_nil }
end
context 'when the file is found' do
let(:identifier) { 'sample_metric_query_result' }
let(:source) { File.join(Rails.root, 'spec/fixtures/gitlab/sample_metrics', "#{identifier}.yml") }
let(:destination) { File.join(Rails.root, Metrics::SampleMetricsService::DIRECTORY, "#{identifier}.yml") }
around do |example|
FileUtils.mkdir_p(Metrics::SampleMetricsService::DIRECTORY)
FileUtils.cp(source, destination)
example.run
ensure
FileUtils.rm(destination)
end
subject { described_class.new(identifier).query }
it 'loads data from the sample file correctly' do
expect(subject).to eq(YAML.load_file(source))
end
end
context 'when the identifier is for a path outside of sample_metrics' do
let(:identifier) { '../config/secrets' }
it { is_expected.to be_nil }
end
end
end
# frozen_string_literal: true
require 'rake_helper'
describe 'gitlab:generate_sample_prometheus_data rake task' do
let(:cluster) { create(:cluster, :provided_by_user, :project) }
let(:environment) { create(:environment, project: cluster.project) }
let(:sample_query_file) { File.join(Rails.root, Metrics::SampleMetricsService::DIRECTORY, 'test_query_result.yml') }
let!(:metric) { create(:prometheus_metric, project: cluster.project, identifier: 'test_query_result') }
around do |example|
example.run
ensure
FileUtils.rm(sample_query_file)
end
it 'creates the file correctly' do
Rake.application.rake_require 'tasks/gitlab/generate_sample_prometheus_data'
allow(Environment).to receive(:find).and_return(environment)
allow(environment).to receive_message_chain(:prometheus_adapter, :prometheus_client, :query_range) { sample_query_result }
run_rake_task('gitlab:generate_sample_prometheus_data', [environment.id])
expect(File.exist?(sample_query_file)).to be true
query_file_content = YAML.load_file(sample_query_file)
expect(query_file_content).to eq(sample_query_result)
end
end
def sample_query_result
file = File.join(Rails.root, 'spec/fixtures/gitlab/sample_metrics', 'sample_metric_query_result.yml')
YAML.load_file(File.expand_path(file, __dir__))
end
Loading
Loading
@@ -4270,10 +4270,10 @@ eslint-plugin-jest@^22.3.0:
resolved "https://registry.yarnpkg.com/eslint-plugin-jest/-/eslint-plugin-jest-22.3.0.tgz#a10f10dedfc92def774ec9bb5bfbd2fb8e1c96d2"
integrity sha512-P1mYVRNlOEoO5T9yTqOfucjOYf1ktmJ26NjwjH8sxpCFQa6IhBGr5TpKl3hcAAT29hOsRJVuMWmTsHoUVo9FoA==
 
eslint-plugin-no-jquery@^2.1.0:
version "2.1.0"
resolved "https://registry.yarnpkg.com/eslint-plugin-no-jquery/-/eslint-plugin-no-jquery-2.1.0.tgz#d03b74224c5cfbc7fc0bdd12ce4eb400d09e0c0b"
integrity sha512-5sr5tOJRfuRviyAvFTe/mr80TXWxTteD/JHRuJtDN8q/bxAh16eSKoKLAevLC7wZCRN2iwnEfhQPQV4rp/gYtg==
eslint-plugin-no-jquery@^2.3.0:
version "2.3.0"
resolved "https://registry.yarnpkg.com/eslint-plugin-no-jquery/-/eslint-plugin-no-jquery-2.3.0.tgz#fccdad84afa61baa4c0527dd6249cdcbfa0f74a8"
integrity sha512-XQQZM5yKO72Y8QAojNhH8oYLnLZU34FovNHVoJlPLBuBPJk0kkiPNOS/K6wRFbVgn47iZHsT6E+7mSLwbcQEsg==
 
eslint-plugin-promise@^4.1.1:
version "4.1.1"
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment