Skip to content
Merged
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
12 changes: 12 additions & 0 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -992,6 +992,18 @@ workflow:
- when: manual
allow_failure: true

.on_ndm_snmp_or_e2e_changes_or_manual:
- !reference [.on_e2e_main_release_or_rc]
- changes:
paths:
- pkg/collector/corechecks/snmp/**/*
- test/new-e2e/tests/ndm/snmp/**/*
- 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
- when: manual
allow_failure: true

.on_trace_agent_changes_or_manual:
- !reference [.except_mergequeue]
- changes:
Expand Down
9 changes: 9 additions & 0 deletions .gitlab/e2e/e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -322,3 +322,12 @@ new-e2e-ndm-netflow:
variables:
TARGETS: ./tests/ndm/netflow
TEAM: network-device-monitoring

new-e2e-ndm-snmp:
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👏 praise

extends: .new_e2e_template
rules: !reference [.on_ndm_snmp_or_e2e_changes_or_manual]
needs:
- qa_agent
variables:
TARGETS: ./tests/ndm/snmp
Comment thread
jmw51798 marked this conversation as resolved.
TEAM: network-device-monitoring
2 changes: 1 addition & 1 deletion test/new-e2e/tests/ndm/snmp/compose/snmpCompose.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
version: "3.9"
services:
snmp:
image: "datadog/docker-library:snmp"
image: "669783387624.dkr.ecr.us-east-1.amazonaws.com/dockerhub/datadog/docker-library:snmp"
ports:
- "1161:1161/udp"
command: --args-from-file=/usr/snmpsim/data/args_list.txt --variation-modules-dir=/usr/local/snmpsim/variation
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ init_config:
instances:
- ip_address: dd-snmp
port: 1161
community_string: "public"
community_string: "cisco-nexus"
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🥜 nitpick
You could update the config file name accordingly

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changed b80d861

47 changes: 45 additions & 2 deletions test/new-e2e/tests/ndm/snmp/snmp_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,18 @@ package snmp

import (
"embed"
"fmt"
"path"
"testing"
"time"

"github.com/DataDog/datadog-agent/test/fakeintake/aggregator"
"github.com/DataDog/datadog-agent/test/new-e2e/pkg/e2e"
"github.com/DataDog/datadog-agent/test/new-e2e/pkg/environments"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"

"github.com/DataDog/test-infra-definitions/common/utils"
"github.com/DataDog/test-infra-definitions/components/datadog/agent"
"github.com/DataDog/test-infra-definitions/components/datadog/dockeragentparams"
"github.com/DataDog/test-infra-definitions/components/docker"
Expand All @@ -30,7 +34,7 @@ import (
//go:embed compose/snmpCompose.yaml
var snmpCompose string

//go:embed config/public.yaml
//go:embed config/cisco-nexus.yaml
var snmpConfig string

const (
Expand Down Expand Up @@ -98,7 +102,12 @@ func snmpDockerProvisioner() e2e.Provisioner {
return err
}

dockerManager, err := docker.NewManager(&awsEnv, host)
installEcrCredsHelperCmd, err := ec2.InstallECRCredentialsHelper(awsEnv, host)
if err != nil {
return err
}

dockerManager, err := docker.NewManager(&awsEnv, host, utils.PulumiDependsOn(installEcrCredsHelperCmd))
if err != nil {
return err
}
Expand Down Expand Up @@ -155,3 +164,37 @@ func (s *snmpDockerSuite) TestSnmp() {
assert.Contains(c, metrics, "snmp.sysUpTimeInstance", "metrics %v doesn't contain snmp.sysUpTimeInstance", metrics)
}, 5*time.Minute, 10*time.Second)
}

func (s *snmpDockerSuite) TestSnmpTagsAreStoredOnRestart() {
fakeintake := s.Env().FakeIntake.Client()
var initialMetrics []*aggregator.MetricSeries
var err error

require.EventuallyWithT(s.T(), func(t *assert.CollectT) {
initialMetrics, err = fakeintake.FilterMetrics("snmp.device.reachable")
assert.NoError(t, err)
}, 5*time.Minute, 5*time.Second)

initialTags := initialMetrics[0].Tags
_, err = s.Env().RemoteHost.Execute("docker stop dd-snmp")
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💬 suggestion
Should be possible to run the request using the Docker client in

Docker *components.RemoteHostDocker

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To be tested:

// stop
s.Env().Docker.GetClient().ContainerStop(context.Background(), "dd-snmp", container.StopOptions{})

// restart
s.Env().Docker.GetClient().ContainerRestart(context.Background(), s.Env().Agent.ContainerName, container.StopOptions{})

But I think you need to get the ID from the container name

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Checked and indeed you would need to get the container ID, will create a card to provide this through the Docker client, we can generate a list of container ids by their name.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes I tried before to get the list of container ids filtered by the name and then get the first one from the list but it is maybe easier like this

require.NoError(s.T(), err)

_, err = s.Env().RemoteHost.Execute(fmt.Sprintf("docker restart %s", s.Env().Agent.ContainerName))
require.NoError(s.T(), err)

err = fakeintake.FlushServerAndResetAggregators()
require.NoError(s.T(), err)

var metrics []*aggregator.MetricSeries

require.EventuallyWithT(s.T(), func(t *assert.CollectT) {
metrics, err = fakeintake.FilterMetrics("snmp.device.reachable")
assert.NoError(t, err)
assert.NotEmpty(t, metrics)
}, 5*time.Minute, 5*time.Second)

tags := metrics[0].Tags

require.Zero(s.T(), metrics[0].Points[0].Value)
require.ElementsMatch(s.T(), tags, initialTags)
Comment thread
jmw51798 marked this conversation as resolved.
}