Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add e2e tests for OutOfServiceTaint remediation #166

Merged
merged 2 commits into from
Jan 9, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 34 additions & 2 deletions e2e/self_node_remediation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ const (
nodeExecTimeout = 20 * time.Second
reconnectInterval = 300 * time.Second
skipLogsEnvVarName = "SKIP_LOG_VERIFICATION"
skipOOSREnvVarName = "SKIP_OOST_REMEDIATION_VERIFICATION"
)

var _ = Describe("Self Node Remediation E2E", func() {
Expand Down Expand Up @@ -123,6 +124,28 @@ var _ = Describe("Self Node Remediation E2E", func() {
})
})

Context("OutOfService Remediation Strategy", func() {
mshitrit marked this conversation as resolved.
Show resolved Hide resolved
var oldPodCreationTime time.Time

BeforeEach(func() {
if _, isExist := os.LookupEnv(skipOOSREnvVarName); isExist {
Skip("Skip this test due to out-of-service taint not supported")
}
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 @@ -392,6 +415,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 +435,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