mirror of
https://github.com/moby/moby.git
synced 2026-01-11 10:41:43 +00:00
daemon/libnetwork: use t.Context() in tests
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
@@ -46,7 +46,7 @@ func testNetwork(networkType string, t *testing.T) {
|
||||
|
||||
epOptions := make(map[string]any)
|
||||
te := &testEndpoint{}
|
||||
err = d.CreateEndpoint(context.TODO(), "dummy", "ep1", te.Interface(), epOptions)
|
||||
err = d.CreateEndpoint(t.Context(), "dummy", "ep1", te.Interface(), epOptions)
|
||||
if err != nil {
|
||||
t.Fatalf("Failed to create an endpoint : %s", err.Error())
|
||||
}
|
||||
|
||||
@@ -437,7 +437,7 @@ func TestNetworkEndpointsWalkers(t *testing.T) {
|
||||
assert.Assert(t, epWanted != nil)
|
||||
assert.Assert(t, is.Equal(epWanted, ep11))
|
||||
|
||||
ctx := context.TODO()
|
||||
ctx := t.Context()
|
||||
current := len(controller.Networks(ctx))
|
||||
|
||||
// Create network 2
|
||||
@@ -1262,7 +1262,7 @@ func externalKeyTest(t *testing.T, reexec bool) {
|
||||
assert.NilError(t, err, "Failed to create new osl sandbox")
|
||||
defer func() {
|
||||
if err := extOsBox.Destroy(); err != nil {
|
||||
log.G(context.TODO()).Warnf("Failed to remove os sandbox: %v", err)
|
||||
log.G(t.Context()).Warnf("Failed to remove os sandbox: %v", err)
|
||||
}
|
||||
}()
|
||||
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package libnetwork
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"net"
|
||||
"net/netip"
|
||||
@@ -176,7 +175,7 @@ func TestAddEpToResolver(t *testing.T) {
|
||||
}
|
||||
|
||||
// Add the endpoint and check expected results.
|
||||
err := addEpToResolverImpl(context.TODO(),
|
||||
err := addEpToResolverImpl(t.Context(),
|
||||
"netname", "epname", tc.epToAdd, resolvers, tc.hnsEndpoints)
|
||||
assert.Check(t, err)
|
||||
for i, resolver := range resolvers {
|
||||
|
||||
@@ -38,6 +38,7 @@ type TestingT interface {
|
||||
assert.TestingT
|
||||
poll.TestingT
|
||||
Helper()
|
||||
Context() context.Context
|
||||
}
|
||||
|
||||
func launchNode(t TestingT, conf Config) *NetworkDB {
|
||||
@@ -82,7 +83,7 @@ func createNetworkDBInstances(t TestingT, num int, namePrefix string, conf *Conf
|
||||
|
||||
func closeNetworkDBInstances(t TestingT, dbs []*NetworkDB) {
|
||||
t.Helper()
|
||||
log.G(context.TODO()).Print("Closing DB instances...")
|
||||
log.G(t.Context()).Print("Closing DB instances...")
|
||||
for _, db := range dbs {
|
||||
db.Close()
|
||||
}
|
||||
@@ -923,7 +924,7 @@ func TestNetworkDBIslands(t *testing.T) {
|
||||
|
||||
// Now the 3 bootstrap nodes will cleanly leave, and will be properly removed from the other 2 nodes
|
||||
for i := 0; i < 3; i++ {
|
||||
log.G(context.TODO()).Infof("node %d leaving", i)
|
||||
log.G(t.Context()).Infof("node %d leaving", i)
|
||||
dbs[i].Close()
|
||||
}
|
||||
|
||||
@@ -958,7 +959,7 @@ func TestNetworkDBIslands(t *testing.T) {
|
||||
|
||||
// Spawn again the first 3 nodes with different names but same IP:port
|
||||
for i := 0; i < 3; i++ {
|
||||
log.G(context.TODO()).Infof("node %d coming back", i)
|
||||
log.G(t.Context()).Infof("node %d coming back", i)
|
||||
conf := *dbs[i].config
|
||||
conf.NodeID = stringid.TruncateID(stringid.GenerateRandomID())
|
||||
dbs[i] = launchNode(t, conf)
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package kernel
|
||||
|
||||
import (
|
||||
"context"
|
||||
"testing"
|
||||
|
||||
"github.com/containerd/log"
|
||||
@@ -18,7 +17,7 @@ func TestReadWriteKnobs(t *testing.T) {
|
||||
// Check if the test is able to read the value
|
||||
v, err := readSystemProperty(k)
|
||||
if err != nil {
|
||||
log.G(context.TODO()).WithError(err).Warnf("Path %v not readable", k)
|
||||
log.G(t.Context()).WithError(err).Warnf("Path %v not readable", k)
|
||||
// the path is not there, skip this key
|
||||
continue
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user