Skip to content

Commit

Permalink
gh comments
Browse files Browse the repository at this point in the history
  • Loading branch information
jmdeal committed May 14, 2024
1 parent 8624b23 commit e59e304
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
3 changes: 1 addition & 2 deletions test/pkg/environment/common/expectations.go
Original file line number Diff line number Diff line change
Expand Up @@ -479,13 +479,12 @@ func (env *Environment) ExpectNodeCount(comparator string, count int) {
Expect(len(nodeList.Items)).To(BeNumerically(comparator, count))
}

func (env *Environment) ExpectNodeClaimCount(comparator string, count int) []*corev1beta1.NodeClaim {
func (env *Environment) ExpectNodeClaimCount(comparator string, count int) {
GinkgoHelper()

nodeClaimList := &corev1beta1.NodeClaimList{}
Expect(env.Client.List(env, nodeClaimList, client.HasLabels{test.DiscoveryLabel})).To(Succeed())
Expect(len(nodeClaimList.Items)).To(BeNumerically(comparator, count))
return lo.ToSlicePtr(nodeClaimList.Items)
}

func NodeClaimNames(nodeClaims []*corev1beta1.NodeClaim) []string {
Expand Down
14 changes: 8 additions & 6 deletions test/suites/drift/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -838,7 +838,7 @@ var _ = Describe("Drift", func() {

env.EventuallyExpectDrifted(startingNodeClaimState...)

// Expect nodes To get tainted, expect only one node is disrupted due to default disruption budgets
// Expect only a single node to be tainted due to default disruption budgets
taintedNodes := env.EventuallyExpectTaintedNodeCount("==", 1)

// Drift should fail and the original node should be untainted
Expand All @@ -849,9 +849,10 @@ var _ = Describe("Drift", func() {
// Assert this over several minutes to ensure a subsequent disruption controller pass doesn't
// successfully schedule the evicted pods to the in-flight nodeclaim and disrupt the original node
Consistently(func(g Gomega) {
nodeClaims := env.ExpectNodeClaimCount(">=", int(numPods))
nodeClaims := &corev1beta1.NodeClaimList{}
g.Expect(env.Client.List(env, nodeClaims, client.HasLabels{coretest.DiscoveryLabel})).To(Succeed())
startingNodeClaimUIDs := sets.New(lo.Map(startingNodeClaimState, func(nc *corev1beta1.NodeClaim, _ int) types.UID { return nc.UID })...)
nodeClaimUIDs := sets.New(lo.Map(nodeClaims, func(nc *corev1beta1.NodeClaim, _ int) types.UID { return nc.UID })...)
nodeClaimUIDs := sets.New(lo.Map(nodeClaims.Items, func(nc corev1beta1.NodeClaim, _ int) types.UID { return nc.UID })...)
g.Expect(nodeClaimUIDs.IsSuperset(startingNodeClaimUIDs)).To(BeTrue())
}, "2m").Should(Succeed())
})
Expand Down Expand Up @@ -881,7 +882,7 @@ var _ = Describe("Drift", func() {

env.EventuallyExpectDrifted(startingNodeClaimState...)

// Expect nodes To get tainted, expect only one node is disrupted due to default disruption budgets
// Expect only a single node to get tainted due to default disruption budgets
taintedNodes := env.EventuallyExpectTaintedNodeCount("==", 1)

// Drift should fail and original node should be untainted
Expand All @@ -901,9 +902,10 @@ var _ = Describe("Drift", func() {
// Assert this over several minutes to ensure a subsequent disruption controller pass doesn't
// successfully schedule the evicted pods to the in-flight nodeclaim and disrupt the original node
Consistently(func(g Gomega) {
nodeClaims := env.ExpectNodeClaimCount(">=", int(numPods))
nodeClaims := &corev1beta1.NodeClaimList{}
g.Expect(env.Client.List(env, nodeClaims, client.HasLabels{coretest.DiscoveryLabel})).To(Succeed())
startingNodeClaimUIDs := sets.New(lo.Map(startingNodeClaimState, func(m *corev1beta1.NodeClaim, _ int) types.UID { return m.UID })...)
nodeClaimUIDs := sets.New(lo.Map(nodeClaims, func(m *corev1beta1.NodeClaim, _ int) types.UID { return m.UID })...)
nodeClaimUIDs := sets.New(lo.Map(nodeClaims.Items, func(m corev1beta1.NodeClaim, _ int) types.UID { return m.UID })...)
g.Expect(nodeClaimUIDs.IsSuperset(startingNodeClaimUIDs)).To(BeTrue())
}, "2m").Should(Succeed())
})
Expand Down

0 comments on commit e59e304

Please sign in to comment.