Skip to content

Commit

Permalink
Add e2e test for Multi-cluster Service Endpoints changes (#4217)
Browse files Browse the repository at this point in the history
Add a new e2e test to validate Endpoint change event to
make sure event filter works as expected.

Signed-off-by: Lan Luo <[email protected]>
  • Loading branch information
luolanzone authored Sep 20, 2022
1 parent 0d98ab1 commit 5ce44ea
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
1 change: 1 addition & 0 deletions multicluster/test/e2e/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ func TestConnectivity(t *testing.T) {
defer tearDownForServiceExportsTest(t, data)
initializeForServiceExportsTest(t, data)
t.Run("Case=MCServiceConnectivity", func(t *testing.T) { testMCServiceConnectivity(t, data) })
t.Run("Case=ScaleDownMCServiceEndpoints", func(t *testing.T) { testScaleDownMCServiceEndpoints(t, data) })
t.Run("Case=ANPToServices", func(t *testing.T) { testANPToServices(t, data) })
})

Expand Down
14 changes: 13 additions & 1 deletion multicluster/test/e2e/service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (
"time"

corev1 "k8s.io/api/core/v1"
apierrors "k8s.io/apimachinery/pkg/api/errors"

crdv1alpha1 "antrea.io/antrea/pkg/apis/crd/v1alpha1"
antreae2e "antrea.io/antrea/test/e2e"
Expand Down Expand Up @@ -100,6 +101,18 @@ func testMCServiceConnectivity(t *testing.T, data *MCTestData) {
data.testMCServiceConnectivity(t)
}

// Delete existing Pod to scale down the number of Endpoints to zero, then
// the Multi-cluster Service should be deleted due to empty Endpoints.
func testScaleDownMCServiceEndpoints(t *testing.T, data *MCTestData) {
deletePodWrapper(t, data, eastCluster, multiClusterTestNamespace, testServerPod)
time.Sleep(2 * time.Second)
mcServiceName := fmt.Sprintf("antrea-mc-%s", eastClusterTestService)
_, err := data.getService(westCluster, multiClusterTestNamespace, mcServiceName)
if !apierrors.IsNotFound(err) {
t.Fatalf("Expected to get not found error when getting the imported Service %s, but got: %v", mcServiceName, err)
}
}

func testANPToServices(t *testing.T, data *MCTestData) {
data.testANPToServices(t)
}
Expand All @@ -126,7 +139,6 @@ func (data *MCTestData) probeMCServiceFromCluster(t *testing.T, clusterName stri
if err := data.probeServiceFromPodInCluster(clusterName, regularClientName, "client", multiClusterTestNamespace, ip); err != nil {
t.Fatalf("Error when probing Service from client Pod %s in cluster %s, err: %v", regularClientName, clusterName, err)
}
return
}

func (data *MCTestData) testANPToServices(t *testing.T) {
Expand Down

0 comments on commit 5ce44ea

Please sign in to comment.