Skip to content

Commit

Permalink
Slow type and run very long command in scripted way
Browse files Browse the repository at this point in the history
It aims to avoid 'key event queue full' issue.
For the detail, see:
https://progress.opensuse.org/issues/19540
  • Loading branch information
mitiao committed Jun 27, 2017
1 parent f701389 commit 8578a46
Showing 1 changed file with 51 additions and 4 deletions.
55 changes: 51 additions & 4 deletions lib/utils.pm
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ our @EXPORT = qw(
service_action
assert_gui_app
install_all_from_repo
slow_run_scripted_commnad
);


Expand Down Expand Up @@ -870,14 +871,17 @@ sub validatelr {
my $uri = $args->{uri};

if ($product eq 'IBM-DLPAR-utils') {
assert_script_run
"zypper lr --uri | awk -F '|' -v OFS=' ' '{ print \$3,\$4,\$NF }' | tr -s ' ' | grep \"$product\[\[:space:\]\[:punct:\]\[:space:\]\]*$enabled_repo $uri\"";
my $cmd
= "zypper lr --uri | awk -F \'|\' -v OFS=\' \' \'{ print \$3,\$4,\$NF }\' | tr -s \' \' | grep --color \"$product\[\[:space:\]\[:punct:\]\[:space:\]\]*$enabled_repo $uri\"";
slow_run_scripted_commnad $cmd;
}
elsif (check_var('DISTRI', 'sle')) {
# SLES12 does not have 'SLES12-Source-Pool' SCC channel
unless (($version eq "12") and ($product_channel eq "Source-Pool")) {
assert_script_run
"zypper lr --uri | awk -F '|' -v OFS=' ' '{ print \$2,\$3,\$4,\$NF }' | tr -s ' ' | grep \"$product$version\[\[:alnum:\]\[:punct:\]\]*-*$product_channel $product$version\[\[:alnum:\]\[:punct:\]\[:space:\]\]*-*$product_channel $enabled_repo $uri\"";
my $cmd
= "zypper lr --uri | awk -F \'|\' -v OFS=\' \' \'{ print \$2,\$3,\$4,\$NF }\' | tr -s \' \' | grep --color \"$product$version\[\[:alnum:\]\[:punct:\]\]*-*$product_channel $product$version\[\[:alnum:\]\[:punct:\]\[:space:\]\]*-*$product_channel $enabled_repo $uri\"";
slow_run_scripted_commnad $cmd;
}
}
}
}
Expand Down Expand Up @@ -1173,6 +1177,49 @@ sub install_all_from_repo {
assert_script_run($exec_str, 900);
}

=head2 slow_run_scripted_commnad
slow_run_scripted_commnad($cmd [, slow_type => <num> ]);
Type slowly to run very long command in scripted way to avoid issue of 'key event queue full' (see poo#12250).
Pass optional slow_type key to control how slow to type the command.
Scripted very long command to shorten typing length.
Default slow_type is type_string_slow.
=cut

sub slow_run_scripted_commnad {
my ($cmd, %args) = @_;
my $suffix = hashed_string("SO$cmd");

open(my $fh, '>', 'current_script');
print $fh $cmd;
close $fh;

my $slow_type = $args{slow_type} // 1;
my $curl_script = "curl -f -v " . autoinst_url("/current_script") . " > /tmp/script$suffix.sh" . " ; echo curl-\$? > /dev/$testapi::serialdev\n";
my $exec_script = "/bin/bash -x /tmp/script$suffix.sh" . " ; echo script$suffix-\$? > /dev/$testapi::serialdev\n";
if ($slow_type == 1) {
type_string_slow $curl_script;
wait_serial "curl-0";
type_string_slow $exec_script;
wait_serial "script$suffix-0";
}
elsif ($slow_type == 2) {
type_string_very_slow $curl_script;
wait_serial "curl-0";
type_string_very_slow $exec_script;
wait_serial "script$suffix-0";
}
elsif ($slow_type == 3) {
type_string $curl_script, wait_screen_change => 1;
wait_serial "curl-0";
type_string $exec_script, wait_screen_change => 1;
wait_serial "script$suffix-0";
}
clear_console;
}

1;

# vim: sw=4 et

0 comments on commit 8578a46

Please sign in to comment.