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 'container::resources' do
|
2021-09-28 22:11:52 +00:00
|
|
|
it 'specific resources added by default' do
|
2021-09-28 13:11:36 +00:00
|
|
|
deployment = chart.resources(kind: "Deployment").first
|
|
|
|
containers = deployment["spec"]["template"]["spec"]["containers"]
|
|
|
|
mainContainer = containers.find{ |c| c["name"] == "common-test" }
|
2021-09-28 22:11:52 +00:00
|
|
|
assert_equal({"limits"=>{"cpu"=>"4000m", "memory"=>"8Gi"}, "requests"=>{"cpu"=>"10m", "memory"=>"50Mi"}}, mainContainer["resources"])
|
2021-09-28 13:11:36 +00:00
|
|
|
end
|
|
|
|
it 'resources can be added' do
|
|
|
|
values = {
|
|
|
|
resources: {
|
|
|
|
testresourcename: "testresourcevalue"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
chart.value values
|
|
|
|
deployment = chart.resources(kind: "Deployment").first
|
|
|
|
containers = deployment["spec"]["template"]["spec"]["containers"]
|
|
|
|
mainContainer = containers.find{ |c| c["name"] == "common-test" }
|
2021-09-28 22:11:52 +00:00
|
|
|
assert_equal({"limits"=>{"cpu"=>"4000m", "memory"=>"8Gi"}, "requests"=>{"cpu"=>"10m", "memory"=>"50Mi"}, "testresourcename"=>"testresourcevalue"}, mainContainer["resources"])
|
2021-09-28 13:11:36 +00:00
|
|
|
end
|
|
|
|
it 'resources.limits can be added' do
|
|
|
|
values = {
|
|
|
|
resources: {
|
|
|
|
limits: {
|
|
|
|
testlimitkey: "testlimitvalue"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
chart.value values
|
|
|
|
deployment = chart.resources(kind: "Deployment").first
|
|
|
|
containers = deployment["spec"]["template"]["spec"]["containers"]
|
|
|
|
mainContainer = containers.find{ |c| c["name"] == "common-test" }
|
2021-09-28 22:11:52 +00:00
|
|
|
assert_equal({"limits"=>{"cpu"=>"4000m", "memory"=>"8Gi", "testlimitkey"=>"testlimitvalue"}, "requests"=>{"cpu"=>"10m", "memory"=>"50Mi"}}, mainContainer["resources"])
|
2021-09-28 13:11:36 +00:00
|
|
|
end
|
|
|
|
it 'resources and resources.limits can both be added' do
|
|
|
|
values = {
|
|
|
|
resources: {
|
|
|
|
testresourcekey: "testresourcevalue",
|
|
|
|
limits: {
|
|
|
|
testlimitkey: "testlimitvalue"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
chart.value values
|
|
|
|
deployment = chart.resources(kind: "Deployment").first
|
|
|
|
containers = deployment["spec"]["template"]["spec"]["containers"]
|
|
|
|
mainContainer = containers.find{ |c| c["name"] == "common-test" }
|
2021-09-28 22:11:52 +00:00
|
|
|
assert_equal({"limits"=>{"cpu"=>"4000m", "memory"=>"8Gi", "testlimitkey"=>"testlimitvalue"}, "requests"=>{"cpu"=>"10m", "memory"=>"50Mi"}, "testresourcekey"=>"testresourcevalue"}, mainContainer["resources"])
|
2021-09-28 13:11:36 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
describe 'container::resources-scaleGPU' do
|
|
|
|
it 'scaleGPU can be set' do
|
|
|
|
values = {
|
|
|
|
scaleGPU: {
|
|
|
|
intelblabla: 1
|
|
|
|
}
|
|
|
|
}
|
|
|
|
chart.value values
|
|
|
|
deployment = chart.resources(kind: "Deployment").first
|
|
|
|
containers = deployment["spec"]["template"]["spec"]["containers"]
|
|
|
|
mainContainer = containers.find{ |c| c["name"] == "common-test" }
|
2021-09-28 22:11:52 +00:00
|
|
|
assert_equal({"limits"=>{"cpu"=>"4000m", "intelblabla"=>1, "memory"=>"8Gi"}, "requests"=>{"cpu"=>"10m", "memory"=>"50Mi"}}, mainContainer["resources"])
|
2021-09-28 13:11:36 +00:00
|
|
|
end
|
|
|
|
it 'scaleGPU can be combined with resources and resource values' do
|
|
|
|
values = {
|
|
|
|
resources: {
|
|
|
|
testresourcekey: "testresourcevalue",
|
|
|
|
limits: {
|
|
|
|
testlimitkey: "testlimitvalue"
|
|
|
|
}
|
|
|
|
},
|
|
|
|
scaleGPU: {
|
|
|
|
intelblabla: 1
|
|
|
|
}
|
|
|
|
}
|
|
|
|
chart.value values
|
|
|
|
deployment = chart.resources(kind: "Deployment").first
|
|
|
|
containers = deployment["spec"]["template"]["spec"]["containers"]
|
|
|
|
mainContainer = containers.find{ |c| c["name"] == "common-test" }
|
2021-09-28 22:11:52 +00:00
|
|
|
assert_equal({"limits"=>{"cpu"=>"4000m", "intelblabla"=>1, "memory"=>"8Gi", "testlimitkey"=>"testlimitvalue"}, "requests"=>{"cpu"=>"10m", "memory"=>"50Mi"}, "testresourcekey"=>"testresourcevalue"}, mainContainer["resources"])
|
2021-09-28 13:11:36 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|