MCPcopy Create free account
hub / github.com/Qovery/engine / test_vpa

Function test_vpa

lib-engine/src/helm.rs:1180–1256  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1178
1179 #[test]
1180 fn test_vpa() {
1181 let vpa_config = VpaConfig {
1182 target_ref: VpaTargetRef {
1183 api_version: VpaTargetRefApiVersion::AppsV1,
1184 kind: VpaTargetRefKind::Deployment,
1185 name: "test".to_string(),
1186 },
1187 container_policy: VpaContainerPolicy {
1188 name: "test".to_string(),
1189 min_allowed_cpu: Some(KubernetesCpuResourceUnit::MilliCpu(100)),
1190 min_allowed_memory: Some(KubernetesMemoryResourceUnit::MebiByte(100)),
1191 max_allowed_cpu: Some(KubernetesCpuResourceUnit::MilliCpu(100)),
1192 max_allowed_memory: Some(KubernetesMemoryResourceUnit::MebiByte(100)),
1193 },
1194 customer_helm_chart_override: None,
1195 };
1196
1197 // install
1198 let chart = ChartInfo::new_from_release_name("vpa_test", "qovery");
1199 let common_chart_vpa = CommonChartVpa::new("./".to_string(), vec![vpa_config.clone()]);
1200 let common_chart = CommonChart::new(chart, None, Some(common_chart_vpa.clone()));
1201 let vpa_chart = common_chart.get_vpa_chart_info(Some(common_chart_vpa));
1202
1203 assert_eq!(vpa_chart.name, "vpa-vpa_test".to_string());
1204 assert_eq!(vpa_chart.path, "./common/charts/vertical-pod-autoscaler-configs");
1205 assert_eq!(vpa_chart.action, super::HelmAction::Deploy);
1206
1207 // test Helm generated config
1208 let vpa_config_string = ChartInfo::generate_vpa_helm_config(vec![vpa_config.clone()]);
1209 assert_eq!(vpa_config_string, "vpa_config:\n- targetRefName: test\n targetRefApiVersion: apps/v1\n targetRefKind: Deployment\n containerName: test\n minAllowedCpu: 100m\n minAllowedMemory: 100Mi\n maxAllowedCpu: 100m\n maxAllowedMemory: 100Mi\n controlledResources:\n - cpu\n - memory\n".to_string());
1210
1211 // uninstall vpa chart if nothing is set
1212 let vpa_chart = common_chart.get_vpa_chart_info(None);
1213 assert_eq!(vpa_chart.action, super::HelmAction::Destroy);
1214
1215 // check vpa all resources are deployed
1216 let vpa_config_all_resources = VpaConfigHelmChart::new_from_vpa_config(vpa_config);
1217 assert_eq!(format!("{:?}", vpa_config_all_resources.controlled_resources), "[Cpu, Memory]");
1218
1219 // only vpa cpu set
1220 let vpa_config_no_mem = VpaConfig {
1221 target_ref: VpaTargetRef {
1222 api_version: VpaTargetRefApiVersion::AppsV1,
1223 kind: VpaTargetRefKind::Deployment,
1224 name: "test".to_string(),
1225 },
1226 container_policy: VpaContainerPolicy {
1227 name: "test".to_string(),
1228 min_allowed_cpu: Some(KubernetesCpuResourceUnit::MilliCpu(100)),
1229 min_allowed_memory: None,
1230 max_allowed_cpu: Some(KubernetesCpuResourceUnit::MilliCpu(100)),
1231 max_allowed_memory: None,
1232 },
1233 customer_helm_chart_override: None,
1234 };
1235 let vpa_config = VpaConfigHelmChart::new_from_vpa_config(vpa_config_no_mem);
1236 assert_eq!(format!("{:?}", vpa_config.controlled_resources), "[Cpu]");
1237

Callers

nothing calls this directly

Calls 2

get_vpa_chart_infoMethod · 0.80
cloneMethod · 0.45

Tested by

no test coverage detected