diff --git a/test/new-e2e/tests/apm/docker_test.go b/test/new-e2e/tests/apm/docker_test.go index cf78c1842074a6..fb1761f3b00777 100644 --- a/test/new-e2e/tests/apm/docker_test.go +++ b/test/new-e2e/tests/apm/docker_test.go @@ -113,6 +113,18 @@ func (s *DockerFakeintakeSuite) TestAutoVersionStats() { }, 2*time.Minute, 10*time.Second, "Failed finding version tags") } +func (s *DockerFakeintakeSuite) TestIsTraceRootTag() { + err := s.Env().FakeIntake.Client().FlushServerAndResetAggregators() + s.Require().NoError(err) + + service := fmt.Sprintf("tracegen-auto-is-trace-root-tag-%s", s.transport) + defer waitTracegenShutdown(&s.Suite, s.Env().FakeIntake) + defer runTracegenDocker(s.Env().RemoteHost, service, tracegenCfg{transport: s.transport})() + s.EventuallyWithTf(func(c *assert.CollectT) { + testIsTraceRootTag(s.T(), c, s.Env().FakeIntake) + }, 2*time.Minute, 10*time.Second, "Failed finding is_trace_root tag") +} + func (s *DockerFakeintakeSuite) TestStatsForService() { err := s.Env().FakeIntake.Client().FlushServerAndResetAggregators() s.Require().NoError(err) diff --git a/test/new-e2e/tests/apm/tests.go b/test/new-e2e/tests/apm/tests.go index a3214c469ab079..5a45b6c0e5318c 100644 --- a/test/new-e2e/tests/apm/tests.go +++ b/test/new-e2e/tests/apm/tests.go @@ -110,6 +110,25 @@ func testAutoVersionStats(t *testing.T, c *assert.CollectT, intake *components.F } } +func testIsTraceRootTag(t *testing.T, c *assert.CollectT, intake *components.FakeIntake) { + t.Helper() + stats, err := intake.Client().GetAPMStats() + assert.NoError(c, err) + assert.NotEmpty(c, stats) + t.Log("Got apm stats:", spew.Sdump(stats)) + for _, p := range stats { + for _, s := range p.StatsPayload.Stats { + t.Log("Client Payload:", spew.Sdump(s)) + for _, b := range s.Stats { + for _, cs := range b.Stats { + t.Logf("Got IsTraceRoot: %v", cs.GetIsTraceRoot()) + assert.Equal(t, trace.TraceRootFlag_TRUE, cs.GetIsTraceRoot()) + } + } + } + } +} + func getContainerTags(t *testing.T, tp *trace.TracerPayload) (map[string]string, bool) { ctags, ok := tp.Tags["_dd.tags.container"] if !ok { diff --git a/test/new-e2e/tests/apm/vm_test.go b/test/new-e2e/tests/apm/vm_test.go index 145223e6683811..1870590cb0b795 100644 --- a/test/new-e2e/tests/apm/vm_test.go +++ b/test/new-e2e/tests/apm/vm_test.go @@ -220,6 +220,29 @@ func (s *VMFakeintakeSuite) TestAutoVersionStats() { }, 3*time.Minute, 10*time.Second, "Failed finding stats") } +func (s *VMFakeintakeSuite) TestIsTraceRootTag() { + err := s.Env().FakeIntake.Client().FlushServerAndResetAggregators() + s.Require().NoError(err) + + service := fmt.Sprintf("tracegen-stats-%s", s.transport) + + // Wait for agent to be live + s.T().Log("Waiting for Trace Agent to be live.") + s.Require().NoError(waitRemotePort(s, 8126)) + + // Run Trace Generator + s.T().Log("Starting Trace Generator.") + defer waitTracegenShutdown(&s.Suite, s.Env().FakeIntake) + shutdown := runTracegenDocker(s.Env().RemoteHost, service, tracegenCfg{transport: s.transport}) + defer shutdown() + + s.EventuallyWithTf(func(c *assert.CollectT) { + s.logStatus() + testIsTraceRootTag(s.T(), c, s.Env().FakeIntake) + s.logJournal() + }, 3*time.Minute, 10*time.Second, "Failed finding stats") +} + func (s *VMFakeintakeSuite) TestBasicTrace() { err := s.Env().FakeIntake.Client().FlushServerAndResetAggregators() s.Require().NoError(err)