Skip to content

Commit 1c026f5

Browse files
author
Ryan Zhang
committed
add a bit more test
Signed-off-by: Ryan Zhang <[email protected]>
1 parent 66d9bdf commit 1c026f5

File tree

1 file changed

+25
-5
lines changed

1 file changed

+25
-5
lines changed

test/e2e/placement_selecting_resources_test.go

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -685,15 +685,16 @@ var _ = Describe("validating CRP when selecting a reserved resource", Ordered, f
685685
})
686686
})
687687

688-
var _ = Describe("When creating a pickN ClusterResourcePlacement with duplicated resources", Ordered, func() {
688+
var _ = FDescribe("When creating a pickN ClusterResourcePlacement with duplicated resources", Ordered, func() {
689689
crpName := fmt.Sprintf(crpNameTemplate, GinkgoParallelProcess())
690+
var crp *placementv1beta1.ClusterResourcePlacement
690691
var existingNS corev1.Namespace
691692
BeforeAll(func() {
692693
By("creating work resources on hub cluster")
693694
createWorkResources()
694695
existingNS = appNamespace()
695696
By("Create a crp that selects the same resource twice")
696-
crp := &placementv1beta1.ClusterResourcePlacement{
697+
crp = &placementv1beta1.ClusterResourcePlacement{
697698
ObjectMeta: metav1.ObjectMeta{
698699
Name: crpName,
699700
// Add a custom finalizer; this would allow us to better observe
@@ -728,8 +729,8 @@ var _ = Describe("When creating a pickN ClusterResourcePlacement with duplicated
728729

729730
It("should update CRP status as expected", func() {
730731
Eventually(func() error {
731-
crp := &placementv1beta1.ClusterResourcePlacement{}
732-
if err := hubClient.Get(ctx, types.NamespacedName{Name: crpName}, crp); err != nil {
732+
gotCRP := &placementv1beta1.ClusterResourcePlacement{}
733+
if err := hubClient.Get(ctx, types.NamespacedName{Name: crpName}, gotCRP); err != nil {
733734
return err
734735
}
735736
wantStatus := placementv1beta1.ClusterResourcePlacementStatus{
@@ -742,12 +743,31 @@ var _ = Describe("When creating a pickN ClusterResourcePlacement with duplicated
742743
},
743744
},
744745
}
745-
if diff := cmp.Diff(crp.Status, wantStatus, crpStatusCmpOptions...); diff != "" {
746+
if diff := cmp.Diff(gotCRP.Status, wantStatus, crpStatusCmpOptions...); diff != "" {
746747
return fmt.Errorf("CRP status diff (-got, +want): %s", diff)
747748
}
748749
return nil
749750
}, eventuallyDuration, eventuallyInterval).Should(Succeed(), "Failed to update CRP %s status as expected", crpName)
750751
})
752+
753+
It("updating the CRP to select one namespace", func() {
754+
crp.Spec.ResourceSelectors = []placementv1beta1.ClusterResourceSelector{
755+
{
756+
Group: corev1.GroupName,
757+
Version: "v1",
758+
Kind: "Namespace",
759+
Name: existingNS.Name,
760+
},
761+
}
762+
Expect(hubClient.Update(ctx, crp)).To(Succeed(), "Failed to update CRP %s", crpName)
763+
})
764+
765+
It("should update CRP status as expected", func() {
766+
crpStatusUpdatedActual := crpStatusUpdatedActual(workResourceIdentifiers(), allMemberClusterNames, nil, "0")
767+
Eventually(crpStatusUpdatedActual, eventuallyDuration, eventuallyInterval).Should(Succeed(), "Failed to update CRP %s status as expected", crpName)
768+
})
769+
770+
It("should place the selected resources on member clusters", checkIfPlacedWorkResourcesOnAllMemberClusters)
751771
})
752772

753773
var _ = Describe("validating CRP when failed to apply resources", Ordered, func() {

0 commit comments

Comments
 (0)