Skip to content

Commit

Permalink
Update K8s tests
Browse files Browse the repository at this point in the history
  • Loading branch information
daniel-taf committed Aug 28, 2024
1 parent 9c468dc commit 717c1cb
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 2 deletions.
13 changes: 12 additions & 1 deletion test/new-e2e/tests/process/config/helm-template.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,17 @@ datadog:
processCollection: {{.ProcessCollection}}
processDiscovery: {{.ProcessDiscoveryCollection}}
containerCollection: {{.ContainerCollection}}
runInCoreAgent: {{.RunInCoreAgent}}
runInCoreAgent: false
networkMonitoring:
enabled: {{.NetworkPerformanceMonitoring}}

agents:
containers:
agent:
env:
- name: DD_PROCESS_CONFIG_RUN_IN_CORE_AGENT_ENABLED
value: {{.RunInCoreAgent}}
processAgent:
env:
- name: DD_PROCESS_CONFIG_RUN_IN_CORE_AGENT_ENABLED
value: {{.RunInCoreAgent}}
14 changes: 13 additions & 1 deletion test/new-e2e/tests/process/k8s_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ func TestK8sTestSuite(t *testing.T) {
}),
awskubernetes.WithAgentOptions(kubernetesagentparams.WithHelmValues(helmValues)),
)),
e2e.WithDevMode(),
}

e2e.Run(t, &K8sSuite{}, options...)
Expand Down Expand Up @@ -166,21 +167,30 @@ func (s *K8sSuite) TestProcessCheckInCoreAgent() {

assert.EventuallyWithT(t, func(*assert.CollectT) {
status := k8sAgentStatus(t, s.Env().KubernetesCluster)

// verify the standalone process-agent is not running
assert.NotEmpty(t, status.ProcessAgentStatus.Error, "status: %+v", status)
assert.Empty(t, status.ProcessAgentStatus.Expvars.Map.EnabledChecks)

// Verify the process component is running in the core agent
assert.ElementsMatch(t, []string{"process", "rtprocess"}, status.ProcessComponentStatus.Expvars.Map.EnabledChecks)
}, 2*time.Minute, 5*time.Second)

// Flush fake intake to remove any payloads which may have
s.Env().FakeIntake.Client().FlushServerAndResetAggregators()

var payloads []*aggregator.ProcessPayload
assert.EventuallyWithT(t, func(c *assert.CollectT) {
var err error
payloads, err = s.Env().FakeIntake.Client().GetProcesses()
assert.NoError(c, err, "failed to get process payloads from fakeintake")

// Wait for two payloads, as processes must be detected in two check runs to be returned
assert.GreaterOrEqual(c, len(payloads), 2, "fewer than 2 payloads returned")
}, 2*time.Minute, 10*time.Second)

assertProcessCollected(t, payloads, false, "stress-ng-cpu [run]")
assertContainersCollected(t, payloads, []string{"stress-ng"})
requireProcessNotCollected(t, payloads, "process-agent")
assertContainersNotCollected(t, payloads, []string{"process-agent"})
}

Expand All @@ -203,6 +213,7 @@ func (s *K8sSuite) TestProcessCheckInCoreAgentWithNPM() {
assert.EventuallyWithT(t, func(*assert.CollectT) {
status := k8sAgentStatus(t, s.Env().KubernetesCluster)
assert.ElementsMatch(t, []string{"process", "rtprocess"}, status.ProcessComponentStatus.Expvars.Map.EnabledChecks)
assert.ElementsMatch(t, []string{"connections"}, status.ProcessAgentStatus.Expvars.Map.EnabledChecks)
}, 2*time.Minute, 5*time.Second)

var payloads []*aggregator.ProcessPayload
Expand All @@ -216,6 +227,7 @@ func (s *K8sSuite) TestProcessCheckInCoreAgentWithNPM() {
}, 2*time.Minute, 10*time.Second)

assertProcessCollected(t, payloads, false, "stress-ng-cpu [run]")
assertProcessCollected(t, payloads, false, "process-agent")
assertContainersCollected(t, payloads, []string{"stress-ng", "process-agent"})
}

Expand Down

0 comments on commit 717c1cb

Please sign in to comment.