diff options
Diffstat (limited to 'spec/services/clusters')
3 files changed, 25 insertions, 9 deletions
diff --git a/spec/services/clusters/applications/check_uninstall_progress_service_spec.rb b/spec/services/clusters/applications/check_uninstall_progress_service_spec.rb index ffb658330d3..9dede1947f8 100644 --- a/spec/services/clusters/applications/check_uninstall_progress_service_spec.rb +++ b/spec/services/clusters/applications/check_uninstall_progress_service_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' describe Clusters::Applications::CheckUninstallProgressService do - RESCHEDULE_PHASES = Gitlab::Kubernetes::Pod::PHASES - [Gitlab::Kubernetes::Pod::SUCCEEDED, Gitlab::Kubernetes::Pod::FAILED].freeze + reschedule_phases = Gitlab::Kubernetes::Pod::PHASES - [Gitlab::Kubernetes::Pod::SUCCEEDED, Gitlab::Kubernetes::Pod::FAILED].freeze let(:application) { create(:clusters_applications_prometheus, :uninstalling) } let(:service) { described_class.new(application) } @@ -42,7 +42,7 @@ describe Clusters::Applications::CheckUninstallProgressService do end context 'when application is uninstalling' do - RESCHEDULE_PHASES.each { |phase| it_behaves_like 'a not yet terminated installation', phase } + reschedule_phases.each { |phase| it_behaves_like 'a not yet terminated installation', phase } context 'when installation POD succeeded' do let(:phase) { Gitlab::Kubernetes::Pod::SUCCEEDED } diff --git a/spec/services/clusters/applications/prometheus_config_service_spec.rb b/spec/services/clusters/applications/prometheus_config_service_spec.rb index 993a697b543..b9032e665ec 100644 --- a/spec/services/clusters/applications/prometheus_config_service_spec.rb +++ b/spec/services/clusters/applications/prometheus_config_service_spec.rb @@ -90,23 +90,25 @@ describe Clusters::Applications::PrometheusConfigService do create(:prometheus_alert, project: project, environment: production, - prometheus_metric: metric) + prometheus_metric: metric, + operator: PrometheusAlert.operators['gt'], + threshold: 0) end let(:metric) do create(:prometheus_metric, query: query, project: project) end - let(:query) { '%{ci_environment_slug}' } + let(:query) { 'up{environment="{{ci_environment_slug}}"}' } it 'substitutes query variables' do expect(Gitlab::Prometheus::QueryVariables) .to receive(:call) - .with(production) + .with(production, start_time: nil, end_time: nil) .and_call_original expr = groups.dig(0, 'rules', 0, 'expr') - expect(expr).to include(production.name) + expect(expr).to eq("up{environment=\"#{production.slug}\"} > 0.0") end end @@ -127,13 +129,15 @@ describe Clusters::Applications::PrometheusConfigService do end it 'substitutes query variables once per environment' do + allow(Gitlab::Prometheus::QueryVariables).to receive(:call).and_call_original + expect(Gitlab::Prometheus::QueryVariables) .to receive(:call) - .with(production) + .with(production, start_time: nil, end_time: nil) expect(Gitlab::Prometheus::QueryVariables) .to receive(:call) - .with(staging) + .with(staging, start_time: nil, end_time: nil) subject end diff --git a/spec/services/clusters/parse_cluster_applications_artifact_service_spec.rb b/spec/services/clusters/parse_cluster_applications_artifact_service_spec.rb index f14c929554a..bb0b107eba6 100644 --- a/spec/services/clusters/parse_cluster_applications_artifact_service_spec.rb +++ b/spec/services/clusters/parse_cluster_applications_artifact_service_spec.rb @@ -85,13 +85,25 @@ describe Clusters::ParseClusterApplicationsArtifactService do end end - context 'job has no deployment cluster' do + context 'job has no deployment' do let(:job) { build(:ci_build) } it 'returns an error' do result = described_class.new(job, user).execute(artifact) expect(result[:status]).to eq(:error) + expect(result[:message]).to eq('No deployment found for this job') + end + end + + context 'job has no deployment cluster' do + let(:deployment) { create(:deployment) } + let(:job) { deployment.deployable } + + it 'returns an error' do + result = described_class.new(job, user).execute(artifact) + + expect(result[:status]).to eq(:error) expect(result[:message]).to eq('No deployment cluster found for this job') end end |