Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add validation to self_update and no_self_update scenarios #10908

Merged
merged 2 commits into from
Aug 31, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion schedule/yast/yast_no_self_update/yast_no_self_update.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ description: >
vars:
INSTALLER_NO_SELF_UPDATE: 1
schedule:
- installation/isosize
- installation/bootloader_start
- installation/welcome
- installation/validate_no_self_update
- installation/accept_license
- installation/scc_registration
- installation/addon_products_sle
Expand Down
4 changes: 2 additions & 2 deletions schedule/yast/yast_self_update/yast_self_update.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ description: >
Installation is validated by successful boot and that YaST does not report
any issue.
vars:
INSTALLER_SELF_UPDATE: 1
INSTALLER_SELF_UPDATE: 'http://openqa.suse.de/assets/repo/%REPO_SLE_PRODUCT_SLES%'
schedule:
- installation/isosize
- installation/bootloader_start
- installation/welcome
- installation/validate_self_update
- installation/accept_license
- installation/scc_registration
- installation/addon_products_sle
Expand Down
34 changes: 34 additions & 0 deletions tests/installation/validate_no_self_update.pm
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Copyright © 2020 SUSE LLC
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program; if not, see <http://www.gnu.org/licenses/>.

# Summary: Validate installer self update is not attempted when explicitly disabled
# Maintainer: QA SLE YaST <qa-sle-yast@suse.de>

use base 'y2_installbase';
use strict;
use warnings;
use testapi;

sub run {
my $self = shift;
select_console('install-shell');
assert_script_run('test -z "$(ls -A /download)"',
fail_message => '/download directory is NOT empty, expected to be empty as no updates should be downloaded');
assert_script_run('! grep /var/log/YaST2/y2log -e "Trying installer update"',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can i ask you to try the usage of --files-without-match. i kinda dislike the use of ! when there is another way, so it makes the expression more readable. For instance grep /var/log/YaST2/y2log --files-without-match -e "Trying installer update" it greps what files do not have the expression "..." and returns 0 if file found have it.

Copy link
Member Author

@rwx788 rwx788 Aug 31, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, I need to check how exactly that flag works, because the idea is that finds files that do not contain this string, so I'm not 100% sure if it will return 0 in case no files found. Let me try it out.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Somehow grep -L 'Trying installer update' /var/log/YaST2/y2log gives 1 as a return code, even though it lists /var/log/YaST2/y2log as file without that string. Feels like a bug to me.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So the only thing I can propose here is to rewrite this line with script_run and compare return code in perl code directly. Do you think this is better than negation of the bash command?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you still need the -e flag. Can you try?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The command I've used is equivalent to grep /var/log/YaST2/y2log -L -e 'BLA' so result is same, and as you can see on the screenshot it works just fine and returns the file, as it doesn't contain the string. I will check if that's expected, and file the bug against grep.

fail_message => 'YaST logs contain entry that self update was attempted, but is explicitly disabled');
select_console('installation');
}

1;
38 changes: 38 additions & 0 deletions tests/installation/validate_self_update.pm
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Copyright © 2020 SUSE LLC
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program; if not, see <http://www.gnu.org/licenses/>.

# Summary: Validate installer self update feature downloads updates and applies
# them to the system
# Maintainer: QA SLE YaST <qa-sle-yast@suse.de>

use base 'y2_installbase';
use strict;
use warnings;
use testapi;

sub run {
my $self = shift;
select_console('install-shell');
my $self_update_repo = get_required_var('INSTALLER_SELF_UPDATE');
assert_script_run("grep /var/log/YaST2/y2log -e '$self_update_repo'",
fail_message => 'Expected to have log entries that self update repo was contacted');
assert_script_run('test -n "$(ls -A /download)"',
fail_message => '/download directory is empty, expected to contain downloaded updates');
assert_script_run('mount | grep -P "/download/yast_\d+"',
fail_message => 'updates are not mounted, expected /download/yast_* to be mounted as /mount/yast_*');
select_console('installation');
}

1;