Skip to content

Commit

Permalink
[netpath] Add initial e2e tests for Network Path Integration (#31964)
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexandreYang authored Dec 11, 2024
1 parent 706fa94 commit c37d0d6
Show file tree
Hide file tree
Showing 4 changed files with 108 additions and 0 deletions.
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -607,6 +607,7 @@
/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
/test/new-e2e/tests/netpath @DataDog/Networks @DataDog/network-device-monitoring
/test/new-e2e/tests/npm @DataDog/Networks
/test/new-e2e/tests/npm/ec2_1host_wkit_test.go @DataDog/Networks @DataDog/windows-kernel-integrations
/test/new-e2e/tests/orchestrator @DataDog/container-app
Expand Down
10 changes: 10 additions & 0 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -981,6 +981,16 @@ workflow:
compare_to: main # TODO: use a variable, when this is supported https://gitlab.com/gitlab-org/gitlab/-/issues/369916
when: on_success

.on_netpath_or_e2e_changes:
- !reference [.on_e2e_main_release_or_rc]
- changes:
paths:
- pkg/collector/corechecks/networkpath/**/*
- test/new-e2e/tests/netpath/**/*
- 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
9 changes: 9 additions & 0 deletions .gitlab/e2e/e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -511,6 +511,15 @@ new-e2e-ha-agent:
TARGETS: ./tests/ha-agent
TEAM: ndm-core

new-e2e-netpath:
extends: .new_e2e_template_needs_deb_x64
rules:
- !reference [.on_netpath_or_e2e_changes]
- !reference [.manual]
variables:
TARGETS: ./tests/netpath
TEAM: network-performance-monitoring

new-e2e-windows-systemprobe:
extends: .new_e2e_template
rules:
Expand Down
88 changes: 88 additions & 0 deletions test/new-e2e/tests/netpath/network_path_integration_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
// 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 netpath contains e2e tests for Network Path Integration feature
package netpath

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

"github.com/DataDog/datadog-agent/test/fakeintake/aggregator"
fakeintakeclient "github.com/DataDog/datadog-agent/test/fakeintake/client"
"github.com/DataDog/test-infra-definitions/components/datadog/agentparams"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"

"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 networkPathIntegrationTestSuite struct {
e2e.BaseSuite[environments.Host]
}

// TestNetworkPathIntegrationSuite runs the Network Path Integration e2e suite
func TestNetworkPathIntegrationSuite(t *testing.T) {
// language=yaml
sysProbeConfig := `
traceroute:
enabled: true
`

// language=yaml
networkPathIntegration := `
instances:
- hostname: api.datadoghq.eu
protocol: TCP
port: 443
- hostname: 8.8.8.8
protocol: UDP
`

e2e.Run(t, &networkPathIntegrationTestSuite{}, e2e.WithProvisioner(awshost.Provisioner(
awshost.WithAgentOptions(
agentparams.WithSystemProbeConfig(sysProbeConfig),
agentparams.WithIntegration("network_path.d", networkPathIntegration),
)),
))
}

func (s *networkPathIntegrationTestSuite) TestNetworkPathIntegrationMetrics() {
fakeClient := s.Env().FakeIntake.Client()

s.EventuallyWithT(func(c *assert.CollectT) {
s.T().Log("try assert datadog.network_path.path.monitored metric")
metrics, err := fakeClient.FilterMetrics("datadog.network_path.path.monitored")
require.NoError(c, err)
assert.NotEmpty(c, metrics)
for _, metric := range metrics {
s.T().Logf(" datadog.network_path.path.monitored metric tags: %+v", metric.Tags)
}

destinationsTagsToAssert := [][]string{
{"destination_hostname:api.datadoghq.eu", "protocol:TCP", "destination_port:443"},
{"destination_hostname:8.8.8.8", "protocol:UDP"},
}
for _, tags := range destinationsTagsToAssert {
// assert destination is monitored
metrics, err = fakeClient.FilterMetrics("datadog.network_path.path.monitored", fakeintakeclient.WithTags[*aggregator.MetricSeries](tags))
assert.NoError(c, err)
assert.NotEmpty(c, metrics, fmt.Sprintf("metric with tags `%v` not found", tags))

// assert hops
metrics, err = fakeClient.FilterMetrics("datadog.network_path.path.hops",
fakeintakeclient.WithTags[*aggregator.MetricSeries](tags),
fakeintakeclient.WithMetricValueHigherThan(0),
)
assert.NoError(c, err)
assert.NotEmpty(c, metrics, fmt.Sprintf("metric with tags `%v` not found", tags))

}
}, 5*time.Minute, 3*time.Second)
}

0 comments on commit c37d0d6

Please sign in to comment.