Skip to content

Commit 757b8ce

Browse files
committed
Focus baseline Dynamic Tests E2E coverage
1 parent 412f580 commit 757b8ce

7 files changed

Lines changed: 69 additions & 15 deletions

File tree

pkg/network/sender/BUILD.bazel

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,7 @@ dd_agent_go_test(
144144
"//comp/core/workloadmeta/mock",
145145
"//comp/forwarder/connectionsforwarder/mock",
146146
"//comp/networkpath/npcollector/impl",
147+
"//comp/networkpath/npcollector/model",
147148
"//pkg/eventmonitor",
148149
"//pkg/network",
149150
"//pkg/network/dns",
@@ -171,6 +172,7 @@ dd_agent_go_test(
171172
"//comp/core/workloadmeta/mock",
172173
"//comp/forwarder/connectionsforwarder/mock",
173174
"//comp/networkpath/npcollector/impl",
175+
"//comp/networkpath/npcollector/model",
174176
"//pkg/eventmonitor",
175177
"//pkg/network",
176178
"//pkg/network/dns",

pkg/network/sender/sender_linux_test.go

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ package sender
99

1010
import (
1111
"fmt"
12+
"math"
1213
"slices"
1314
"strconv"
1415
"testing"
@@ -32,6 +33,7 @@ import (
3233
workloadmetamock "github.com/DataDog/datadog-agent/comp/core/workloadmeta/mock"
3334
connectionsforwardermock "github.com/DataDog/datadog-agent/comp/forwarder/connectionsforwarder/mock"
3435
npcollectorimpl "github.com/DataDog/datadog-agent/comp/networkpath/npcollector/impl"
36+
npmodel "github.com/DataDog/datadog-agent/comp/networkpath/npcollector/model"
3537
"github.com/DataDog/datadog-agent/pkg/eventmonitor"
3638
"github.com/DataDog/datadog-agent/pkg/network"
3739
"github.com/DataDog/datadog-agent/pkg/network/dns"
@@ -155,6 +157,29 @@ func TestNetworkConnectionBatching(t *testing.T) {
155157
}
156158
}
157159

160+
func TestNetworkPathConnectionsBaselineSignals(t *testing.T) {
161+
d := mockDirectSender(t)
162+
conn := makeConnection(1)
163+
conn.TCPFailures = map[uint16]uint32{npmodel.TCPTimeoutErrno: 1}
164+
conn.Last.TCPRTOCount = 2
165+
conn.Last.Retransmits = 3
166+
conn.RTTVar = 4
167+
conn.Last.SentBytes = math.MaxUint64
168+
conn.Last.RecvBytes = 1
169+
170+
got := slices.Collect(d.networkPathConnections(&network.Connections{
171+
BufferedData: network.BufferedData{Conns: []network.ConnectionStats{conn}},
172+
}))
173+
174+
require.Len(t, got, 1)
175+
assert.True(t, got[0].TCPTimeout)
176+
assert.True(t, got[0].TCPRTO)
177+
assert.Equal(t, uint64(3), got[0].Retransmits)
178+
assert.Equal(t, uint64(4), got[0].RTTVar)
179+
assert.Equal(t, uint64(math.MaxUint64), got[0].Bytes)
180+
assert.True(t, got[0].NumericSaturated)
181+
}
182+
158183
func TestNetworkConnectionBatchingWithDNS(t *testing.T) {
159184
d := mockDirectSender(t)
160185
d.maxConnsPerMessage = 1

pkg/process/checks/BUILD.bazel

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,7 @@ dd_agent_go_test(
248248
"//comp/core/workloadmeta/def",
249249
"//comp/core/workloadmeta/fx-mock",
250250
"//comp/core/workloadmeta/mock",
251+
"//comp/networkpath/npcollector/model",
251252
"//comp/process/gpusubscriber/fx-mock",
252253
"//pkg/config/env",
253254
"//pkg/config/mock",

pkg/process/checks/net.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ package checks
77

88
import (
99
"fmt"
10+
"iter"
1011
"net/http"
1112
"net/netip"
1213
"sort"
@@ -219,7 +220,11 @@ func (c *ConnectionsCheck) Cleanup() {
219220
}
220221

221222
func (c *ConnectionsCheck) scheduleNetworkPath(conns *model.Connections) {
222-
c.npCollector.ScheduleNetworkPathTests(func(yield func(npmodel.NetworkPathConnection) bool) {
223+
c.npCollector.ScheduleNetworkPathTests(networkPathConnections(conns))
224+
}
225+
226+
func networkPathConnections(conns *model.Connections) iter.Seq[npmodel.NetworkPathConnection] {
227+
return func(yield func(npmodel.NetworkPathConnection) bool) {
223228
for _, conn := range conns.Conns {
224229
srcIP, err := netip.ParseAddr(conn.Laddr.GetIp())
225230
if err != nil {
@@ -263,7 +268,7 @@ func (c *ConnectionsCheck) scheduleNetworkPath(conns *model.Connections) {
263268
return
264269
}
265270
}
266-
})
271+
}
267272
}
268273

269274
func getDNSNameForIP(conns *model.Connections, ip string) string {

pkg/process/checks/net_test.go

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,18 @@ package checks
77

88
import (
99
"fmt"
10+
"math"
1011
"os"
1112
"runtime"
13+
"slices"
1214
"strconv"
1315
"testing"
1416

1517
"github.com/stretchr/testify/assert"
1618
"github.com/stretchr/testify/require"
1719

1820
model "github.com/DataDog/agent-payload/v5/process"
21+
npmodel "github.com/DataDog/datadog-agent/comp/networkpath/npcollector/model"
1922

2023
taggerfxmock "github.com/DataDog/datadog-agent/comp/core/tagger/fx-mock"
2124
taggertypes "github.com/DataDog/datadog-agent/comp/core/tagger/types"
@@ -167,6 +170,28 @@ func TestNetworkConnectionBatching(t *testing.T) {
167170
}
168171
}
169172

173+
func TestNetworkPathConnectionsBaselineSignals(t *testing.T) {
174+
conn := makeConnection(1)
175+
conn.Laddr.Ip = "10.0.0.1"
176+
conn.Raddr.Ip = "10.0.0.2"
177+
conn.TcpFailuresByErrCode = map[uint32]uint32{uint32(npmodel.TCPTimeoutErrno): 1}
178+
conn.LastTcpRtoCount = 2
179+
conn.LastRetransmits = 3
180+
conn.RttVar = 4
181+
conn.LastBytesSent = math.MaxUint64
182+
conn.LastBytesReceived = 1
183+
184+
got := slices.Collect(networkPathConnections(&model.Connections{Conns: []*model.Connection{conn}}))
185+
186+
require.Len(t, got, 1)
187+
assert.True(t, got[0].TCPTimeout)
188+
assert.True(t, got[0].TCPRTO)
189+
assert.Equal(t, uint64(3), got[0].Retransmits)
190+
assert.Equal(t, uint64(4), got[0].RTTVar)
191+
assert.Equal(t, uint64(math.MaxUint64), got[0].Bytes)
192+
assert.True(t, got[0].NumericSaturated)
193+
}
194+
170195
func TestNetworkConnectionBatchingWithDNS(t *testing.T) {
171196
p := makeConnections(4)
172197

test/new-e2e/tests/netpath/dynamic-tests/config/baseline_host_traffic_dynamic_path.yaml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
network_path:
2-
remote_config:
3-
enabled: true
42
connections_monitoring:
53
baseline_tests:
64
enabled: true

test/new-e2e/tests/netpath/dynamic-tests/host_traffic_dynamic_path_test.go

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,8 @@ type hostTrafficDynamicPathEnv struct {
9494

9595
type hostTrafficDynamicPathSuite struct {
9696
e2e.BaseSuite[hostTrafficDynamicPathEnv]
97-
remoteConfigAdded bool
98-
preserveInitialPayloads bool
97+
remoteConfigAdded bool
98+
skipRemoteConfig bool
9999
}
100100

101101
type baselineHostTrafficDynamicPathSuite struct {
@@ -110,7 +110,7 @@ func TestHostTrafficDynamicPathSuite(t *testing.T) {
110110
// TestBaselineHostTrafficDynamicPathSuite verifies baseline tests from packaged Agent configuration through fakeintake.
111111
func TestBaselineHostTrafficDynamicPathSuite(t *testing.T) {
112112
suite := &baselineHostTrafficDynamicPathSuite{
113-
hostTrafficDynamicPathSuite: hostTrafficDynamicPathSuite{preserveInitialPayloads: true},
113+
hostTrafficDynamicPathSuite: hostTrafficDynamicPathSuite{skipRemoteConfig: true},
114114
}
115115
e2e.Run(t, suite, e2e.WithProvisioner(hostTrafficDynamicPathProvisioner("baselineHostTrafficDynamicPath", baselineHostTrafficDynamicPathAgentConfig, baselineHostTrafficSystemProbeConfig)))
116116
}
@@ -183,6 +183,11 @@ func (s *hostTrafficDynamicPathSuite) SetupSuite() {
183183
s.assertHostTrafficDomainResolves()
184184

185185
fakeintake := s.Env().FakeIntake.Client()
186+
if s.skipRemoteConfig {
187+
require.NoError(s.T(), fakeintake.FlushServerAndResetAggregators())
188+
return
189+
}
190+
186191
s.EventuallyWithT(func(c *assert.CollectT) {
187192
stats, err := fakeintake.RCStats()
188193
assert.NoError(c, err)
@@ -198,9 +203,7 @@ func (s *hostTrafficDynamicPathSuite) SetupSuite() {
198203
assert.Greater(c, stats.Polls, statsAfterAdd.Polls, "agent did not poll Remote Config after the dynamic config was added")
199204
}, 2*time.Minute, 5*time.Second)
200205

201-
if !s.preserveInitialPayloads {
202-
require.NoError(s.T(), fakeintake.FlushServerAndResetAggregators())
203-
}
206+
require.NoError(s.T(), fakeintake.FlushServerAndResetAggregators())
204207
}
205208

206209
func (s *hostTrafficDynamicPathSuite) TearDownSuite() {
@@ -285,9 +288,6 @@ func (s *baselineHostTrafficDynamicPathSuite) TestHostTrafficDynamicNetworkPath(
285288
assert.Equal(c, uint16(80), match.Destination.Port)
286289
require.NotEmpty(c, match.Traceroute.Runs, "matched network path has no traceroute runs")
287290
assert.True(c, hasTracerouteDestinationIP(match), "matched network path has no traceroute destination IP")
288-
assert.Empty(c, match.TestConfigID, "baseline test unexpectedly inherited Remote Config attribution")
289-
assert.Empty(c, match.TestConfigSource, "baseline test unexpectedly inherited Remote Config attribution")
290-
assert.Empty(c, match.Tags, "baseline test unexpectedly inherited Remote Config tags")
291291
}, 5*time.Minute, 10*time.Second)
292292
}
293293

@@ -396,8 +396,6 @@ fi
396396
func (s *hostTrafficDynamicPathSuite) assertHostTrafficDomainResolves() {
397397
output := s.Env().RemoteHost.MustExecute("getent ahostsv4 " + shellQuote(hostTrafficRemoteConfigDomain))
398398
require.Contains(s.T(), output, s.Env().HTTPBinHost.Address)
399-
400-
s.Env().RemoteHost.MustExecute(fmt.Sprintf("curl -4 -fsS --retry 3 --max-time 5 %s >/dev/null", shellQuote(hostTrafficURL(hostTrafficRemoteConfigDomain))))
401399
}
402400

403401
func (s *hostTrafficDynamicPathSuite) startHostTrafficGenerator(duration time.Duration) {

0 commit comments

Comments
 (0)