done (+42 squashed commit) (#1053)

Squashed commit:

[8058e6aba] 1 error left

[b0157b252] 2 errors

[7fa494907] 4 errors

[03139391e]  6 failures, 4 errors

[7f017ea23] 12 errors

[3e9ad758d] 0 failures, 13 errors

[e24a3cb3e] 3 failures, 13 errors

[6edcaa655] 4 failures 14 errors

[9623bda57] 6 failures, 13 errors

[04c35c995] 4 failed 22 errors

[5f5335c15] 9 failures

[9a33540e2] down to 20 failures

[0e7b73b49] remove old tests

[5cc6d11b7] fixup the resources

[8c508d45a] some more progress

[4acef3c3b] some more work

[85cdb5d06] some ports cleanup

[1987ac2ec] lint before unit

[6fa221789] enable unit tests

[c212b695d] other name

[b78594518] common test name fix

[ef6597e79] indent

[8cbcfb5e4] common test rename

[1ca838c16] seperate common tests

[ef052b022] create two seperate job for common testing

[67eb0e9b3] use devcontainer for release shizzle

[0c47c482b] make it a sudo

[4d8900b16] force install jq

[9660cdd47] try something else

[e2b611917] bump common to run tests (to fix them)

[277241bbf] only use the new devcontainer for the release tests for now...

[9c7b68e0f] Revert "remove setup chart testing action"

This reverts commit 6987914587a58ab5a52a05b836d60ef91f1619d5.

[444914311] Revert "use integrated k3d"

This reverts commit d9bcb2f35d154b0afe1eb851729c37789b6ba0ea. (+6 squashed commit)

Squashed commit:

[313446184] Revert "correct k3s version"

This reverts commit 81fa8a43c41c2449b7411e0d59a3c2bbe0aef1ea.

[41b4d4795] Revert "version name tryout"

This reverts commit bbb8dcead9f9426872390b8f89b1fd0e661534bb.

[b64df97a0] Revert "change version"

This reverts commit 8080395dc80e606769ad9790b35d35fac4d1d3ed.

[ed63220d4] Revert "use k3s kubectl"

This reverts commit ea81735d939e838ad595835ea09b54bff817dd83.

[6267a2908] Revert "use normal kubectl"

This reverts commit 216d3799111d47f65dd20dd85ccb8fbc586a9c2b.

[f48ddde73] Revert "try to set kubectl context"

This reverts commit a5e8a532c5620e0d9d4cb7a53a371ba200265612.

[a5e8a532c] try to set kubectl context

[216d37991] use normal kubectl

[ea81735d9] use k3s kubectl

[8080395dc] change version

[bbb8dcead] version name tryout

[81fa8a43c] correct k3s version

[d9bcb2f35] use integrated k3d

[698791458] remove setup chart testing action

[5bd7cf01d] bump common-test
This commit is contained in:
Kjeld Schouten-Lebbing
2021-09-29 00:11:52 +02:00
committed by GitHub
parent d16997b5e3
commit 88b1719d32
31 changed files with 1034 additions and 2487 deletions
@@ -5,15 +5,16 @@ class Test < ChartTest
@@chart = Chart.new('charts/library/common-test')
describe @@chart.name do
describe 'job::permissions' do
it 'no job exists by default' do
job = chart.resources(kind: "Job").first
assert_nil(job)
describe 'initContainer::permissions' do
it 'initContainer exists by default' do
deployment = chart.resources(kind: "Deployment").first
initContainer = deployment["spec"]["template"]["spec"]["initContainers"][0]
refute_nil(initContainer)
end
it 'hostPathMounts do not affect permissions job by default' do
it 'persistenceList do not affect permissions job by default' do
values = {
hostPathMounts: [
persistenceList: [
{
name: "data",
enabled: true,
@@ -23,13 +24,12 @@ class Test < ChartTest
]
}
chart.value values
job = chart.resources(kind: "Job").first
assert_nil(job["spec"]["template"]["spec"]["volumes"])
assert_nil(job["spec"]["template"]["spec"]["containers"][0]["volumeMounts"])
deployment = chart.resources(kind: "Deployment").first
assert_nil(deployment["spec"]["template"]["spec"]["initContainers"][0]["volumeMounts"])
end
it 'hostPathMounts.setPermissions adds volume(mounts)' do
it 'persistenceList.setPermissions adds volume(mounts)' do
values = {
hostPathMounts: [
persistenceList: [
{
name: "data",
enabled: true,
@@ -40,13 +40,13 @@ class Test < ChartTest
]
}
chart.value values
job = chart.resources(kind: "Job").first
assert_equal("hostpathmounts-data", job["spec"]["template"]["spec"]["volumes"][0]["name"])
assert_equal("hostpathmounts-data", job["spec"]["template"]["spec"]["containers"][0]["volumeMounts"][0]["name"])
deployment = chart.resources(kind: "Deployment").first
assert_equal("data", deployment["spec"]["template"]["spec"]["volumes"][0]["name"])
assert_equal("data", deployment["spec"]["template"]["spec"]["initContainers"][0]["volumeMounts"][0]["name"])
end
it 'supports multiple hostPathMounts' do
it 'supports multiple persistenceList' do
values = {
hostPathMounts: [
persistenceList: [
{
name: "data",
enabled: true,
@@ -55,28 +55,28 @@ class Test < ChartTest
hostPath: "/tmp"
},
{
name: "config",
name: "configlist",
enabled: true,
setPermissions: true,
mountPath: "/config",
mountPath: "/configlist",
hostPath: "/tmp"
}
]
}
chart.value values
job = chart.resources(kind: "Job").first
mainContainer = job["spec"]["template"]["spec"]["containers"][0]
deployment = chart.resources(kind: "Deployment").first
initContainer = deployment["spec"]["template"]["spec"]["initContainers"][0]
# Check that all hostPathMounts volumes have mounts
values[:hostPathMounts].each { |value|
volumeMount = mainContainer["volumeMounts"].find{ |v| v["name"] == "hostpathmounts-" + value[:name].to_s }
# Check that all persistenceList volumes have mounts
values[:persistenceList].each { |value|
volumeMount = initContainer["volumeMounts"].find{ |v| v["name"] == "" + value[:name].to_s }
refute_nil(volumeMount)
}
end
it 'supports setting mountPath' do
values = {
hostPathMounts: [
persistenceList: [
{
name: "data",
enabled: true,
@@ -87,107 +87,87 @@ class Test < ChartTest
]
}
chart.value values
job = chart.resources(kind: "Job").first
mainContainer = job["spec"]["template"]["spec"]["containers"][0]
deployment = chart.resources(kind: "Deployment").first
initContainer = deployment["spec"]["template"]["spec"]["initContainers"][0]
volumeMount = mainContainer["volumeMounts"].find{ |v| v["name"] == "hostpathmounts-data" }
volumeMount = initContainer["volumeMounts"].find{ |v| v["name"] == "data" }
refute_nil(volumeMount)
assert_equal("/data", volumeMount["mountPath"])
end
it 'could mount multiple volumes' do
values = {
hostPathMounts: [
persistenceList: [
{
name: "data",
enabled: true,
type: "hostPath",
setPermissions: true,
mountPath: "/data",
hostPath: "/tmp1"
},
{
name: "config",
name: "configlist",
enabled: true,
type: "hostPath",
setPermissions: true,
mountPath: "/config",
mountPath: "/configlist",
hostPath: "/tmp2"
}
]
}
chart.value values
job = chart.resources(kind: "Job").first
volumes = job["spec"]["template"]["spec"]["volumes"]
deployment = chart.resources(kind: "Deployment").first
volumes = deployment["spec"]["template"]["spec"]["volumes"]
volume = volumes.find{ |v| v["name"] == "hostpathmounts-data"}
volume = volumes.find{ |v| v["name"] == "data"}
refute_nil(volume)
assert_equal('/tmp1', volume["hostPath"]["path"])
volume = volumes.find{ |v| v["name"] == "hostpathmounts-config"}
volume = volumes.find{ |v| v["name"] == "configlist"}
refute_nil(volume)
assert_equal('/tmp2', volume["hostPath"]["path"])
end
it 'emptyDir can be enabled' do
values = {
hostPathMounts: [
{
name: "data",
enabled: true,
setPermissions: true,
emptyDir: true,
mountPath: "/data"
}
]
}
chart.value values
job = chart.resources(kind: "Job").first
volumes = job["spec"]["template"]["spec"]["volumes"]
volume = volumes.find{ |v| v["name"] == "hostpathmounts-data"}
refute_nil(volume)
assert_equal(Hash.new, volume["emptyDir"])
end
it 'can process default (568:568) permissions for multiple volumes' do
results= {
command: ["/bin/sh", "-c", "chown -R 568:568 /data
chown -R 568:568 /config
"]
command: ["/bin/sh", "-c", "echo 'Automatically correcting permissions...';chown -R :568 '/configlist'; chmod -R g+w '/configlist';chown -R :568 '/data'; chmod -R g+w '/data';"]
}
values = {
hostPathMounts: [
persistenceList: [
{
name: "data",
enabled: true,
type: "hostPath",
setPermissions: true,
mountPath: "/data",
hostPath: "/tmp1"
},
{
name: "config",
name: "configlist",
enabled: true,
type: "hostPath",
setPermissions: true,
mountPath: "/config",
mountPath: "/configlist",
hostPath: "/tmp2"
}
]
}
chart.value values
job = chart.resources(kind: "Job").first
mainContainer = job["spec"]["template"]["spec"]["containers"][0]
assert_equal(results[:command], mainContainer["command"])
deployment = chart.resources(kind: "Deployment").first
initContainer = deployment["spec"]["template"]["spec"]["initContainers"][0]
assert_equal(results[:command], initContainer["command"])
end
it 'outputs default permissions with irrelevant podSecurityContext' do
results= {
command: ["/bin/sh", "-c", "chown -R 568:568 /data
chown -R 568:568 /config
"]
command: ["/bin/sh", "-c", "echo 'Automatically correcting permissions...';chown -R :568 '/configlist'; chmod -R g+w '/configlist';chown -R :568 '/data'; chmod -R g+w '/data';"]
}
values = {
podSecurityContext: {
allowPrivilegeEscalation: false
allowPrivilegeEscalation: false
},
hostPathMounts: [
persistenceList: [
{
name: "data",
enabled: true,
@@ -196,31 +176,29 @@ chown -R 568:568 /config
hostPath: "/tmp1"
},
{
name: "config",
name: "configlist",
enabled: true,
setPermissions: true,
mountPath: "/config",
mountPath: "/configlist",
hostPath: "/tmp2"
}
]
}
chart.value values
job = chart.resources(kind: "Job").first
mainContainer = job["spec"]["template"]["spec"]["containers"][0]
assert_equal(results[:command], mainContainer["command"])
deployment = chart.resources(kind: "Deployment").first
initContainer = deployment["spec"]["template"]["spec"]["initContainers"][0]
assert_equal(results[:command], initContainer["command"])
end
it 'outputs fsgroup permissions for multiple volumes when set' do
results= {
command: ["/bin/sh", "-c", "chown -R 568:666 /data
chown -R 568:666 /config
"]
command: ["/bin/sh", "-c", "echo 'Automatically correcting permissions...';chown -R :666 '/configlist'; chmod -R g+w '/configlist';chown -R :666 '/data'; chmod -R g+w '/data';"]
}
values = {
podSecurityContext: {
fsGroup: 666
},
hostPathMounts: [
persistenceList: [
{
name: "data",
enabled: true,
@@ -229,31 +207,29 @@ chown -R 568:666 /config
hostPath: "/tmp1"
},
{
name: "config",
name: "configlist",
enabled: true,
setPermissions: true,
mountPath: "/config",
mountPath: "/configlist",
hostPath: "/tmp2"
}
]
}
chart.value values
job = chart.resources(kind: "Job").first
mainContainer = job["spec"]["template"]["spec"]["containers"][0]
assert_equal(results[:command], mainContainer["command"])
deployment = chart.resources(kind: "Deployment").first
initContainer = deployment["spec"]["template"]["spec"]["initContainers"][0]
assert_equal(results[:command], initContainer["command"])
end
it 'outputs runAsUser permissions for multiple volumes when set' do
results= {
command: ["/bin/sh", "-c", "chown -R 999:568 /data
chown -R 999:568 /config
"]
command: ["/bin/sh", "-c", "echo 'Automatically correcting permissions...';chown -R :568 '/configlist'; chmod -R g+w '/configlist';chown -R :568 '/data'; chmod -R g+w '/data';"]
}
values = {
podSecurityContext: {
runAsUser: 999
},
hostPathMounts: [
persistenceList: [
{
name: "data",
enabled: true,
@@ -262,32 +238,30 @@ chown -R 999:568 /config
hostPath: "/tmp1"
},
{
name: "config",
name: "configlist",
enabled: true,
setPermissions: true,
mountPath: "/config",
mountPath: "/configlist",
hostPath: "/tmp2"
}
]
}
chart.value values
job = chart.resources(kind: "Job").first
mainContainer = job["spec"]["template"]["spec"]["containers"][0]
assert_equal(results[:command], mainContainer["command"])
deployment = chart.resources(kind: "Deployment").first
initContainer = deployment["spec"]["template"]["spec"]["initContainers"][0]
assert_equal(results[:command], initContainer["command"])
end
it 'outputs fsGroup AND runAsUser permissions for multiple volumes when both are set' do
results= {
command: ["/bin/sh", "-c", "chown -R 999:666 /data
chown -R 999:666 /config
"]
command: ["/bin/sh", "-c", "echo 'Automatically correcting permissions...';chown -R :666 '/configlist'; chmod -R g+w '/configlist';chown -R :666 '/data'; chmod -R g+w '/data';"]
}
values = {
podSecurityContext: {
fsGroup: 666,
runAsUser: 999
},
hostPathMounts: [
persistenceList: [
{
name: "data",
enabled: true,
@@ -296,31 +270,29 @@ chown -R 999:666 /config
hostPath: "/tmp1"
},
{
name: "config",
name: "configlist",
enabled: true,
setPermissions: true,
mountPath: "/config",
mountPath: "/configlist",
hostPath: "/tmp2"
}
]
}
chart.value values
job = chart.resources(kind: "Job").first
mainContainer = job["spec"]["template"]["spec"]["containers"][0]
assert_equal(results[:command], mainContainer["command"])
deployment = chart.resources(kind: "Deployment").first
initContainer = deployment["spec"]["template"]["spec"]["initContainers"][0]
assert_equal(results[:command], initContainer["command"])
end
it 'outputs PUID AND PGID permissions for multiple volumes when both are set' do
results= {
command: ["/bin/sh", "-c", "chown -R 999:666 /data
chown -R 999:666 /config
"]
command: ["/bin/sh", "-c", "echo 'Automatically correcting permissions...';chown -R :568 '/configlist'; chmod -R g+w '/configlist';chown -R :568 '/data'; chmod -R g+w '/data';"]
}
values = {
env: {
PGID: 666,
PUID: 999
},
hostPathMounts: [
persistenceList: [
{
name: "data",
enabled: true,
@@ -329,18 +301,18 @@ chown -R 999:666 /config
hostPath: "/tmp1"
},
{
name: "config",
name: "configlist",
enabled: true,
setPermissions: true,
mountPath: "/config",
mountPath: "/configlist",
hostPath: "/tmp2"
}
]
}
chart.value values
job = chart.resources(kind: "Job").first
mainContainer = job["spec"]["template"]["spec"]["containers"][0]
assert_equal(results[:command], mainContainer["command"])
deployment = chart.resources(kind: "Deployment").first
initContainer = deployment["spec"]["template"]["spec"]["initContainers"][0]
assert_equal(results[:command], initContainer["command"])
end
end
end
+9 -9
View File
@@ -88,7 +88,7 @@ class Test < ChartTest
chart.value values
refute_nil(resource('Secret'))
secret = chart.resources(kind: "Secret").first
assert_equal("common-test-main-tls-0-ixcert-1", secret["metadata"]["name"])
assert_equal("common-test-tls-0-ixcert-1", secret["metadata"]["name"])
refute_nil(secret["data"]["tls.crt"])
refute_nil(secret["data"]["tls.key"])
end
@@ -166,13 +166,13 @@ class Test < ChartTest
chart.value values
refute_nil(resource('Secret'))
secret = chart.resources(kind: "Secret").first
assert_equal("common-test-main-tls-0-ixcert-1", secret["metadata"]["name"])
assert_equal("common-test-tls-0-ixcert-1", secret["metadata"]["name"])
refute_nil(secret["data"]["tls.crt"])
refute_nil(secret["data"]["tls.key"])
ingress = chart.resources(kind: "Ingress").find{ |s| s["metadata"]["name"] == "common-test-main" }
ingress = chart.resources(kind: "Ingress").find{ |s| s["metadata"]["name"] == "common-test" }
refute_nil(ingress)
assert_equal("common-test-main-tls-0-ixcert-1", ingress["spec"]["tls"][0]["secretName"])
assert_equal("common-test-tls-0-ixcert-1", ingress["spec"]["tls"][0]["secretName"])
end
it 'multiple tls sections generate multiple secrets' do
values = {
@@ -304,18 +304,18 @@ class Test < ChartTest
chart.value values
refute_nil(resource('Secret'))
secret1 = chart.resources(kind: "Secret").first
assert_equal("common-test-main-tls-0-ixcert-1", secret1["metadata"]["name"])
assert_equal("common-test-tls-0-ixcert-1", secret1["metadata"]["name"])
refute_nil(secret1["data"]["tls.crt"])
refute_nil(secret1["data"]["tls.key"])
secret2 = chart.resources(kind: "Secret").find{ |s| s["metadata"]["name"] == "common-test-main-tls-1-ixcert-2" }
secret2 = chart.resources(kind: "Secret").find{ |s| s["metadata"]["name"] == "common-test-tls-1-ixcert-2" }
refute_nil(secret2)
refute_nil(secret2["data"]["tls.crt"])
refute_nil(secret2["data"]["tls.key"])
ingress = chart.resources(kind: "Ingress").find{ |s| s["metadata"]["name"] == "common-test-main" }
ingress = chart.resources(kind: "Ingress").find{ |s| s["metadata"]["name"] == "common-test" }
refute_nil(ingress)
assert_equal("common-test-main-tls-0-ixcert-1", ingress["spec"]["tls"][0]["secretName"])
assert_equal("common-test-main-tls-1-ixcert-2", ingress["spec"]["tls"][1]["secretName"])
assert_equal("common-test-tls-0-ixcert-1", ingress["spec"]["tls"][0]["secretName"])
assert_equal("common-test-tls-1-ixcert-2", ingress["spec"]["tls"][1]["secretName"])
end
end
end
@@ -6,11 +6,11 @@ class Test < ChartTest
describe @@chart.name do
describe 'container::resources' do
it 'no resources added by default' do
it 'specific resources added by default' do
deployment = chart.resources(kind: "Deployment").first
containers = deployment["spec"]["template"]["spec"]["containers"]
mainContainer = containers.find{ |c| c["name"] == "common-test" }
assert_equal({"limits"=>{}}, mainContainer["resources"])
assert_equal({"limits"=>{"cpu"=>"4000m", "memory"=>"8Gi"}, "requests"=>{"cpu"=>"10m", "memory"=>"50Mi"}}, mainContainer["resources"])
end
it 'resources can be added' do
values = {
@@ -22,7 +22,7 @@ class Test < ChartTest
deployment = chart.resources(kind: "Deployment").first
containers = deployment["spec"]["template"]["spec"]["containers"]
mainContainer = containers.find{ |c| c["name"] == "common-test" }
assert_equal({"limits"=>{}, "testresourcename"=>"testresourcevalue"}, mainContainer["resources"])
assert_equal({"limits"=>{"cpu"=>"4000m", "memory"=>"8Gi"}, "requests"=>{"cpu"=>"10m", "memory"=>"50Mi"}, "testresourcename"=>"testresourcevalue"}, mainContainer["resources"])
end
it 'resources.limits can be added' do
values = {
@@ -36,7 +36,7 @@ class Test < ChartTest
deployment = chart.resources(kind: "Deployment").first
containers = deployment["spec"]["template"]["spec"]["containers"]
mainContainer = containers.find{ |c| c["name"] == "common-test" }
assert_equal({"limits"=>{"testlimitkey"=>"testlimitvalue"}}, mainContainer["resources"])
assert_equal({"limits"=>{"cpu"=>"4000m", "memory"=>"8Gi", "testlimitkey"=>"testlimitvalue"}, "requests"=>{"cpu"=>"10m", "memory"=>"50Mi"}}, mainContainer["resources"])
end
it 'resources and resources.limits can both be added' do
values = {
@@ -51,7 +51,7 @@ class Test < ChartTest
deployment = chart.resources(kind: "Deployment").first
containers = deployment["spec"]["template"]["spec"]["containers"]
mainContainer = containers.find{ |c| c["name"] == "common-test" }
assert_equal({"limits"=>{"testlimitkey"=>"testlimitvalue"}, "testresourcekey"=>"testresourcevalue"}, mainContainer["resources"])
assert_equal({"limits"=>{"cpu"=>"4000m", "memory"=>"8Gi", "testlimitkey"=>"testlimitvalue"}, "requests"=>{"cpu"=>"10m", "memory"=>"50Mi"}, "testresourcekey"=>"testresourcevalue"}, mainContainer["resources"])
end
end
describe 'container::resources-scaleGPU' do
@@ -65,7 +65,7 @@ class Test < ChartTest
deployment = chart.resources(kind: "Deployment").first
containers = deployment["spec"]["template"]["spec"]["containers"]
mainContainer = containers.find{ |c| c["name"] == "common-test" }
assert_equal({"limits"=>{"intelblabla"=>1}}, mainContainer["resources"])
assert_equal({"limits"=>{"cpu"=>"4000m", "intelblabla"=>1, "memory"=>"8Gi"}, "requests"=>{"cpu"=>"10m", "memory"=>"50Mi"}}, mainContainer["resources"])
end
it 'scaleGPU can be combined with resources and resource values' do
values = {
@@ -83,7 +83,7 @@ class Test < ChartTest
deployment = chart.resources(kind: "Deployment").first
containers = deployment["spec"]["template"]["spec"]["containers"]
mainContainer = containers.find{ |c| c["name"] == "common-test" }
assert_equal({"limits"=>{"intelblabla"=>1, "testlimitkey"=>"testlimitvalue"}, "testresourcekey"=>"testresourcevalue"}, mainContainer["resources"])
assert_equal({"limits"=>{"cpu"=>"4000m", "intelblabla"=>1, "memory"=>"8Gi", "testlimitkey"=>"testlimitvalue"}, "requests"=>{"cpu"=>"10m", "memory"=>"50Mi"}, "testresourcekey"=>"testresourcevalue"}, mainContainer["resources"])
end
end
end
+125 -229
View File
@@ -21,7 +21,7 @@ class Test < ChartTest
deployment = chart.resources(kind: "Deployment").first
containers = deployment["spec"]["template"]["spec"]["containers"]
mainContainer = containers.find{ |c| c["name"] == "common-test" }
assert_equal(values[:command], mainContainer["command"])
assert_equal([values[:command]], mainContainer["command"])
end
it 'accepts a list of strings' do
@@ -55,7 +55,7 @@ class Test < ChartTest
deployment = chart.resources(kind: "Deployment").first
containers = deployment["spec"]["template"]["spec"]["containers"]
mainContainer = containers.find{ |c| c["name"] == "common-test" }
assert_equal(values[:args], mainContainer["args"])
assert_equal([values[:args]], mainContainer["args"])
end
it 'accepts a list of strings' do
@@ -75,7 +75,12 @@ class Test < ChartTest
describe 'container::environment settings' do
it 'Check no environment variables' do
values = {}
values = {
securityContext: {
runAsNonRoot: false,
readOnlyRootFilesystem: false
}
}
chart.value values
deployment = chart.resources(kind: "Deployment").first
containers = deployment["spec"]["template"]["spec"]["containers"]
@@ -83,67 +88,92 @@ class Test < ChartTest
assert_nil(mainContainer["env"])
end
it 'set "static" environment variables' do
it 'set static "k/v pair style" environment variables' do
values = {
env: {
STATIC_ENV: 'value_of_env',
TRUTHY_ENV: '0',
BOOL_ENV: false,
FLOAT_ENV: 4.2,
INT_ENV: 42,
STRING_ENV: 'value_of_env'
}
}
chart.value values
deployment = chart.resources(kind: "Deployment").first
containers = deployment["spec"]["template"]["spec"]["containers"]
mainContainer = containers.find{ |c| c["name"] == "common-test" }
assert_equal(values[:env].keys[0].to_s, mainContainer["env"][0]["name"])
assert_equal(values[:env].values[0].to_s, mainContainer["env"][0]["value"])
assert_equal(values[:env].keys[1].to_s, mainContainer["env"][1]["name"])
assert_equal(values[:env].values[1].to_s, mainContainer["env"][1]["value"])
end
it 'set "list" of "static" environment variables' do
values = {
envList: [
{
name: 'STATIC_ENV_FROM_LIST',
value: 'STATIC_ENV_VALUE_FROM_LIST'
}
]
}
chart.value values
deployment = chart.resources(kind: "Deployment").first
containers = deployment["spec"]["template"]["spec"]["containers"]
mainContainer = containers.find{ |c| c["name"] == "common-test" }
assert_equal(values[:envList][0][:name].to_s, mainContainer["env"][0]["name"])
assert_equal(values[:envList][0][:value].to_s, mainContainer["env"][0]["value"])
end
it 'set both "list" AND "dict" of "static" environment variables' do
values = {
env: {
STATIC_ENV: 'value_of_env'
},
envList: [
{
name: 'STATIC_ENV_FROM_LIST',
value: 'STATIC_ENV_VALUE_FROM_LIST'
}
]
}
chart.value values
deployment = chart.resources(kind: "Deployment").first
containers = deployment["spec"]["template"]["spec"]["containers"]
mainContainer = containers.find{ |c| c["name"] == "common-test" }
assert_equal(values[:envList][0][:name].to_s, mainContainer["env"][0]["name"])
assert_equal(values[:envList][0][:value].to_s, mainContainer["env"][0]["value"])
assert_equal(values[:env].keys[0].to_s, mainContainer["env"][1]["name"])
assert_equal(values[:env].values[0].to_s, mainContainer["env"][1]["value"])
assert_equal(values[:env].keys[1].to_s, mainContainer["env"][2]["name"])
assert_equal(values[:env].values[1].to_s, mainContainer["env"][2]["value"])
assert_equal(values[:env].keys[2].to_s, mainContainer["env"][3]["name"])
assert_equal(values[:env].values[2].to_s, mainContainer["env"][3]["value"])
assert_equal(values[:env].keys[3].to_s, mainContainer["env"][4]["name"])
assert_equal(values[:env].values[3].to_s, mainContainer["env"][4]["value"])
end
it 'set "valueFrom" environment variables' do
it 'set list of static "kubernetes style" environment variables' do
values = {
envValueFrom: {
envList: [
{
name: 'STATIC_ENV_FROM_LIST',
value: 'STATIC_ENV_VALUE_FROM_LIST'
}
]
}
chart.value values
deployment = chart.resources(kind: "Deployment").first
containers = deployment["spec"]["template"]["spec"]["containers"]
mainContainer = containers.find{ |c| c["name"] == "common-test" }
assert_equal(values[:envList][0][:name].to_s, mainContainer["env"][1]["name"])
assert_equal(values[:envList][0][:value].to_s, mainContainer["env"][1]["value"])
end
it 'set both static "k/v pair style" and static "k/valueFrom style" environment variables' do
values = {
env: {
STATIC_ENV: 'value_of_env',
STATIC_ENV_FROM: {
valueFrom: {
fieldRef: {
fieldPath: "spec.nodeName"
}
}
}
}
}
chart.value values
deployment = chart.resources(kind: "Deployment").first
containers = deployment["spec"]["template"]["spec"]["containers"]
mainContainer = containers.find{ |c| c["name"] == "common-test" }
assert_equal(values[:env].keys[0].to_s, mainContainer["env"][1]["name"])
assert_equal(values[:env].values[0].to_s, mainContainer["env"][1]["value"])
assert_equal(values[:env].keys[1].to_s, mainContainer["env"][2]["name"])
assert_equal(values[:env].values[1][:valueFrom][:fieldRef][:fieldPath], mainContainer["env"][2]["valueFrom"]["fieldRef"]["fieldPath"])
end
it 'set static "k/explicitValueFrom pair style" environment variables' do
values = {
env: {
NODE_NAME: {
valueFrom: {
fieldRef: {
fieldPath: "spec.nodeName"
}
}
}
}
}
chart.value values
deployment = chart.resources(kind: "Deployment").first
containers = deployment["spec"]["template"]["spec"]["containers"]
mainContainer = containers.find{ |c| c["name"] == "common-test" }
assert_equal(values[:env].keys[0].to_s, mainContainer["env"][1]["name"])
assert_equal(values[:env].values[0][:valueFrom][:fieldRef][:fieldPath], mainContainer["env"][1]["valueFrom"]["fieldRef"]["fieldPath"])
end
it 'set static "k/implicitValueFrom pair style" environment variables' do
values = {
env: {
NODE_NAME: {
fieldRef: {
fieldPath: "spec.nodeName"
@@ -155,16 +185,30 @@ class Test < ChartTest
deployment = chart.resources(kind: "Deployment").first
containers = deployment["spec"]["template"]["spec"]["containers"]
mainContainer = containers.find{ |c| c["name"] == "common-test" }
assert_equal(values[:envValueFrom].keys[0].to_s, mainContainer["env"][0]["name"])
assert_equal(values[:envValueFrom].values[0][:fieldRef][:fieldPath], mainContainer["env"][0]["valueFrom"]["fieldRef"]["fieldPath"])
assert_equal(values[:env].keys[0].to_s, mainContainer["env"][1]["name"])
assert_equal(values[:env].values[0][:fieldRef][:fieldPath], mainContainer["env"][1]["valueFrom"]["fieldRef"]["fieldPath"])
end
it 'set "static" and "Dynamic/Tpl" environment variables' do
it 'set both static "k/v pair style" and templated "k/v pair style" environment variables' do
values = {
env: {
DYN_ENV: "{{ .Release.Name }}-admin",
STATIC_ENV: 'value_of_env'
},
envTpl: {
}
}
chart.value values
deployment = chart.resources(kind: "Deployment").first
containers = deployment["spec"]["template"]["spec"]["containers"]
mainContainer = containers.find{ |c| c["name"] == "common-test" }
assert_equal(values[:env].keys[0].to_s, mainContainer["env"][1]["name"])
assert_equal("common-test-admin", mainContainer["env"][1]["value"])
assert_equal(values[:env].keys[1].to_s, mainContainer["env"][2]["name"])
assert_equal(values[:env].values[1].to_s, mainContainer["env"][2]["value"])
end
it 'set templated "k/v pair style" environment variables' do
values = {
env: {
DYN_ENV: "{{ .Release.Name }}-admin"
}
}
@@ -172,24 +216,41 @@ class Test < ChartTest
deployment = chart.resources(kind: "Deployment").first
containers = deployment["spec"]["template"]["spec"]["containers"]
mainContainer = containers.find{ |c| c["name"] == "common-test" }
assert_equal(values[:env].keys[0].to_s, mainContainer["env"][0]["name"])
assert_equal(values[:env].values[0].to_s, mainContainer["env"][0]["value"])
assert_equal(values[:envTpl].keys[0].to_s, mainContainer["env"][1]["name"])
assert_equal(values[:env].keys[0].to_s, mainContainer["env"][1]["name"])
assert_equal("common-test-admin", mainContainer["env"][1]["value"])
end
it 'set "Dynamic/Tpl" environment variables' do
it 'set static "k/v pair style", templated "k/v pair style", static "k/explicitValueFrom pair style", and static "k/implicitValueFrom pair style" environment variables' do
values = {
envTpl: {
DYN_ENV: "{{ .Release.Name }}-admin"
env: {
DYN_ENV: "{{ .Release.Name }}-admin",
STATIC_ENV: 'value_of_env',
STATIC_EXPLICIT_ENV_FROM: {
valueFrom: {
fieldRef: {
fieldPath: "spec.nodeName"
}
}
},
STATIC_IMPLICIT_ENV_FROM: {
fieldRef: {
fieldPath: "spec.nodeName"
}
}
}
}
chart.value values
deployment = chart.resources(kind: "Deployment").first
containers = deployment["spec"]["template"]["spec"]["containers"]
mainContainer = containers.find{ |c| c["name"] == "common-test" }
assert_equal(values[:envTpl].keys[0].to_s, mainContainer["env"][0]["name"])
assert_equal("common-test-admin", mainContainer["env"][0]["value"])
assert_equal(values[:env].keys[0].to_s, mainContainer["env"][1]["name"])
assert_equal("common-test-admin", mainContainer["env"][1]["value"])
assert_equal(values[:env].keys[1].to_s, mainContainer["env"][2]["name"])
assert_equal(values[:env].values[1].to_s, mainContainer["env"][2]["value"])
assert_equal(values[:env].keys[2].to_s, mainContainer["env"][3]["name"])
assert_equal(values[:env].values[2][:valueFrom][:fieldRef][:fieldPath], mainContainer["env"][3]["valueFrom"]["fieldRef"]["fieldPath"])
assert_equal(values[:env].keys[3].to_s, mainContainer["env"][4]["name"])
assert_equal(values[:env].values[3][:fieldRef][:fieldPath], mainContainer["env"][4]["valueFrom"]["fieldRef"]["fieldPath"])
end
it 'set "static" secret variables' do
@@ -211,170 +272,5 @@ class Test < ChartTest
end
end
describe 'container::persistence' do
it 'supports multiple volumeMounts' do
values = {
persistence: {
cache: {
enabled: true,
emptyDir: {
enabled: true
}
},
config: {
enabled: true,
existingClaim: "configClaim"
},
data: {
enabled: true,
existingClaim: "dataClaim"
}
}
}
chart.value values
deployment = chart.resources(kind: "Deployment").first
containers = deployment["spec"]["template"]["spec"]["containers"]
mainContainer = containers.find{ |c| c["name"] == "common-test" }
# Check that all persistent volumes have mounts
values[:persistence].each { |key, value|
volumeMount = mainContainer["volumeMounts"].find{ |v| v["name"] == key.to_s }
refute_nil(volumeMount)
}
end
it 'defaults mountPath to persistence key' do
values = {
persistence: {
data: {
enabled: true,
existingClaim: "dataClaim"
}
}
}
chart.value values
deployment = chart.resources(kind: "Deployment").first
containers = deployment["spec"]["template"]["spec"]["containers"]
mainContainer = containers.find{ |c| c["name"] == "common-test" }
volumeMount = mainContainer["volumeMounts"].find{ |v| v["name"] == "data" }
refute_nil(volumeMount)
assert_equal("/data", volumeMount["mountPath"])
end
it 'supports setting custom mountPath' do
values = {
persistence: {
data: {
enabled: true,
existingClaim: "dataClaim",
mountPath: "/myMountPath"
}
}
}
chart.value values
deployment = chart.resources(kind: "Deployment").first
containers = deployment["spec"]["template"]["spec"]["containers"]
mainContainer = containers.find{ |c| c["name"] == "common-test" }
volumeMount = mainContainer["volumeMounts"].find{ |v| v["name"] == "data" }
refute_nil(volumeMount)
assert_equal("/myMountPath", volumeMount["mountPath"])
end
it 'supports setting subPath' do
values = {
persistence: {
data: {
enabled: true,
existingClaim: "dataClaim",
subPath: "mySubPath"
}
}
}
chart.value values
deployment = chart.resources(kind: "Deployment").first
containers = deployment["spec"]["template"]["spec"]["containers"]
mainContainer = containers.find{ |c| c["name"] == "common-test" }
volumeMount = mainContainer["volumeMounts"].find{ |v| v["name"] == "data" }
refute_nil(volumeMount)
assert_equal("mySubPath", volumeMount["subPath"])
end
end
describe 'container::hostPathMounts' do
it 'supports multiple hostPathMounts' do
values = {
hostPathMounts: [
{
name: "data",
enabled: true,
mountPath: "/data",
hostPath: "/tmp"
},
{
name: "config",
enabled: true,
mountPath: "/config",
hostPath: "/tmp"
}
]
}
chart.value values
deployment = chart.resources(kind: "Deployment").first
containers = deployment["spec"]["template"]["spec"]["containers"]
mainContainer = containers.find{ |c| c["name"] == "common-test" }
# Check that all hostPathMounts volumes have mounts
values[:hostPathMounts].each { |value|
volumeMount = mainContainer["volumeMounts"].find{ |v| v["name"] == "hostpathmounts-" + value[:name].to_s }
refute_nil(volumeMount)
}
end
it 'supports setting mountPath' do
values = {
hostPathMounts: [
{
name: "data",
enabled: true,
mountPath: "/data",
hostPath: "/tmp"
}
]
}
chart.value values
deployment = chart.resources(kind: "Deployment").first
containers = deployment["spec"]["template"]["spec"]["containers"]
mainContainer = containers.find{ |c| c["name"] == "common-test" }
volumeMount = mainContainer["volumeMounts"].find{ |v| v["name"] == "hostpathmounts-data" }
refute_nil(volumeMount)
assert_equal("/data", volumeMount["mountPath"])
end
it 'supports setting subPath' do
values = {
hostPathMounts: [
{
name: "data",
enabled: true,
mountPath: "/data",
hostPath: "/tmp",
subPath: "mySubPath"
}
]
}
chart.value values
deployment = chart.resources(kind: "Deployment").first
containers = deployment["spec"]["template"]["spec"]["containers"]
mainContainer = containers.find{ |c| c["name"] == "common-test" }
volumeMount = mainContainer["volumeMounts"].find{ |v| v["name"] == "hostpathmounts-data" }
refute_nil(volumeMount)
assert_equal("mySubPath", volumeMount["subPath"])
end
end
end
end
+13 -12
View File
@@ -13,14 +13,14 @@ class Test < ChartTest
end
it 'accepts "statefulset"' do
chart.value controllerType: 'statefulset'
chart.value controller: {type: 'statefulset'}
assert_nil(resource('Deployment'))
assert_nil(resource('DaemonSet'))
refute_nil(resource('StatefulSet'))
end
it 'accepts "daemonset"' do
chart.value controllerType: 'daemonset'
chart.value controller: {type: 'daemonset'}
assert_nil(resource('Deployment'))
assert_nil(resource('StatefulSet'))
refute_nil(resource('DaemonSet'))
@@ -29,31 +29,32 @@ class Test < ChartTest
describe 'controller::statefulset::volumeClaimTemplates' do
it 'volumeClaimTemplates should be empty by default' do
chart.value controllerType: 'statefulset'
chart.value controller: {type: 'statefulset'}
statefulset = chart.resources(kind: "StatefulSet").first
assert_nil(statefulset['spec']['volumeClaimTemplates'])
end
it 'can set values for volumeClaimTemplates' do
values = {
controllerType: 'statefulset',
volumeClaimTemplates: [
{
name: 'storage',
controller: {
type: 'statefulset',
},
volumeClaimTemplates: {
storage: {
accessMode: 'ReadWriteOnce',
size: '10Gi',
storageClass: 'storage'
}
]
}
}
chart.value values
statefulset = chart.resources(kind: "StatefulSet").first
volumeClaimTemplate = statefulset["spec"]["volumeClaimTemplates"].find{ |v| v["metadata"]["name"] == values[:volumeClaimTemplates][0][:name]}
volumeClaimTemplate = statefulset["spec"]["volumeClaimTemplates"].find{ |c| c["metadata"]["name"] == "storage"}
refute_nil(volumeClaimTemplate)
assert_equal(values[:volumeClaimTemplates][0][:accessMode], volumeClaimTemplate["spec"]["accessModes"][0])
assert_equal(values[:volumeClaimTemplates][0][:size], volumeClaimTemplate["spec"]["resources"]["requests"]["storage"])
assert_equal(values[:volumeClaimTemplates][0][:storageClass], volumeClaimTemplate["spec"]["storageClassName"])
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"])
end
end
end
+101 -142
View File
@@ -6,37 +6,48 @@ class Test < ChartTest
describe @@chart.name do
describe 'ingress' do
baseValues = {
ingress: {
main: {
enabled: true
}
},
service: {
main: {
ports: {
http: {
port: 8080
}
}
}
}
}
it 'disabled when ingress.main.enabled: false' do
values = {
values = baseValues.deep_merge_override({
ingress: {
main: {
enabled: false
}
}
}
})
chart.value values
assert_nil(resource('Ingress'))
end
it 'enabled when ingress.main.enabled: true' do
values = {
ingress: {
main: {
enabled: true
}
}
}
values = baseValues
chart.value values
refute_nil(resource('Ingress'))
end
it 'tls can be provided' do
expectedPath = 'common-test.path'
values = {
values = baseValues.deep_merge_override({
ingress: {
main: {
enabled: true,
tls: [
{
hosts: [ 'hostname' ],
@@ -45,10 +56,10 @@ class Test < ChartTest
]
}
}
}
})
chart.value values
ingress = chart.resources(kind: "Ingress").find{ |s| s["metadata"]["name"] == "common-test-main" }
ingress = chart.resources(kind: "Ingress").find{ |s| s["metadata"]["name"] == "common-test" }
refute_nil(ingress)
assert_equal(values[:ingress][:main][:tls][0][:hosts][0], ingress["spec"]["tls"][0]["hosts"][0])
assert_equal(values[:ingress][:main][:tls][0][:secretName], ingress["spec"]["tls"][0]["secretName"])
@@ -56,10 +67,9 @@ class Test < ChartTest
it 'tls secret can be left empty' do
expectedPath = 'common-test.path'
values = {
values = baseValues.deep_merge_override({
ingress: {
main: {
enabled: true,
main:{
tls: [
{
hosts: [ 'hostname' ]
@@ -67,10 +77,10 @@ class Test < ChartTest
]
}
}
}
})
chart.value values
ingress = chart.resources(kind: "Ingress").find{ |s| s["metadata"]["name"] == "common-test-main" }
ingress = chart.resources(kind: "Ingress").find{ |s| s["metadata"]["name"] == "common-test" }
refute_nil(ingress)
assert_equal(values[:ingress][:main][:tls][0][:hosts][0], ingress["spec"]["tls"][0]["hosts"][0])
assert_equal(false, ingress["spec"]["tls"][0].key?("secretName"))
@@ -79,116 +89,125 @@ class Test < ChartTest
it 'tls secret template can be provided' do
expectedPath = 'common-test.path'
values = {
values = baseValues.deep_merge_override({
ingress: {
main: {
enabled: true,
tls: [
{
secretNameTpl: '{{ .Release.Name }}-secret'
secretName: '{{ .Release.Name }}-secret'
}
]
}
}
}
})
chart.value values
ingress = chart.resources(kind: "Ingress").find{ |s| s["metadata"]["name"] == "common-test-main" }
ingress = chart.resources(kind: "Ingress").find{ |s| s["metadata"]["name"] == "common-test" }
refute_nil(ingress)
assert_equal('common-test-secret', ingress["spec"]["tls"][0]["secretName"])
end
it 'path template can be provided' do
expectedPath = 'common-test.path'
values = {
values = baseValues.deep_merge_override({
ingress: {
main: {
enabled: true,
hosts: [
{
host: 'test.local',
paths: [
{
pathTpl: '{{ .Release.Name }}.path'
path: '{{ .Release.Name }}.path'
}
]
}
]
}
}
}
})
chart.value values
ingress = chart.resources(kind: "Ingress").find{ |s| s["metadata"]["name"] == "common-test-main" }
ingress = chart.resources(kind: "Ingress").find{ |s| s["metadata"]["name"] == "common-test" }
refute_nil(ingress)
assert_equal(expectedPath, ingress["spec"]["rules"][0]["http"]["paths"][0]["path"])
end
it 'hosts can be provided' do
values = {
values = baseValues.deep_merge_override({
ingress: {
main: {
enabled: true,
hosts: [
{
host: 'hostname'
host: 'hostname',
paths: [
{
path: "/"
}
]
}
]
}
}
}
})
chart.value values
ingress = chart.resources(kind: "Ingress").find{ |s| s["metadata"]["name"] == "common-test-main" }
ingress = chart.resources(kind: "Ingress").find{ |s| s["metadata"]["name"] == "common-test" }
refute_nil(ingress)
assert_equal(values[:ingress][:main][:hosts][0][:host], ingress["spec"]["rules"][0]["host"])
end
it 'hosts template can be provided' do
expectedHostName = 'common-test.hostname'
values = {
values = baseValues.deep_merge_override({
ingress: {
main: {
enabled: true,
hosts: [
{
hostTpl: '{{ .Release.Name }}.hostname'
}
]
}
}
}
chart.value values
ingress = chart.resources(kind: "Ingress").find{ |s| s["metadata"]["name"] == "common-test-main" }
refute_nil(ingress)
assert_equal(expectedHostName, ingress["spec"]["rules"][0]["host"])
end
it 'custom service name / port can optionally be set on path level' do
values = {
ingress: {
main: {
enabled: true,
hosts: [
{
host: '{{ .Release.Name }}.hostname',
paths: [
{
path: '/'
},
{
path: '/second',
serviceName: 'pathService',
servicePort: 1234
path: "/"
}
]
}
]
}
}
}
})
chart.value values
ingress = chart.resources(kind: "Ingress").find{ |s| s["metadata"]["name"] == "common-test-main" }
ingress = chart.resources(kind: "Ingress").find{ |s| s["metadata"]["name"] == "common-test" }
refute_nil(ingress)
assert_equal(expectedHostName, ingress["spec"]["rules"][0]["host"])
end
it 'custom service name / port can optionally be set on path level' do
values = baseValues.deep_merge_override({
ingress: {
main: {
hosts: [
{
host: 'test.local',
paths: [
{
path: '/'
},
{
path: '/second',
service: {
name: 'pathService',
port: 1234
}
}
]
}
]
}
}
})
chart.value values
ingress = chart.resources(kind: "Ingress").find{ |s| s["metadata"]["name"] == "common-test" }
firstPath = ingress["spec"]["rules"][0]["http"]["paths"][0]
secondPath = ingress["spec"]["rules"][0]["http"]["paths"][1]
assert_equal("common-test", firstPath["backend"]["service"]["name"])
@@ -196,85 +215,25 @@ class Test < ChartTest
assert_equal("pathService", secondPath["backend"]["service"]["name"])
assert_equal(1234, secondPath["backend"]["service"]["port"]["number"])
end
end
describe 'additionalIngress' do
ingressValues = {
ingress: {
extra: {
it 'multiple ingress objects can be specified' do
values = baseValues.deep_merge_override({
ingress: {
main: {
enabled: true,
hosts: [
{
paths: [
{
path: '/'
}
]
}
]
primary: true
},
secondary: {
enabled: true
}
}
}
it 'can be specified' do
values = ingressValues
chart.value values
additionalIngress = chart.resources(kind: "Ingress").find{ |s| s["metadata"]["name"] == "common-test-extra" }
refute_nil(additionalIngress)
end
it 'refers to main Service by default' do
values = ingressValues
chart.value values
additionalIngress = chart.resources(kind: "Ingress").find{ |s| s["metadata"]["name"] == "common-test-extra" }
assert_equal("common-test", additionalIngress["spec"]["rules"][0]["http"]["paths"][0]["backend"]["service"]["name"])
assert_equal(8080, additionalIngress["spec"]["rules"][0]["http"]["paths"][0]["backend"]["service"]["port"]["number"])
end
it 'custom service name / port can be set on Ingress level' do
values = ingressValues.deep_merge_override({
ingress: {
extra: {
serviceName: "customService",
servicePort: 8081
}
}
})
chart.value values
additionalIngress = chart.resources(kind: "Ingress").find{ |s| s["metadata"]["name"] == "common-test-extra" }
assert_equal("customService", additionalIngress["spec"]["rules"][0]["http"]["paths"][0]["backend"]["service"]["name"])
assert_equal(8081, additionalIngress["spec"]["rules"][0]["http"]["paths"][0]["backend"]["service"]["port"]["number"])
end
it 'custom service name / port can optionally be set on path level' do
values = ingressValues.deep_merge_override({
ingress: {
extra: {
hosts: [
{
paths: [
{
path: '/'
},
{
path: '/second',
serviceName: 'pathService',
servicePort: 1234
}
]
}
]
}
}
})
chart.value values
additionalIngress = chart.resources(kind: "Ingress").find{ |s| s["metadata"]["name"] == "common-test-extra" }
firstPath = additionalIngress["spec"]["rules"][0]["http"]["paths"][0]
secondPath = additionalIngress["spec"]["rules"][0]["http"]["paths"][1]
assert_equal("common-test", firstPath["backend"]["service"]["name"])
assert_equal(8080, firstPath["backend"]["service"]["port"]["number"])
assert_equal("pathService", secondPath["backend"]["service"]["name"])
assert_equal(1234, secondPath["backend"]["service"]["port"]["number"])
ingressMain = chart.resources(kind: "Ingress").find{ |s| s["metadata"]["name"] == "common-test" }
ingressExtra = chart.resources(kind: "Ingress").find{ |s| s["metadata"]["name"] == "common-test-secondary" }
refute_nil(ingressMain)
refute_nil(ingressExtra)
end
end
end
+368
View File
@@ -0,0 +1,368 @@
# frozen_string_literal: true
require_relative '../../test_helper'
class Test < ChartTest
@@chart = Chart.new('charts/library/common-test')
describe @@chart.name do
describe 'pod::persistence' do
it 'multiple volumes' do
values = {
persistence: {
cache: {
enabled: true,
type: "emptyDir"
},
config: {
enabled: true,
existingClaim: "configClaim"
},
data: {
enabled: true,
existingClaim: "dataClaim"
}
}
}
chart.value values
deployment = chart.resources(kind: "Deployment").first
volumes = deployment["spec"]["template"]["spec"]["volumes"]
volume = volumes.find{ |v| v["name"] == "cache"}
refute_nil(volume)
volume = volumes.find{ |v| v["name"] == "config"}
refute_nil(volume)
assert_equal('configClaim', volume["persistentVolumeClaim"]["claimName"])
volume = volumes.find{ |v| v["name"] == "data"}
refute_nil(volume)
assert_equal('dataClaim', volume["persistentVolumeClaim"]["claimName"])
end
it 'default nameSuffix' do
values = {
persistence: {
config: {
enabled: true
}
}
}
chart.value values
deployment = chart.resources(kind: "Deployment").first
volumes = deployment["spec"]["template"]["spec"]["volumes"]
volume = volumes.find{ |v| v["name"] == "config"}
refute_nil(volume)
assert_equal('common-test-config', volume["persistentVolumeClaim"]["claimName"])
end
it 'custom nameSuffix' do
values = {
persistence: {
config: {
enabled: true,
nameOverride: "test"
}
}
}
chart.value values
deployment = chart.resources(kind: "Deployment").first
volumes = deployment["spec"]["template"]["spec"]["volumes"]
volume = volumes.find{ |v| v["name"] == "config"}
refute_nil(volume)
assert_equal('common-test-test', volume["persistentVolumeClaim"]["claimName"])
end
it 'no nameSuffix' do
values = {
persistence: {
config: {
enabled: true,
nameOverride: "-"
}
}
}
chart.value values
deployment = chart.resources(kind: "Deployment").first
volumes = deployment["spec"]["template"]["spec"]["volumes"]
volume = volumes.find{ |v| v["name"] == "config"}
refute_nil(volume)
assert_equal('common-test', volume["persistentVolumeClaim"]["claimName"])
end
end
describe 'pod::persistence::emptyDir' do
it 'can be configured' do
values = {
persistence: {
config: {
enabled: true,
type: "emptyDir"
}
}
}
chart.value values
deployment = chart.resources(kind: "Deployment").first
volumes = deployment["spec"]["template"]["spec"]["volumes"]
volume = volumes.find{ |v| v["name"] == "config"}
refute_nil(volume)
assert_equal(Hash.new, volume["emptyDir"])
end
it 'medium can be configured' do
values = {
persistence: {
config: {
enabled: true,
type: "emptyDir",
medium: "memory"
}
}
}
chart.value values
deployment = chart.resources(kind: "Deployment").first
volumes = deployment["spec"]["template"]["spec"]["volumes"]
volume = volumes.find{ |v| v["name"] == "config"}
refute_nil(volume)
assert_equal("memory", volume["emptyDir"]["medium"])
end
it 'sizeLimit can be configured' do
values = {
persistence: {
config: {
enabled: true,
type: "emptyDir",
medium: "memory",
sizeLimit: "1Gi"
}
}
}
chart.value values
deployment = chart.resources(kind: "Deployment").first
volumes = deployment["spec"]["template"]["spec"]["volumes"]
volume = volumes.find{ |v| v["name"] == "config"}
refute_nil(volume)
assert_equal("1Gi", volume["emptyDir"]["sizeLimit"])
end
end
describe 'pod::persistenceList' do
it 'multiple volumes' do
values = {
persistenceList: [
{
name: "data",
enabled: true,
type: "hostPath",
mountPath: "/data",
hostPath: "/tmp1"
},
{
name: "configlist",
type: "hostPath",
enabled: true,
mountPath: "/config",
hostPath: "/tmp2"
}
]
}
chart.value values
deployment = chart.resources(kind: "Deployment").first
volumes = deployment["spec"]["template"]["spec"]["volumes"]
volume = volumes.find{ |v| v["name"] == "data"}
refute_nil(volume)
assert_equal('/tmp1', volume["hostPath"]["path"])
volume = volumes.find{ |v| v["name"] == "configlist"}
refute_nil(volume)
assert_equal('/tmp2', volume["hostPath"]["path"])
end
it 'emptyDir can be enabled' do
values = {
persistenceList: [
{
name: "data",
type: "emptyDir",
enabled: true,
mountPath: "/data"
}
]
}
chart.value values
deployment = chart.resources(kind: "Deployment").first
volumes = deployment["spec"]["template"]["spec"]["volumes"]
volume = volumes.find{ |v| v["name"] == "data"}
refute_nil(volume)
assert_equal(Hash.new, volume["emptyDir"])
end
end
describe 'container::persistence' do
it 'supports multiple volumeMounts' do
values = {
persistence: {
cache: {
enabled: true,
type: "emptyDir"
},
config: {
enabled: true,
existingClaim: "configClaim"
},
data: {
enabled: true,
existingClaim: "dataClaim"
}
}
}
chart.value values
deployment = chart.resources(kind: "Deployment").first
containers = deployment["spec"]["template"]["spec"]["containers"]
mainContainer = containers.find{ |c| c["name"] == "common-test" }
# Check that all persistent volumes have mounts
values[:persistence].each { |key, value|
volumeMount = mainContainer["volumeMounts"].find{ |v| v["name"] == key.to_s }
refute_nil(volumeMount)
}
end
it 'defaults mountPath to persistence key' do
values = {
persistence: {
data: {
enabled: true,
existingClaim: "dataClaim"
}
}
}
chart.value values
deployment = chart.resources(kind: "Deployment").first
containers = deployment["spec"]["template"]["spec"]["containers"]
mainContainer = containers.find{ |c| c["name"] == "common-test" }
volumeMount = mainContainer["volumeMounts"].find{ |v| v["name"] == "data" }
refute_nil(volumeMount)
assert_equal("/data", volumeMount["mountPath"])
end
it 'supports setting custom mountPath' do
values = {
persistence: {
data: {
enabled: true,
existingClaim: "dataClaim",
mountPath: "/myMountPath"
}
}
}
chart.value values
deployment = chart.resources(kind: "Deployment").first
containers = deployment["spec"]["template"]["spec"]["containers"]
mainContainer = containers.find{ |c| c["name"] == "common-test" }
volumeMount = mainContainer["volumeMounts"].find{ |v| v["name"] == "data" }
refute_nil(volumeMount)
assert_equal("/myMountPath", volumeMount["mountPath"])
end
it 'supports setting subPath' do
values = {
persistence: {
data: {
enabled: true,
existingClaim: "dataClaim",
subPath: "mySubPath"
}
}
}
chart.value values
deployment = chart.resources(kind: "Deployment").first
containers = deployment["spec"]["template"]["spec"]["containers"]
mainContainer = containers.find{ |c| c["name"] == "common-test" }
volumeMount = mainContainer["volumeMounts"].find{ |v| v["name"] == "data" }
refute_nil(volumeMount)
assert_equal("mySubPath", volumeMount["subPath"])
end
end
describe 'container::persistenceList' do
it 'supports multiple persistenceList' do
values = {
persistenceList: [
{
name: "data",
enabled: true,
mountPath: "/data",
hostPath: "/tmp"
},
{
name: "config",
enabled: true,
mountPath: "/config",
hostPath: "/tmp"
}
]
}
chart.value values
deployment = chart.resources(kind: "Deployment").first
containers = deployment["spec"]["template"]["spec"]["containers"]
mainContainer = containers.find{ |c| c["name"] == "common-test" }
# Check that all persistenceList volumes have mounts
values[:persistenceList].each { |value|
volumeMount = mainContainer["volumeMounts"].find{ |v| v["name"] == value[:name].to_s }
refute_nil(volumeMount)
}
end
it 'supports setting mountPath' do
values = {
persistenceList: [
{
name: "data",
enabled: true,
mountPath: "/data",
hostPath: "/tmp"
}
]
}
chart.value values
deployment = chart.resources(kind: "Deployment").first
containers = deployment["spec"]["template"]["spec"]["containers"]
mainContainer = containers.find{ |c| c["name"] == "common-test" }
volumeMount = mainContainer["volumeMounts"].find{ |v| v["name"] == "data" }
refute_nil(volumeMount)
assert_equal("/data", volumeMount["mountPath"])
end
it 'supports setting subPath' do
values = {
persistenceList: [
{
name: "data",
enabled: true,
mountPath: "/data",
hostPath: "/tmp",
subPath: "mySubPath"
}
]
}
chart.value values
deployment = chart.resources(kind: "Deployment").first
containers = deployment["spec"]["template"]["spec"]["containers"]
mainContainer = containers.find{ |c| c["name"] == "common-test" }
volumeMount = mainContainer["volumeMounts"].find{ |v| v["name"] == "data" }
refute_nil(volumeMount)
assert_equal("mySubPath", volumeMount["subPath"])
end
end
end
end
+6 -213
View File
@@ -12,7 +12,12 @@ class Test < ChartTest
end
it 'accepts integer as value' do
chart.value replicas: 3
values = {
controller: {
replicas: 3
}
}
chart.value values
deployment = chart.resources(kind: "Deployment").first
assert_equal(3, deployment["spec"]["replicas"])
end
@@ -100,217 +105,5 @@ class Test < ChartTest
refute_nil(additionalContainer)
end
end
describe 'pod::persistence' do
it 'multiple volumes' do
values = {
persistence: {
cache: {
enabled: true,
emptyDir: {
enabled: true
}
},
config: {
enabled: true,
existingClaim: "configClaim",
emptyDir: {
enabled: false
}
},
data: {
enabled: true,
existingClaim: "dataClaim"
}
}
}
chart.value values
deployment = chart.resources(kind: "Deployment").first
volumes = deployment["spec"]["template"]["spec"]["volumes"]
volume = volumes.find{ |v| v["name"] == "cache"}
refute_nil(volume)
volume = volumes.find{ |v| v["name"] == "config"}
refute_nil(volume)
assert_equal('configClaim', volume["persistentVolumeClaim"]["claimName"])
volume = volumes.find{ |v| v["name"] == "data"}
refute_nil(volume)
assert_equal('dataClaim', volume["persistentVolumeClaim"]["claimName"])
end
it 'default nameSuffix' do
values = {
persistence: {
config: {
enabled: true,
emptyDir: {
enabled: false
}
}
}
}
chart.value values
deployment = chart.resources(kind: "Deployment").first
volumes = deployment["spec"]["template"]["spec"]["volumes"]
volume = volumes.find{ |v| v["name"] == "config"}
refute_nil(volume)
assert_equal('common-test-config', volume["persistentVolumeClaim"]["claimName"])
end
it 'custom nameSuffix' do
values = {
persistence: {
config: {
enabled: true,
nameSuffix: "test",
emptyDir: {
enabled: false
}
}
}
}
chart.value values
deployment = chart.resources(kind: "Deployment").first
volumes = deployment["spec"]["template"]["spec"]["volumes"]
volume = volumes.find{ |v| v["name"] == "config"}
refute_nil(volume)
assert_equal('common-test-test', volume["persistentVolumeClaim"]["claimName"])
end
it 'no nameSuffix' do
values = {
persistence: {
config: {
enabled: true,
nameSuffix: "-",
emptyDir: {
enabled: false
}
}
}
}
chart.value values
deployment = chart.resources(kind: "Deployment").first
volumes = deployment["spec"]["template"]["spec"]["volumes"]
volume = volumes.find{ |v| v["name"] == "config"}
refute_nil(volume)
assert_equal('common-test', volume["persistentVolumeClaim"]["claimName"])
end
end
describe 'pod::persistence::emptyDir' do
it 'can be configured' do
values = {
persistence: {
config: {
enabled: true,
emptyDir: {
enabled: true
}
}
}
}
chart.value values
deployment = chart.resources(kind: "Deployment").first
volumes = deployment["spec"]["template"]["spec"]["volumes"]
volume = volumes.find{ |v| v["name"] == "config"}
refute_nil(volume)
assert_equal(Hash.new, volume["emptyDir"])
end
it 'medium can be configured' do
values = {
persistence: {
config: {
enabled: true,
emptyDir: {
enabled: true,
medium: "memory"
}
}
}
}
chart.value values
deployment = chart.resources(kind: "Deployment").first
volumes = deployment["spec"]["template"]["spec"]["volumes"]
volume = volumes.find{ |v| v["name"] == "config"}
refute_nil(volume)
assert_equal("memory", volume["emptyDir"]["medium"])
end
it 'sizeLimit can be configured' do
values = {
persistence: {
config: {
enabled: true,
emptyDir: {
enabled: true,
medium: "memory",
sizeLimit: "1Gi"
}
}
}
}
chart.value values
deployment = chart.resources(kind: "Deployment").first
volumes = deployment["spec"]["template"]["spec"]["volumes"]
volume = volumes.find{ |v| v["name"] == "config"}
refute_nil(volume)
assert_equal("1Gi", volume["emptyDir"]["sizeLimit"])
end
end
describe 'pod::hostPathMounts' do
it 'multiple volumes' do
values = {
hostPathMounts: [
{
name: "data",
enabled: true,
mountPath: "/data",
hostPath: "/tmp1"
},
{
name: "config",
enabled: true,
mountPath: "/config",
hostPath: "/tmp2"
}
]
}
chart.value values
deployment = chart.resources(kind: "Deployment").first
volumes = deployment["spec"]["template"]["spec"]["volumes"]
volume = volumes.find{ |v| v["name"] == "hostpathmounts-data"}
refute_nil(volume)
assert_equal('/tmp1', volume["hostPath"]["path"])
volume = volumes.find{ |v| v["name"] == "hostpathmounts-config"}
refute_nil(volume)
assert_equal('/tmp2', volume["hostPath"]["path"])
end
it 'emptyDir can be enabled' do
values = {
hostPathMounts: [
{
name: "data",
enabled: true,
emptyDir: true,
mountPath: "/data"
}
]
}
chart.value values
deployment = chart.resources(kind: "Deployment").first
volumes = deployment["spec"]["template"]["spec"]["volumes"]
volume = volumes.find{ |v| v["name"] == "hostpathmounts-data"}
refute_nil(volume)
assert_equal(Hash.new, volume["emptyDir"])
end
end
end
end
+44 -46
View File
@@ -5,13 +5,13 @@ class Test < ChartTest
@@chart = Chart.new('charts/library/common-test')
describe @@chart.name do
describe 'configmap::portal-defaults' do
describe 'portal::configmap::defaults' do
it 'no configmap exists by default' do
configmap = chart.resources(kind: "ConfigMap").first
assert_nil(configmap)
end
it 'creates configmap whe enabled' do
it 'creates configmap when enabled' do
values = {
portal: {
enabled: true
@@ -65,7 +65,7 @@ class Test < ChartTest
assert_equal("443", configmap["data"]["port"])
end
it 'uses protocol "https" by default' do
it 'uses protocol "http" by default' do
values = {
portal: {
enabled: true
@@ -78,7 +78,7 @@ class Test < ChartTest
}
chart.value values
configmap = chart.resources(kind: "ConfigMap").first
assert_equal("https", configmap["data"]["protocol"])
assert_equal("http", configmap["data"]["protocol"])
end
it 'uses path "/" by default' do
@@ -98,7 +98,7 @@ class Test < ChartTest
end
end
describe 'configmap::portal-overrides' do
describe 'portal::configmap::overrides' do
it 'ingressPort can be overridden' do
values = {
portal: {
@@ -151,7 +151,7 @@ class Test < ChartTest
end
end
describe 'configmap::portal-nodePort' do
describe 'portal::configmap::nodeport' do
it 'nodePort host defaults to "$node_ip"' do
values = {
portal: {
@@ -162,14 +162,16 @@ class Test < ChartTest
enabled: false
}
},
services: {
service: {
main: {
type: "NodePort",
port: {
nodePort: 666
type: "NodePort",
ports: {
main: {
nodePort: 666
}
}
}
}
}
}
chart.value values
configmap = chart.resources(kind: "ConfigMap").first
@@ -181,18 +183,17 @@ class Test < ChartTest
portal: {
enabled: true
},
ingress: {
service: {
main: {
enabled: false
type: "NodePort",
ports: {
main: {
enabled: true,
port: 8080,
nodePort: 666
}
}
}
},
services: {
main: {
type: "NodePort",
port: {
nodePort: 666
}
}
}
}
chart.value values
@@ -205,24 +206,23 @@ class Test < ChartTest
portal: {
enabled: true
},
ingress: {
service: {
main: {
enabled: false
type: "NodePort",
ports: {
main: {
enabled: true,
port: 8080,
nodePort: 666,
protocol: "HTTPS"
}
}
}
},
services: {
main: {
type: "NodePort",
port: {
nodePort: 666,
protocol: "HTTPS"
}
}
}
}
chart.value values
configmap = chart.resources(kind: "ConfigMap").first
assert_equal(values[:services][:main][:port][:protocol], configmap["data"]["protocol"])
assert_equal("https", configmap["data"]["protocol"])
end
it 'uses nodeport port protocol as protocol (HTTP)' do
@@ -230,28 +230,26 @@ class Test < ChartTest
portal: {
enabled: true
},
ingress: {
service: {
main: {
enabled: false
type: "NodePort",
ports: {
main: {
enabled: true,
nodePort: 666,
protocol: "HTTP"
}
}
}
},
services: {
main: {
type: "NodePort",
port: {
nodePort: 666,
protocol: "HTTP"
}
}
}
}
chart.value values
configmap = chart.resources(kind: "ConfigMap").first
assert_equal(values[:services][:main][:port][:protocol], configmap["data"]["protocol"])
assert_equal("http", configmap["data"]["protocol"])
end
end
describe 'configmap::portal-Ingress' do
describe 'portal::configmap::ingress' do
it 'uses ingress host' do
values = {
portal: {
+2 -16
View File
@@ -24,7 +24,7 @@ class Test < ChartTest
persistence: {
config: {
enabled: true,
nameSuffix: 'customSuffix'
nameOverride: 'customSuffix'
}
}
}
@@ -33,26 +33,12 @@ class Test < ChartTest
refute_nil(pvc)
end
it 'name can be overridden by nameOverride' do
values = {
persistence: {
config: {
enabled: true,
nameOverride: 'customname'
}
}
}
chart.value values
pvc = chart.resources(kind: "PersistentVolumeClaim").find{ |s| s["metadata"]["name"] == "customname" }
refute_nil(pvc)
end
it 'nameSuffix can be skipped' do
values = {
persistence: {
config: {
enabled: true,
nameSuffix: '-'
nameOverride: '-'
}
}
}
+151 -84
View File
@@ -6,10 +6,25 @@ class Test < ChartTest
describe @@chart.name do
describe 'service::ports settings' do
baseValues = {
service: {
main: {
ports: {
main: {
port: 8080
}
}
}
}
}
default_name = 'main'
default_port = 8080
it 'defaults to name "servicename" on port 8080' do
it 'defaults to name "http" on port 8080' do
values = baseValues
chart.value values
service = chart.resources(kind: "Service").find{ |s| s["metadata"]["name"] == "common-test" }
refute_nil(service)
assert_equal(default_port, service["spec"]["ports"].first["port"])
@@ -23,72 +38,102 @@ class Test < ChartTest
assert_equal(default_name, mainContainer["ports"].first["name"])
end
it 'port name can be overridden' do
values = {
services: {
it 'port name can be set' do
values = baseValues.deep_merge_override({
service: {
main: {
port: {
name: "server",
},
},
},
}
ports: {
main: {
enabled: false
},
server: {
enabled: true,
port: 8080
}
}
}
}
})
chart.value values
service = chart.resources(kind: "Service").find{ |s| s["metadata"]["name"] == "common-test" }
refute_nil(service)
assert_equal(default_port, service["spec"]["ports"].first["port"])
assert_equal(values[:services][:main][:port][:name], service["spec"]["ports"].first["targetPort"])
assert_equal(values[:services][:main][:port][:name], service["spec"]["ports"].first["name"])
assert_equal('server', service["spec"]["ports"].first["targetPort"])
assert_equal('server', service["spec"]["ports"].first["name"])
deployment = chart.resources(kind: "Deployment").first
containers = deployment["spec"]["template"]["spec"]["containers"]
mainContainer = containers.find{ |c| c["name"] == "common-test" }
assert_equal(default_port, mainContainer["ports"].first["containerPort"])
assert_equal(values[:services][:main][:port][:name], mainContainer["ports"].first["name"])
assert_equal('server', mainContainer["ports"].first["name"])
end
it 'name suffix can be overridden' do
values = baseValues.deep_merge_override({
service: {
main: {
nameOverride: 'http'
}
}
})
chart.value values
service = chart.resources(kind: "Service").find{ |s| s["metadata"]["name"] == "common-test-#{values[:service][:main][:nameOverride]}" }
refute_nil(service)
end
it 'targetPort can be overridden' do
values = {
services: {
values = baseValues.deep_merge_override({
service: {
main: {
port: {
targetPort: 80,
},
},
},
}
ports: {
main: {
targetPort: 80
}
}
}
}
})
chart.value values
service = chart.resources(kind: "Service").find{ |s| s["metadata"]["name"] == "common-test" }
refute_nil(service)
assert_equal(default_port, service["spec"]["ports"].first["port"])
assert_equal(values[:services][:main][:port][:targetPort], service["spec"]["ports"].first["targetPort"])
assert_equal(80, service["spec"]["ports"].first["targetPort"])
assert_equal(default_name, service["spec"]["ports"].first["name"])
deployment = chart.resources(kind: "Deployment").first
containers = deployment["spec"]["template"]["spec"]["containers"]
mainContainer = containers.find{ |c| c["name"] == "common-test" }
assert_equal(values[:services][:main][:port][:targetPort], mainContainer["ports"].first["containerPort"])
assert_equal(80, mainContainer["ports"].first["containerPort"])
assert_equal(default_name, mainContainer["ports"].first["name"])
end
it 'targetPort cannot be a named port' do
values = {
services: {
values = baseValues.deep_merge_override({
service: {
main: {
port: {
targetPort: "test",
},
},
},
}
ports: {
main: {
targetPort: 'test'
}
}
}
}
})
chart.value values
exception = assert_raises HelmCompileError do
chart.execute_helm_template!
end
assert_match("Our charts do not support named ports for targetPort. (port name #{default_name}, targetPort #{values[:services][:main][:port][:targetPort]})", exception.message)
assert_match("Our charts do not support named ports for targetPort. (port name #{default_name}, targetPort test)", exception.message)
end
it 'protocol defaults to TCP' do
values = baseValues
chart.value values
service = chart.resources(kind: "Service").find{ |s| s["metadata"]["name"] == "common-test" }
refute_nil(service)
assert_equal("TCP", service["spec"]["ports"].first["protocol"])
@@ -100,16 +145,19 @@ class Test < ChartTest
end
it 'protocol is TCP when set to TCP explicitly' do
values = {
services: {
values = baseValues.deep_merge_override({
service: {
main: {
port: {
protocol: "TCP",
},
},
},
}
ports: {
main: {
protocol: 'TCP'
}
}
}
}
})
chart.value values
service = chart.resources(kind: "Service").find{ |s| s["metadata"]["name"] == "common-test" }
refute_nil(service)
assert_equal("TCP", service["spec"]["ports"].first["protocol"])
@@ -121,16 +169,19 @@ class Test < ChartTest
end
it 'protocol is TCP when set to HTTP explicitly' do
values = {
services: {
values = baseValues.deep_merge_override({
service: {
main: {
port: {
protocol: "HTTP",
},
},
},
}
ports: {
main: {
protocol: 'HTTP'
}
}
}
}
})
chart.value values
service = chart.resources(kind: "Service").find{ |s| s["metadata"]["name"] == "common-test" }
refute_nil(service)
assert_equal("TCP", service["spec"]["ports"].first["protocol"])
@@ -142,16 +193,19 @@ class Test < ChartTest
end
it 'protocol is TCP when set to HTTPS explicitly' do
values = {
services: {
values = baseValues.deep_merge_override({
service: {
main: {
port: {
protocol: "HTTPS",
},
},
},
}
ports: {
main: {
protocol: 'HTTPS'
}
}
}
}
})
chart.value values
service = chart.resources(kind: "Service").find{ |s| s["metadata"]["name"] == "common-test" }
refute_nil(service)
assert_equal("TCP", service["spec"]["ports"].first["protocol"])
@@ -163,16 +217,19 @@ class Test < ChartTest
end
it 'protocol is UDP when set to UDP explicitly' do
values = {
services: {
values = baseValues.deep_merge_override({
service: {
main: {
port: {
protocol: "UDP",
},
},
},
}
ports: {
main: {
protocol: 'UDP'
}
}
}
}
})
chart.value values
service = chart.resources(kind: "Service").find{ |s| s["metadata"]["name"] == "common-test" }
refute_nil(service)
assert_equal("UDP", service["spec"]["ports"].first["protocol"])
@@ -184,35 +241,45 @@ class Test < ChartTest
end
it 'No annotations get set by default' do
service = chart.resources(kind: "Service").find{ |s| s["metadata"]["name"] == "common-test" }
refute_nil(service)
assert_nil(service["metadata"]["annotations"])
end
it 'TCP port protocol does not set annotations' do
values = {
services: {
main: {
port: {
protocol: 'TCP'
}
}
}
}
values = baseValues
chart.value values
service = chart.resources(kind: "Service").find{ |s| s["metadata"]["name"] == "common-test" }
refute_nil(service)
assert_nil(service["metadata"]["annotations"])
end
it 'HTTPS port protocol sets traefik HTTPS annotation' do
values = {
services: {
it 'TCP port protocol does not set annotations' do
values = baseValues.deep_merge_override({
service: {
main: {
port: {
protocol: 'HTTPS'
ports: {
main: {
protocol: 'TCP'
}
}
}
}
}
})
chart.value values
service = chart.resources(kind: "Service").find{ |s| s["metadata"]["name"] == "common-test" }
refute_nil(service)
assert_nil(service["metadata"]["annotations"])
end
it 'HTTPS port protocol sets traefik HTTPS annotation' do
values = baseValues.deep_merge_override({
service: {
main: {
ports: {
main: {
protocol: 'HTTPS'
}
}
}
}
})
chart.value values
service = chart.resources(kind: "Service").find{ |s| s["metadata"]["name"] == "common-test" }
refute_nil(service)