Skip to content

Commit

Permalink
only test the namespace workload-tracegen
Browse files Browse the repository at this point in the history
  • Loading branch information
AliDatadog committed Feb 27, 2024
1 parent 8ad567c commit ee14dcb
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 35 deletions.
6 changes: 1 addition & 5 deletions test/new-e2e/tests/containers/eks_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,7 @@ type eksSuite struct {
}

func TestEKSSuite(t *testing.T) {
suite.Run(t, &eksSuite{
k8sSuite: k8sSuite{
cgroupTests: true,
},
})
suite.Run(t, &eksSuite{k8sSuite: k8sSuite{}})
}

func (suite *eksSuite) SetupSuite() {
Expand Down
31 changes: 5 additions & 26 deletions test/new-e2e/tests/containers/k8s_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,7 @@ import (
const (
kubeNamespaceDogstatsWorkload = "workload-dogstatsd"
kubeNamespaceDogstatsStandaloneWorkload = "workload-dogstatsd-standalone"
kubeNamespaceTracegenCgroupV1Workload = "workload-tracegen-cgroupv1"
kubeNamespaceTracegenCgroupV2Workload = "workload-tracegen-cgroupv2"
kubeNamespaceTracegenWorkload = "workload-tracegen"
kubeDeploymentTracegenUDPWorkload = "tracegen-udp"
kubeDeploymentTracegenUDSWorkload = "tracegen-uds"
)
Expand All @@ -53,9 +52,6 @@ type k8sSuite struct {

K8sConfig *restclient.Config
K8sClient kubernetes.Interface

// cgroupTests is a flag to enable or disable cgroup-specific tests
cgroupTests bool
}

func (suite *k8sSuite) SetupSuite() {
Expand Down Expand Up @@ -1044,32 +1040,15 @@ func (suite *k8sSuite) podExec(namespace, pod, container string, cmd []string) (
return stdoutSb.String(), stderrSb.String(), nil
}

func (suite *k8sSuite) TestCgroupV1TraceOriginDetection() {
if !suite.cgroupTests {
return
}
// We use a nodeselector to schedule the pods on bottlerocket nodes that currently
// run with cgroupv1 now and use host cgroup namespace.
// We currently simply assume that they use cgroupv1.
suite.testTraceInNamespace(kubeNamespaceTracegenCgroupV1Workload)
}

func (suite *k8sSuite) TestCgroupV2TraceOriginDetection() {
if !suite.cgroupTests {
return
}
suite.testTraceInNamespace(kubeNamespaceTracegenCgroupV2Workload)
}

func (suite *k8sSuite) testTraceInNamespace(namespace string) {
func (suite *k8sSuite) TestTraces() {
deployments := []string{kubeDeploymentTracegenUDSWorkload, kubeDeploymentTracegenUDPWorkload}
for _, app := range deployments {
suite.testTrace(namespace, app)
suite.testTraceForDeployment(app)
}
}

// testTrace verifies that traces are tagged with container and pod tags.
func (suite *k8sSuite) testTrace(kubeNamespace, kubeDeployment string) {
func (suite *k8sSuite) testTraceForDeployment(kubeDeployment string) {
suite.EventuallyWithTf(func(c *assert.CollectT) {
traces, cerr := suite.Fakeintake.GetTraces()
require.NoErrorf(c, cerr, "Failed to query fake intake")
Expand All @@ -1090,7 +1069,7 @@ func (suite *k8sSuite) testTrace(kubeNamespace, kubeDeployment string) {
regexp.MustCompile(`^image_tag:main$`),
regexp.MustCompile(`^kube_container_name:` + kubeDeployment + `$`),
regexp.MustCompile(`^kube_deployment:` + kubeDeployment + `$`),
regexp.MustCompile(`^kube_namespace:` + kubeNamespace + `$`),
regexp.MustCompile(`^kube_namespace:` + kubeNamespaceTracegenWorkload + `$`),
regexp.MustCompile(`^kube_ownerref_kind:replicaset$`),
regexp.MustCompile(`^kube_ownerref_name:` + kubeDeployment + `-[[:alnum:]]+$`),
regexp.MustCompile(`^kube_replica_set:` + kubeDeployment + `-[[:alnum:]]+$`),
Expand Down
4 changes: 0 additions & 4 deletions test/new-e2e/tests/containers/kindvm_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,3 @@ func (suite *kindSuite) TestControlPlane() {
},
})
}

func (suite *kindSuite) TestTraceOriginDetection() {
suite.testTraceInNamespace("workload-tracegen")
}

0 comments on commit ee14dcb

Please sign in to comment.