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 fa63e98
Show file tree
Hide file tree
Showing 2 changed files with 45 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,8 +696,18 @@ func (env *Environment) EventuallyExpectDrifted(nodeClaims ...*corev1beta1.NodeC
}).Should(Succeed())
}

func (env *Environment) ConsistentlyExpectNotDrifted(nodeClaim *corev1beta1.NodeClaim) {
GinkgoHelper()
By(fmt.Sprintf("waiting to verify nodeclaims to be %s does not drift", nodeClaim.Name))
Consistently(func(g Gomega) {
g.Expect(env.Client.Get(env, client.ObjectKeyFromObject(nodeClaim), nodeClaim)).To(Succeed())
g.Expect(nodeClaim.StatusConditions().GetCondition(corev1beta1.Drifted).IsFalse()).To(BeFalse())
}, time.Minute*1).Should(Succeed())
}

func (env *Environment) EventuallyExpectEmpty(nodeClaims ...*corev1beta1.NodeClaim) {
GinkgoHelper()

Eventually(func(g Gomega) {
for _, nc := range nodeClaims {
g.Expect(env.Client.Get(env, client.ObjectKeyFromObject(nc), nc)).To(Succeed())
Expand Down
35 changes: 35 additions & 0 deletions test/suites/drift/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -719,6 +719,41 @@ 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()

By("expect nodepool and nodeclaim to have hash values")
Eventually(func(g Gomega) {
g.Expect(nodePool.Annotations).To(HaveKeyWithValue(corev1beta1.NodePoolHashAnnotationKey, expectedHash))
g.Expect(nodePool.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
g.Expect(nodeClaim.Annotations).To(HaveKeyWithValue(corev1beta1.NodePoolHashAnnotationKey, expectedHash))
g.Expect(nodeClaim.Annotations).To(HaveKeyWithValue(corev1beta1.NodePoolHashVersionAnnotationKey, corev1beta1.NodePoolHashVersion))

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

View workflow job for this annotation

GitHub Actions / ci

undefined: corev1beta1.NodePoolHashVersionAnnotationKey

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

View workflow job for this annotation

GitHub Actions / ci

undefined: corev1beta1.NodePoolHashVersion
}).Should(Succeed())

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

Check failure on line 739 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 741 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)
Eventually(func(g Gomega) {
g.Expect(nodePool.Annotations).To(HaveKeyWithValue(corev1beta1.NodePoolHashAnnotationKey, expectedHash))
g.Expect(nodePool.Annotations).To(HaveKeyWithValue(corev1beta1.NodePoolHashVersionAnnotationKey, corev1beta1.NodePoolHashVersion))

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

View workflow job for this annotation

GitHub Actions / ci

undefined: corev1beta1.NodePoolHashVersionAnnotationKey

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

View workflow job for this annotation

GitHub Actions / ci

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

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

View workflow job for this annotation

GitHub Actions / ci

undefined: corev1beta1.NodePoolHashVersionAnnotationKey

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

View workflow job for this annotation

GitHub Actions / ci

undefined: corev1beta1.NodePoolHashVersion
}).Should(Succeed())
})
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 fa63e98

Please sign in to comment.