diff options
author | Thong Kuah <tkuah@gitlab.com> | 2018-10-01 10:32:09 +1300 |
---|---|---|
committer | Thong Kuah <tkuah@gitlab.com> | 2018-10-01 11:16:07 +1300 |
commit | f6ff32d9bd7a9817bb74379a1f28954aa378559c (patch) | |
tree | 8ab1683c75fe0117b573f8754591c546fd103711 /spec/lib/gitlab | |
parent | f03eb2332682c9419103df905045bf33f04a5158 (diff) | |
download | gitlab-ce-f6ff32d9bd7a9817bb74379a1f28954aa378559c.tar.gz |
Port Helm::Api EE extensions to CE49952-port-upgrade-command-to-ce
We will need these utility level code in the future to help upgrade all
helm applications.
Diffstat (limited to 'spec/lib/gitlab')
-rw-r--r-- | spec/lib/gitlab/kubernetes/helm/api_spec.rb | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/spec/lib/gitlab/kubernetes/helm/api_spec.rb b/spec/lib/gitlab/kubernetes/helm/api_spec.rb index 25c3b37753d..9200724ed23 100644 --- a/spec/lib/gitlab/kubernetes/helm/api_spec.rb +++ b/spec/lib/gitlab/kubernetes/helm/api_spec.rb @@ -150,6 +150,43 @@ describe Gitlab::Kubernetes::Helm::Api do end end + describe '#update' do + let(:rbac) { false } + + let(:command) do + Gitlab::Kubernetes::Helm::UpgradeCommand.new( + application_name, + chart: 'chart-name', + files: files, + rbac: rbac + ) + end + + before do + allow(namespace).to receive(:ensure_exists!).once + + allow(client).to receive(:update_config_map).and_return(nil) + allow(client).to receive(:create_pod).and_return(nil) + end + + it 'ensures the namespace exists before creating the pod' do + expect(namespace).to receive(:ensure_exists!).once.ordered + expect(client).to receive(:create_pod).once.ordered + + subject.update(command) + end + + it 'updates the config map on kubeclient when one exists' do + resource = Gitlab::Kubernetes::ConfigMap.new( + application_name, files + ).generate + + expect(client).to receive(:update_config_map).with(resource).once + + subject.update(command) + end + end + describe '#status' do let(:phase) { Gitlab::Kubernetes::Pod::RUNNING } let(:pod) { Kubeclient::Resource.new(status: { phase: phase }) } # partial representation @@ -179,4 +216,25 @@ describe Gitlab::Kubernetes::Helm::Api do subject.delete_pod!(command.pod_name) end end + + describe '#get_config_map' do + before do + allow(namespace).to receive(:ensure_exists!).once + allow(client).to receive(:get_config_map).and_return(nil) + end + + it 'ensures the namespace exists before retrieving the config map' do + expect(namespace).to receive(:ensure_exists!).once + + subject.get_config_map('example-config-map-name') + end + + it 'gets the config map on kubeclient' do + expect(client).to receive(:get_config_map) + .with('example-config-map-name', namespace.name) + .once + + subject.get_config_map('example-config-map-name') + end + end end |