Skip to content

Commit

Permalink
Fixes to entity selector integration test.
Browse files Browse the repository at this point in the history
- Reduce wait time after CES CR config is applied.
- Fetch existing CES before updating the CES from the test in order to get the latest
version of CES CR.

Signed-off-by: Archana Holla <[email protected]>
  • Loading branch information
archanapholla authored and reachjainrahul committed Sep 7, 2023
1 parent 8934f5d commit 4655984
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions test/integration/entityselector_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import (
corev1 "k8s.io/api/core/v1"
v1 "k8s.io/api/core/v1"
v12 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/types"
logf "sigs.k8s.io/controller-runtime/pkg/log"

"antrea.io/nephe/apis/crd/v1alpha1"
Expand Down Expand Up @@ -111,6 +112,11 @@ var _ = Describe(fmt.Sprintf("%s: Entity selector test", focusAws), func() {
VMSelector: []v1alpha1.VirtualMachineSelector{},
},
}
} else {
// fetch the latest CES in order to avoid resource version related issues on CES update.
namespacedName := types.NamespacedName{Name: testAccountName, Namespace: cesNs[i].Name}
err := k8sClient.Get(context.TODO(), namespacedName, &selector[i])
Expect(err).ToNot(HaveOccurred())
}

switch matchKey {
Expand Down Expand Up @@ -195,10 +201,9 @@ var _ = Describe(fmt.Sprintf("%s: Entity selector test", focusAws), func() {
return true
}

tester := func(matchKey string, matchValue []string, selectorExists bool, numOfInterval int, cesNs []v1.Namespace,
expectedResult [][]string) {
tester := func(matchKey string, matchValue []string, selectorExists bool, cesNs []v1.Namespace, expectedResult [][]string) {
applyEntitySelector(matchKey, matchValue, selectorExists, cesNs)
time.Sleep(time.Duration(numOfInterval) * time.Duration(pollInterval) * time.Second)
time.Sleep(time.Duration(pollInterval) * time.Second)

for i := range cesNs {
var expectedResultValue []string
Expand Down Expand Up @@ -353,15 +358,15 @@ var _ = Describe(fmt.Sprintf("%s: Entity selector test", focusAws), func() {
func(matchKey string) {
By("Apply entity selector with valid match key")
matchValue, expectedResult := setParams(matchKey, "")
tester(matchKey, matchValue, false, 2, cesNamespace, expectedResult)
tester(matchKey, matchValue, false, cesNamespace, expectedResult)

By("Change match key to invalid non-empty value")
matchValue, _ = setParams(matchKey, "xyz")
tester(matchKey, matchValue, true, 2, cesNamespace, nil)
tester(matchKey, matchValue, true, cesNamespace, nil)

By("Change match key back to valid value again")
matchValue, expectedResult = setParams(matchKey, "")
tester(matchKey, matchValue, true, 2, cesNamespace, expectedResult)
tester(matchKey, matchValue, true, cesNamespace, expectedResult)

},
Entry(focusAzure+":"+"VPC id match", vpcIDMatch),
Expand Down

0 comments on commit 4655984

Please sign in to comment.