Skip to content

Commit 8c1ec11

Browse files
committed
fix the UT and e2e
Signed-off-by: Ryan Zhang <[email protected]>
1 parent 48b82e7 commit 8c1ec11

File tree

3 files changed

+9
-11
lines changed

3 files changed

+9
-11
lines changed

pkg/controllers/placement/controller_test.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4476,7 +4476,7 @@ func TestShouldCreateNewResourceSnapshotNow(t *testing.T) {
44764476
collectionDuration: 30 * time.Second,
44774477
annotationValue: now.Add(-10 * time.Second).Format(time.RFC3339),
44784478
wantAnnoation: true,
4479-
wantRequeue: ctrl.Result{Requeue: true, RequeueAfter: 20 * time.Second},
4479+
wantRequeue: ctrl.Result{RequeueAfter: 20 * time.Second},
44804480
},
44814481
{
44824482
name: "ResourceChangesCollectionDuration is 0",
@@ -4486,7 +4486,7 @@ func TestShouldCreateNewResourceSnapshotNow(t *testing.T) {
44864486
// no annotation → sets it and requeues
44874487
annotationValue: "",
44884488
wantAnnoation: true,
4489-
wantRequeue: ctrl.Result{Requeue: true, RequeueAfter: 295 * time.Second},
4489+
wantRequeue: ctrl.Result{RequeueAfter: 295 * time.Second},
44904490
},
44914491
{
44924492
name: "next detection time (now) + collection duration < latest resource snapshot creation time + creation interval",
@@ -4496,7 +4496,7 @@ func TestShouldCreateNewResourceSnapshotNow(t *testing.T) {
44964496
// no annotation → sets it and requeues
44974497
annotationValue: "",
44984498
wantAnnoation: true,
4499-
wantRequeue: ctrl.Result{Requeue: true, RequeueAfter: 295 * time.Second},
4499+
wantRequeue: ctrl.Result{RequeueAfter: 295 * time.Second},
45004500
},
45014501
{
45024502
name: "next detection time (annotation) + collection duration < latest resource snapshot creation time + creation interval",
@@ -4505,23 +4505,23 @@ func TestShouldCreateNewResourceSnapshotNow(t *testing.T) {
45054505
creationTime: now.Add(-10 * time.Second),
45064506
annotationValue: now.Add(-5 * time.Second).Format(time.RFC3339),
45074507
wantAnnoation: true,
4508-
wantRequeue: ctrl.Result{Requeue: true, RequeueAfter: 290 * time.Second},
4508+
wantRequeue: ctrl.Result{RequeueAfter: 290 * time.Second},
45094509
},
45104510
{
45114511
name: "last resource snapshot created long time before",
45124512
creationInterval: 60 * time.Second,
45134513
collectionDuration: 30 * time.Second,
45144514
creationTime: now.Add(-1 * time.Hour),
45154515
wantAnnoation: true,
4516-
wantRequeue: ctrl.Result{Requeue: true, RequeueAfter: 30 * time.Second},
4516+
wantRequeue: ctrl.Result{RequeueAfter: 30 * time.Second},
45174517
},
45184518
{
45194519
name: "next detection time (now) + collection duration >= latest resource snapshot creation time + creation interval",
45204520
creationInterval: 60 * time.Second,
45214521
collectionDuration: 60 * time.Second,
45224522
creationTime: now.Add(-40 * time.Second),
45234523
wantAnnoation: true,
4524-
wantRequeue: ctrl.Result{Requeue: true, RequeueAfter: 60 * time.Second},
4524+
wantRequeue: ctrl.Result{RequeueAfter: 60 * time.Second},
45254525
},
45264526
}
45274527

pkg/controllers/workapplier/apply_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -384,7 +384,7 @@ func TestSetFleetLastAppliedAnnotation(t *testing.T) {
384384
nsManifestObj1 := ns.DeepCopy()
385385
wantNSManifestObj1 := ns.DeepCopy()
386386
wantNSManifestObj1.SetAnnotations(map[string]string{
387-
fleetv1beta1.LastAppliedConfigAnnotation: string("{\"apiVersion\":\"v1\",\"kind\":\"Namespace\",\"metadata\":{\"annotations\":{},\"creationTimestamp\":null,\"name\":\"ns-1\"},\"spec\":{},\"status\":{}}\n"),
387+
fleetv1beta1.LastAppliedConfigAnnotation: string("{\"apiVersion\":\"v1\",\"kind\":\"Namespace\",\"metadata\":{\"annotations\":{},\"name\":\"ns-1\"},\"spec\":{},\"status\":{}}\n"),
388388
})
389389

390390
nsManifestObj2 := ns.DeepCopy()
@@ -393,7 +393,7 @@ func TestSetFleetLastAppliedAnnotation(t *testing.T) {
393393
})
394394
wantNSManifestObj2 := ns.DeepCopy()
395395
wantNSManifestObj2.SetAnnotations(map[string]string{
396-
fleetv1beta1.LastAppliedConfigAnnotation: string("{\"apiVersion\":\"v1\",\"kind\":\"Namespace\",\"metadata\":{\"annotations\":{},\"creationTimestamp\":null,\"name\":\"ns-1\"},\"spec\":{},\"status\":{}}\n"),
396+
fleetv1beta1.LastAppliedConfigAnnotation: string("{\"apiVersion\":\"v1\",\"kind\":\"Namespace\",\"metadata\":{\"annotations\":{},\"name\":\"ns-1\"},\"spec\":{},\"status\":{}}\n"),
397397
})
398398

399399
// Annotation size limit is 262144 bytes.

test/e2e/join_and_leave_test.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -516,9 +516,7 @@ var _ = Describe("Test member cluster join and leave with clusterProfile", Label
516516
})
517517

518518
It("Delete member cluster CR associated to the member cluster to simulate member left", func() {
519-
var mc clusterv1beta1.MemberCluster
520-
Expect(hubClient.Get(ctx, types.NamespacedName{Name: memberCluster3WestProdName}, &mc)).To(Succeed(), "Failed to get member cluster")
521-
Expect(hubClient.Delete(ctx, &mc)).Should(Succeed())
519+
markMemberClusterAsLeft(memberCluster3WestProdName)
522520
})
523521

524522
It("Make sure we delete the corresponding cluster profiles", func() {

0 commit comments

Comments
 (0)