Skip to content

Commit

Permalink
add http monitor tests (#13114)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
guyarb authored Aug 31, 2022
1 parent 3a05d06 commit 8c0e44c
Show file tree
Hide file tree
Showing 5 changed files with 310 additions and 45 deletions.
2 changes: 2 additions & 0 deletions pkg/config/system_probe.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,8 @@ func InitSystemProbeConfig(cfg Config) {
cfg.BindEnvAndSetDefault(join(spNS, "collect_dns_domains"), true, "DD_COLLECT_DNS_DOMAINS")
cfg.BindEnvAndSetDefault(join(spNS, "max_dns_stats"), 20000)
cfg.BindEnvAndSetDefault(join(spNS, "dns_timeout_in_s"), 15)
cfg.BindEnvAndSetDefault(join(spNS, "http_map_cleaner_interval_in_s"), 300)
cfg.BindEnvAndSetDefault(join(spNS, "http_idle_connection_ttl_in_s"), 30)

cfg.BindEnvAndSetDefault(join(spNS, "enable_conntrack"), true)
cfg.BindEnvAndSetDefault(join(spNS, "conntrack_max_state_size"), 65536*2)
Expand Down
9 changes: 9 additions & 0 deletions pkg/network/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,12 @@ type Config struct {
// EnableRootNetNs disables using the network namespace of the root process (1)
// for things like creating netlink sockets for conntrack updates, etc.
EnableRootNetNs bool

// HTTPMapCleanerInterval is the interval to run the cleaner function.
HTTPMapCleanerInterval time.Duration

// HTTPIdleConnectionTTL is the time an idle connection counted as "inactive" and should be deleted.
HTTPIdleConnectionTTL time.Duration
}

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

EnableRootNetNs: cfg.GetBool(join(netNS, "enable_root_netns")),

HTTPMapCleanerInterval: time.Duration(cfg.GetInt(join(spNS, "http_map_cleaner_interval_in_s"))) * time.Second,
HTTPIdleConnectionTTL: time.Duration(cfg.GetInt(join(spNS, "http_idle_connection_ttl_in_s"))) * time.Second,
}

if !cfg.IsSet(join(spNS, "max_closed_connections_buffered")) {
Expand Down
4 changes: 2 additions & 2 deletions pkg/network/http/ebpf_main.go
Original file line number Diff line number Diff line change
Expand Up @@ -258,8 +258,8 @@ func (e *ebpfProgram) setupMapCleaner() {
return
}

ttl := maxRequestLinger.Nanoseconds()
httpMapCleaner.Clean(5*time.Minute, func(now int64, key, val interface{}) bool {
ttl := e.cfg.HTTPIdleConnectionTTL.Nanoseconds()
httpMapCleaner.Clean(e.cfg.HTTPMapCleanerInterval, func(now int64, key, val interface{}) bool {
httpTX, ok := val.(*httpTX)
if !ok {
return false
Expand Down
Loading

0 comments on commit 8c0e44c

Please sign in to comment.