mirror of
https://github.com/netbirdio/gvisor.git
synced 2026-05-22 17:12:49 -07:00
iptables: use log package to get timestamps in tests
Useful in debugging buildkite flakes, e.g: https://buildkite.com/gvisor/pipeline/builds/26145 PiperOrigin-RevId: 586125192
This commit is contained in:
committed by
gVisor bot
parent
9cf9d1d01d
commit
b4ef436453
@@ -38,6 +38,7 @@ go_test(
|
||||
"manual",
|
||||
],
|
||||
deps = [
|
||||
"//pkg/log",
|
||||
"//pkg/test/dockerutil",
|
||||
"//pkg/test/testutil",
|
||||
],
|
||||
|
||||
@@ -23,6 +23,7 @@ import (
|
||||
"sync"
|
||||
"testing"
|
||||
|
||||
"gvisor.dev/gvisor/pkg/log"
|
||||
"gvisor.dev/gvisor/pkg/test/dockerutil"
|
||||
"gvisor.dev/gvisor/pkg/test/testutil"
|
||||
)
|
||||
@@ -50,7 +51,8 @@ func singleTest(t *testing.T, test TestCase) {
|
||||
|
||||
func iptablesTest(t *testing.T, test TestCase, ipv6 bool) {
|
||||
if _, ok := Tests[test.Name()]; !ok {
|
||||
t.Fatalf("no test found with name %q. Has it been registered?", test.Name())
|
||||
log.Infof("no test found with name %q. Has it been registered?", test.Name())
|
||||
t.FailNow()
|
||||
}
|
||||
|
||||
// Wait for the local and container goroutines to finish.
|
||||
@@ -63,9 +65,9 @@ func iptablesTest(t *testing.T, test TestCase, ipv6 bool) {
|
||||
d := dockerutil.MakeContainer(ctx, t)
|
||||
defer func() {
|
||||
if logs, err := d.Logs(context.Background()); err != nil {
|
||||
t.Logf("Failed to retrieve container logs.")
|
||||
log.Infof("Failed to retrieve container logs.")
|
||||
} else {
|
||||
t.Logf("=== Container logs: ===\n%s", logs)
|
||||
log.Infof("=== Container logs: ===\n%s", logs)
|
||||
}
|
||||
// Use a new context, as cleanup should run even when we
|
||||
// timeout.
|
||||
@@ -83,7 +85,8 @@ func iptablesTest(t *testing.T, test TestCase, ipv6 bool) {
|
||||
args = append(args, "-ipv6")
|
||||
}
|
||||
if err := d.Spawn(ctx, opts, args...); err != nil {
|
||||
t.Fatalf("docker run failed: %v", err)
|
||||
log.Infof("docker run failed: %v", err)
|
||||
t.FailNow()
|
||||
}
|
||||
|
||||
// Get the container IP.
|
||||
@@ -91,14 +94,17 @@ func iptablesTest(t *testing.T, test TestCase, ipv6 bool) {
|
||||
if err != nil {
|
||||
// If ipv6 is not configured, don't fail.
|
||||
if ipv6 && err == dockerutil.ErrNoIP {
|
||||
t.Skipf("No ipv6 address is available.")
|
||||
log.Infof("No ipv6 address is available.")
|
||||
t.Skip()
|
||||
}
|
||||
t.Fatalf("failed to get container IP: %v", err)
|
||||
log.Infof("failed to get container IP: %v", err)
|
||||
t.FailNow()
|
||||
}
|
||||
|
||||
// Give the container our IP.
|
||||
if err := sendIP(ip); err != nil {
|
||||
t.Fatalf("failed to send IP to container: %v", err)
|
||||
log.Infof("failed to send IP to container: %v", err)
|
||||
t.FailNow()
|
||||
}
|
||||
|
||||
// Run our side of the test.
|
||||
|
||||
Reference in New Issue
Block a user