2019-07-31 22:56:46 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
describe Gitlab::Kubernetes::Helm::DeleteCommand do
|
2020-05-24 23:13:21 +05:30
|
|
|
subject(:delete_command) { described_class.new(name: app_name, rbac: rbac, files: files) }
|
|
|
|
|
2019-07-31 22:56:46 +05:30
|
|
|
let(:app_name) { 'app-name' }
|
|
|
|
let(:rbac) { true }
|
|
|
|
let(:files) { {} }
|
|
|
|
|
2020-05-24 23:13:21 +05:30
|
|
|
it_behaves_like 'helm command generator' do
|
2019-07-31 22:56:46 +05:30
|
|
|
let(:commands) do
|
|
|
|
<<~EOS
|
2020-01-01 13:55:28 +05:30
|
|
|
export HELM_HOST="localhost:44134"
|
|
|
|
tiller -listen ${HELM_HOST} -alsologtostderr &
|
|
|
|
helm init --client-only
|
2019-07-31 22:56:46 +05:30
|
|
|
helm delete --purge app-name
|
|
|
|
EOS
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2020-01-01 13:55:28 +05:30
|
|
|
context 'tillerless feature disabled' do
|
|
|
|
before do
|
|
|
|
stub_feature_flags(managed_apps_local_tiller: false)
|
|
|
|
end
|
2019-07-31 22:56:46 +05:30
|
|
|
|
2020-05-24 23:13:21 +05:30
|
|
|
it_behaves_like 'helm command generator' do
|
2019-07-31 22:56:46 +05:30
|
|
|
let(:commands) do
|
|
|
|
<<~EOS
|
|
|
|
helm init --upgrade
|
2020-01-01 13:55:28 +05:30
|
|
|
for i in $(seq 1 30); do helm version && s=0 && break || s=$?; sleep 1s; echo \"Retrying ($i)...\"; done; (exit $s)
|
|
|
|
helm delete --purge app-name
|
2019-07-31 22:56:46 +05:30
|
|
|
EOS
|
|
|
|
end
|
2020-01-01 13:55:28 +05:30
|
|
|
end
|
2019-07-31 22:56:46 +05:30
|
|
|
|
2020-01-01 13:55:28 +05:30
|
|
|
context 'when there is a ca.pem file' do
|
|
|
|
let(:files) { { 'ca.pem': 'some file content' } }
|
|
|
|
|
|
|
|
let(:tls_flags) do
|
2019-07-31 22:56:46 +05:30
|
|
|
<<~EOS.squish
|
2020-01-01 13:55:28 +05:30
|
|
|
--tls
|
|
|
|
--tls-ca-cert /data/helm/app-name/config/ca.pem
|
|
|
|
--tls-cert /data/helm/app-name/config/cert.pem
|
|
|
|
--tls-key /data/helm/app-name/config/key.pem
|
2019-07-31 22:56:46 +05:30
|
|
|
EOS
|
|
|
|
end
|
2020-01-01 13:55:28 +05:30
|
|
|
|
2020-05-24 23:13:21 +05:30
|
|
|
it_behaves_like 'helm command generator' do
|
2020-01-01 13:55:28 +05:30
|
|
|
let(:commands) do
|
|
|
|
<<~EOS
|
|
|
|
helm init --upgrade
|
|
|
|
for i in $(seq 1 30); do helm version #{tls_flags} && s=0 && break || s=$?; sleep 1s; echo \"Retrying ($i)...\"; done; (exit $s)
|
|
|
|
#{helm_delete_command}
|
|
|
|
EOS
|
|
|
|
end
|
|
|
|
|
|
|
|
let(:helm_delete_command) do
|
|
|
|
<<~EOS.squish
|
|
|
|
helm delete --purge app-name
|
|
|
|
#{tls_flags}
|
|
|
|
EOS
|
|
|
|
end
|
|
|
|
end
|
2019-07-31 22:56:46 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
describe '#pod_name' do
|
|
|
|
subject { delete_command.pod_name }
|
|
|
|
|
|
|
|
it { is_expected.to eq('uninstall-app-name') }
|
|
|
|
end
|
2020-05-24 23:13:21 +05:30
|
|
|
|
|
|
|
it_behaves_like 'helm command' do
|
|
|
|
let(:command) { delete_command }
|
|
|
|
end
|
|
|
|
|
|
|
|
describe '#delete_command' do
|
|
|
|
it 'deletes the release' do
|
|
|
|
expect(subject.delete_command).to eq('helm delete --purge app-name')
|
|
|
|
end
|
|
|
|
end
|
2019-07-31 22:56:46 +05:30
|
|
|
end
|