Skip to content

Commit

Permalink
Adjust to admiral's VerifyNamespaceReactor changes
Browse files Browse the repository at this point in the history
Signed-off-by: Tom Pantelis <[email protected]>
  • Loading branch information
tpantelis authored and submariner-bot committed Sep 4, 2024
1 parent bcae15e commit 9476467
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
16 changes: 12 additions & 4 deletions pkg/agent/controller/clusterip_service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import (
corev1 "k8s.io/api/core/v1"
discovery "k8s.io/api/discovery/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/client-go/dynamic"
"k8s.io/utils/ptr"
mcsv1a1 "sigs.k8s.io/mcs-api/pkg/apis/v1alpha1"
)
Expand Down Expand Up @@ -306,8 +307,18 @@ func testClusterIPServiceInOneCluster() {
})

When("the namespace of an exported service does not initially exist on an importing cluster", func() {
createNamespace := func(dynClient dynamic.Interface, name string) {
test.CreateResource(dynClient.Resource(corev1.SchemeGroupVersion.WithResource("namespaces")), &corev1.Namespace{
ObjectMeta: metav1.ObjectMeta{
Name: name,
},
})
}

BeforeEach(func() {
fake.AddVerifyNamespaceReactor(&t.cluster2.localDynClient.Fake, "serviceimports", "endpointslices")

createNamespace(t.cluster2.localDynClient, test.LocalNamespace)
})

JustBeforeEach(func() {
Expand Down Expand Up @@ -339,10 +350,7 @@ func testClusterIPServiceInOneCluster() {

By("Creating namespace on importing cluster")

test.CreateResource(t.cluster2.localDynClient.Resource(corev1.SchemeGroupVersion.WithResource("namespaces")),
&corev1.Namespace{
ObjectMeta: metav1.ObjectMeta{Name: t.cluster1.service.Namespace},
})
createNamespace(t.cluster2.localDynClient, t.cluster1.service.Namespace)

t.awaitNonHeadlessServiceExported(&t.cluster1)
})
Expand Down
4 changes: 4 additions & 0 deletions pkg/agent/controller/controller_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -669,6 +669,10 @@ func awaitServiceImport(client dynamic.NamespaceableResourceInterface, expected

func findEndpointSlices(client dynamic.ResourceInterface, namespace, name, clusterID string) []*discovery.EndpointSlice {
list, err := client.List(context.TODO(), metav1.ListOptions{})
if resource.IsMissingNamespaceErr(err) {
return []*discovery.EndpointSlice{}
}

Expect(err).To(Succeed())

var endpointSlices []*discovery.EndpointSlice
Expand Down

0 comments on commit 9476467

Please sign in to comment.