From 88f03dc979e4d3b33db21905e8f5e5013f7e830a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9na=C3=AFc=20Huard?= Date: Mon, 16 Dec 2024 18:08:21 +0100 Subject: [PATCH] [incident-33304] Expect container tags on dogstatsd metrics (#32222) --- test/new-e2e/tests/containers/k8s_test.go | 41 +++++------------------ 1 file changed, 8 insertions(+), 33 deletions(-) diff --git a/test/new-e2e/tests/containers/k8s_test.go b/test/new-e2e/tests/containers/k8s_test.go index ce0a53578e40c..3c2b4c4e8b4d5 100644 --- a/test/new-e2e/tests/containers/k8s_test.go +++ b/test/new-e2e/tests/containers/k8s_test.go @@ -41,6 +41,7 @@ const ( kubeNamespaceDogstatsWorkload = "workload-dogstatsd" kubeNamespaceDogstatsStandaloneWorkload = "workload-dogstatsd-standalone" kubeNamespaceTracegenWorkload = "workload-tracegen" + kubeDeploymentDogstatsdUDP = "dogstatsd-udp" kubeDeploymentDogstatsdUDPOrigin = "dogstatsd-udp-origin-detection" kubeDeploymentDogstatsdUDS = "dogstatsd-uds" kubeDeploymentTracegenTCPWorkload = "tracegen-tcp" @@ -797,48 +798,22 @@ func (suite *k8sSuite) TestCPU() { func (suite *k8sSuite) TestDogstatsdInAgent() { // Test with UDS - suite.testDogstatsdContainerID(kubeNamespaceDogstatsWorkload, kubeDeploymentDogstatsdUDS) + suite.testDogstatsd(kubeNamespaceDogstatsWorkload, kubeDeploymentDogstatsdUDS) // Test with UDP + Origin detection - suite.testDogstatsdContainerID(kubeNamespaceDogstatsWorkload, kubeDeploymentDogstatsdUDPOrigin) + suite.testDogstatsd(kubeNamespaceDogstatsWorkload, kubeDeploymentDogstatsdUDPOrigin) // Test with UDP + DD_ENTITY_ID - suite.testDogstatsdPodUID(kubeNamespaceDogstatsWorkload) + suite.testDogstatsd(kubeNamespaceDogstatsWorkload, kubeDeploymentDogstatsdUDP) } func (suite *k8sSuite) TestDogstatsdStandalone() { // Test with UDS - suite.testDogstatsdContainerID(kubeNamespaceDogstatsStandaloneWorkload, kubeDeploymentDogstatsdUDS) + suite.testDogstatsd(kubeNamespaceDogstatsStandaloneWorkload, kubeDeploymentDogstatsdUDS) // Dogstatsd standalone does not support origin detection // Test with UDP + DD_ENTITY_ID - suite.testDogstatsdPodUID(kubeNamespaceDogstatsWorkload) + suite.testDogstatsd(kubeNamespaceDogstatsWorkload, kubeDeploymentDogstatsdUDP) } -func (suite *k8sSuite) testDogstatsdPodUID(kubeNamespace string) { - // Test dogstatsd origin detection with UDP + DD_ENTITY_ID - suite.testMetric(&testMetricArgs{ - Filter: testMetricFilterArgs{ - Name: "custom.metric", - Tags: []string{ - "^kube_deployment:dogstatsd-udp$", - "^kube_namespace:" + regexp.QuoteMeta(kubeNamespace) + "$", - }, - }, - Expect: testMetricExpectArgs{ - Tags: &[]string{ - `^kube_deployment:dogstatsd-udp$`, - "^kube_namespace:" + regexp.QuoteMeta(kubeNamespace) + "$", - `^kube_ownerref_kind:replicaset$`, - `^kube_ownerref_name:dogstatsd-udp-[[:alnum:]]+$`, - `^kube_qos:Burstable$`, - `^kube_replica_set:dogstatsd-udp-[[:alnum:]]+$`, - `^pod_name:dogstatsd-udp-[[:alnum:]]+-[[:alnum:]]+$`, - `^pod_phase:running$`, - `^series:`, - }, - }, - }) -} - -func (suite *k8sSuite) testDogstatsdContainerID(kubeNamespace, kubeDeployment string) { +func (suite *k8sSuite) testDogstatsd(kubeNamespace, kubeDeployment string) { suite.testMetric(&testMetricArgs{ Filter: testMetricFilterArgs{ Name: "custom.metric", @@ -853,7 +828,7 @@ func (suite *k8sSuite) testDogstatsdContainerID(kubeNamespace, kubeDeployment st `^container_name:dogstatsd$`, `^display_container_name:dogstatsd`, `^git.commit.sha:`, // org.opencontainers.image.revision docker image label - `^git.repository_url:https://github.com/DataDog/test-infra-definitions$`, // org.opencontainers.image.source docker image label + `^git.repository_url:https://github.com/DataDog/test-infra-definitions$`, // org.opencontainers.image.source docker image label `^image_id:ghcr.io/datadog/apps-dogstatsd@sha256:`, `^image_name:ghcr.io/datadog/apps-dogstatsd$`, `^image_tag:main$`,