diff options
author | Tiago Botelho <tiagonbotelho@hotmail.com> | 2018-06-25 10:57:29 +0100 |
---|---|---|
committer | Tiago Botelho <tiagonbotelho@hotmail.com> | 2018-07-25 09:39:39 +0100 |
commit | eb7c08c7a644fa07b274b83624005ac53acf7faf (patch) | |
tree | 08102d7589a06e1aa550d1703a79f845b9333610 /spec | |
parent | 4063141223f9b89248e3c33df5711201f75d3718 (diff) | |
download | gitlab-ce-eb7c08c7a644fa07b274b83624005ac53acf7faf.tar.gz |
Backports relevant changes made in https://gitlab.com/gitlab-org/gitlab-ee/merge_requests/5163 to CE
Diffstat (limited to 'spec')
4 files changed, 66 insertions, 16 deletions
diff --git a/spec/lib/gitlab/kubernetes/config_map_spec.rb b/spec/lib/gitlab/kubernetes/config_map_spec.rb index 33dfa461202..e253b291277 100644 --- a/spec/lib/gitlab/kubernetes/config_map_spec.rb +++ b/spec/lib/gitlab/kubernetes/config_map_spec.rb @@ -22,4 +22,10 @@ describe Gitlab::Kubernetes::ConfigMap do is_expected.to eq(resource) end end + + describe '#config_map_name' do + it 'returns the config_map name' do + expect(config_map.config_map_name).to eq("values-content-configuration-#{application.name}") + end + end end diff --git a/spec/lib/gitlab/kubernetes/helm/api_spec.rb b/spec/lib/gitlab/kubernetes/helm/api_spec.rb index aa7e43dfb16..6e9b4ca0869 100644 --- a/spec/lib/gitlab/kubernetes/helm/api_spec.rb +++ b/spec/lib/gitlab/kubernetes/helm/api_spec.rb @@ -49,33 +49,33 @@ describe Gitlab::Kubernetes::Helm::Api do end end - describe '#installation_status' do + describe '#status' do let(:phase) { Gitlab::Kubernetes::Pod::RUNNING } let(:pod) { Kubeclient::Resource.new(status: { phase: phase }) } # partial representation it 'fetches POD phase from kubernetes cluster' do expect(client).to receive(:get_pod).with(command.pod_name, gitlab_namespace).once.and_return(pod) - expect(subject.installation_status(command.pod_name)).to eq(phase) + expect(subject.status(command.pod_name)).to eq(phase) end end - describe '#installation_log' do + describe '#log' do let(:log) { 'some output' } let(:response) { RestClient::Response.new(log) } it 'fetches POD phase from kubernetes cluster' do expect(client).to receive(:get_pod_log).with(command.pod_name, gitlab_namespace).once.and_return(response) - expect(subject.installation_log(command.pod_name)).to eq(log) + expect(subject.log(command.pod_name)).to eq(log) end end - describe '#delete_installation_pod!' do + describe '#delete_pod!' do it 'deletes the POD from kubernetes cluster' do expect(client).to receive(:delete_pod).with(command.pod_name, gitlab_namespace).once - subject.delete_installation_pod!(command.pod_name) + subject.delete_pod!(command.pod_name) end end end diff --git a/spec/models/clusters/applications/prometheus_spec.rb b/spec/models/clusters/applications/prometheus_spec.rb index efd57040005..784b60fef8d 100644 --- a/spec/models/clusters/applications/prometheus_spec.rb +++ b/spec/models/clusters/applications/prometheus_spec.rb @@ -34,6 +34,47 @@ describe Clusters::Applications::Prometheus do end end + describe '#ready' do + let(:project) { create(:project) } + let(:cluster) { create(:cluster, projects: [project]) } + + it 'returns true when installed' do + application = build(:clusters_applications_prometheus, :installed, cluster: cluster) + + expect(application.ready?).to be true + end + + it 'returns false when not_installable' do + application = build(:clusters_applications_prometheus, :not_installable, cluster: cluster) + + expect(application.ready?).to be false + end + + it 'returns false when installable' do + application = build(:clusters_applications_prometheus, :installable, cluster: cluster) + + expect(application.ready?).to be false + end + + it 'returns false when scheduled' do + application = build(:clusters_applications_prometheus, :scheduled, cluster: cluster) + + expect(application.ready?).to be false + end + + it 'returns false when installing' do + application = build(:clusters_applications_prometheus, :installing, cluster: cluster) + + expect(application.ready?).to be false + end + + it 'returns false when errored' do + application = build(:clusters_applications_prometheus, :errored, cluster: cluster) + + expect(application.ready?).to be false + end + end + describe '#prometheus_client' do context 'cluster is nil' do it 'returns nil' do @@ -102,15 +143,17 @@ describe Clusters::Applications::Prometheus do let(:kubeclient) { double('kubernetes client') } let(:prometheus) { create(:clusters_applications_prometheus) } - subject { prometheus.install_command } - - it { is_expected.to be_an_instance_of(Gitlab::Kubernetes::Helm::InstallCommand) } + it 'returns an instance of Gitlab::Kubernetes::Helm::InstallCommand' do + expect(prometheus.install_command).to be_an_instance_of(Gitlab::Kubernetes::Helm::InstallCommand) + end it 'should be initialized with 3 arguments' do - expect(subject.name).to eq('prometheus') - expect(subject.chart).to eq('stable/prometheus') - expect(subject.version).to eq('6.7.3') - expect(subject.values).to eq(prometheus.values) + command = prometheus.install_command + + expect(command.name).to eq('prometheus') + expect(command.chart).to eq('stable/prometheus') + expect(command.version).to eq('6.7.3') + expect(command.values).to eq(prometheus.values) end end diff --git a/spec/support/prometheus/additional_metrics_shared_examples.rb b/spec/support/prometheus/additional_metrics_shared_examples.rb index c7c3346d39e..0fd67531c3b 100644 --- a/spec/support/prometheus/additional_metrics_shared_examples.rb +++ b/spec/support/prometheus/additional_metrics_shared_examples.rb @@ -25,7 +25,7 @@ RSpec.shared_examples 'additional metrics query' do shared_examples 'query context containing environment slug and filter' do it 'contains ci_environment_slug' do - expect(subject).to receive(:query_metrics).with(project, hash_including(ci_environment_slug: environment.slug)) + expect(subject).to receive(:query_metrics).with(project, environment, hash_including(ci_environment_slug: environment.slug)) subject.query(*query_params) end @@ -33,6 +33,7 @@ RSpec.shared_examples 'additional metrics query' do it 'contains environment filter' do expect(subject).to receive(:query_metrics).with( project, + environment, hash_including( environment_filter: "container_name!=\"POD\",environment=\"#{environment.slug}\"" ) @@ -50,7 +51,7 @@ RSpec.shared_examples 'additional metrics query' do it_behaves_like 'query context containing environment slug and filter' it 'query context contains kube_namespace' do - expect(subject).to receive(:query_metrics).with(project, hash_including(kube_namespace: kube_namespace)) + expect(subject).to receive(:query_metrics).with(project, environment, hash_including(kube_namespace: kube_namespace)) subject.query(*query_params) end @@ -74,7 +75,7 @@ RSpec.shared_examples 'additional metrics query' do it_behaves_like 'query context containing environment slug and filter' it 'query context contains empty kube_namespace' do - expect(subject).to receive(:query_metrics).with(project, hash_including(kube_namespace: '')) + expect(subject).to receive(:query_metrics).with(project, environment, hash_including(kube_namespace: '')) subject.query(*query_params) end |