Skip to content

Commit

Permalink
Add config file for custom ignored_simple_tests
Browse files Browse the repository at this point in the history
  • Loading branch information
adamkankovsky committed Nov 7, 2024
1 parent dbad402 commit e688449
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 4 deletions.
8 changes: 7 additions & 1 deletion script-pre-install.ks.in
Original file line number Diff line number Diff line change
Expand Up @@ -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
21 changes: 18 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,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}
}
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 <[email protected]>
#
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

0 comments on commit e688449

Please sign in to comment.