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

Extract backend code to it's own package #6316

Merged
merged 6 commits into from Dec 14, 2018
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
62 changes: 62 additions & 0 deletions lib/Utils/Backends.pm
@@ -0,0 +1,62 @@
# Copyright (C) 2018 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/>.

package Utils::Backends;
use strict;
use warnings;

use base qw(Exporter);
use Exporter;
use testapi qw(:DEFAULT);

use constant {
BACKEND => [
qw(
is_remote_backend
)
],
CONSOLES => [
qw(
use_ssh_serial_console
Copy link
Member

Choose a reason for hiding this comment

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

I know that you are addressing another issue, but I wanted to mention that is a hack. And then we have a lot of calls like check_var('BACKEND', 'ipmi') ? use_ssh_serial_console : select_console 'root-console';.
Last time I tried to fix select_console with callbacks, but could not finish it quick, so postponed the idea. However, I believe we should get rid of this method in all 15 files and have select_console "root-console" only. Same for user-console, except that we should switch user.

Copy link
Member Author

Choose a reason for hiding this comment

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

@rwx788 actually that's a path I'd choose for later. A bit more care needs to be added there, But completely feasible, specially if poo#45146 is addressed properly and we stop covering at the test distri level, for things that should be provided by the backend...

I'm actually cringing after seeing stuff like this :)

)
]
};

our @EXPORT = (@{(+CONSOLES)}, @{+BACKEND});

our %EXPORT_TAGS = (
CONSOLES => (CONSOLES),
BACKEND => (BACKEND)
);

# Use it after SUT boot finish, as it requires ssh connection to SUT to
# interact with SUT, including window and serial console
sub use_ssh_serial_console {
select_console('root-ssh');
$serialdev = 'sshserial';
set_var('SERIALDEV', $serialdev);
bmwqemu::save_vars();
}

sub is_remote_backend {

# s390x uses only remote repos
return check_var('ARCH', 's390x') ||
check_var('BACKEND', 'svirt') ||
check_var('BACKEND', 'ipmi') ||
check_var('BACKEND', 'spvm');
}

1;
3 changes: 2 additions & 1 deletion lib/bootloader_setup.pm
Expand Up @@ -19,7 +19,8 @@ use Time::HiRes 'sleep';

use testapi;
use utils;
use version_utils qw(is_caasp is_jeos is_leap is_sle is_remote_backend);
use Utils::Backends 'is_remote_backend';
use version_utils qw(is_caasp is_jeos is_leap is_sle);
use caasp 'pause_until';
use mm_network;

Expand Down
12 changes: 2 additions & 10 deletions lib/ipmi_backend_utils.pm
@@ -1,6 +1,6 @@
# SUSE's openQA tests
#
# Copyright © 2012-2017 SUSE LLC
# Copyright © 2012-2018 SUSE LLC
#
# Copying and distribution of this file, with or without modification,
# are permitted in any medium without royalty provided the copyright
Expand All @@ -21,22 +21,14 @@ use version_utils qw(is_storage_ng is_sle);
use utils;
use power_action_utils 'prepare_system_shutdown';

our @EXPORT = qw(use_ssh_serial_console set_serial_console_on_vh switch_from_ssh_to_sol_console);
our @EXPORT = qw(set_serial_console_on_vh switch_from_ssh_to_sol_console);

#With the new ipmi backend, we only use the root-ssh console when the SUT boot up,
#and no longer setup the real serial console for either kvm or xen.
#When needs reboot, we will switch back to sut console which relies on ipmi.
#We will mostly rely on ikvm to continue the test flow.
#TODO: we need the serial output to debug issues in reboot, coolo will help add it.

#use it after SUT boot finish, as it requires ssh connection to SUT to interact with SUT, including window and serial console
sub use_ssh_serial_console {
select_console('root-ssh');
$serialdev = 'sshserial';
set_var('SERIALDEV', $serialdev);
bmwqemu::save_vars();
}

sub switch_from_ssh_to_sol_console {
my (%opts) = @_;

Expand Down
1 change: 1 addition & 0 deletions lib/main_common.pm
Expand Up @@ -19,6 +19,7 @@ use testapi qw(check_var get_var get_required_var set_var check_var_array diag);
use autotest;
use utils;
use version_utils qw(:VERSION :BACKEND :SCENARIO);
use Utils::Backends 'is_remote_backend';
foursixnine marked this conversation as resolved.
Show resolved Hide resolved
use bmwqemu ();
use strict;
use warnings;
Expand Down
2 changes: 1 addition & 1 deletion lib/susedistribution.pm
Expand Up @@ -14,7 +14,7 @@ use utils qw(
zypper_call
);
use version_utils qw(is_hyperv_in_gui is_sle is_leap is_svirt_except_s390x);
use ipmi_backend_utils 'use_ssh_serial_console';
use Utils::Backends 'use_ssh_serial_console';

# Base class implementation of distribution class necessary for testapi

Expand Down
7 changes: 0 additions & 7 deletions lib/version_utils.pm
Expand Up @@ -51,7 +51,6 @@ use constant {
is_hyperv
is_hyperv_in_gui
is_aarch64_uefi_boot_hdd
is_remote_backend
is_svirt_except_s390x
)
],
Expand Down Expand Up @@ -296,12 +295,6 @@ sub is_x86_64 {
return check_var('ARCH', 'x86_64');
}

sub is_remote_backend {
# s390x uses only remote repos
return is_s390x() || check_var('BACKEND', 'svirt') || check_var('BACKEND', 'ipmi') || check_var('BACKEND', 'spvm');
}

foursixnine marked this conversation as resolved.
Show resolved Hide resolved

sub is_server {
return 1 if is_sles4sap();
return 1 if get_var('FLAVOR', '') =~ /^Server/;
Expand Down
10 changes: 7 additions & 3 deletions tests/autoyast/login.pm
@@ -1,4 +1,4 @@
# Copyright (C) 2015-2017 SUSE LLC
# Copyright (C) 2015-2018 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
Expand All @@ -19,12 +19,16 @@
use strict;
use base 'y2logsstep';
use testapi;
use ipmi_backend_utils;
use Utils::Backends qw(use_ssh_serial_console is_remote_backend);

sub run {
my $self = shift;
assert_screen("autoyast-system-login-console", 20);
$self->result('fail'); # default result
# default result
$self->result('fail');

# TODO: is_remote_backend could be a better fit here, but not
# too sure if it would make sense for svirt or s390 for example
if (check_var('BACKEND', 'ipmi')) {
#use console based on ssh to avoid unstable ipmi
use_ssh_serial_console;
Expand Down
2 changes: 1 addition & 1 deletion tests/console/check_network.pm
Expand Up @@ -12,7 +12,7 @@

use base "consoletest";
use testapi;
use ipmi_backend_utils 'use_ssh_serial_console';
use Utils::Backends 'use_ssh_serial_console';
use strict;

sub run {
Expand Down
2 changes: 1 addition & 1 deletion tests/console/consoletest_setup.pm
Expand Up @@ -16,7 +16,7 @@
use base "consoletest";
use testapi;
use utils;
use ipmi_backend_utils 'use_ssh_serial_console';
use Utils::Backends 'use_ssh_serial_console';
use strict;

sub disable_bash_mail_notification {
Expand Down
2 changes: 1 addition & 1 deletion tests/console/prepare_test_data.pm
Expand Up @@ -13,7 +13,7 @@
use base "consoletest";
use testapi;
use utils;
use ipmi_backend_utils 'use_ssh_serial_console';
use Utils::Backends 'use_ssh_serial_console';
use strict;

sub run {
Expand Down
2 changes: 1 addition & 1 deletion tests/console/system_prepare.pm
Expand Up @@ -13,7 +13,7 @@
use base 'consoletest';
use testapi;
use utils;
use ipmi_backend_utils 'use_ssh_serial_console';
use Utils::Backends 'use_ssh_serial_console';
use bootloader_setup qw(change_grub_config grub_mkconfig);
use strict;

Expand Down
2 changes: 1 addition & 1 deletion tests/console/system_state.pm
Expand Up @@ -14,7 +14,7 @@
use base "consoletest";
use testapi;
use utils;
use ipmi_backend_utils 'use_ssh_serial_console';
use Utils::Backends 'use_ssh_serial_console';
use strict;

sub run {
Expand Down
1 change: 1 addition & 0 deletions tests/installation/logs_from_installation_system.pm
Expand Up @@ -16,6 +16,7 @@ use base 'y2logsstep';
use testapi;
use lockapi;
use utils;
use Utils::Backends 'use_ssh_serial_console';
use ipmi_backend_utils;

sub run {
Expand Down
1 change: 1 addition & 0 deletions tests/kernel/ib_tests.pm
Expand Up @@ -17,6 +17,7 @@ use testapi;
use utils;
use power_action_utils 'power_action';
use lockapi;
use Utils::Backends 'use_ssh_serial_console';
use ipmi_backend_utils;


Expand Down
2 changes: 1 addition & 1 deletion tests/sles4sap/wizard_hana_install.pm
Expand Up @@ -15,7 +15,7 @@ use base 'sles4sap';
use strict;
use testapi;
use utils qw(type_string_slow zypper_call turn_off_gnome_screensaver);
use ipmi_backend_utils 'use_ssh_serial_console';
use Utils::Backends 'use_ssh_serial_console';
use version_utils 'is_sle';

sub get_total_mem {
Expand Down
3 changes: 2 additions & 1 deletion tests/virt_autotest/login_console.pm
@@ -1,6 +1,6 @@
# SUSE's openQA tests
#
# Copyright © 2012-2016 SUSE LLC
# Copyright © 2012-2018 SUSE LLC
#
# Copying and distribution of this file, with or without modification,
# are permitted in any medium without royalty provided the copyright
Expand All @@ -16,6 +16,7 @@ use strict;
use warnings;
use File::Basename;
use testapi;
use Utils::Backends 'use_ssh_serial_console';
use ipmi_backend_utils;

sub login_to_console {
Expand Down