Skip to content

Commit

Permalink
address comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Arvindthiru committed Oct 18, 2023
1 parent 6b2b005 commit b9abb93
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -676,7 +676,7 @@ func TestHandleMemberCluster(t *testing.T) {

for testName, testCase := range testCases {
t.Run(testName, func(t *testing.T) {
gotResult := testCase.resourceValidator.handleV1Alpha1MemberCluster(testCase.req)
gotResult := testCase.resourceValidator.handleMemberCluster(testCase.req)
assert.Equal(t, testCase.wantResponse, gotResult, utils.TestCaseMsg, testName)
})
}
Expand Down
15 changes: 11 additions & 4 deletions test/e2e/utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,15 @@ package e2e

import (
"fmt"

"github.com/google/go-cmp/cmp"
"github.com/google/go-cmp/cmp/cmpopts"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
rbacv1 "k8s.io/api/rbac/v1"
"k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/types"
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/controller/controllerutil"

clusterv1beta1 "go.goms.io/fleet/apis/cluster/v1beta1"
placementv1beta1 "go.goms.io/fleet/apis/placement/v1beta1"
Expand Down Expand Up @@ -152,7 +151,6 @@ func deleteResourcesForFleetGuardRail() {

func createMemberClusterResource(name string) {
// Create the MC.
By(fmt.Sprintf("In MC BeforeAll %s", name))
mc := &clusterv1beta1.MemberCluster{
ObjectMeta: metav1.ObjectMeta{
Name: name,
Expand All @@ -170,17 +168,26 @@ func createMemberClusterResource(name string) {
}

func deleteMemberClusterResource(name string) {
By(fmt.Sprintf("In MC AfterAll %s", name))
Eventually(func(g Gomega) error {
var mc clusterv1beta1.MemberCluster
err := hubClient.Get(ctx, types.NamespacedName{Name: name}, &mc)
if errors.IsNotFound(err) {
return nil
}
g.Expect(err).Should(Succeed(), "Failed to get MC %s", name)
controllerutil.RemoveFinalizer(&mc, placementv1beta1.MemberClusterFinalizer)
g.Expect(hubClient.Update(ctx, &mc)).Should(Succeed())
g.Expect(hubClient.Delete(ctx, &mc)).Should(Succeed())
return nil
}, eventuallyDuration, eventuallyInterval).Should(Succeed())

Eventually(func(g Gomega) error {
var mc clusterv1beta1.MemberCluster
if err := hubClient.Get(ctx, types.NamespacedName{Name: name}, &mc); !errors.IsNotFound(err) {
return fmt.Errorf("MC still exists or an unexpected error occurred: %w", err)
}
return nil
}, eventuallyDuration, eventuallyInterval).Should(Succeed())
}

// createWorkResources creates some resources on the hub cluster for testing purposes.
Expand Down

0 comments on commit b9abb93

Please sign in to comment.