Skip to content

Commit d437b2c

Browse files
authored
test: fix flaky capacity-based scheduling e2e (#121)
1 parent d83c930 commit d437b2c

File tree

3 files changed

+7
-2
lines changed

3 files changed

+7
-2
lines changed

test/e2e/scheduler_watchers_test.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ package e2e
2020

2121
import (
2222
"fmt"
23+
"time"
2324

2425
. "github.com/onsi/ginkgo/v2"
2526
. "github.com/onsi/gomega"
@@ -1381,7 +1382,9 @@ var _ = Describe("responding to specific member cluster changes", func() {
13811382
It("should pick the new cluster", func() {
13821383
targetClusterNames := []string{memberCluster3WestProdName}
13831384
crpStatusUpdatedActual := crpStatusUpdatedActual(workResourceIdentifiers(), targetClusterNames, nil, "0")
1384-
Eventually(crpStatusUpdatedActual, workloadEventuallyDuration, eventuallyInterval).Should(Succeed(), "Failed to update CRP status as expected")
1385+
// CRP should be scheduled only after member-agent reports the newly added capacity.
1386+
// Set the timeout to be a bit longer than the member cluster heartbeat period.
1387+
Eventually(crpStatusUpdatedActual, eventuallyDuration+time.Second*memberClusterHeartbeatPeriodSeconds, eventuallyInterval).Should(Succeed(), "Failed to update CRP status as expected")
13851388
Consistently(crpStatusUpdatedActual, consistentlyDuration, consistentlyInterval).Should(Succeed(), "Failed to update CRP status as expected")
13861389
})
13871390

test/e2e/setup_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,8 @@ const (
8080
azurePropertyProviderEnvVarValue = "azure"
8181
fleetClusterResourceIDAnnotationKey = "fleet.azure.com/cluster-resource-id"
8282
fleetLocationAnnotationKey = "fleet.azure.com/location"
83+
84+
memberClusterHeartbeatPeriodSeconds = 60
8385
)
8486

8587
const (

test/e2e/utils_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ func createMemberCluster(name, svcAccountName string, labels, annotations map[st
8181
Kind: "ServiceAccount",
8282
Namespace: fleetSystemNS,
8383
},
84-
HeartbeatPeriodSeconds: 60,
84+
HeartbeatPeriodSeconds: memberClusterHeartbeatPeriodSeconds,
8585
},
8686
}
8787
Expect(hubClient.Create(ctx, mcObj)).To(Succeed(), "Failed to create member cluster object %s", name)

0 commit comments

Comments
 (0)