Skip to content

Commit

Permalink
Fix Policy Recommendation E2E test in Kind Cluster (#410)
Browse files Browse the repository at this point in the history
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 <dyongming@vmware.com>
  • Loading branch information
dreamtalen authored Aug 1, 2023
1 parent 32d4c83 commit 68492cc
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 5 deletions.
4 changes: 2 additions & 2 deletions ci/kind/test-e2e-kind.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

}
Expand Down
20 changes: 17 additions & 3 deletions test/e2e/policyrecommendation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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
}
Expand Down

0 comments on commit 68492cc

Please sign in to comment.