@@ -11,8 +11,10 @@ import (
1111 "github.com/linkerd/linkerd2/pkg/multicluster"
1212 logging "github.com/sirupsen/logrus"
1313 corev1 "k8s.io/api/core/v1"
14+ v1 "k8s.io/api/core/v1"
1415 "k8s.io/apimachinery/pkg/api/errors"
1516 metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
17+ "k8s.io/client-go/tools/record"
1618 "k8s.io/client-go/util/workqueue"
1719)
1820
@@ -221,6 +223,7 @@ func TestLocalNamespaceCreatedAfterServiceExport(t *testing.T) {
221223 localAPI .Sync (nil )
222224
223225 q := workqueue .NewRateLimitingQueue (workqueue .DefaultControllerRateLimiter ())
226+ eventRecorder := record .NewFakeRecorder (100 )
224227
225228 watcher := RemoteClusterServiceWatcher {
226229 link : & multicluster.Link {
@@ -235,6 +238,7 @@ func TestLocalNamespaceCreatedAfterServiceExport(t *testing.T) {
235238 remoteAPIClient : remoteAPI ,
236239 localAPIClient : localAPI ,
237240 stopper : nil ,
241+ recorder : eventRecorder ,
238242 log : logging .WithFields (logging.Fields {"cluster" : clusterName }),
239243 eventsQueue : q ,
240244 requeueLimit : 0 ,
@@ -268,6 +272,11 @@ func TestLocalNamespaceCreatedAfterServiceExport(t *testing.T) {
268272 t .Fatalf ("unexpected error: %v" , err )
269273 }
270274
275+ skippedEvent := <- eventRecorder .Events
276+ if skippedEvent != fmt .Sprintf ("%s %s %s" , v1 .EventTypeNormal , eventTypeSkipped , "Skipped mirroring service: namespace does not exist" ) {
277+ t .Error ("Expected skipped event, got:" , skippedEvent )
278+ }
279+
271280 ns , err := localAPI .Client .CoreV1 ().Namespaces ().Create (context .Background (), & corev1.Namespace {ObjectMeta : metav1.ObjectMeta {Name : "ns1" }}, metav1.CreateOptions {})
272281 if err != nil {
273282 t .Fatal (err )
@@ -277,9 +286,8 @@ func TestLocalNamespaceCreatedAfterServiceExport(t *testing.T) {
277286 for q .Len () > 0 {
278287 watcher .processNextEvent (context .Background ())
279288 }
280- localAPI .Sync (nil )
281289
282- _ , err = localAPI .Svc (). Lister ().Services ("ns1" ).Get ("service-one-remote" )
290+ _ , err = localAPI .Client . CoreV1 ().Services ("ns1" ).Get (context . Background (), "service-one-remote" , metav1. GetOptions {} )
283291 if err != nil {
284292 t .Fatalf ("error getting service-one locally: %v" , err )
285293 }
0 commit comments