gpathak wrote in #note-11:
@jbaier_cz's observation about post_run_hook
is right. post_run_hook
even if present, doesn't execute in case of a failure encountered in run
subroutine of a test. In case of a failure the post_fail_hook
gets executed if present.
I ran the reproducer from https://openqa.opensuse.org/tests/4880517 on my local setup and got exact same result.
I also did some modifications as well, I added some initial code from prepare.pm
in reproducer.pm
for setting up console and logging in as root
user and removed zypper calls to reduce testing time.
use Mojo::Base 'openQAcoretest';
use utils qw(disable_packagekit switch_to_root_console);
use testapi;
sub run {
switch_to_root_console;
assert_screen 'inst-console';
type_string "root\n";
assert_screen 'password-prompt';
type_password;
send_key 'ret';
wait_still_screen(2);
assert_script_run("echo 'hello_world!'");
assert_script_run("echo ''");
#assert_script_run("/bin/false");
enter_cmd "echo 'hello_world' > /dev/$serialdev";
die "we could not see expected output" unless wait_serial "hello_world", 30;
}
sub post_run_hook {
#record_info 'this will not run on test failure';
force_soft_failure 'post_run_hook: this should be only a softfail';
}
sub post_fail_hook {
force_soft_failure 'post_fail_hook: this should be only a softfail';
}
1;
This resulted in a soft failure from post_run_hook
but in this case post_fail_hook
wasn't called.

Used this command to trigger the test
openqa-cli api -X POST jobs HDD_1=opensuse-Tumbleweed-x86_64-20250223-minimalx@64bit.qcow2 MACHINE=64bit TEST=tests/install/boot,install/reproducer DISTRI=openqa EXCLUDE_MODULES=openqa_webui,openqa_worker,test_distribution,worker,start_test,test_running,dashboard,login,tests,search,shutdown,prepare
Modified post_run_hook
to test if post_fail_hook
is called when a failure is encountered in post_run_hook
sub post_run_hook {
die "we could not see expected output" unless wait_serial "post_run_hook: this should fail and call post_fail_hook", 30;
}
sub post_fail_hook {
force_soft_failure 'post_fail_hook: this should be only a softfail';
}

