Skip to content

Commit 8c0e44c

Browse files
authored
add http monitor tests (#13114)
* network: http: Changed the map clenaer interval to a configurable value with 5 minutes as default * network: http: tests: Added configurable read/write timeouts for the test server * network: http: tests: Added test for slow response This test checks the eBPF capturer with various scenarios for receiving a slow response from the test server and multiple IDLE http connection TTL and map cleaner running intervals * network: http: tests: Converted the test server into http echo server The change will allow us to send request body and get the same body in the response. It will allow us to have more scenarios to be tested against. * network: http: tests: Checking the eBPF capturing against scenarios in which we had request/response body We expect to have zero influence from the request/response body on the capturing process, no matter the size of the request/response. The tests here will examine this thesis against various body sizes * network: http: tests: Fixed TestHTTPMonitorLoadWithIncompleteBuffers Reduced number of requests during the load phase to 100. Closing the channel after all goroutines have ended (otherwise the loop on the channel will be blocked forever) Changed requestNotIncluded to includesRequest on the 'fast request' * network: http: tests: Fixed rebase error * network: http: tests: Made TestHTTPMonitorLoadWithIncompleteBuffers more robust * network: http: tests: Added more robust check * network: http: tests: Fixed flaky tests
1 parent 3a05d06 commit 8c0e44c

File tree

5 files changed

+310
-45
lines changed

5 files changed

+310
-45
lines changed

pkg/config/system_probe.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,8 @@ func InitSystemProbeConfig(cfg Config) {
121121
cfg.BindEnvAndSetDefault(join(spNS, "collect_dns_domains"), true, "DD_COLLECT_DNS_DOMAINS")
122122
cfg.BindEnvAndSetDefault(join(spNS, "max_dns_stats"), 20000)
123123
cfg.BindEnvAndSetDefault(join(spNS, "dns_timeout_in_s"), 15)
124+
cfg.BindEnvAndSetDefault(join(spNS, "http_map_cleaner_interval_in_s"), 300)
125+
cfg.BindEnvAndSetDefault(join(spNS, "http_idle_connection_ttl_in_s"), 30)
124126

125127
cfg.BindEnvAndSetDefault(join(spNS, "enable_conntrack"), true)
126128
cfg.BindEnvAndSetDefault(join(spNS, "conntrack_max_state_size"), 65536*2)

pkg/network/config/config.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,12 @@ type Config struct {
165165
// EnableRootNetNs disables using the network namespace of the root process (1)
166166
// for things like creating netlink sockets for conntrack updates, etc.
167167
EnableRootNetNs bool
168+
169+
// HTTPMapCleanerInterval is the interval to run the cleaner function.
170+
HTTPMapCleanerInterval time.Duration
171+
172+
// HTTPIdleConnectionTTL is the time an idle connection counted as "inactive" and should be deleted.
173+
HTTPIdleConnectionTTL time.Duration
168174
}
169175

170176
func join(pieces ...string) string {
@@ -227,6 +233,9 @@ func New() *Config {
227233
RecordedQueryTypes: cfg.GetStringSlice(join(netNS, "dns_recorded_query_types")),
228234

229235
EnableRootNetNs: cfg.GetBool(join(netNS, "enable_root_netns")),
236+
237+
HTTPMapCleanerInterval: time.Duration(cfg.GetInt(join(spNS, "http_map_cleaner_interval_in_s"))) * time.Second,
238+
HTTPIdleConnectionTTL: time.Duration(cfg.GetInt(join(spNS, "http_idle_connection_ttl_in_s"))) * time.Second,
230239
}
231240

232241
if !cfg.IsSet(join(spNS, "max_closed_connections_buffered")) {

pkg/network/http/ebpf_main.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -258,8 +258,8 @@ func (e *ebpfProgram) setupMapCleaner() {
258258
return
259259
}
260260

261-
ttl := maxRequestLinger.Nanoseconds()
262-
httpMapCleaner.Clean(5*time.Minute, func(now int64, key, val interface{}) bool {
261+
ttl := e.cfg.HTTPIdleConnectionTTL.Nanoseconds()
262+
httpMapCleaner.Clean(e.cfg.HTTPMapCleanerInterval, func(now int64, key, val interface{}) bool {
263263
httpTX, ok := val.(*httpTX)
264264
if !ok {
265265
return false

0 commit comments

Comments
 (0)