From 9c3aab4bba27af1d06e8744cdf167450294e5b0d Mon Sep 17 00:00:00 2001 From: lilyeyes Date: Mon, 9 Sep 2024 10:47:03 +0800 Subject: [PATCH] Fix SDAF sporadic fail caused by multi line banner Fix SDAF sporadic failures caused by multi line banner TEAM-9639 - [SDAF][BUG] sporadic failures caused by multi line banner --- .../sap_deployment_automation_framework/deployment.pm | 5 +---- t/20_sdaf_deployment_library.t | 10 ++++------ 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/lib/sles4sap/sap_deployment_automation_framework/deployment.pm b/lib/sles4sap/sap_deployment_automation_framework/deployment.pm index 47d691d6b0a3..d3a1a7c0f54b 100644 --- a/lib/sles4sap/sap_deployment_automation_framework/deployment.pm +++ b/lib/sles4sap/sap_deployment_automation_framework/deployment.pm @@ -418,11 +418,8 @@ sub serial_console_diag_banner { # max_length - length of the text - 4x2 dividing spaces my $symbol_fill = ($max_length - length($input_text) - 8) / 2; $input_text = '#' x $symbol_fill . ' ' x 4 . $input_text . ' ' x 4 . '#' x $symbol_fill; - my $fill_line = '#' x length($input_text); - foreach ($fill_line, $input_text, $fill_line) { - enter_cmd($_); - } + enter_cmd($input_text, wait_still_screen => 2); wait_serial(qr/:~|#|>/, timeout => 5, quiet => 1); } diff --git a/t/20_sdaf_deployment_library.t b/t/20_sdaf_deployment_library.t index ce9a745790e8..6e8b12e6da3f 100644 --- a/t/20_sdaf_deployment_library.t +++ b/t/20_sdaf_deployment_library.t @@ -166,15 +166,13 @@ subtest '[replace_tfvars_variables] Test correct variable replacement' => sub { subtest '[serial_console_diag_banner] ' => sub { my $ms_sdaf = Test::MockModule->new('sles4sap::sap_deployment_automation_framework::deployment', no_auto => 1); - my @printed_lines; - $ms_sdaf->redefine(enter_cmd => sub { push(@printed_lines, $_[0]); return 1; }); + my $printed_line; + $ms_sdaf->redefine(enter_cmd => sub { $printed_line = $_[0]; return 1; }); $ms_sdaf->redefine(wait_serial => sub { return 1; }); serial_console_diag_banner('Module: deploy_sdaf.pm'); - note("Banner:\n" . join("\n", @printed_lines)); - is @printed_lines, 3, 'Banner consists of three text lines'; - ok(grep { length($_) == length($printed_lines[1]) } @printed_lines, 'All banner lines must be equally long'); - ok(grep(/Module: deploy_sdaf.pm/, @printed_lines), 'Banner must include message'); + note("Banner:\n" . join("\n", $printed_line)); + ok(grep(/Module: deploy_sdaf.pm/, $printed_line), 'Banner must include message'); dies_ok { serial_console_diag_banner() } 'Fail with missing test to be printed'; dies_ok { serial_console_diag_banner('exeCuTing deploYment' x 6) } 'Fail with string exceeds max number of characters'; };