From 68492ccd823e5dda8c28b55ad40c63a333511ac5 Mon Sep 17 00:00:00 2001 From: Yongming Ding Date: Tue, 1 Aug 2023 14:48:59 -0700 Subject: [PATCH] Fix Policy Recommendation E2E test in Kind Cluster (#410) Kind cluster introduced a new Pod local-path-provisioner recently which causes Policy Recommendation E2E test because of recomming extra Network Policies. To fix test, we add the new Pod's namespace local-path-storage into the argument when starting the recommendation job in Kind cluster. Signed-off-by: Yongming Ding --- ci/kind/test-e2e-kind.sh | 4 ++-- test/e2e/policyrecommendation_test.go | 20 +++++++++++++++++--- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/ci/kind/test-e2e-kind.sh b/ci/kind/test-e2e-kind.sh index c91c06cc..8a8ecb5f 100755 --- a/ci/kind/test-e2e-kind.sh +++ b/ci/kind/test-e2e-kind.sh @@ -185,9 +185,9 @@ function run_test { sleep 1 if $coverage; then - go test -v -timeout=30m antrea.io/theia/test/e2e -provider=kind --logs-export-dir=$ANTREA_LOG_DIR -cover -covermode=atomic --skip=$skiplist + go test -v -timeout=45m antrea.io/theia/test/e2e -provider=kind --logs-export-dir=$ANTREA_LOG_DIR -cover -covermode=atomic --skip=$skiplist else - go test -v -timeout=30m antrea.io/theia/test/e2e -provider=kind --logs-export-dir=$ANTREA_LOG_DIR --skip=$skiplist + go test -v -timeout=45m antrea.io/theia/test/e2e -provider=kind --logs-export-dir=$ANTREA_LOG_DIR --skip=$skiplist fi } diff --git a/test/e2e/policyrecommendation_test.go b/test/e2e/policyrecommendation_test.go index 5f0933a0..b3dc2d6f 100644 --- a/test/e2e/policyrecommendation_test.go +++ b/test/e2e/policyrecommendation_test.go @@ -33,7 +33,7 @@ const ( jobCompleteTimeout = 10 * time.Minute jobSubmitTimeout = 2 * time.Minute jobFailedTimeout = 2 * time.Minute - startCmd = "./theia policy-recommendation run" + startBaseCmd = "./theia policy-recommendation run" statusCmd = "./theia policy-recommendation status" listCmd = "./theia policy-recommendation list" deleteCmd = "./theia policy-recommendation delete" @@ -313,8 +313,15 @@ func testPolicyRecommendationRetrieve(t *testing.T, data *TestData, isIPv6 bool, // recommendation job recommends 3 allow ANP, and 3 default deny ACNP. // Besides, there will always be 3 allow ACNP recommended for the // 'kube-system', 'flow-aggregator', and 'flow-visibility' Namespace. + // For Kind cluster, there will be 1 more Namespace 'local-path-storage' + // having allow ACNP recommended. expectedAllowANPCnt := 3 - expectedAllowACNPCnt := 3 + var expectedAllowACNPCnt int + if testOptions.providerName == "kind" { + expectedAllowACNPCnt = 4 + } else { + expectedAllowACNPCnt = 3 + } expectedRejectANPCnt := 0 expectedRejectACNPCnt := 3 @@ -398,7 +405,14 @@ func testPolicyRecommendationRetrieve(t *testing.T, data *TestData, isIPv6 bool, } func runJob(t *testing.T, data *TestData) (stdout string, jobName string, err error) { - stdout, jobName, err = RunJob(t, data, startCmd) + // For Kind cluster, there is 1 more default traffic allow Namespace 'local-path-storage'. + var startJobCmd string + if testOptions.providerName == "kind" { + startJobCmd = startBaseCmd + " --ns-allow-list " + "[\"kube-system\",\"flow-aggregator\",\"flow-visibility\",\"local-path-storage\"]" + } else { + startJobCmd = startBaseCmd + } + stdout, jobName, err = RunJob(t, data, startJobCmd) if err != nil { return "", "", err }