Skip to content
Open
Show file tree
Hide file tree
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
11 changes: 9 additions & 2 deletions script-pre-install.ks.in
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,17 @@ with open("/mnt/sysroot/root/preinstall_python.log", "a") as log_file:
%end

# Second pre-install script with intentional error
%pre-install --log=/mnt/sysroot/root/preinstall_error.log
%pre-install --erroronfail --log=/mnt/sysroot/root/preinstall_error.log
echo "SUCCESS"
echo "Logging from bash pre-install script" >> /mnt/sysroot/root/preinstall_error.log
# fixup this workaround after non-interactive mode is fixed
shutdown +1
exit 1
%end

text
# Pre-install script that should be unreachable
%pre-install
echo "Unreachable code"
%end

text --non-interactive
20 changes: 17 additions & 3 deletions script-pre-install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,13 @@ TESTTYPE="ksscript"

. ${KSTESTDIR}/functions.sh

# Define the path to the config file (must match the path in log_handler.py)
CONFIG_FILE_PATH="/tmp/ignored_simple_tests.conf"

# Write the messages to ignore into the config file
# In this example, we're adding "Traceback" to be ignored
echo "Traceback" > "${CONFIG_FILE_PATH}"

validate() {
local disksdir=$1
local status=0
Expand All @@ -32,14 +39,21 @@ validate() {
local success_count
success_count=$(grep -c "SUCCESS" "${disksdir}/virt-install.log")

if [[ $success_count -ne 2 ]]; then
if [[ $success_count -lt 2 ]]; then
echo "*** ERROR: Expected 2 SUCCESS messages, but found ${success_count}."
status=1
fi

# Check for the specific error message in the virt-install.log
if ! grep -q "kickstart.script: Error code 1 running the kickstart script" "${disksdir}/virt-install.log"; then
echo '*** ERROR: Expected error message "kickstart.script: Error code 1 running the kickstart script" not found in virt-install.log.'
if ! grep -q "Error code 1 running the kickstart script" "${disksdir}/virt-install.log"; then
echo '*** ERROR: Expected error message "Error code 1 running the kickstart script" not found in virt-install.log.'
status=1
fi

# Ensure that the "Unreachable code" message is NOT present.
grep -q "Unreachable code" "${disksdir}/virt-install.log"
if [[ $? == 0 ]]; then
echo '*** ERROR: The test failed because unreachable code was executed after "exit 1".'
status=1
fi

Expand Down
14 changes: 14 additions & 0 deletions scripts/launcher/lib/log_monitor/log_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
#
# Red Hat Author(s): Vendula Poncova <vponcova@redhat.com>
#
import os

from pylorax.monitor import LogRequestHandler


Expand All @@ -42,6 +44,18 @@ class VirtualLogRequestHandler(LogRequestHandler):
"Call Trace:"
]

# Path to the config file
CONFIG_FILE_PATH = '/tmp/ignored_simple_tests.conf'

if os.path.isfile(CONFIG_FILE_PATH):
with open(CONFIG_FILE_PATH, 'r') as config_file:
extra_ignored_tests = [line.strip() for line in config_file if line.strip()]
# Extend the ignored_simple_tests list
ignored_simple_tests.extend(extra_ignored_tests)

# Remove the config file after reading
os.remove(CONFIG_FILE_PATH)

# Specify error lines you want to add on top
# of the default ones contained in Lorax
simple_tests = LogRequestHandler.simple_tests + [
Expand Down