Skip to content

Commit

Permalink
Fix SDAF sporadic fail caused by multi line banner
Browse files Browse the repository at this point in the history
Fix SDAF sporadic failures caused by multi line banner
TEAM-9639 - [SDAF][BUG] sporadic failures caused by multi line banner
  • Loading branch information
lilyeyes committed Sep 9, 2024
1 parent 1172093 commit 9c3aab4
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
10 changes: 4 additions & 6 deletions t/20_sdaf_deployment_library.t
Original file line number Diff line number Diff line change
Expand Up @@ -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';
};
Expand Down

0 comments on commit 9c3aab4

Please sign in to comment.