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-05-19 18:44:42 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2021-05-19 18:44:42 +0300
commit4555e1b21c365ed8303ffb7a3325d773c9b8bf31 (patch)
tree5423a1c7516cffe36384133ade12572cf709398d /spec/models/clusters/integrations
parente570267f2f6b326480d284e0164a6464ba4081bc (diff)
Add latest changes from gitlab-org/gitlab@13-12-stable-eev13.12.0-rc42
Diffstat (limited to 'spec/models/clusters/integrations')
-rw-r--r--spec/models/clusters/integrations/elastic_stack_spec.rb19
-rw-r--r--spec/models/clusters/integrations/prometheus_spec.rb56
2 files changed, 75 insertions, 0 deletions
diff --git a/spec/models/clusters/integrations/elastic_stack_spec.rb b/spec/models/clusters/integrations/elastic_stack_spec.rb
new file mode 100644
index 00000000000..be4d59b52a2
--- /dev/null
+++ b/spec/models/clusters/integrations/elastic_stack_spec.rb
@@ -0,0 +1,19 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+
+RSpec.describe Clusters::Integrations::ElasticStack 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
+
+ it_behaves_like 'cluster-based #elasticsearch_client', :clusters_integrations_elastic_stack
+end
diff --git a/spec/models/clusters/integrations/prometheus_spec.rb b/spec/models/clusters/integrations/prometheus_spec.rb
index a7be1673ce2..680786189ad 100644
--- a/spec/models/clusters/integrations/prometheus_spec.rb
+++ b/spec/models/clusters/integrations/prometheus_spec.rb
@@ -15,6 +15,62 @@ RSpec.describe Clusters::Integrations::Prometheus do
it { is_expected.not_to allow_value(nil).for(:enabled) }
end
+ describe 'after_destroy' do
+ subject(:integration) { create(:clusters_integrations_prometheus, cluster: cluster, enabled: true) }
+
+ let(:cluster) { create(:cluster, :with_installed_helm) }
+
+ it 'deactivates prometheus_service' do
+ expect(Clusters::Applications::DeactivateServiceWorker)
+ .to receive(:perform_async).with(cluster.id, 'prometheus')
+
+ integration.destroy!
+ end
+ end
+
+ describe 'after_save' do
+ subject(:integration) { create(:clusters_integrations_prometheus, cluster: cluster, enabled: enabled) }
+
+ let(:cluster) { create(:cluster, :with_installed_helm) }
+ let(:enabled) { true }
+
+ context 'when no change to enabled status' do
+ it 'does not touch project services' do
+ integration # ensure integration exists before we set the expectations
+
+ expect(Clusters::Applications::DeactivateServiceWorker)
+ .not_to receive(:perform_async)
+
+ expect(Clusters::Applications::ActivateServiceWorker)
+ .not_to receive(:perform_async)
+
+ integration.update!(enabled: enabled)
+ end
+ end
+
+ context 'when enabling' do
+ let(:enabled) { false }
+
+ it 'deactivates prometheus_service' do
+ expect(Clusters::Applications::ActivateServiceWorker)
+ .to receive(:perform_async).with(cluster.id, 'prometheus')
+
+ integration.update!(enabled: true)
+ end
+ end
+
+ context 'when disabling' do
+ let(:enabled) { true }
+
+ it 'activates prometheus_service' do
+ expect(Clusters::Applications::DeactivateServiceWorker)
+ .to receive(:perform_async).with(cluster.id, 'prometheus')
+
+ integration.update!(enabled: false)
+ end
+ end
+ end
+
describe '#prometheus_client' do
include_examples '#prometheus_client shared' do
let(:factory) { :clusters_integrations_prometheus }