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

[netpath] Add initial e2e tests for Network Path Integration #31964

Merged
merged 7 commits into from
Dec 11, 2024
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
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -606,6 +606,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 @@ -980,6 +980,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 @@ -480,6 +480,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)
}
Loading