Skip to content

Commit

Permalink
Test success log with node name
Browse files Browse the repository at this point in the history
checkFarLogs will use node name in order to verify a successful response message, since prior to this change checkFarLogs searched for the existance of success message which could have been from an earlier remediation
  • Loading branch information
razo7 committed Jul 30, 2023
1 parent 53bf095 commit f762d00
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
1 change: 1 addition & 0 deletions controllers/fenceagentsremediation_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ func (r *FenceAgentsRemediationReconciler) Reconcile(ctx context.Context, req ct
r.Log.Error(err, "Fence Agent response wasn't a success message", "CR's Name", req.Name)
return emptyResult, err
}
r.Log.Info("Fence Agent command was finished successfully", "Fence Agent", far.Spec.Agent, "Node name", req.Name, "Response", SuccessFAResponse)

// Reboot was finished and now we remove workloads (pods and their VA)
r.Log.Info("Manual workload deletion", "Fence Agent", far.Spec.Agent, "Node Name", req.Name)
Expand Down
10 changes: 9 additions & 1 deletion test/e2e/far_e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,13 @@ func wasFarTaintAdded(nodeName string) {
log.Info("FAR taint was added", "node name", node.Name, "taint key", farTaint.Key, "taint effect", farTaint.Effect)
}

// buildExpectedLogOutput returns a string with a node identifier and a success message for the reboot action
func buildExpectedLogOutput(nodeName, sucesssMessage string) string {
expectedString := "\"Node name\": \"" + nodeName + "\", \"Response\": \"" + sucesssMessage
log.Info("Substring to search in the logs is ", "expectedString", expectedString)
return expectedString
}

// checkFarLogs gets the FAR pod and checks whether it's logs have logString
func checkFarLogs(farNodeName, logString string) {
EventuallyWithOffset(1, func() string {
Expand Down Expand Up @@ -383,7 +390,8 @@ func checkRemediation(nodeName string, nodeBootTimeBefore time.Time, oldPodCreat
wasFarTaintAdded(nodeName)

By("Check if the response of the FA was a success")
checkFarLogs(nodeName, controllers.SuccessFAResponse)
expectedLog := buildExpectedLogOutput(nodeName, controllers.SuccessFAResponse)
checkFarLogs(nodeName, expectedLog)

By("Getting new node's boot time")
wasNodeRebooted(nodeName, nodeBootTimeBefore)
Expand Down

0 comments on commit f762d00

Please sign in to comment.