debian-mirror-gitlab/spec/lib/gitlab/kubernetes/helm/install_command_spec.rb

89 lines
2.8 KiB
Ruby
Raw Normal View History

2018-03-17 18:26:18 +05:30
require 'rails_helper'
describe Gitlab::Kubernetes::Helm::InstallCommand do
2018-03-27 19:54:05 +05:30
let(:application) { create(:clusters_applications_prometheus) }
let(:namespace) { Gitlab::Kubernetes::Helm::NAMESPACE }
2018-11-08 19:23:39 +05:30
let(:install_command) { application.install_command }
2018-03-17 18:26:18 +05:30
2018-10-15 14:42:47 +05:30
subject { install_command }
2018-03-17 18:26:18 +05:30
2018-11-08 19:23:39 +05:30
context 'for ingress' do
let(:application) { create(:clusters_applications_ingress) }
it_behaves_like 'helm commands' do
let(:commands) do
<<~EOS
2018-10-15 14:42:47 +05:30
helm init --client-only >/dev/null
helm install #{application.chart} --name #{application.name} --namespace #{namespace} -f /data/helm/#{application.name}/config/values.yaml >/dev/null
2018-11-08 19:23:39 +05:30
EOS
end
end
end
context 'for prometheus' do
let(:application) { create(:clusters_applications_prometheus) }
it_behaves_like 'helm commands' do
let(:commands) do
<<~EOS
helm init --client-only >/dev/null
helm install #{application.chart} --name #{application.name} --version #{application.version} --namespace #{namespace} -f /data/helm/#{application.name}/config/values.yaml >/dev/null
EOS
end
2018-03-17 18:26:18 +05:30
end
2018-10-15 14:42:47 +05:30
end
2018-03-17 18:26:18 +05:30
2018-11-08 19:23:39 +05:30
context 'for runner' do
2018-10-15 14:42:47 +05:30
let(:ci_runner) { create(:ci_runner) }
let(:application) { create(:clusters_applications_runner, runner: ci_runner) }
2018-11-08 19:23:39 +05:30
it_behaves_like 'helm commands' do
let(:commands) do
<<~EOS
helm init --client-only >/dev/null
helm repo add #{application.name} #{application.repository}
helm install #{application.chart} --name #{application.name} --namespace #{namespace} -f /data/helm/#{application.name}/config/values.yaml >/dev/null
EOS
end
2018-10-15 14:42:47 +05:30
end
2018-11-08 19:23:39 +05:30
end
context 'for jupyter' do
let(:application) { create(:clusters_applications_jupyter) }
2018-03-17 18:26:18 +05:30
2018-10-15 14:42:47 +05:30
it_behaves_like 'helm commands' do
let(:commands) do
<<~EOS
2018-11-08 19:23:39 +05:30
helm init --client-only >/dev/null
helm repo add #{application.name} #{application.repository}
helm install #{application.chart} --name #{application.name} --namespace #{namespace} -f /data/helm/#{application.name}/config/values.yaml >/dev/null
2018-10-15 14:42:47 +05:30
EOS
2018-03-17 18:26:18 +05:30
end
end
2018-03-27 19:54:05 +05:30
end
2018-03-17 18:26:18 +05:30
2018-03-27 19:54:05 +05:30
describe '#config_map?' do
subject { install_command.config_map? }
2018-03-17 18:26:18 +05:30
2018-03-27 19:54:05 +05:30
it { is_expected.to be_truthy }
end
2018-03-17 18:26:18 +05:30
2018-03-27 19:54:05 +05:30
describe '#config_map_resource' do
let(:metadata) do
{
name: "values-content-configuration-#{application.name}",
namespace: namespace,
labels: { name: "values-content-configuration-#{application.name}" }
}
2018-03-17 18:26:18 +05:30
end
2018-03-27 19:54:05 +05:30
let(:resource) { ::Kubeclient::Resource.new(metadata: metadata, data: { values: application.values }) }
2018-03-17 18:26:18 +05:30
2018-03-27 19:54:05 +05:30
subject { install_command.config_map_resource }
2018-03-17 18:26:18 +05:30
2018-03-27 19:54:05 +05:30
it 'returns a KubeClient resource with config map content for the application' do
is_expected.to eq(resource)
2018-03-17 18:26:18 +05:30
end
end
end