diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-10-19 09:09:36 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-10-19 09:09:36 +0300 |
commit | a04f7f36d7a8fb7657de899879f904e23b93ce42 (patch) | |
tree | e9e1afe2ecdfb62a9677944f63ee4d49e01d9f64 /spec | |
parent | dc97e5514114912508318ada1d35666d85fd3ab7 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec')
-rw-r--r-- | spec/models/clusters/cluster_spec.rb | 6 | ||||
-rw-r--r-- | spec/services/clusters/integrations/prometheus_health_check_service_spec.rb (renamed from spec/services/clusters/applications/prometheus_health_check_service_spec.rb) | 32 | ||||
-rw-r--r-- | spec/support/database/cross-join-allowlist.yml | 1 | ||||
-rw-r--r-- | spec/workers/clusters/integrations/check_prometheus_health_worker_spec.rb (renamed from spec/workers/clusters/applications/check_prometheus_health_worker_spec.rb) | 8 |
4 files changed, 23 insertions, 24 deletions
diff --git a/spec/models/clusters/cluster_spec.rb b/spec/models/clusters/cluster_spec.rb index 9d305e31bad..d61bed80aaa 100644 --- a/spec/models/clusters/cluster_spec.rb +++ b/spec/models/clusters/cluster_spec.rb @@ -178,13 +178,13 @@ RSpec.describe Clusters::Cluster, :use_clean_rails_memory_store_caching do end end - describe '.with_application_prometheus' do - subject { described_class.with_application_prometheus } + describe '.with_integration_prometheus' do + subject { described_class.with_integration_prometheus } let!(:cluster) { create(:cluster) } context 'cluster has prometheus application' do - let!(:application) { create(:clusters_applications_prometheus, :installed, cluster: cluster) } + let!(:application) { create(:clusters_integrations_prometheus, cluster: cluster) } it { is_expected.to include(cluster) } end diff --git a/spec/services/clusters/applications/prometheus_health_check_service_spec.rb b/spec/services/clusters/integrations/prometheus_health_check_service_spec.rb index e6c7b147ab7..9db3b9d2417 100644 --- a/spec/services/clusters/applications/prometheus_health_check_service_spec.rb +++ b/spec/services/clusters/integrations/prometheus_health_check_service_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -RSpec.describe Clusters::Applications::PrometheusHealthCheckService, '#execute' do +RSpec.describe Clusters::Integrations::PrometheusHealthCheckService, '#execute' do let(:service) { described_class.new(cluster) } subject { service.execute } @@ -26,10 +26,10 @@ RSpec.describe Clusters::Applications::PrometheusHealthCheckService, '#execute' end RSpec.shared_examples 'correct health stored' do - it 'stores the correct health of prometheus app' do + it 'stores the correct health of prometheus' do subject - expect(prometheus.healthy).to eq(client_healthy) + expect(prometheus.healthy?).to eq(client_healthy) end end @@ -43,19 +43,19 @@ RSpec.describe Clusters::Applications::PrometheusHealthCheckService, '#execute' let_it_be(:project) { create(:project) } let_it_be(:integration) { create(:alert_management_http_integration, project: project) } - let(:applications_prometheus_healthy) { true } - let(:prometheus) { create(:clusters_applications_prometheus, status: prometheus_status_value, healthy: applications_prometheus_healthy) } - let(:cluster) { create(:cluster, :project, application_prometheus: prometheus, projects: [project]) } + let(:previous_health_status) { :healthy } + let(:prometheus) { create(:clusters_integrations_prometheus, enabled: prometheus_enabled, health_status: previous_health_status) } + let(:cluster) { create(:cluster, :project, integration_prometheus: prometheus, projects: [project]) } - context 'when prometheus not installed' do - let(:prometheus_status_value) { Clusters::Applications::Prometheus.state_machine.states[:installing].value } + context 'when prometheus not enabled' do + let(:prometheus_enabled) { false } it { expect(subject).to eq(nil) } include_examples 'no alert' end - context 'when prometheus installed' do - let(:prometheus_status_value) { Clusters::Applications::Prometheus.state_machine.states[:installed].value } + context 'when prometheus enabled' do + let(:prometheus_enabled) { true } before do client = instance_double('PrometheusClient', healthy?: client_healthy) @@ -63,7 +63,7 @@ RSpec.describe Clusters::Applications::PrometheusHealthCheckService, '#execute' end context 'when newly unhealthy' do - let(:applications_prometheus_healthy) { true } + let(:previous_health_status) { :healthy } let(:client_healthy) { false } include_examples 'sends alert' @@ -71,7 +71,7 @@ RSpec.describe Clusters::Applications::PrometheusHealthCheckService, '#execute' end context 'when newly healthy' do - let(:applications_prometheus_healthy) { false } + let(:previous_health_status) { :unhealthy } let(:client_healthy) { true } include_examples 'no alert' @@ -79,7 +79,7 @@ RSpec.describe Clusters::Applications::PrometheusHealthCheckService, '#execute' end context 'when continuously unhealthy' do - let(:applications_prometheus_healthy) { false } + let(:previous_health_status) { :unhealthy } let(:client_healthy) { false } include_examples 'no alert' @@ -87,7 +87,7 @@ RSpec.describe Clusters::Applications::PrometheusHealthCheckService, '#execute' end context 'when continuously healthy' do - let(:applications_prometheus_healthy) { true } + let(:previous_health_status) { :healthy } let(:client_healthy) { true } include_examples 'no alert' @@ -95,7 +95,7 @@ RSpec.describe Clusters::Applications::PrometheusHealthCheckService, '#execute' end context 'when first health check and healthy' do - let(:applications_prometheus_healthy) { nil } + let(:previous_health_status) { :unknown } let(:client_healthy) { true } include_examples 'no alert' @@ -103,7 +103,7 @@ RSpec.describe Clusters::Applications::PrometheusHealthCheckService, '#execute' end context 'when first health check and not healthy' do - let(:applications_prometheus_healthy) { nil } + let(:previous_health_status) { :unknown } let(:client_healthy) { false } include_examples 'sends alert' diff --git a/spec/support/database/cross-join-allowlist.yml b/spec/support/database/cross-join-allowlist.yml index c209d275fc8..54375e43833 100644 --- a/spec/support/database/cross-join-allowlist.yml +++ b/spec/support/database/cross-join-allowlist.yml @@ -38,7 +38,6 @@ - "./spec/models/user_spec.rb" - "./spec/presenters/packages/detail/package_presenter_spec.rb" - "./spec/requests/api/ci/runner/runners_post_spec.rb" -- "./spec/requests/api/ci/runners_spec.rb" - "./spec/requests/api/graphql/ci/runner_spec.rb" - "./spec/requests/api/graphql/group_query_spec.rb" - "./spec/requests/api/graphql/packages/composer_spec.rb" diff --git a/spec/workers/clusters/applications/check_prometheus_health_worker_spec.rb b/spec/workers/clusters/integrations/check_prometheus_health_worker_spec.rb index fb779bf3b01..6f70870bd09 100644 --- a/spec/workers/clusters/applications/check_prometheus_health_worker_spec.rb +++ b/spec/workers/clusters/integrations/check_prometheus_health_worker_spec.rb @@ -2,16 +2,16 @@ require 'spec_helper' -RSpec.describe Clusters::Applications::CheckPrometheusHealthWorker, '#perform' do +RSpec.describe Clusters::Integrations::CheckPrometheusHealthWorker, '#perform' do subject { described_class.new.perform } it 'triggers health service' do cluster = create(:cluster) allow(Gitlab::Monitor::DemoProjects).to receive(:primary_keys) - allow(Clusters::Cluster).to receive_message_chain(:with_application_prometheus, :with_project_http_integrations).and_return([cluster]) + allow(Clusters::Cluster).to receive_message_chain(:with_integration_prometheus, :with_project_http_integrations).and_return([cluster]) - service_instance = instance_double(Clusters::Applications::PrometheusHealthCheckService) - expect(Clusters::Applications::PrometheusHealthCheckService).to receive(:new).with(cluster).and_return(service_instance) + service_instance = instance_double(Clusters::Integrations::PrometheusHealthCheckService) + expect(Clusters::Integrations::PrometheusHealthCheckService).to receive(:new).with(cluster).and_return(service_instance) expect(service_instance).to receive(:execute) subject |