diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-11-11 18:07:37 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-11-11 18:07:37 +0000 |
commit | 76960690493db51cbbf3d24943f2fc6bb09e5ce4 (patch) | |
tree | 31ece6be23b6173ef1c01c5c62e307da1cd21ced /spec/models/clusters | |
parent | 34ce62a494ab1e8f1e76dc4f0bda925593a4c0cb (diff) | |
download | gitlab-ce-76960690493db51cbbf3d24943f2fc6bb09e5ce4.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/models/clusters')
-rw-r--r-- | spec/models/clusters/platforms/kubernetes_spec.rb | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/spec/models/clusters/platforms/kubernetes_spec.rb b/spec/models/clusters/platforms/kubernetes_spec.rb index 99dbb654b7f..b280275c2e5 100644 --- a/spec/models/clusters/platforms/kubernetes_spec.rb +++ b/spec/models/clusters/platforms/kubernetes_spec.rb @@ -433,6 +433,55 @@ RSpec.describe Clusters::Platforms::Kubernetes do let(:cluster) { create(:cluster, :project, platform_kubernetes: service) } include_examples 'successful deployment request' + + context 'when reading ingress raises NoMethodError' do + before do + allow_next_instance_of(Gitlab::Kubernetes::KubeClient) do |kube_client| + allow(kube_client).to receive(:get_pods).with(namespace: namespace).and_return([]) + allow(kube_client).to receive(:get_deployments).with(namespace: namespace).and_return([]) + allow(kube_client).to receive(:get_ingresses).with(namespace: namespace).and_raise(NoMethodError) + end + end + + context 'when version request succeeds' do + before do + stub_server_min_version(min_server_version) + end + + context 'when server min version is < 23' do + let(:min_server_version) { "18" } + + it 'does not raise error', :unlimited_max_formatted_output_length do + expect { subject }.not_to raise_error + end + + it 'returns empty array for the K8s component keys' do + expect(subject).to include({ pods: [], deployments: [], ingresses: [] }) + end + end + + context 'when server min version is >= 23' do + let(:min_server_version) { "23" } + + it 'does raise error' do + expect { subject }.to raise_error(NoMethodError) + end + end + end + + context 'when the version request fails' do + before do + stub_server_min_version_failed_request + end + + it "tracks error and returns empty arrays" do + expect(Gitlab::ErrorTracking) + .to receive(:track_exception).with(kind_of(Clusters::Platforms::Kubernetes::FailedVersionCheckError)) + + expect(subject).to include({ pods: [], deployments: [], ingresses: [] }) + end + end + end end context 'on a group level cluster' do |