diff --git a/script-pre-install.ks.in b/script-pre-install.ks.in index bda9afa8..3d822882 100644 --- a/script-pre-install.ks.in +++ b/script-pre-install.ks.in @@ -12,10 +12,16 @@ 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 +shutdown +1 exit 1 %end +# Pre-install script that should be unreachable +%pre-install +echo "Unreachable code" >> /mnt/sysroot/root/preinstall_error.log +%end + text diff --git a/script-pre-install.sh b/script-pre-install.sh index 7f6ce32c..9487ca65 100755 --- a/script-pre-install.sh +++ b/script-pre-install.sh @@ -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 @@ -32,16 +39,24 @@ 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 + # 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 + # 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 + rm -f "${CONFIG_FILE_PATH}" return ${status} } diff --git a/scripts/launcher/lib/log_monitor/log_handler.py b/scripts/launcher/lib/log_monitor/log_handler.py index 1520bdc1..8d95fcc9 100644 --- a/scripts/launcher/lib/log_monitor/log_handler.py +++ b/scripts/launcher/lib/log_monitor/log_handler.py @@ -17,6 +17,8 @@ # # Red Hat Author(s): Vendula Poncova # +import os + from pylorax.monitor import LogRequestHandler @@ -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 + [