From 40f822c568345b5af618b0a96a3aee5970f55c94 Mon Sep 17 00:00:00 2001 From: lilyeyes Date: Tue, 5 Sep 2023 11:16:23 +0800 Subject: [PATCH] testing for missing sudo passwd --- lib/qesapdeployment.pm | 13 +++++++++++++ tests/sles4sap/qesapdeployment/deploy.pm | 6 ++++-- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/lib/qesapdeployment.pm b/lib/qesapdeployment.pm index 4ef1478e971d..91793ad9306c 100644 --- a/lib/qesapdeployment.pm +++ b/lib/qesapdeployment.pm @@ -438,6 +438,19 @@ sub qesap_ansible_log_find_timeout return $timeout_match ? 1 : 0; } +=head3 qesap_ansible_log_find_missing_sudo_password + + Return the '"msg": "Missing sudo password"' error found in the Ansible log or not +=cut + +sub qesap_ansible_log_find_missing_sudo_password +{ + my ($file) = @_; + my $search_string = 'Missing sudo password'; + my $timeout_match = script_output("grep \"$search_string\" $file || exit 0"); + return $timeout_match ? 1 : 0; +} + =head3 qesap_get_inventory Return the path of the generated inventory diff --git a/tests/sles4sap/qesapdeployment/deploy.pm b/tests/sles4sap/qesapdeployment/deploy.pm index 55410b5eaeda..b323e7e6399a 100644 --- a/tests/sles4sap/qesapdeployment/deploy.pm +++ b/tests/sles4sap/qesapdeployment/deploy.pm @@ -25,8 +25,10 @@ sub run { if ($ret[0]) { my $rec_timeout = qesap_ansible_log_find_timeout($ret[1]); - if ($rec_timeout) { - record_info('DETECTED ANSIBLE TIMEOUT ERROR'); + my $rec_missing_sudo_password = qesap_ansible_log_find_timeout($ret[1]); + if ($rec_timeout || $rec_missing_sudo_password) { + record_info('DETECTED ANSIBLE TIMEOUT ERROR') if $rec_timeout; + record_info('DETECTED ANSIBLE MISSING SUDO PASSWORD ERROR') if $rec_missing_sudo_password; $self->clean_up(); @ret = qesap_execute(cmd => 'terraform', verbose => 1, timeout => 1800); die "'qesap.py terraform' return: $ret[0]" if ($ret[0]);