lntest: assert shutdown via logs only if log handle is present

Ensure shutdown assertions through log inspection are only performed
when the harness node has an active log file handle. This avoids
errors during shutdown when log file output is disabled.
This commit is contained in:
ffranr committed 2025-04-11 15:30:13 +01:00
1 parent b732525a98
commit 24ba098798
1 file changed
+11 -7
+11 -7
View File
@@ -671,14 +671,18 @@ func (hn *HarnessNode) WaitForProcessExit() error {
hn.printErrf("timeout waiting for process to exit") hn.printErrf("timeout waiting for process to exit")
} }
// Make sure log file is closed and renamed if necessary. // If the node has an open log file handle, inspect the log file
filename := finalizeLogfile(hn) // to verify that the node shut down correctly.
if hn.logFile != nil {
// Make sure log file is closed and renamed if necessary.
filename := finalizeLogfile(hn)
// Assert the node has shut down from the log file. // Assert the node has shut down from the log file.
err1 := assertNodeShutdown(filename) err1 := assertNodeShutdown(filename)
if err1 != nil { if err1 != nil {
return fmt.Errorf("[%s]: assert shutdown failed in log[%s]: %w", return fmt.Errorf("[%s]: assert shutdown failed in "+
hn.Name(), filename, err1) "log[%s]: %w", hn.Name(), filename, err1)
}
} }
// Rename the etcd.log file if the node was running on embedded etcd. // Rename the etcd.log file if the node was running on embedded etcd.