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>2021-04-21 02:50:22 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2021-04-21 02:50:22 +0300
commit9dc93a4519d9d5d7be48ff274127136236a3adb3 (patch)
tree70467ae3692a0e35e5ea56bcb803eb512a10bedb /spec/models/clusters/integrations
parent4b0f34b6d759d6299322b3a54453e930c6121ff0 (diff)
Add latest changes from gitlab-org/gitlab@13-11-stable-eev13.11.0-rc43
Diffstat (limited to 'spec/models/clusters/integrations')
-rw-r--r--spec/models/clusters/integrations/prometheus_spec.rb57
1 files changed, 57 insertions, 0 deletions
diff --git a/spec/models/clusters/integrations/prometheus_spec.rb b/spec/models/clusters/integrations/prometheus_spec.rb
new file mode 100644
index 00000000000..a7be1673ce2
--- /dev/null
+++ b/spec/models/clusters/integrations/prometheus_spec.rb
@@ -0,0 +1,57 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+
+RSpec.describe Clusters::Integrations::Prometheus do
+ include KubernetesHelpers
+ include StubRequests
+
+ describe 'associations' do
+ it { is_expected.to belong_to(:cluster).class_name('Clusters::Cluster') }
+ end
+
+ describe 'validations' do
+ it { is_expected.to validate_presence_of(:cluster) }
+ it { is_expected.not_to allow_value(nil).for(:enabled) }
+ end
+
+ describe '#prometheus_client' do
+ include_examples '#prometheus_client shared' do
+ let(:factory) { :clusters_integrations_prometheus }
+ end
+ end
+
+ describe '#configured?' do
+ let(:prometheus) { create(:clusters_integrations_prometheus, cluster: cluster) }
+
+ subject { prometheus.configured? }
+
+ context 'when a kubenetes client is present' do
+ let(:cluster) { create(:cluster, :project, :provided_by_gcp) }
+
+ it { is_expected.to be_truthy }
+
+ context 'when it is disabled' do
+ let(:prometheus) { create(:clusters_integrations_prometheus, :disabled, cluster: cluster) }
+
+ it { is_expected.to be_falsey }
+ end
+
+ context 'when the kubernetes URL is blocked' do
+ before do
+ blocked_ip = '127.0.0.1' # localhost addresses are blocked by default
+
+ stub_all_dns(cluster.platform.api_url, ip_address: blocked_ip)
+ end
+
+ it { is_expected.to be_falsey }
+ end
+ end
+
+ context 'when a kubenetes client is not present' do
+ let(:cluster) { create(:cluster) }
+
+ it { is_expected.to be_falsy }
+ end
+ end
+end