convert k8s.io/kubernetes/pkg/proxy to contextual logging, part 1
Signed-off-by: Ziqi Zhao <zhaoziqi9146@gmail.com>
This commit is contained in:
@@ -561,6 +561,7 @@ detectLocalMode: "BridgeInterface"`)
|
||||
}
|
||||
|
||||
for _, tc := range testCases {
|
||||
_, ctx := ktesting.NewTestContext(t)
|
||||
file, tempDir, err := setUp()
|
||||
if err != nil {
|
||||
t.Fatalf("unexpected error when setting up environment: %v", err)
|
||||
@@ -576,7 +577,7 @@ detectLocalMode: "BridgeInterface"`)
|
||||
|
||||
errCh := make(chan error, 1)
|
||||
go func() {
|
||||
errCh <- opt.runLoop()
|
||||
errCh <- opt.runLoop(ctx)
|
||||
}()
|
||||
|
||||
if tc.append {
|
||||
@@ -598,6 +599,7 @@ detectLocalMode: "BridgeInterface"`)
|
||||
}
|
||||
|
||||
func Test_waitForPodCIDR(t *testing.T) {
|
||||
_, ctx := ktesting.NewTestContext(t)
|
||||
expected := []string{"192.168.0.0/24", "fd00:1:2::/64"}
|
||||
nodeName := "test-node"
|
||||
oldNode := &v1.Node{
|
||||
@@ -636,7 +638,7 @@ func Test_waitForPodCIDR(t *testing.T) {
|
||||
// set the PodCIDRs on the new node
|
||||
fakeWatch.Modify(updatedNode)
|
||||
}()
|
||||
got, err := waitForPodCIDR(client, node.Name)
|
||||
got, err := waitForPodCIDR(ctx, client, node.Name)
|
||||
if err != nil {
|
||||
t.Errorf("waitForPodCIDR() unexpected error %v", err)
|
||||
return
|
||||
@@ -679,8 +681,8 @@ func TestGetConntrackMax(t *testing.T) {
|
||||
Min: ptr.To(tc.min),
|
||||
MaxPerCore: ptr.To(tc.maxPerCore),
|
||||
}
|
||||
logger, _ := ktesting.NewTestContext(t)
|
||||
x, e := getConntrackMax(logger, cfg)
|
||||
_, ctx := ktesting.NewTestContext(t)
|
||||
x, e := getConntrackMax(ctx, cfg)
|
||||
if e != nil {
|
||||
if tc.err == "" {
|
||||
t.Errorf("[%d] unexpected error: %v", i, e)
|
||||
@@ -720,6 +722,7 @@ func TestProxyServer_platformSetup(t *testing.T) {
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
_, ctx := ktesting.NewTestContext(t)
|
||||
client := clientsetfake.NewSimpleClientset(tt.node)
|
||||
s := &ProxyServer{
|
||||
Config: tt.config,
|
||||
@@ -730,7 +733,7 @@ func TestProxyServer_platformSetup(t *testing.T) {
|
||||
v1.IPv6Protocol: net.IPv6zero,
|
||||
},
|
||||
}
|
||||
err := s.platformSetup()
|
||||
err := s.platformSetup(ctx)
|
||||
if err != nil {
|
||||
t.Errorf("ProxyServer.createProxier() error = %v", err)
|
||||
return
|
||||
|
Reference in New Issue
Block a user