Skip to content

Commit

Permalink
check cluster role membercluster
Browse files Browse the repository at this point in the history
  • Loading branch information
Arvindthiru committed Sep 20, 2022
1 parent 6811f9f commit 75d354b
Showing 1 changed file with 20 additions and 12 deletions.
32 changes: 20 additions & 12 deletions test/e2e/work_load_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,22 @@ var _ = Describe("workload orchestration testing", func() {
testutils.WaitCreateClusterResourcePlacementStatus(ctx, *HubCluster, crp, crpStatus, 3*testutils.PollTimeout)

By("check if cluster role is propagated to member cluster")
Expect(MemberCluster.KubeClient.Get(ctx, types.NamespacedName{Name: clusterRole.Name}, clusterRole)).Should(Succeed(), "Failed to get cluster role %s in %s cluster", clusterRole.Name, HubCluster.ClusterName)
ownerReferences := []metav1.OwnerReference{
{
APIVersion: workapi.GroupVersion.String(),
BlockOwnerDeletion: pointer.Bool(false),
Kind: "AppliedWork",
Name: crp.Name,
},
}
expectedClusterRole := clusterRole
expectedClusterRole.OwnerReferences = ownerReferences
clusterRole = &rbacv1.ClusterRole{
ObjectMeta: metav1.ObjectMeta{
Name: "test-cluster-role",
},
}
testutils.CmpClusterRole(ctx, *MemberCluster, clusterRole, expectedClusterRole)

By("update cluster role in Hub cluster")
rules := []rbacv1.PolicyRule{
Expand All @@ -195,18 +210,11 @@ var _ = Describe("workload orchestration testing", func() {
}
Expect(HubCluster.KubeClient.Update(ctx, updatedClusterRole)).Should(Succeed(), "Failed to update cluster role %s in %s cluster", updatedClusterRole.Name, HubCluster.ClusterName)

expectedClusterRole := &rbacv1.ClusterRole{
expectedClusterRole = &rbacv1.ClusterRole{
ObjectMeta: metav1.ObjectMeta{
Name: "test-cluster-role",
Labels: updatedClusterRole.Labels,
OwnerReferences: []metav1.OwnerReference{
{
APIVersion: workapi.GroupVersion.String(),
BlockOwnerDeletion: pointer.Bool(false),
Kind: "AppliedWork",
Name: crp.Name,
},
},
Name: "test-cluster-role",
Labels: updatedClusterRole.Labels,
OwnerReferences: ownerReferences,
},
Rules: rules,
}
Expand Down

0 comments on commit 75d354b

Please sign in to comment.