Skip to content

Commit

Permalink
Address comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Arvindthiru committed Oct 17, 2022
1 parent d2e8069 commit 9052173
Show file tree
Hide file tree
Showing 7 changed files with 62 additions and 84 deletions.
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ run-e2e: build-e2e
creat-kind-cluster: create-hub-kind-cluster create-member-kind-cluster install-helm

.PHONY: install-helm
install-helm: docker-build-hub-agent docker-build-member-agent docker-build-refresh-token load-hub-docker-image load-member-docker-image install-member-agent-helm
install-helm: load-hub-docker-image load-member-docker-image install-member-agent-helm

.PHONY: e2e-tests
e2e-tests: creat-kind-cluster run-e2e
Expand Down Expand Up @@ -227,7 +227,7 @@ run-memberagent: manifests generate fmt vet ## Run a controllers from your host.
## Images
## --------------------------------------

OUTPUT_TYPE ?= type=docker
OUTPUT_TYPE ?= type=registry
BUILDX_BUILDER_NAME ?= img-builder
QEMU_VERSION ?= 5.2.0-2

Expand Down
2 changes: 1 addition & 1 deletion test/e2e/e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ var (
sortOption,
}
crpStatusCmpOptions = []cmp.Option{
cmpopts.IgnoreFields(metav1.Condition{}, "ObservedGeneration", "LastTransitionTime"),
cmpopts.IgnoreFields(metav1.Condition{}, "ObservedGeneration", "LastTransitionTime", "Message"),
sortOption,
}

Expand Down
39 changes: 20 additions & 19 deletions test/e2e/join_leave_placement_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import (
"k8s.io/apimachinery/pkg/types"

"go.goms.io/fleet/apis/v1alpha1"
testutils "go.goms.io/fleet/test/e2e/utils"
"go.goms.io/fleet/test/e2e/utils"
)

// Serial - Ginkgo will guarantee that these specs will never run in parallel with other specs.
Expand Down Expand Up @@ -50,7 +50,7 @@ var _ = Describe("workload orchestration testing with join/leave", Serial, func(
AgentStatus: imcLeftAgentStatus,
Conditions: mcLeftConditions,
}
testutils.CheckMemberClusterStatus(ctx, *HubCluster, &types.NamespacedName{Name: mc.Name}, wantMCStatus, mcStatusCmpOptions)
utils.CheckMemberClusterStatus(ctx, *HubCluster, &types.NamespacedName{Name: mc.Name}, wantMCStatus, mcStatusCmpOptions)

By("create the resources to be propagated")
cr := &rbacv1.ClusterRole{
Expand Down Expand Up @@ -86,12 +86,12 @@ var _ = Describe("workload orchestration testing with join/leave", Serial, func(
},
},
}
testutils.CreateClusterResourcePlacement(ctx, *HubCluster, crp)
Expect(HubCluster.KubeClient.Create(ctx, crp)).Should(Succeed(), "Failed to create cluster resource placement %s in %s cluster", crp.Name, HubCluster.ClusterName)

By("verify the resource is not propagated to member cluster")
Consistently(func() bool {
return apierrors.IsNotFound(MemberCluster.KubeClient.Get(ctx, types.NamespacedName{Name: cr.Name}, cr))
}, testutils.PollTimeout, testutils.PollInterval).Should(BeTrue(), "Failed to verify cluster role %s is not propagated to %s cluster", cr.Name, MemberCluster.ClusterName)
}, utils.PollTimeout, utils.PollInterval).Should(BeTrue(), "Failed to verify cluster role %s is not propagated to %s cluster", cr.Name, MemberCluster.ClusterName)

By("update member cluster in the hub cluster to join")
Expect(HubCluster.KubeClient.Get(ctx, types.NamespacedName{Name: mc.Name}, mc)).Should(Succeed(), "Failed to retrieve member cluster %s in %s cluster", mc.Name, HubCluster.ClusterName)
Expand All @@ -103,22 +103,20 @@ var _ = Describe("workload orchestration testing with join/leave", Serial, func(
AgentStatus: imcJoinedAgentStatus,
Conditions: mcJoinedConditions,
}
testutils.CheckMemberClusterStatus(ctx, *HubCluster, &types.NamespacedName{Name: mc.Name}, wantMCStatus, mcStatusCmpOptions)
utils.CheckMemberClusterStatus(ctx, *HubCluster, &types.NamespacedName{Name: mc.Name}, wantMCStatus, mcStatusCmpOptions)

By("verify that the cluster resource placement is applied")
crpStatus := v1alpha1.ClusterResourcePlacementStatus{
Conditions: []metav1.Condition{
{
Message: "Successfully scheduled resources for placement",
Reason: "ScheduleSucceeded",
Status: metav1.ConditionTrue,
Type: string(v1alpha1.ResourcePlacementConditionTypeScheduled),
Reason: "ScheduleSucceeded",
Status: metav1.ConditionTrue,
Type: string(v1alpha1.ResourcePlacementConditionTypeScheduled),
},
{
Message: "Successfully applied resources to member clusters",
Reason: "ApplySucceeded",
Status: metav1.ConditionTrue,
Type: string(v1alpha1.ResourcePlacementStatusConditionTypeApplied),
Reason: "ApplySucceeded",
Status: metav1.ConditionTrue,
Type: string(v1alpha1.ResourcePlacementStatusConditionTypeApplied),
},
},
SelectedResources: []v1alpha1.ResourceIdentifier{
Expand All @@ -131,7 +129,7 @@ var _ = Describe("workload orchestration testing with join/leave", Serial, func(
},
TargetClusters: []string{"kind-member-testing"},
}
testutils.WaitCreateClusterResourcePlacementStatus(ctx, *HubCluster, &types.NamespacedName{Name: crp.Name}, crpStatus, crpStatusCmpOptions, 3*testutils.PollTimeout)
utils.WaitCreateClusterResourcePlacementStatus(ctx, *HubCluster, &types.NamespacedName{Name: crp.Name}, crpStatus, crpStatusCmpOptions, 3*utils.PollTimeout)

By("verify the resource is propagated to member cluster")
Expect(MemberCluster.KubeClient.Get(ctx, types.NamespacedName{Name: cr.Name}, cr)).Should(Succeed(), "Failed to verify cluster role %s is propagated to %s cluster", cr.Name, MemberCluster.ClusterName)
Expand All @@ -146,24 +144,27 @@ var _ = Describe("workload orchestration testing with join/leave", Serial, func(
AgentStatus: imcLeftAgentStatus,
Conditions: mcLeftConditions,
}
testutils.CheckMemberClusterStatus(ctx, *HubCluster, &types.NamespacedName{Name: mc.Name}, wantMCStatus, mcStatusCmpOptions)
utils.CheckMemberClusterStatus(ctx, *HubCluster, &types.NamespacedName{Name: mc.Name}, wantMCStatus, mcStatusCmpOptions)

By("verify that the resource is still on the member cluster")
Consistently(func() error {
return MemberCluster.KubeClient.Get(ctx, types.NamespacedName{Name: cr.Name}, cr)
}, testutils.PollTimeout, testutils.PollInterval).Should(Succeed(), "Failed to verify cluster role %s is still on %s cluster", cr.Name, MemberCluster.ClusterName)
}, utils.PollTimeout, utils.PollInterval).Should(Succeed(), "Failed to verify cluster role %s is still on %s cluster", cr.Name, MemberCluster.ClusterName)

By("delete the crp from the hub")
testutils.DeleteClusterResourcePlacement(ctx, *HubCluster, crp)
utils.DeleteClusterResourcePlacement(ctx, *HubCluster, crp)

By("verify that the resource is still on the member cluster")
Consistently(func() error {
return MemberCluster.KubeClient.Get(ctx, types.NamespacedName{Name: cr.Name, Namespace: ""}, cr)
}, testutils.PollTimeout, testutils.PollInterval).Should(Succeed(), "Failed to verify cluster role %s is still on %s cluster", cr.Name, MemberCluster.ClusterName)
}, utils.PollTimeout, utils.PollInterval).Should(Succeed(), "Failed to verify cluster role %s is still on %s cluster", cr.Name, MemberCluster.ClusterName)

By("delete cluster role on hub cluster")
Expect(HubCluster.KubeClient.Delete(ctx, cr)).Should(Succeed(), "Failed to delete cluster role %s in %s cluster", cr.Name, HubCluster.ClusterName)

By("delete cluster role on member cluster")
Expect(MemberCluster.KubeClient.Delete(ctx, cr)).Should(Succeed(), "Failed to delete cluster role %s in %s cluster", cr.Name, MemberCluster.ClusterName)

By("update member cluster in the hub cluster to join")
Expect(HubCluster.KubeClient.Get(ctx, types.NamespacedName{Name: mc.Name}, mc)).Should(Succeed(), "Failed to retrieve member cluster %s in %s cluster", mc.Name, HubCluster.ClusterName)
mc.Spec.State = v1alpha1.ClusterStateJoin
Expand All @@ -174,6 +175,6 @@ var _ = Describe("workload orchestration testing with join/leave", Serial, func(
AgentStatus: imcJoinedAgentStatus,
Conditions: mcJoinedConditions,
}
testutils.CheckMemberClusterStatus(ctx, *HubCluster, &types.NamespacedName{Name: mc.Name}, wantMCStatus, mcStatusCmpOptions)
utils.CheckMemberClusterStatus(ctx, *HubCluster, &types.NamespacedName{Name: mc.Name}, wantMCStatus, mcStatusCmpOptions)
})
})
8 changes: 0 additions & 8 deletions test/e2e/utils/helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,14 +85,6 @@ func WaitWork(ctx context.Context, cluster framework.Cluster, workName, workName
}, PollTimeout, PollInterval).Should(gomega.Succeed(), "Work %s not synced", name)
}

// CreateNamespace create namespace and waits for namespace to exist.
func CreateNamespace(ctx context.Context, cluster framework.Cluster, ns *corev1.Namespace) {
gomega.Expect(cluster.KubeClient.Create(ctx, ns)).Should(gomega.Succeed(), "Failed to create namespace %s in %s cluster", ns.Name, cluster.ClusterName)
gomega.Eventually(func() error {
return cluster.KubeClient.Get(ctx, types.NamespacedName{Name: ns.Name}, ns)
}, PollTimeout, PollInterval).Should(gomega.Succeed(), "Failed to wait for namespace %s to be created in %s cluster", ns.Name, cluster.ClusterName)
}

// DeleteNamespace delete namespace.
func DeleteNamespace(ctx context.Context, cluster framework.Cluster, ns *corev1.Namespace) {
gomega.Expect(cluster.KubeClient.Delete(context.TODO(), ns)).Should(gomega.Succeed(), "Failed to delete namespace %s in %s cluster", ns.Name, cluster.ClusterName)
Expand Down
8 changes: 0 additions & 8 deletions test/e2e/utils/workload_test_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,14 +78,6 @@ func CmpRoleBinding(ctx context.Context, cluster framework.Cluster, objectKey *t
}, PollTimeout, PollInterval).Should(gomega.Succeed(), "Failed to compare actual and expected role bindings in %s cluster", cluster.ClusterName)
}

// CreateClusterResourcePlacement created ClusterResourcePlacement and waits for ClusterResourcePlacement to exist in hub cluster.
func CreateClusterResourcePlacement(ctx context.Context, cluster framework.Cluster, crp *fleetv1alpha1.ClusterResourcePlacement) {
gomega.Expect(cluster.KubeClient.Create(ctx, crp)).Should(gomega.Succeed())
gomega.Eventually(func() error {
return cluster.KubeClient.Get(ctx, types.NamespacedName{Name: crp.Name}, crp)
}, PollTimeout, PollInterval).Should(gomega.Succeed(), "Failed to create cluster resource placement %s in %s cluster", crp.Name, cluster.ClusterName)
}

// WaitCreateClusterResourcePlacementStatus waits for ClusterResourcePlacement to present on th hub cluster with a specific status.
func WaitCreateClusterResourcePlacementStatus(ctx context.Context, cluster framework.Cluster, objectKey *types.NamespacedName, wantCRPStatus fleetv1alpha1.ClusterResourcePlacementStatus, crpStatusCmpOptions []cmp.Option, customTimeout time.Duration) {
gotCRP := &fleetv1alpha1.ClusterResourcePlacement{}
Expand Down
3 changes: 2 additions & 1 deletion test/e2e/work_api_e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,8 @@ var _ = Describe("Work API Controller test", func() {
Name: resourceNamespaceName,
},
}
testutils.CreateNamespace(ctx, *MemberCluster, resourceNamespace)
//testutils.CreateNamespace(ctx, *MemberCluster, resourceNamespace)
Expect(MemberCluster.KubeClient.Create(ctx, resourceNamespace)).Should(Succeed(), "Failed to create namespace %s in %s cluster", resourceNamespace.Name, MemberCluster.ClusterName)
})

AfterEach(func() {
Expand Down
Loading

0 comments on commit 9052173

Please sign in to comment.