Skip to content

Commit 9a43c6d

Browse files
committed
Simplify baseline dynamic test configuration
1 parent 239d15e commit 9a43c6d

11 files changed

Lines changed: 25 additions & 36 deletions

File tree

comp/networkpath/npcollector/impl/baseline_window_test.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ func baselineWindowConn(host string, bytes uint64) npmodel.NetworkPathConnection
3535

3636
func TestBaselineFirstSnapshotAndSteadyWindow(t *testing.T) {
3737
_, collector := newTestNpCollector(t, map[string]any{
38-
"network_path.connections_monitoring.baseline_tests.enabled": true,
38+
"network_path.connections_monitoring.baseline_tests_enabled": true,
3939
"network_path.collector.monitor_ip_without_domain": true,
4040
"network_path.collector.pathtest_interval": time.Second,
4141
}, &teststatsd.Client{}, nil)
@@ -69,7 +69,7 @@ func TestBaselineFirstSnapshotAndSteadyWindow(t *testing.T) {
6969

7070
func TestBaselineEmptySnapshotsDoNotStartVirtualWindow(t *testing.T) {
7171
_, collector := newTestNpCollector(t, map[string]any{
72-
"network_path.connections_monitoring.baseline_tests.enabled": true,
72+
"network_path.connections_monitoring.baseline_tests_enabled": true,
7373
"network_path.collector.monitor_ip_without_domain": true,
7474
}, &teststatsd.Client{}, nil)
7575
collector.ScheduleNetworkPathTests(slices.Values([]npmodel.NetworkPathConnection{{
@@ -84,7 +84,7 @@ func TestBaselineEmptySnapshotsDoNotStartVirtualWindow(t *testing.T) {
8484

8585
func TestBaselineDisabledCreatesNoCollectorMachinery(t *testing.T) {
8686
_, collector := newTestNpCollector(t, map[string]any{
87-
"network_path.connections_monitoring.baseline_tests.enabled": false,
87+
"network_path.connections_monitoring.baseline_tests_enabled": false,
8888
"network_path.collector.monitor_ip_without_domain": true,
8989
}, &teststatsd.Client{}, nil)
9090

@@ -97,7 +97,7 @@ func TestBaselineDisabledCreatesNoCollectorMachinery(t *testing.T) {
9797
func TestBaselineSelectionConsumesSlotsBeforeChannelAdmission(t *testing.T) {
9898
stats := &teststatsd.Client{}
9999
_, collector := newTestNpCollector(t, map[string]any{
100-
"network_path.connections_monitoring.baseline_tests.enabled": true,
100+
"network_path.connections_monitoring.baseline_tests_enabled": true,
101101
"network_path.collector.monitor_ip_without_domain": true,
102102
"network_path.collector.input_chan_size": 1,
103103
}, stats, nil)
@@ -118,7 +118,7 @@ func TestBaselineBypassesRemoteFiltersButStandardDoesNot(t *testing.T) {
118118
remoteExclude := []connfilter.Config{{Type: connfilter.FilterTypeExclude, MatchIP: "10.0.0.1"}}
119119

120120
_, baseline := newTestNpCollector(t, map[string]any{
121-
"network_path.connections_monitoring.baseline_tests.enabled": true,
121+
"network_path.connections_monitoring.baseline_tests_enabled": true,
122122
"network_path.collector.monitor_ip_without_domain": true,
123123
}, &teststatsd.Client{}, nil)
124124
baseline.replaceRemoteFilters(remoteExclude)

comp/networkpath/npcollector/impl/config.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ import (
1919

2020
type collectorConfigs struct {
2121
dynamicTestsState npconfig.DynamicTestsState
22-
baselineWindow time.Duration
2322
netflowMonitoringEnabled bool
2423
workers int
2524
timeout time.Duration
@@ -55,7 +54,6 @@ func newConfig(agentConfig config.Component, logger log.Component) *collectorCon
5554
filterConfigs = nil
5655
}
5756
return &collectorConfigs{
58-
baselineWindow: 30 * time.Minute,
5957
netflowMonitoringEnabled: agentConfig.GetBool("network_path.netflow_monitoring.enabled"),
6058
workers: agentConfig.GetInt("network_path.collector.workers"),
6159
timeout: agentConfig.GetDuration("network_path.collector.timeout") * time.Millisecond,

comp/networkpath/npcollector/impl/config_test.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ func TestNewConfig(t *testing.T) {
4747
"network_path.collector.filters": []map[string]any{},
4848
},
4949
expectedConfig: &collectorConfigs{
50-
baselineWindow: 30 * time.Minute,
5150
netflowMonitoringEnabled: false,
5251
workers: 4,
5352
timeout: 1000 * time.Millisecond,
@@ -120,7 +119,6 @@ func TestNewConfig(t *testing.T) {
120119
},
121120
},
122121
expectedConfig: &collectorConfigs{
123-
baselineWindow: 30 * time.Minute,
124122
netflowMonitoringEnabled: false,
125123
workers: 8,
126124
timeout: 5000 * time.Millisecond,

comp/networkpath/npcollector/impl/npcollector.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ import (
3838
)
3939

4040
const (
41+
baselineSelectionInterval = 30 * time.Minute
4142
reverseDNSLookupMetricPrefix = common.NetworkPathCollectorMetricPrefix + "reverse_dns_lookup."
4243
reverseDNSLookupFailuresMetricName = reverseDNSLookupMetricPrefix + "failures"
4344
reverseDNSLookupSuccessesMetricName = reverseDNSLookupMetricPrefix + "successes"
@@ -398,7 +399,7 @@ func (s *npCollectorImpl) scheduleBaselineNetworkPathTests(conns iter.Seq[npmode
398399
func (s *npCollectorImpl) closeBaselineWindow(now time.Time) {
399400
selected := s.baselineSelector.selectPathtests()
400401
s.baselineSelector.reset()
401-
s.baselineDeadline = now.Add(s.collectorConfigs.baselineWindow)
402+
s.baselineDeadline = now.Add(baselineSelectionInterval)
402403
_ = s.statsdClient.Incr(common.NetworkPathCollectorMetricPrefix+"baseline.windows_closed", nil, 1)
403404
for i := range selected {
404405
_ = s.statsdClient.Incr(common.NetworkPathCollectorMetricPrefix+"baseline.selections", nil, 1)

comp/rdnsquerier/impl/config_test.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -348,8 +348,7 @@ func TestConfigEnabledForBaselineNetworkPathTests(t *testing.T) {
348348
mockConfig := mock.NewFromYAML(t, `
349349
network_path:
350350
connections_monitoring:
351-
baseline_tests:
352-
enabled: true
351+
baseline_tests_enabled: true
353352
`)
354353

355354
systemProbeConfig := mock.NewSystemProbe(t)
@@ -363,8 +362,7 @@ func TestConfigDisabledForIneffectiveBaselineNetworkPathTests(t *testing.T) {
363362
mockConfig := mock.NewFromYAML(t, `
364363
network_path:
365364
connections_monitoring:
366-
baseline_tests:
367-
enabled: true
365+
baseline_tests_enabled: true
368366
`)
369367

370368
assert.False(t, newConfig(mockConfig, mock.NewSystemProbe(t)).enabled)

pkg/config/schema/yaml/core_schema.yaml

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1723,19 +1723,14 @@ properties:
17231723
description: Enables Network Path Dynamic Test for monitoring network
17241724
connections via Network Path.
17251725
example: 'true'
1726-
baseline_tests:
1727-
node_type: section
1728-
type: object
1729-
description: Configuration for included baseline Network Path Dynamic Tests.
1730-
properties:
1731-
enabled:
1732-
node_type: setting
1733-
type: boolean
1734-
default: false
1735-
description: Enables up to three included Network Path Dynamic Tests immediately
1736-
for the first eligible snapshot, then every 30 minutes, when Cloud Network
1737-
Monitoring is enabled.
1738-
example: 'true'
1726+
baseline_tests_enabled:
1727+
node_type: setting
1728+
type: boolean
1729+
default: false
1730+
description: Enables up to three included Network Path Dynamic Tests immediately
1731+
for the first eligible snapshot, then every 30 minutes, when Cloud Network
1732+
Monitoring is enabled.
1733+
example: 'true'
17391734
collector:
17401735
node_type: section
17411736
type: object

pkg/config/setup/config_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -749,7 +749,7 @@ func TestNetworkPathDefaults(t *testing.T) {
749749
config := confFromYAML(t, datadogYaml)
750750

751751
assert.Equal(t, false, config.GetBool("network_path.connections_monitoring.enabled"))
752-
assert.Equal(t, false, config.GetBool("network_path.connections_monitoring.baseline_tests.enabled"))
752+
assert.Equal(t, false, config.GetBool("network_path.connections_monitoring.baseline_tests_enabled"))
753753
assert.Equal(t, false, config.GetBool("network_path.remote_config.enabled"))
754754
assert.Equal(t, 4, config.GetInt("network_path.collector.workers"))
755755
assert.Equal(t, 1000, config.GetInt("network_path.collector.timeout"))

pkg/networkpath/config/state.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ func (s DynamicTestsState) String() string {
3636

3737
const (
3838
standardEnabledKey = "network_path.connections_monitoring.enabled"
39-
baselineEnabledKey = "network_path.connections_monitoring.baseline_tests.enabled"
39+
baselineEnabledKey = "network_path.connections_monitoring.baseline_tests_enabled"
4040
systemProbeKey = "system_probe_config.enabled"
4141
networkConfigKey = "network_config.enabled"
4242
)

pkg/system-probe/config/config_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -172,10 +172,10 @@ func TestTracerouteModuleDynamicTestsState(t *testing.T) {
172172
wantEnable bool
173173
checkDefaultInjector bool
174174
}{
175-
{name: "baseline disabled has no impact", core: map[string]any{"network_path.connections_monitoring.baseline_tests.enabled": false}, sysprobe: map[string]any{"system_probe_config.enabled": true, "network_config.enabled": true}},
176-
{name: "baseline outside CNM", core: map[string]any{"network_path.connections_monitoring.baseline_tests.enabled": true}, sysprobe: map[string]any{"system_probe_config.enabled": true, "network_config.enabled": false}},
177-
{name: "effective baseline with implicit system probe", core: map[string]any{"network_path.connections_monitoring.baseline_tests.enabled": true}, sysprobe: map[string]any{"network_config.enabled": true}, wantEnable: true},
178-
{name: "effective baseline", core: map[string]any{"network_path.connections_monitoring.baseline_tests.enabled": true}, sysprobe: map[string]any{"system_probe_config.enabled": true, "network_config.enabled": true}, wantEnable: true},
175+
{name: "baseline disabled has no impact", core: map[string]any{"network_path.connections_monitoring.baseline_tests_enabled": false}, sysprobe: map[string]any{"system_probe_config.enabled": true, "network_config.enabled": true}},
176+
{name: "baseline outside CNM", core: map[string]any{"network_path.connections_monitoring.baseline_tests_enabled": true}, sysprobe: map[string]any{"system_probe_config.enabled": true, "network_config.enabled": false}},
177+
{name: "effective baseline with implicit system probe", core: map[string]any{"network_path.connections_monitoring.baseline_tests_enabled": true}, sysprobe: map[string]any{"network_config.enabled": true}, wantEnable: true},
178+
{name: "effective baseline", core: map[string]any{"network_path.connections_monitoring.baseline_tests_enabled": true}, sysprobe: map[string]any{"system_probe_config.enabled": true, "network_config.enabled": true}, wantEnable: true},
179179
{name: "effective standard", core: map[string]any{"network_path.connections_monitoring.enabled": true}, sysprobe: map[string]any{"system_probe_config.enabled": true, "network_config.enabled": true}, wantEnable: true},
180180
{name: "explicit traceroute remains supported", sysprobe: map[string]any{"traceroute.enabled": true}, wantEnable: true, checkDefaultInjector: true},
181181
}

releasenotes/notes/add-cnm-baseline-dynamic-tests-ac7c4a3d73c865b4.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22
features:
33
- |
44
Add opt-in baseline Dynamic Tests for Cloud Network Monitoring. When
5-
``network_path.connections_monitoring.baseline_tests.enabled`` is enabled,
5+
``network_path.connections_monitoring.baseline_tests_enabled`` is enabled,
66
the Agent runs a small, bounded set of one-time path tests for eligible
77
connections while full recurring Dynamic Tests remain disabled.

0 commit comments

Comments
 (0)