Skip to content

Commit

Permalink
set trace log level for our flakyest tests (#21595)
Browse files Browse the repository at this point in the history
set trace log level for our flakyest tests
  • Loading branch information
akarpz authored Dec 20, 2023
1 parent 9010795 commit 890419a
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 0 deletions.
1 change: 1 addition & 0 deletions pkg/network/tracer/conntracker_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ const (
)

func TestConntrackers(t *testing.T) {
ebpftest.LogLevel(t, "trace")
t.Run("netlink", func(t *testing.T) {
runConntrackerTest(t, "netlink", setupNetlinkConntracker)
})
Expand Down
9 changes: 9 additions & 0 deletions pkg/network/tracer/offsetguess/conntrack.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ func (c *conntrackOffsetGuesser) checkAndUpdateCurrentOffset(mp *ebpf.Map, expec
case GuessCtTupleOrigin:
c.status.Offset_origin, overlapped = skipOverlaps(c.status.Offset_origin, c.nfConnRanges())
if overlapped {
log.Tracef("offset %v overlaps with another field, skipping", whatString[GuessWhat(c.status.What)])
// adjusted offset from eBPF overlapped with another field, we need to check new offset
break
}
Expand All @@ -155,11 +156,14 @@ func (c *conntrackOffsetGuesser) checkAndUpdateCurrentOffset(mp *ebpf.Map, expec
c.logAndAdvance(c.status.Offset_origin, GuessCtTupleReply)
break
}
log.Tracef("%v %d does not match expected %d, incrementing offset %d",
whatString[GuessWhat(c.status.What)], c.status.Saddr, expected.saddr, c.status.Offset_origin)
c.status.Offset_origin++
c.status.Offset_origin, _ = skipOverlaps(c.status.Offset_origin, c.nfConnRanges())
case GuessCtTupleReply:
c.status.Offset_reply, overlapped = skipOverlaps(c.status.Offset_reply, c.nfConnRanges())
if overlapped {
log.Tracef("offset %v overlaps with another field, skipping", whatString[GuessWhat(c.status.What)])
// adjusted offset from eBPF overlapped with another field, we need to check new offset
break
}
Expand All @@ -168,11 +172,14 @@ func (c *conntrackOffsetGuesser) checkAndUpdateCurrentOffset(mp *ebpf.Map, expec
c.logAndAdvance(c.status.Offset_reply, GuessCtNet)
break
}
log.Tracef("%v %d does not match expected %d, incrementing offset %d",
whatString[GuessWhat(c.status.What)], c.status.Saddr, expected.daddr, c.status.Offset_reply)
c.status.Offset_reply++
c.status.Offset_reply, _ = skipOverlaps(c.status.Offset_reply, c.nfConnRanges())
case GuessCtNet:
c.status.Offset_netns, overlapped = skipOverlaps(c.status.Offset_netns, c.nfConnRanges())
if overlapped {
log.Tracef("offset %v overlaps with another field, skipping", whatString[GuessWhat(c.status.What)])
// adjusted offset from eBPF overlapped with another field, we need to check new offset
break
}
Expand All @@ -181,6 +188,8 @@ func (c *conntrackOffsetGuesser) checkAndUpdateCurrentOffset(mp *ebpf.Map, expec
c.logAndAdvance(c.status.Offset_netns, GuessNotApplicable)
return c.setReadyState(mp)
}
log.Tracef("%v %d does not match expected %d, incrementing offset %d",
whatString[GuessWhat(c.status.What)], c.status.Netns, expected.netns, c.status.Offset_netns)
c.status.Offset_netns++
c.status.Offset_netns, _ = skipOverlaps(c.status.Offset_netns, c.nfConnRanges())
default:
Expand Down
2 changes: 2 additions & 0 deletions pkg/network/tracer/offsetguess_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ func (o offsetT) String() string {
}

func TestOffsetGuess(t *testing.T) {
ebpftest.LogLevel(t, "trace")
ebpftest.TestBuildMode(t, ebpftest.RuntimeCompiled, "", testOffsetGuess)
}

Expand Down Expand Up @@ -156,6 +157,7 @@ func testOffsetGuess(t *testing.T) {
consts := map[offsetT]uint64{}
for _, c := range _consts {
value := c.Value.(uint64)
t.Logf("Guessed offset %v with value %v", c.Name, value)
switch c.Name {
case "offset_saddr":
consts[offsetSaddr] = value
Expand Down
4 changes: 4 additions & 0 deletions pkg/network/tracer/tracer_linux_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ import (
ddebpf "github.com/DataDog/datadog-agent/pkg/ebpf"
"github.com/DataDog/datadog-agent/pkg/ebpf/bytecode"
rc "github.com/DataDog/datadog-agent/pkg/ebpf/bytecode/runtime"
"github.com/DataDog/datadog-agent/pkg/ebpf/ebpftest"
"github.com/DataDog/datadog-agent/pkg/network"
"github.com/DataDog/datadog-agent/pkg/network/config"
"github.com/DataDog/datadog-agent/pkg/network/config/sysctl"
Expand Down Expand Up @@ -382,6 +383,7 @@ func (s *TracerSuite) TestConnectionExpirationRegression() {

func (s *TracerSuite) TestConntrackExpiration() {
t := s.T()
ebpftest.LogLevel(t, "trace")
netlinktestutil.SetupDNAT(t)
wg := sync.WaitGroup{}

Expand Down Expand Up @@ -2027,6 +2029,7 @@ func (s *TracerSuite) TestGetHelpersTelemetry() {
}

func TestEbpfConntrackerFallback(t *testing.T) {
ebpftest.LogLevel(t, "trace")
type testCase struct {
enableRuntimeCompiler bool
allowPrecompiledFallback bool
Expand Down Expand Up @@ -2102,6 +2105,7 @@ func TestEbpfConntrackerFallback(t *testing.T) {
}

func TestConntrackerFallback(t *testing.T) {
ebpftest.LogLevel(t, "trace")
cfg := testConfig()
cfg.EnableEbpfConntracker = false
cfg.AllowNetlinkConntrackerFallback = true
Expand Down

0 comments on commit 890419a

Please sign in to comment.