Skip to content

Commit

Permalink
Add E2E for NodePools hash version
Browse files Browse the repository at this point in the history
  • Loading branch information
engedaam committed Mar 7, 2024
1 parent e798c27 commit cb861c0
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 0 deletions.
10 changes: 10 additions & 0 deletions test/pkg/environment/common/expectations.go
Original file line number Diff line number Diff line change
Expand Up @@ -696,6 +696,16 @@ func (env *Environment) EventuallyExpectDrifted(nodeClaims ...*corev1beta1.NodeC
}).Should(Succeed())
}

func (env *Environment) ConsistentlyExpectNotDrifted(nodeClaims ...*corev1beta1.NodeClaim) {
GinkgoHelper()
Consistently(func(g Gomega) {
for _, nc := range nodeClaims {
g.Expect(env.Client.Get(env, client.ObjectKeyFromObject(nc), nc)).To(Succeed())
g.Expect(nc.StatusConditions().GetCondition(corev1beta1.Drifted).IsFalse()).To(BeFalse())
}
}, time.Minute*1).Should(Succeed())
}

func (env *Environment) EventuallyExpectEmpty(nodeClaims ...*corev1beta1.NodeClaim) {
GinkgoHelper()
Eventually(func(g Gomega) {
Expand Down
30 changes: 30 additions & 0 deletions test/suites/drift/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -719,6 +719,36 @@ var _ = Describe("Drift", func() {
env.EventuallyExpectNotFound(pod, node)
env.EventuallyExpectHealthyPodCount(selector, numPods)
})
It("should update nodepool-hash and nodepool-hash-version and re-propagates to the NodeClaim", func() {
env.ExpectCreated(dep, nodeClass, nodePool)
env.EventuallyExpectHealthyPodCount(selector, numPods)
nodeClaim := env.EventuallyExpectCreatedNodeClaimCount("==", 1)[0]
err := env.Client.Get(env.Context, client.ObjectKeyFromObject(nodePool), nodePool)
Expect(err).ToNot(HaveOccurred())
expectedHash := nodeClass.Hash()

Expect(nodeClass.Annotations).To(HaveKeyWithValue(corev1beta1.NodePoolHashAnnotationKey, expectedHash))
Expect(nodeClass.Annotations).To(HaveKeyWithValue(corev1beta1.NodePoolHashVersionAnnotationKey, corev1beta1.NodePoolHashVersion))

Check failure on line 731 in test/suites/drift/suite_test.go

View workflow job for this annotation

GitHub Actions / ci

undefined: corev1beta1.NodePoolHashVersionAnnotationKey

Check failure on line 731 in test/suites/drift/suite_test.go

View workflow job for this annotation

GitHub Actions / ci

undefined: corev1beta1.NodePoolHashVersion
Expect(nodeClaim.Annotations).To(HaveKeyWithValue(corev1beta1.NodePoolHashAnnotationKey, expectedHash))
Expect(nodeClaim.Annotations).To(HaveKeyWithValue(corev1beta1.NodePoolHashVersionAnnotationKey, corev1beta1.NodePoolHashVersion))

Check failure on line 733 in test/suites/drift/suite_test.go

View workflow job for this annotation

GitHub Actions / ci

undefined: corev1beta1.NodePoolHashVersionAnnotationKey

Check failure on line 733 in test/suites/drift/suite_test.go

View workflow job for this annotation

GitHub Actions / ci

undefined: corev1beta1.NodePoolHashVersion

nodePool.Annotations = map[string]string{corev1beta1.NodePoolHashAnnotationKey: "test-version-1"}
nodePool.Annotations = map[string]string{corev1beta1.NodePoolHashVersionAnnotationKey: "test-version-1"}

Check failure on line 736 in test/suites/drift/suite_test.go

View workflow job for this annotation

GitHub Actions / ci

undefined: corev1beta1.NodePoolHashVersionAnnotationKey
nodeClaim.Annotations = map[string]string{corev1beta1.NodePoolHashAnnotationKey: "test-version-2"}
nodeClaim.Annotations = map[string]string{corev1beta1.NodePoolHashVersionAnnotationKey: "test-version-2"}

Check failure on line 738 in test/suites/drift/suite_test.go

View workflow job for this annotation

GitHub Actions / ci

undefined: corev1beta1.NodePoolHashVersionAnnotationKey

env.ExpectUpdated(nodePool, nodeClaim)
err = env.Client.Get(env.Context, client.ObjectKeyFromObject(nodePool), nodePool)
Expect(err).ToNot(HaveOccurred())
nodeClaim = env.EventuallyExpectCreatedNodeClaimCount("==", 1)[0]

// Should expect the NodeClaim not be drifted and contain the controller hash version
env.ConsistentlyExpectNotDrifted(nodeClaim)
Expect(nodeClass.Annotations).To(HaveKeyWithValue(corev1beta1.NodePoolHashAnnotationKey, expectedHash))
Expect(nodeClass.Annotations).To(HaveKeyWithValue(corev1beta1.NodePoolHashVersionAnnotationKey, corev1beta1.NodePoolHashVersion))

Check failure on line 748 in test/suites/drift/suite_test.go

View workflow job for this annotation

GitHub Actions / ci

undefined: corev1beta1.NodePoolHashVersionAnnotationKey

Check failure on line 748 in test/suites/drift/suite_test.go

View workflow job for this annotation

GitHub Actions / ci

undefined: corev1beta1.NodePoolHashVersion
Expect(nodeClaim.Annotations).To(HaveKeyWithValue(corev1beta1.NodePoolHashAnnotationKey, expectedHash))
Expect(nodeClaim.Annotations).To(HaveKeyWithValue(corev1beta1.NodePoolHashVersionAnnotationKey, corev1beta1.NodePoolHashVersion))

Check failure on line 750 in test/suites/drift/suite_test.go

View workflow job for this annotation

GitHub Actions / ci

undefined: corev1beta1.NodePoolHashVersionAnnotationKey

Check failure on line 750 in test/suites/drift/suite_test.go

View workflow job for this annotation

GitHub Actions / ci

undefined: corev1beta1.NodePoolHashVersion
})
Context("Failure", func() {
It("should not continue to drift if a node never registers", func() {
// launch a new nodeClaim
Expand Down

0 comments on commit cb861c0

Please sign in to comment.