Repository: submariner-io/lighthouse
Pull request #257 (2020-08-19 14:29:21)

Define test package for UT files in serviceimport
It's good practice to put UTs in the `_test` package.



Patch:
diff --git a/pkg/agent/controller/agent.go b/pkg/agent/controller/agent.go
index 60fce85..7d309fa 100644
--- a/pkg/agent/controller/agent.go
+++ b/pkg/agent/controller/agent.go
@@ -238,7 +238,7 @@ func (a *Controller) serviceExportToRemoteServiceImport(obj runtime.Object, op s
 		},
 	}
 
-	if svcType == lighthousev2a1.SuperclusterIP {
+	if svcType == lighthousev2a1.ClusterSetIP {
 		/* We also store the clusterIP in an annotation as an optimization to recover it in case the IPs are
 		cleared out when here's no backing Endpoint pods.
 		*/
@@ -260,7 +260,7 @@ func getServiceImportType(service *corev1.Service) (lighthousev2a1.ServiceImport
 		return lighthousev2a1.Headless, true
 	}
 
-	return lighthousev2a1.SuperclusterIP, true
+	return lighthousev2a1.ClusterSetIP, true
 }
 
 func (a *Controller) onSuccessfulServiceImportSync(synced runtime.Object, op syncer.Operation) {
@@ -330,7 +330,7 @@ func (a *Controller) endpointToRemoteServiceImport(obj runtime.Object, op syncer
 
 	ipList := getIPsFromEndpoint(ep)
 
-	if serviceImport.Spec.Type == lighthousev2a1.SuperclusterIP && len(ipList) > 0 {
+	if serviceImport.Spec.Type == lighthousev2a1.ClusterSetIP && len(ipList) > 0 {
 		/*
 			When there's no healthy pods, the IPs in the Endpoint will become empty and
 			thus we also clear the ServiceImport IPs to avoid clients sending a request
@@ -448,7 +448,7 @@ func (a *Controller) getServiceImport(svcExport *lighthousev2a1.ServiceExport) (
 }
 
 func (a *Controller) getIPsForService(service *corev1.Service, siType lighthousev2a1.ServiceImportType) []string {
-	if siType == lighthousev2a1.SuperclusterIP {
+	if siType == lighthousev2a1.ClusterSetIP {
 		mcsIp := getGlobalIpFromService(service)
 		if mcsIp == "" {
 			mcsIp = service.Spec.ClusterIP
diff --git a/pkg/apis/lighthouse.submariner.io/v2alpha1/types.go b/pkg/apis/lighthouse.submariner.io/v2alpha1/types.go
index e79d573..e1f2e4c 100644
--- a/pkg/apis/lighthouse.submariner.io/v2alpha1/types.go
+++ b/pkg/apis/lighthouse.submariner.io/v2alpha1/types.go
@@ -36,11 +36,11 @@ type ServiceExportConditionType string
 const (
 	// ServiceExportInitialized means the service export has been noticed
 	// by the controller, has passed validation, has appropriate finalizers
-	// set, and any required supercluster resources like the IP have been
+	// set, and any required clusterset resources like the IP have been
 	// reserved
 	ServiceExportInitialized ServiceExportConditionType = "Initialized"
 	// ServiceExportExported means that the service referenced by this
-	// service export has been synced to all clusters in the supercluster
+	// service export has been synced to all clusters in the clusterset
 	ServiceExportExported ServiceExportConditionType = "Exported"
 )
 
@@ -74,7 +74,7 @@ type ServiceExportList struct {
 //+k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
 // +genclient:noStatus
 
-// ServiceImport describes a service imported from clusters in a supercluster.
+// ServiceImport describes a service imported from clusters in a clusterset.
 type ServiceImport struct {
 	metav1.TypeMeta `json:",inline"`
 	// +optional
@@ -89,8 +89,8 @@ type ServiceImport struct {
 type ServiceImportType string
 
 const (
-	// Services are only accessible via their supercluster IP.
-	SuperclusterIP ServiceImportType = "SuperclusterIP"
+	// Services are only accessible via their clusterset IP.
+	ClusterSetIP ServiceImportType = "ClusterSetIP"
 	// Headless services allow backend pods to be addressed directly.
 	Headless ServiceImportType = "Headless"
 )
diff --git a/pkg/serviceimport/controller.go b/pkg/serviceimport/controller.go
index e527c93..878603f 100644
--- a/pkg/serviceimport/controller.go
+++ b/pkg/serviceimport/controller.go
@@ -16,7 +16,7 @@ import (
 
 type Controller struct {
 	// Indirection hook for unit tests to supply fake client sets
-	newClientset    func(kubeConfig *rest.Config) (lighthouseClientset.Interface, error)
+	NewClientset    func(kubeConfig *rest.Config) (lighthouseClientset.Interface, error)
 	serviceInformer cache.SharedIndexInformer
 	queue           workqueue.RateLimitingInterface
 	stopCh          chan struct{}
@@ -26,7 +26,7 @@ type Controller struct {
 func NewController(serviceImportStore Store) *Controller {
 	return &Controller{
 		queue: workqueue.NewRateLimitingQueue(workqueue.DefaultControllerRateLimiter()),
-		newClientset: func(c *rest.Config) (lighthouseClientset.Interface, error) {
+		NewClientset: func(c *rest.Config) (lighthouseClientset.Interface, error) {
 			return lighthouseClientset.NewForConfig(c)
 		},
 		store:  serviceImportStore,
@@ -37,7 +37,7 @@ func NewController(serviceImportStore Store) *Controller {
 func (c *Controller) Start(kubeConfig *rest.Config) error {
 	klog.Infof("Starting ServiceImport Controller")
 
-	clientSet, err := c.newClientset(kubeConfig)
+	clientSet, err := c.NewClientset(kubeConfig)
 	if err != nil {
 		return fmt.Errorf("Error creating client set: %v", err)
 	}
diff --git a/scripts/deploy b/scripts/deploy
index e438506..7b36e79 100755
--- a/scripts/deploy
+++ b/scripts/deploy
@@ -12,7 +12,7 @@ source ${SCRIPTS_DIR}/lib/version
 
 function update_coredns_configmap() {
     kubectl get cm -n kube-system coredns -o yaml > /tmp/coremap-${cluster}.yaml
-    if !(grep -q supercluster /tmp/coremap-${cluster}.yaml); then
+    if !(grep -q clusterset /tmp/coremap-${cluster}.yaml); then
         CLUSTER_IP=`kubectl get svc -n submariner-operator submariner-lighthouse-coredns | tail -n 1| awk '{print $3;}'`
         sed 's/dnsip/'${CLUSTER_IP}'/g' scripts/resources/coredns-cm.yaml > /tmp/coredns-cm-${CLUSTER_IP}.yaml
         sed -i -e "/Corefile:/r /tmp/coredns-cm-${CLUSTER_IP}.yaml" /tmp/coremap-${cluster}.yaml
diff --git a/scripts/resources/coredns-cm.yaml b/scripts/resources/coredns-cm.yaml
index ac31f72..4927260 100644
--- a/scripts/resources/coredns-cm.yaml
+++ b/scripts/resources/coredns-cm.yaml
@@ -1,3 +1,6 @@
+    clusterset.local:53 {
+        forward . dnsip
+    }
     supercluster.local:53 {
         forward . dnsip
     }


Test patch:
diff --git a/pkg/agent/controller/agent_test.go b/pkg/agent/controller/agent_test.go
index 06f5034..a64d7e7 100644
--- a/pkg/agent/controller/agent_test.go
+++ b/pkg/agent/controller/agent_test.go
@@ -2,6 +2,8 @@ package controller_test
 
 import (
 	"fmt"
+	"reflect"
+	"sort"
 	"time"
 
 	. "github.com/onsi/ginkgo"
@@ -18,7 +20,6 @@ import (
 	apierrors "k8s.io/apimachinery/pkg/api/errors"
 	"k8s.io/apimachinery/pkg/api/meta"
 	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
-	"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
 	"k8s.io/apimachinery/pkg/runtime"
 	"k8s.io/apimachinery/pkg/runtime/schema"
 	"k8s.io/apimachinery/pkg/util/wait"
@@ -100,6 +101,23 @@ var _ = Describe("ServiceImport syncing", func() {
 		})
 	})
 
+	When("the Service's pod endpoint IPs are lost and then reestablished", func() {
+		It("should clear and restore the ServiceImport's IPs", func() {
+			t.createService()
+			t.createEndpoints()
+			t.createServiceExport()
+			t.awaitServiceExported(t.service.Spec.ClusterIP, 0)
+
+			t.endpoints.Subsets[0].Addresses = nil
+			t.updateEndpoints()
+			t.awaitUpdatedServiceImport(t.localServiceImportClient)
+
+			t.endpoints.Subsets[0].Addresses = append(t.endpoints.Subsets[0].Addresses, corev1.EndpointAddress{IP: "192.168.5.10"})
+			t.updateEndpoints()
+			t.awaitUpdatedServiceImport(t.localServiceImportClient, t.service.Spec.ClusterIP)
+		})
+	})
+
 	When("the ServiceExportCondition list count reaches MaxExportStatusConditions", func() {
 		var oldMaxExportStatusConditions int
 
@@ -120,6 +138,21 @@ var _ = Describe("ServiceImport syncing", func() {
 				corev1.ConditionTrue, ""))
 		})
 	})
+
+	When("a ServiceExport is created for a Service whose type is other than ServiceTypeClusterIP", func() {
+		BeforeEach(func() {
+			t.service.Spec.Type = corev1.ServiceTypeNodePort
+		})
+
+		It("should update the ServiceExport status and not sync a ServiceImport", func() {
+			t.createService()
+			t.createServiceExport()
+
+			t.awaitServiceExportStatus(0, newServiceExportCondition(lighthousev2a1.ServiceExportInitialized,
+				corev1.ConditionFalse, "UnsupportedServiceType"))
+			t.awaitNoServiceImport(t.brokerServiceImportClient)
+		})
+	})
 })
 
 var _ = Describe("Globalnet enabled", func() {
@@ -155,6 +188,73 @@ var _ = Describe("Globalnet enabled", func() {
 			t.awaitServiceExported(globalIP, 1)
 		})
 	})
+
+	When("a ServiceExport is created for a headless Service", func() {
+		BeforeEach(func() {
+			t.service.Spec.ClusterIP = corev1.ClusterIPNone
+		})
+
+		It("should update the ServiceExport status and not sync a ServiceImport", func() {
+			t.awaitServiceExportStatus(0, newServiceExportCondition(lighthousev2a1.ServiceExportInitialized,
+				corev1.ConditionFalse, "UnsupportedServiceType"))
+
+			t.awaitNoServiceImport(t.brokerServiceImportClient)
+		})
+	})
+})
+
+var _ = Describe("Headless service syncing", func() {
+	t := newTestDiver()
+
+	BeforeEach(func() {
+		t.service.Spec.ClusterIP = corev1.ClusterIPNone
+	})
+
+	JustBeforeEach(func() {
+		t.createService()
+	})
+
+	When("a ServiceExport is created", func() {
+		When("the Endpoints already exists", func() {
+			It("should correctly sync a ServiceImport", func() {
+				t.createEndpoints()
+				t.createServiceExport()
+
+				t.awaitServiceImport(t.localServiceImportClient, lighthousev2a1.Headless, t.endpointIPs()...)
+				t.awaitServiceImport(t.brokerServiceImportClient, lighthousev2a1.Headless, t.endpointIPs()...)
+			})
+		})
+
+		When("the Endpoints doesn't initially exist", func() {
+			It("should eventually sync a correct ServiceImport", func() {
+				t.createServiceExport()
+
+				t.awaitServiceImport(t.localServiceImportClient, lighthousev2a1.Headless)
+				t.awaitServiceImport(t.brokerServiceImportClient, lighthousev2a1.Headless)
+
+				t.createEndpoints()
+
+				t.awaitUpdatedServiceImport(t.localServiceImportClient, t.endpointIPs()...)
+				t.awaitUpdatedServiceImport(t.brokerServiceImportClient, t.endpointIPs()...)
+			})
+		})
+	})
+
+	When("the Endpoints for a service are updated", func() {
+		It("should update the ServiceImport", func() {
+			t.createEndpoints()
+			t.createServiceExport()
+
+			t.awaitServiceImport(t.localServiceImportClient, lighthousev2a1.Headless, t.endpointIPs()...)
+			t.awaitServiceImport(t.brokerServiceImportClient, lighthousev2a1.Headless, t.endpointIPs()...)
+
+			t.endpoints.Subsets[0].Addresses = append(t.endpoints.Subsets[0].Addresses, corev1.EndpointAddress{IP: "192.168.5.3"})
+			t.updateEndpoints()
+
+			t.awaitUpdatedServiceImport(t.localServiceImportClient, t.endpointIPs()...)
+			t.awaitUpdatedServiceImport(t.brokerServiceImportClient, t.endpointIPs()...)
+		})
+	})
 })
 
 type testDriver struct {
@@ -169,6 +269,7 @@ type testDriver struct {
 	lighthouseClient          lighthouseClientset.Interface
 	service                   *corev1.Service
 	serviceExport             *lighthousev2a1.ServiceExport
+	endpoints                 *corev1.Endpoints
 	stopCh                    chan struct{}
 	now                       time.Time
 	restMapper                meta.RESTMapper
@@ -202,6 +303,25 @@ func newTestDiver() *testDriver {
 			},
 		}
 
+		t.endpoints = &corev1.Endpoints{
+			ObjectMeta: metav1.ObjectMeta{
+				Name:      t.service.Name,
+				Namespace: t.service.Namespace,
+			},
+			Subsets: []corev1.EndpointSubset{
+				{
+					Addresses: []corev1.EndpointAddress{
+						{
+							IP: "192.168.5.1",
+						},
+						{
+							IP: "192.168.5.2",
+						},
+					},
+				},
+			},
+		}
+
 		t.restMapper = test.GetRESTMapperFor(&lighthousev2a1.ServiceExport{}, &lighthousev2a1.ServiceImport{},
 			&corev1.Service{}, &corev1.Endpoints{})
 
@@ -253,11 +373,25 @@ func (t *testDriver) createService() {
 	_, err := t.localServiceClient.CoreV1().Services(t.service.Namespace).Create(t.service)
 	Expect(err).To(Succeed())
 
-	rawService := &unstructured.Unstructured{}
-	Expect(scheme.Scheme.Convert(t.service, rawService, nil)).To(Succeed())
+	test.CreateResource(t.dynamicServiceClient(), t.service)
+}
+
+func (t *testDriver) createEndpoints() {
+	_, err := t.localServiceClient.CoreV1().Endpoints(t.endpoints.Namespace).Create(t.endpoints)
+	Expect(err).To(Succeed())
+
+	test.CreateResource(t.dynamicEndpointsClient(), t.endpoints)
+}
 
-	_, err = t.dynamicServiceClient().Create(rawService, metav1.CreateOptions{})
+func (t *testDriver) updateEndpoints() {
+	_, err := t.localServiceClient.CoreV1().Endpoints(t.endpoints.Namespace).Update(t.endpoints)
 	Expect(err).To(Succeed())
+
+	test.UpdateResource(t.dynamicEndpointsClient(), t.endpoints)
+}
+
+func (t *testDriver) dynamicEndpointsClient() dynamic.ResourceInterface {
+	return t.localDynClient.Resource(schema.GroupVersionResource{Version: "v1", Resource: "endpoints"}).Namespace(t.service.Namespace)
 }
 
 func (t *testDriver) createServiceExport() {
@@ -278,7 +412,7 @@ func (t *testDriver) dynamicServiceClient() dynamic.ResourceInterface {
 	return t.localDynClient.Resource(schema.GroupVersionResource{Version: "v1", Resource: "services"}).Namespace(t.service.Namespace)
 }
 
-func (t *testDriver) awaitServiceImport(client dynamic.ResourceInterface, serviceIP string) {
+func (t *testDriver) awaitServiceImport(client dynamic.ResourceInterface, sType lighthousev2a1.ServiceImportType, serviceIPs ...string) {
 	obj := test.AwaitResource(client, t.service.Name+"-"+t.service.Namespace+"-"+clusterID)
 
 	serviceImport := &lighthousev2a1.ServiceImport{}
@@ -286,12 +420,43 @@ func (t *testDriver) awaitServiceImport(client dynamic.ResourceInterface, servic
 
 	Expect(serviceImport.GetAnnotations()["origin-name"]).To(Equal(t.service.Name))
 	Expect(serviceImport.GetAnnotations()["origin-namespace"]).To(Equal(t.service.Namespace))
-	Expect(serviceImport.Spec.Type).To(Equal(lighthousev2a1.SuperclusterIP))
+	Expect(serviceImport.Spec.Type).To(Equal(sType))
 
 	Expect(serviceImport.Status.Clusters).To(HaveLen(1))
 	Expect(serviceImport.Status.Clusters[0].Cluster).To(Equal(clusterID))
-	Expect(serviceImport.Status.Clusters[0].IPs).To(HaveLen(1))
-	Expect(serviceImport.Status.Clusters[0].IPs[0]).To(Equal(serviceIP))
+
+	sort.Strings(serviceIPs)
+	sort.Strings(serviceImport.Status.Clusters[0].IPs)
+	Expect(serviceImport.Status.Clusters[0].IPs).To(Equal(serviceIPs))
+
+	_, err := t.lighthouseClient.LighthouseV2alpha1().ServiceImports(serviceImport.Namespace).Create(serviceImport)
+	Expect(err).To(Succeed())
+}
+
+func (t *testDriver) awaitUpdatedServiceImport(client dynamic.ResourceInterface, serviceIPs ...string) {
+	name := t.service.Name + "-" + t.service.Namespace + "-" + clusterID
+
+	sort.Strings(serviceIPs)
+
+	var serviceImport *lighthousev2a1.ServiceImport
+
+	err := wait.PollImmediate(50*time.Millisecond, 5*time.Second, func() (bool, error) {
+		obj, err := client.Get(name, metav1.GetOptions{})
+		Expect(err).To(Succeed())
+
+		serviceImport = &lighthousev2a1.ServiceImport{}
+		Expect(scheme.Scheme.Convert(obj, serviceImport, nil)).To(Succeed())
+
+		sort.Strings(serviceImport.Status.Clusters[0].IPs)
+
+		return reflect.DeepEqual(serviceImport.Status.Clusters[0].IPs, serviceIPs), nil
+	})
+
+	if err == wait.ErrWaitTimeout {
+		Expect(serviceImport.Status.Clusters[0].IPs).To(Equal(serviceIPs))
+	}
+
+	Expect(err).To(Succeed())
 }
 
 func (t *testDriver) awaitNoServiceImport(client dynamic.ResourceInterface) {
@@ -373,8 +538,8 @@ func (t *testDriver) awaitNotServiceExportStatus(notCond *lighthousev2a1.Service
 }
 
 func (t *testDriver) awaitServiceExported(serviceIP string, statusIndex int) int {
-	t.awaitServiceImport(t.brokerServiceImportClient, serviceIP)
-	t.awaitServiceImport(t.localServiceImportClient, serviceIP)
+	t.awaitServiceImport(t.brokerServiceImportClient, lighthousev2a1.ClusterSetIP, serviceIP)
+	t.awaitServiceImport(t.localServiceImportClient, lighthousev2a1.ClusterSetIP, serviceIP)
 
 	t.awaitServiceExportStatus(statusIndex, newServiceExportCondition(lighthousev2a1.ServiceExportInitialized,
 		corev1.ConditionTrue, "AwaitingSync"), newServiceExportCondition(lighthousev2a1.ServiceExportExported,
@@ -388,6 +553,15 @@ func (t *testDriver) awaitServiceUnavailableStatus(atIndex int) {
 		corev1.ConditionFalse, "ServiceUnavailable"))
 }
 
+func (t *testDriver) endpointIPs() []string {
+	ips := []string{}
+	for _, a := range t.endpoints.Subsets[0].Addresses {
+		ips = append(ips, a.IP)
+	}
+
+	return ips
+}
+
 func newServiceExportCondition(cType lighthousev2a1.ServiceExportConditionType,
 	status corev1.ConditionStatus, reason string) *lighthousev2a1.ServiceExportCondition {
 	return &lighthousev2a1.ServiceExportCondition{
diff --git a/pkg/serviceimport/controller_test.go b/pkg/serviceimport/controller_test.go
index 17c378e..51324b1 100644
--- a/pkg/serviceimport/controller_test.go
+++ b/pkg/serviceimport/controller_test.go
@@ -1,4 +1,4 @@
-package serviceimport
+package serviceimport_test
 
 import (
 	. "github.com/onsi/ginkgo"
@@ -6,6 +6,7 @@ import (
 	lighthousev2a1 "github.com/submariner-io/lighthouse/pkg/apis/lighthouse.submariner.io/v2alpha1"
 	lighthouseClientset "github.com/submariner-io/lighthouse/pkg/client/clientset/versioned"
 	fakeClientSet "github.com/submariner-io/lighthouse/pkg/client/clientset/versioned/fake"
+	"github.com/submariner-io/lighthouse/pkg/serviceimport"
 	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
 	"k8s.io/client-go/rest"
 )
@@ -26,7 +27,7 @@ func testLifecycleNotifications() {
 
 	var (
 		serviceImport *lighthousev2a1.ServiceImport
-		controller    *Controller
+		controller    *serviceimport.Controller
 		fakeClientset lighthouseClientset.Interface
 		store         *fakeStore
 	)
@@ -38,10 +39,10 @@ func testLifecycleNotifications() {
 		}
 
 		serviceImport = newServiceImport(namespace1, service1, serviceIP, clusterID)
-		controller = NewController(store)
+		controller = serviceimport.NewController(store)
 		fakeClientset = fakeClientSet.NewSimpleClientset()
 
-		controller.newClientset = func(c *rest.Config) (lighthouseClientset.Interface, error) {
+		controller.NewClientset = func(c *rest.Config) (lighthouseClientset.Interface, error) {
 			return fakeClientset, nil
 		}
 
@@ -129,7 +130,7 @@ func newServiceImport(namespace, name, serviceIP, clusterID string) *lighthousev
 			},
 		},
 		Spec: lighthousev2a1.ServiceImportSpec{
-			Type: lighthousev2a1.SuperclusterIP,
+			Type: lighthousev2a1.ClusterSetIP,
 		},
 		Status: lighthousev2a1.ServiceImportStatus{
 			Clusters: []lighthousev2a1.ClusterStatus{
diff --git a/pkg/serviceimport/map_test.go b/pkg/serviceimport/map_test.go
index 41a9b7d..2332f9d 100644
--- a/pkg/serviceimport/map_test.go
+++ b/pkg/serviceimport/map_test.go
@@ -1,4 +1,4 @@
-package serviceimport
+package serviceimport_test
 
 import (
 	"sort"
@@ -6,6 +6,7 @@ import (
 	. "github.com/onsi/ginkgo"
 	. "github.com/onsi/gomega"
 	lighthousev2a1 "github.com/submariner-io/lighthouse/pkg/apis/lighthouse.submariner.io/v2alpha1"
+	"github.com/submariner-io/lighthouse/pkg/serviceimport"
 )
 
 var _ = Describe("ServiceImport Map", func() {
@@ -23,12 +24,12 @@ var _ = Describe("ServiceImport Map", func() {
 
 	var (
 		clusterStatusMap map[string]bool
-		serviceImportMap *Map
+		serviceImportMap *serviceimport.Map
 	)
 
 	BeforeEach(func() {
 		clusterStatusMap = map[string]bool{clusterID1: true, clusterID2: true, clusterID3: true}
-		serviceImportMap = NewMap()
+		serviceImportMap = serviceimport.NewMap()
 	})
 
 	checkCluster := func(id string) bool {
diff --git a/pkg/serviceimport/suite_test.go b/pkg/serviceimport/suite_test.go
index 9f630fc..dd96093 100644
--- a/pkg/serviceimport/suite_test.go
+++ b/pkg/serviceimport/suite_test.go
@@ -1,4 +1,4 @@
-package serviceimport
+package serviceimport_test
 
 import (
 	"testing"
diff --git a/plugin/lighthouse/handler_test.go b/plugin/lighthouse/handler_test.go
index 49d36fa..fbeafe9 100644
--- a/plugin/lighthouse/handler_test.go
+++ b/plugin/lighthouse/handler_test.go
@@ -86,7 +86,7 @@ func testWithoutFallback() {
 
 	When("type A DNS query for an existing service with a different namespace", func() {
 		It("should succeed and write an A record response", func() {
-			lh.serviceImports.Put(newServiceImport(namespace2, service1, clusterID, []string{serviceIP}, lighthousev2a1.SuperclusterIP))
+			lh.serviceImports.Put(newServiceImport(namespace2, service1, clusterID, []string{serviceIP}, lighthousev2a1.ClusterSetIP))
 			executeTestCase(lh, rec, test.Case{
 				Qname: service1 + "." + namespace2 + ".svc.cluster.local.",
 				Qtype: dns.TypeA,
@@ -253,7 +253,7 @@ func testClusterStatus() {
 			serviceImports: setupServiceImportMap(),
 			clusterStatus:  mockCs,
 		}
-		lh.serviceImports.Put(newServiceImport(namespace1, service1, clusterID2, []string{serviceIP}, lighthousev2a1.SuperclusterIP))
+		lh.serviceImports.Put(newServiceImport(namespace1, service1, clusterID2, []string{serviceIP}, lighthousev2a1.ClusterSetIP))
 
 		rec = dnstest.NewRecorder(&test.ResponseWriter{})
 	})
@@ -273,7 +273,7 @@ func testClusterStatus() {
 
 	When("service is in two connected clusters and one has no IP", func() {
 		JustBeforeEach(func() {
-			lh.serviceImports.Put(newServiceImport(namespace1, service1, clusterID, []string{}, lighthousev2a1.SuperclusterIP))
+			lh.serviceImports.Put(newServiceImport(namespace1, service1, clusterID, []string{}, lighthousev2a1.ClusterSetIP))
 		})
 		It("should succeed and write an A record response with the available IP", func() {
 			executeTestCase(lh, rec, test.Case{
@@ -436,7 +436,7 @@ func executeTestCase(lh *Lighthouse, rec *dnstest.Recorder, tc test.Case) {
 
 func setupServiceImportMap() *serviceimport.Map {
 	siMap := serviceimport.NewMap()
-	siMap.Put(newServiceImport(namespace1, service1, clusterID, []string{serviceIP}, lighthousev2a1.SuperclusterIP))
+	siMap.Put(newServiceImport(namespace1, service1, clusterID, []string{serviceIP}, lighthousev2a1.ClusterSetIP))
 
 	return siMap
 }
diff --git a/test/e2e/discovery/service_discovery.go b/test/e2e/discovery/service_discovery.go
index 709fcfe..fd9a27d 100644
--- a/test/e2e/discovery/service_discovery.go
+++ b/test/e2e/discovery/service_discovery.go
@@ -13,9 +13,13 @@ import (
 
 const (
 	submarinerIpamGlobalIp = "submariner.io/globalIp"
+	clustersetDomain       = "clusterset.local"
 	superclusterDomain     = "supercluster.local"
 )
 
+// Both domains need to be checked, until the operator is updated to use clusterset
+var checkedDomains = []string{clustersetDomain, superclusterDomain}
+
 var _ = Describe("[discovery] Test Service Discovery Across Clusters", func() {
 	f := lhframework.NewFramework("discovery")
 
@@ -64,14 +68,14 @@ func RunServiceDiscoveryTest(f *lhframework.Framework) {
 		f.AwaitServiceImportIP(framework.ClusterA, nginxServiceClusterB)
 	}
 
-	verifyServiceIpWithDig(f.Framework, framework.ClusterA, nginxServiceClusterB, netshootPodList, superclusterDomain, true)
+	verifyServiceIpWithDig(f.Framework, framework.ClusterA, nginxServiceClusterB, netshootPodList, checkedDomains, true)
 
 	f.DeleteServiceExport(framework.ClusterB, nginxServiceClusterB.Name, nginxServiceClusterB.Namespace)
 	f.AwaitServiceImportDelete(framework.ClusterA, nginxServiceClusterB.Name, nginxServiceClusterB.Namespace)
 
 	f.DeleteService(framework.ClusterB, nginxServiceClusterB.Name)
 
-	verifyServiceIpWithDig(f.Framework, framework.ClusterA, nginxServiceClusterB, netshootPodList, superclusterDomain, false)
+	verifyServiceIpWithDig(f.Framework, framework.ClusterA, nginxServiceClusterB, netshootPodList, checkedDomains, false)
 }
 
 func RunServiceDiscoveryLocalTest(f *lhframework.Framework) {
@@ -102,7 +106,7 @@ func RunServiceDiscoveryLocalTest(f *lhframework.Framework) {
 	netshootPodList := f.NewNetShootDeployment(framework.ClusterA)
 	clusterADomain := getClusterDomain(f.Framework, framework.ClusterA, netshootPodList)
 
-	verifyServiceIpWithDig(f.Framework, framework.ClusterA, nginxServiceClusterA, netshootPodList, clusterADomain, true)
+	verifyServiceIpWithDig(f.Framework, framework.ClusterA, nginxServiceClusterA, netshootPodList, []string{clusterADomain}, true)
 
 	f.DeleteService(framework.ClusterA, nginxServiceClusterA.Name)
 
@@ -111,14 +115,14 @@ func RunServiceDiscoveryLocalTest(f *lhframework.Framework) {
 		f.AwaitServiceImportIP(framework.ClusterA, nginxServiceClusterB)
 	}
 
-	verifyServiceIpWithDig(f.Framework, framework.ClusterA, nginxServiceClusterB, netshootPodList, superclusterDomain, true)
+	verifyServiceIpWithDig(f.Framework, framework.ClusterA, nginxServiceClusterB, netshootPodList, checkedDomains, true)
 
 	f.DeleteServiceExport(framework.ClusterB, nginxServiceClusterB.Name, nginxServiceClusterB.Namespace)
 	f.AwaitServiceImportDelete(framework.ClusterA, nginxServiceClusterB.Name, nginxServiceClusterB.Namespace)
 
 	f.DeleteService(framework.ClusterB, nginxServiceClusterB.Name)
 
-	verifyServiceIpWithDig(f.Framework, framework.ClusterA, nginxServiceClusterB, netshootPodList, superclusterDomain, false)
+	verifyServiceIpWithDig(f.Framework, framework.ClusterA, nginxServiceClusterB, netshootPodList, checkedDomains, false)
 }
 
 func RunServiceExportTest(f *lhframework.Framework) {
@@ -145,16 +149,16 @@ func RunServiceExportTest(f *lhframework.Framework) {
 		f.AwaitServiceImportIP(framework.ClusterA, nginxServiceClusterB)
 	}
 
-	verifyServiceIpWithDig(f.Framework, framework.ClusterA, nginxServiceClusterB, netshootPodList, superclusterDomain, true)
+	verifyServiceIpWithDig(f.Framework, framework.ClusterA, nginxServiceClusterB, netshootPodList, checkedDomains, true)
 
 	f.DeleteServiceExport(framework.ClusterB, nginxServiceClusterB.Name, nginxServiceClusterB.Namespace)
 	f.AwaitServiceImportDelete(framework.ClusterA, nginxServiceClusterB.Name, nginxServiceClusterB.Namespace)
 
-	verifyServiceIpWithDig(f.Framework, framework.ClusterA, nginxServiceClusterB, netshootPodList, superclusterDomain, false)
+	verifyServiceIpWithDig(f.Framework, framework.ClusterA, nginxServiceClusterB, netshootPodList, checkedDomains, false)
 }
 
 func verifyServiceIpWithDig(f *framework.Framework, cluster framework.ClusterIndex, service *corev1.Service, targetPod *corev1.PodList,
-	domain string, shouldContain bool) {
+	domains []string, shouldContain bool) {
 	var serviceIP string
 	var ok bool
 
@@ -162,7 +166,11 @@ func verifyServiceIpWithDig(f *framework.Framework, cluster framework.ClusterInd
 		serviceIP = service.Spec.ClusterIP
 	}
 
-	cmd := []string{"dig", service.Name + "." + f.Namespace + ".svc." + domain, "+short"}
+	cmd := []string{"dig", "+short"}
+	for i := range domains {
+		cmd = append(cmd, service.Name+"."+f.Namespace+".svc."+domains[i])
+	}
+
 	op := "is"
 	if !shouldContain {
 		op += " not"