Skip to content

Commit

Permalink
add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
eloytoro committed Feb 3, 2025
1 parent 53ebb01 commit 82e210a
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions internal/controller/datadogagent/feature/apm/feature_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,17 @@ func TestAPMFeature(t *testing.T) {
}
},
},
{
Name: "error tracking standalone enabled",
DDA: v2alpha1test.NewDatadogAgentBuilder().
WithAPMEnabled(true).
WithAPMHostPortEnabled(false, apiutils.NewInt32Pointer(8126)).
WithAPMUDSEnabled(true, apmSocketHostPath).
WithErrorTrackingStandalone(true).
Build(),
WantConfigure: true,
Agent: testAgentErrorTrackingStandalone(),
},
}

tests.Run(t, buildAPMFeature)
Expand Down Expand Up @@ -444,6 +455,35 @@ func testAgentHostPortOnly() *test.ComponentTest {
)
}

func testAgentErrorTrackingStandalone() *test.ComponentTest {
return test.NewDefaultComponentTest().WithWantFunc(
func(t testing.TB, mgrInterface feature.PodTemplateManagers) {
mgr := mgrInterface.(*fake.PodTemplateManagers)

agentEnvs := mgr.EnvVarMgr.EnvVarsByC[apicommon.TraceAgentContainerName]
expectedAgentEnvs := []*corev1.EnvVar{
{
Name: apicommon.DDAPMEnabled,
Value: "true",
},
{
Name: apicommon.DDAPMReceiverSocket,
Value: apmSocketLocalPath,
},
{
Name: apicommon.DDAPMErrorTrackingStandaloneEnabled,
Value: "true",
},
}
assert.True(
t,
apiutils.IsEqualStruct(agentEnvs, expectedAgentEnvs),
"Trace Agent ENVs \ndiff = %s", cmp.Diff(agentEnvs, expectedAgentEnvs),
)
},
)
}

func testAgentUDSOnly(agentContainerName apicommon.AgentContainerName) *test.ComponentTest {
return test.NewDefaultComponentTest().WithWantFunc(
func(t testing.TB, mgrInterface feature.PodTemplateManagers) {
Expand Down

0 comments on commit 82e210a

Please sign in to comment.