Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DRAFT] Ndmii 3190 ha agent e2e keep #31682

Closed
wants to merge 22 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -611,6 +611,7 @@
/test/new-e2e/tests/agent-subcommands @DataDog/agent-shared-components
/test/new-e2e/tests/containers @DataDog/container-integrations @DataDog/container-platform
/test/new-e2e/tests/discovery @DataDog/universal-service-monitoring
/test/new-e2e/tests/ha-agent @DataDog/ndm-core
/test/new-e2e/tests/language-detection @DataDog/processes
/test/new-e2e/tests/ndm @DataDog/ndm-core
/test/new-e2e/tests/ndm/netflow @DataDog/ndm-integrations
Expand Down
10 changes: 10 additions & 0 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -998,6 +998,16 @@ workflow:
- when: manual
allow_failure: true

.on_ha_agent_or_e2e_changes:
- !reference [.on_e2e_main_release_or_rc]
- changes:
paths:
- comp/netflow/**/*
- test/new-e2e/tests/ha-agent/**/*
- test/new-e2e/go.mod
compare_to: main # TODO: use a variable, when this is supported https://gitlab.com/gitlab-org/gitlab/-/issues/369916
when: on_success

.on_otel_or_e2e_changes:
- !reference [.on_e2e_main_release_or_rc]
- changes:
Expand Down
12 changes: 12 additions & 0 deletions .gitlab/e2e/e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -470,6 +470,18 @@ new-e2e-ndm-snmp:
TARGETS: ./tests/ndm/snmp
TEAM: network-device-monitoring

new-e2e-ha-agent:
extends: .new_e2e_template
rules:
- !reference [.on_ndm_netflow_or_e2e_changes]
- !reference [.manual]
needs:
- !reference [.needs_new_e2e_template]
- qa_agent
variables:
TARGETS: ./tests/ha-agent
TEAM: ndm-core

new-e2e-windows-systemprobe:
extends: .new_e2e_template
rules:
Expand Down
69 changes: 69 additions & 0 deletions test/new-e2e/tests/ha-agent/haagent_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
// Unless explicitly stated otherwise all files in this repository are licensed
// under the Apache License Version 2.0.
// This product includes software developed at Datadog (https://www.datadoghq.com/).
// Copyright 2016-present Datadog, Inc.

// Package haagent contains e2e tests for HA Agent feature
package haagent

import (
_ "embed"
"testing"
"time"

"github.com/stretchr/testify/assert"

"github.com/DataDog/test-infra-definitions/components/datadog/agentparams"

"github.com/DataDog/datadog-agent/test/fakeintake/aggregator"
fakeintakeclient "github.com/DataDog/datadog-agent/test/fakeintake/client"
"github.com/DataDog/datadog-agent/test/new-e2e/pkg/e2e"
"github.com/DataDog/datadog-agent/test/new-e2e/pkg/environments"
awshost "github.com/DataDog/datadog-agent/test/new-e2e/pkg/environments/aws/host"
)

type haAgentTestSuite03 struct {
e2e.BaseSuite[environments.Host]
}

// TestHaAgentSuite runs the netflow e2e suite
func TestHaAgentSuite(t *testing.T) {
// language=yaml
agentConfig := `
ha_agent:
enabled: true
group: test-group01
log_level: debug
`
e2e.Run(t, &haAgentTestSuite03{}, e2e.WithProvisioner(awshost.Provisioner(
awshost.WithAgentOptions(agentparams.WithAgentConfig(agentConfig))),
))
}

func (s *haAgentTestSuite03) TestHaAgentGroupTag_PresentOnDatadogAgentRunningMetric() {
fakeClient := s.Env().FakeIntake.Client()
s.EventuallyWithT(func(c *assert.CollectT) {
s.T().Log("try assert datadog.agent.running metric")
metrics, err := fakeClient.FilterMetrics("datadog.agent.running")
assert.NoError(c, err)
assert.NotEmpty(c, metrics)
for _, metric := range metrics {
s.T().Logf(" datadog.agent.running metric in fake intake: %+v", metric)
}

tags := []string{"agent_group:test-group01"}
metrics, err = fakeClient.FilterMetrics("datadog.agent.running", fakeintakeclient.WithTags[*aggregator.MetricSeries](tags))
assert.NoError(c, err)
assert.NotEmpty(c, metrics)
}, 5*time.Minute, 3*time.Second)
}

func (s *haAgentTestSuite03) TestHaAgentAddedToRCListeners() {
s.EventuallyWithT(func(c *assert.CollectT) {
output, err := s.Env().RemoteHost.Execute("cat /var/log/datadog/agent.log")
if !assert.NoError(c, err) {
return
}
assert.Contains(c, output, "Add onHaAgentUpdate RCListener")
}, 3*time.Minute, 1*time.Second)
}
Loading