From f762d009b7313ed2fada688ed94947168e6e4543 Mon Sep 17 00:00:00 2001 From: razo7 Date: Sun, 30 Jul 2023 16:56:12 +0300 Subject: [PATCH] Test success log with node name 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 --- controllers/fenceagentsremediation_controller.go | 1 + test/e2e/far_e2e_test.go | 10 +++++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/controllers/fenceagentsremediation_controller.go b/controllers/fenceagentsremediation_controller.go index c4faea8c..4ea33b20 100644 --- a/controllers/fenceagentsremediation_controller.go +++ b/controllers/fenceagentsremediation_controller.go @@ -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) diff --git a/test/e2e/far_e2e_test.go b/test/e2e/far_e2e_test.go index 98bb80f8..78e95807 100644 --- a/test/e2e/far_e2e_test.go +++ b/test/e2e/far_e2e_test.go @@ -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 { @@ -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)