2021-09-28 13:11:36 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
require_relative '../../test_helper'
|
|
|
|
|
|
|
|
class Test < ChartTest
|
|
|
|
@@chart = Chart.new('charts/library/common-test')
|
|
|
|
|
|
|
|
describe @@chart.name do
|
|
|
|
describe 'controller::type' do
|
|
|
|
it 'defaults to "Deployment"' do
|
|
|
|
assert_nil(resource('StatefulSet'))
|
|
|
|
assert_nil(resource('DaemonSet'))
|
|
|
|
refute_nil(resource('Deployment'))
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'accepts "statefulset"' do
|
2021-09-28 22:11:52 +00:00
|
|
|
chart.value controller: {type: 'statefulset'}
|
2021-09-28 13:11:36 +00:00
|
|
|
assert_nil(resource('Deployment'))
|
|
|
|
assert_nil(resource('DaemonSet'))
|
|
|
|
refute_nil(resource('StatefulSet'))
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'accepts "daemonset"' do
|
2021-09-28 22:11:52 +00:00
|
|
|
chart.value controller: {type: 'daemonset'}
|
2021-09-28 13:11:36 +00:00
|
|
|
assert_nil(resource('Deployment'))
|
|
|
|
assert_nil(resource('StatefulSet'))
|
|
|
|
refute_nil(resource('DaemonSet'))
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
describe 'controller::statefulset::volumeClaimTemplates' do
|
|
|
|
it 'volumeClaimTemplates should be empty by default' do
|
2021-09-28 22:11:52 +00:00
|
|
|
chart.value controller: {type: 'statefulset'}
|
2021-09-28 13:11:36 +00:00
|
|
|
statefulset = chart.resources(kind: "StatefulSet").first
|
|
|
|
assert_nil(statefulset['spec']['volumeClaimTemplates'])
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'can set values for volumeClaimTemplates' do
|
|
|
|
values = {
|
2021-09-28 22:11:52 +00:00
|
|
|
controller: {
|
|
|
|
type: 'statefulset',
|
|
|
|
},
|
|
|
|
volumeClaimTemplates: {
|
|
|
|
storage: {
|
2021-09-28 13:11:36 +00:00
|
|
|
accessMode: 'ReadWriteOnce',
|
|
|
|
size: '10Gi',
|
|
|
|
storageClass: 'storage'
|
|
|
|
}
|
2021-09-28 22:11:52 +00:00
|
|
|
}
|
2021-09-28 13:11:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
chart.value values
|
|
|
|
statefulset = chart.resources(kind: "StatefulSet").first
|
2021-09-28 22:11:52 +00:00
|
|
|
volumeClaimTemplate = statefulset["spec"]["volumeClaimTemplates"].find{ |c| c["metadata"]["name"] == "storage"}
|
2021-09-28 13:11:36 +00:00
|
|
|
refute_nil(volumeClaimTemplate)
|
2021-09-28 22:11:52 +00:00
|
|
|
assert_equal(values[:volumeClaimTemplates][:storage][:accessMode], volumeClaimTemplate["spec"]["accessModes"][0])
|
|
|
|
assert_equal(values[:volumeClaimTemplates][:storage][:size], volumeClaimTemplate["spec"]["resources"]["requests"]["storage"])
|
|
|
|
assert_equal(values[:volumeClaimTemplates][:storage][:storageClass], volumeClaimTemplate["spec"]["storageClassName"])
|
2021-09-28 13:11:36 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|