From 25a04096e86652197e8b789da558a6a7ef8a092d Mon Sep 17 00:00:00 2001 From: hasheddan Date: Fri, 13 Nov 2020 10:29:21 -0600 Subject: [PATCH 1/2] Match pod resource metrics to pod not container Update node resource metrics e2e tests to match pod metrics to pod instread of containers. Signed-off-by: hasheddan --- test/e2e_node/resource_metrics_test.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/test/e2e_node/resource_metrics_test.go b/test/e2e_node/resource_metrics_test.go index f6a076bf66e..b39bc18e050 100644 --- a/test/e2e_node/resource_metrics_test.go +++ b/test/e2e_node/resource_metrics_test.go @@ -88,12 +88,12 @@ var _ = framework.KubeDescribe("ResourceMetricsAPI [NodeFeature:ResourceMetrics] fmt.Sprintf("%s::%s::%s", f.Namespace.Name, pod1, "busybox-container"): boundedSample(10*e2evolume.Kb, 80*e2evolume.Mb), }), - "pod_cpu_usage_seconds_total": gstruct.MatchElements(containerID, gstruct.IgnoreExtras, gstruct.Elements{ + "pod_cpu_usage_seconds_total": gstruct.MatchElements(podID, gstruct.IgnoreExtras, gstruct.Elements{ fmt.Sprintf("%s::%s", f.Namespace.Name, pod0): boundedSample(0, 100), fmt.Sprintf("%s::%s", f.Namespace.Name, pod1): boundedSample(0, 100), }), - "pod_memory_working_set_bytes": gstruct.MatchAllElements(containerID, gstruct.Elements{ + "pod_memory_working_set_bytes": gstruct.MatchAllElements(podID, gstruct.Elements{ fmt.Sprintf("%s::%s", f.Namespace.Name, pod0): boundedSample(10*e2evolume.Kb, 80*e2evolume.Mb), fmt.Sprintf("%s::%s", f.Namespace.Name, pod1): boundedSample(10*e2evolume.Kb, 80*e2evolume.Mb), }), @@ -129,6 +129,11 @@ func nodeID(element interface{}) string { return "" } +func podID(element interface{}) string { + el := element.(*model.Sample) + return fmt.Sprintf("%s::%s", el.Metric["namespace"], el.Metric["pod"]) +} + func containerID(element interface{}) string { el := element.(*model.Sample) return fmt.Sprintf("%s::%s::%s", el.Metric["namespace"], el.Metric["pod"], el.Metric["container"]) From 56c104a4407ed7f6317c9579fcc0c4b154be30d6 Mon Sep 17 00:00:00 2001 From: hasheddan Date: Fri, 13 Nov 2020 11:23:15 -0600 Subject: [PATCH 2/2] Relax matching on pod_memory_working_set_bytes metrics Relaxes matching of pod_memory_working_set_bytes metric so that we won't error due to presence of other pods. Signed-off-by: hasheddan --- test/e2e_node/resource_metrics_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/e2e_node/resource_metrics_test.go b/test/e2e_node/resource_metrics_test.go index b39bc18e050..f17065f4197 100644 --- a/test/e2e_node/resource_metrics_test.go +++ b/test/e2e_node/resource_metrics_test.go @@ -93,7 +93,7 @@ var _ = framework.KubeDescribe("ResourceMetricsAPI [NodeFeature:ResourceMetrics] fmt.Sprintf("%s::%s", f.Namespace.Name, pod1): boundedSample(0, 100), }), - "pod_memory_working_set_bytes": gstruct.MatchAllElements(podID, gstruct.Elements{ + "pod_memory_working_set_bytes": gstruct.MatchElements(podID, gstruct.IgnoreExtras, gstruct.Elements{ fmt.Sprintf("%s::%s", f.Namespace.Name, pod0): boundedSample(10*e2evolume.Kb, 80*e2evolume.Mb), fmt.Sprintf("%s::%s", f.Namespace.Name, pod1): boundedSample(10*e2evolume.Kb, 80*e2evolume.Mb), }),