Skip to content

Commit

Permalink
fix: correct log level in e2e tests
Browse files Browse the repository at this point in the history
Signed-off-by: Niklas Treml <[email protected]>
  • Loading branch information
niklastreml committed Aug 5, 2024
1 parent 63292f0 commit 6c5f24a
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 6 deletions.
3 changes: 0 additions & 3 deletions .github/workflows/e2e_checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@ permissions:
jobs:
test_e2e:
runs-on: ubuntu-latest
env:
LOG_LEVEL: DEBUG
LOG_FORMAT: TEXT
steps:
- name: Checkout repository
uses: actions/checkout@v4
Expand Down
2 changes: 2 additions & 0 deletions e2e/traceroute/lab.conf
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ r2[image]="kathara/base"

pc1[0]="A"
pc1[image]="kathara/base"
pc1[env]="LOG_LEVEL=DEBUG"
pc1[env]="LOG_FORMAT=TEXT"

pc2[0]="C"
pc2[image]="kathara/base"
2 changes: 2 additions & 0 deletions pkg/checks/traceroute/test-lab/lab.conf
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ r2[image]="kathara/base"

pc1[0]="A"
pc1[image]="kathara/base"
pc1[env]="LOG_LEVEL=DEBUG"
pc1[env]="LOG_FORMAT=TEXT"

pc2[0]="C"
pc2[image]="kathara/base"
6 changes: 3 additions & 3 deletions pkg/checks/traceroute/traceroute.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ func randomPort() int {
return rand.Intn(10_000) + 30_000 // #nosec G404 // math.rand is fine here, we're not doing encryption
}

func tcpHop(addr net.Addr, ttl int, timeout time.Duration) (net.Conn, int, error) {
func tcpHop(ctx context.Context, addr net.Addr, ttl int, timeout time.Duration) (net.Conn, int, error) {
for {
port := randomPort()
// Dialer with control function to set IP_TTL
Expand All @@ -53,7 +53,7 @@ func tcpHop(addr net.Addr, ttl int, timeout time.Duration) (net.Conn, int, error
}

// Attempt to connect to the target host
conn, err := dialer.Dial("tcp", addr.String())
conn, err := dialer.DialContext(ctx, "tcp", addr.String())
if !errors.Is(err, unix.EADDRINUSE) {
return conn, port, err
}
Expand Down Expand Up @@ -179,7 +179,7 @@ func traceroute(ctx context.Context, addr net.Addr, ttl int, timeout time.Durati
defer closeIcmpListener(canIcmp, icmpListener)

start := time.Now()
conn, clientPort, err := tcpHop(addr, ttl, timeout)
conn, clientPort, err := tcpHop(ctx, addr, ttl, timeout)
latency := time.Since(start)
if err == nil {
return handleTcpSuccess(conn, addr, ttl, latency), nil
Expand Down

0 comments on commit 6c5f24a

Please sign in to comment.