diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index 51fba3f61278c..4647c2ede6ae0 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -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 diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index abfece6aac73b..67afb78dc55d8 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -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: diff --git a/.gitlab/e2e/e2e.yml b/.gitlab/e2e/e2e.yml index 6064179b1069b..c62f11a8165e2 100644 --- a/.gitlab/e2e/e2e.yml +++ b/.gitlab/e2e/e2e.yml @@ -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: diff --git a/test/new-e2e/tests/netpath/network_path_integration_test.go b/test/new-e2e/tests/netpath/network_path_integration_test.go new file mode 100644 index 0000000000000..d93729d413f7a --- /dev/null +++ b/test/new-e2e/tests/netpath/network_path_integration_test.go @@ -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) +}