Skip to content

Commit

Permalink
Add e2e tests for OutOfServiceTaint remediation
Browse files Browse the repository at this point in the history
  • Loading branch information
k-keiichi-rh committed Nov 29, 2023
1 parent 7cdbec8 commit ac248dd
Showing 1 changed file with 49 additions and 2 deletions.
51 changes: 49 additions & 2 deletions e2e/self_node_remediation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,25 @@ var _ = Describe("Self Node Remediation E2E", func() {
})
})

Context("OutOfService Remediation Strategy", func() {
var oldPodCreationTime time.Time

BeforeEach(func() {
remediationStrategy = v1alpha1.OutOfServiceTaintRemediationStrategy
oldPodCreationTime = findSnrPod(node).CreationTimestamp.Time
})

It("should delete pods", func() {
checkPodRecreated(node, oldPodCreationTime)
//Simulate NHC trying to delete SNR
deleteAndWait(snr)
snr = nil

checkNoExecuteTaintRemoved(node)
checkOutOfServiceTaintRemoved(node)
})
})

})
})

Expand Down Expand Up @@ -342,6 +361,25 @@ var _ = Describe("Self Node Remediation E2E", func() {
})
})

Context("OutOfService Remediation Strategy", func() {
var oldPodCreationTime time.Time

BeforeEach(func() {
remediationStrategy = v1alpha1.OutOfServiceTaintRemediationStrategy
oldPodCreationTime = findSnrPod(controlPlaneNode).CreationTimestamp.Time
})

It("should delete pods", func() {
checkPodRecreated(controlPlaneNode, oldPodCreationTime)
//Simulate NHC trying to delete SNR
deleteAndWait(snr)
snr = nil

checkNoExecuteTaintRemoved(controlPlaneNode)
checkOutOfServiceTaintRemoved(controlPlaneNode)
})
})

})
})

Expand Down Expand Up @@ -392,6 +430,15 @@ func getBootTime(node *v1.Node) (*time.Time, error) {

func checkNoExecuteTaintRemoved(node *v1.Node) {
By("checking if NoExecute taint was removed")
checkTaintRemoved(node, controllers.NodeNoExecuteTaint)
}

func checkOutOfServiceTaintRemoved(node *v1.Node) {
By("checking if out-of-service taint was removed")
checkTaintRemoved(node, controllers.OutOfServiceTaint)
}

func checkTaintRemoved(node *v1.Node, taintToCheck *v1.Taint) {
EventuallyWithOffset(1, func() error {
key := client.ObjectKey{
Name: node.GetName(),
Expand All @@ -403,8 +450,8 @@ func checkNoExecuteTaintRemoved(node *v1.Node) {
}
logger.Info("", "taints", newNode.Spec.Taints)
for _, taint := range newNode.Spec.Taints {
if taint.MatchTaint(controllers.NodeNoExecuteTaint) {
return fmt.Errorf("NoExecute taint still exists")
if taint.MatchTaint(taintToCheck) {
return fmt.Errorf("Taint still exists taint key:%s, taint effect:%s", taintToCheck.Key, taintToCheck.Effect)
}
}
return nil
Expand Down

0 comments on commit ac248dd

Please sign in to comment.