Skip to content

Commit ea56b16

Browse files
committed
test: add UT for mtpnc not ready error
1 parent f0a96a1 commit ea56b16

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

cns/middlewares/k8sSwiftV2_linux_test.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package middlewares
33
import (
44
"context"
55
"fmt"
6+
"strings"
67
"testing"
78

89
"github.com/Azure/azure-container-networking/cns"
@@ -243,6 +244,17 @@ func TestGetSWIFTv2IPConfigFailure(t *testing.T) {
243244
assert.Error(t, err, errMTPNCNotReady.Error())
244245
}
245246

247+
// In AKS, for kubelet to retry faster it is particularly looking for "network is not ready" error string.
248+
// https://github.com/kubernetes/kubernetes/blob/efd2a0d1f514be96a2f012fc3cb40f7c872b4e67/pkg/kubelet/pod_workers.go#L1495C2-L1501C3
249+
// This test is to ensure that the error string errMTPNCNotReady contains "network is not ready"
250+
func TestMTPNCNotReadyErrorMessage(t *testing.T) {
251+
middleware := K8sSWIFTv2Middleware{Cli: mock.NewClient()}
252+
// Pod's MTPNC is not ready test
253+
_, err := middleware.getIPConfig(context.TODO(), testPod4Info)
254+
255+
assert.Equal(t, strings.Contains(err.Error(), "network is not ready"), true)
256+
}
257+
246258
func TestSetRoutesSuccess(t *testing.T) {
247259
middleware := K8sSWIFTv2Middleware{Cli: mock.NewClient()}
248260
t.Setenv(configuration.EnvPodCIDRs, "10.0.1.10/24,16A0:0010:AB00:001E::2/32")

0 commit comments

Comments
 (0)