Skip to content

Commit

Permalink
Merge pull request #5712 from jknphy/add_service_widget_iscsi
Browse files Browse the repository at this point in the history
Add service widget for iscsi
  • Loading branch information
Rodion Iafarov committed Sep 17, 2018
2 parents 8082f7e + 95cda4a commit 2af518a
Show file tree
Hide file tree
Showing 10 changed files with 80 additions and 44 deletions.
24 changes: 0 additions & 24 deletions lib/console_yasttest.pm
Original file line number Diff line number Diff line change
Expand Up @@ -5,30 +5,6 @@ use base 'y2logsstep';
use strict;
use testapi;

sub change_service_configuration {
my ($self, %args) = @_;
my $after_writing_ref = $args{after_writing};
my $after_reboot_ref = $args{after_reboot};

assert_screen 'yast2_ncurses_service_start_widget';
change_service_configuration_step('after_writing_conf', $after_writing_ref) if $after_writing_ref;
change_service_configuration_step('after_reboot', $after_reboot_ref) if $after_reboot_ref;
}

sub change_service_configuration_step {
my ($step_name, $step_conf_ref) = @_;
my ($action) = keys %$step_conf_ref;
my ($shortcut) = values %$step_conf_ref;
my $needle_selection = 'yast2_ncurses_service_' . $action . '_' . $step_name;
my $needle_check = 'yast2_ncurses_service_check_' . $action . '_' . $step_name;

send_key $shortcut;
send_key 'end';
send_key_until_needlematch $needle_selection, 'up', 5, 1;
send_key 'ret';
assert_screen $needle_check;
}

sub post_fail_hook {
my $self = shift;

Expand Down
55 changes: 55 additions & 0 deletions lib/yast2_widget_utils.pm
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# SUSE's openQA tests
#
# Copyright © 2018 SUSE LLC
#
# Copying and distribution of this file, with or without modification,
# are permitted in any medium without royalty provided the copyright
# notice and this notice are preserved. This file is offered as-is,
# without any warranty.

# Summary: This module provides helper functions for handling YaST widgets in text and graphical mode
# Maintainer: Joaquín Rivera <jeriveramoya@suse.de>

package yast2_widget_utils;

use base Exporter;
use Exporter;

use strict;
use testapi;

our @EXPORT = qw(change_service_configuration);

=head2 change_service_configuration
Modify service configuration: "after writing" and/or "after reboot" steps
=cut
sub change_service_configuration {
my (%args) = @_;
my $after_writing_ref = $args{after_writing};
my $after_reboot_ref = $args{after_reboot};

assert_screen 'yast2_ncurses_service_start_widget';
change_service_configuration_step('after_writing_conf', $after_writing_ref) if $after_writing_ref;
change_service_configuration_step('after_reboot', $after_reboot_ref) if $after_reboot_ref;
}

=head2 change_service_configuration_step
Modify one service configuration step
=cut
sub change_service_configuration_step {
my ($step_name, $step_conf_ref) = @_;
my ($action) = keys %$step_conf_ref;
my ($shortcut) = values %$step_conf_ref;
my $needle_selection = 'yast2_ncurses_service_' . $action . '_' . $step_name;
my $needle_check = 'yast2_ncurses_service_check_' . $action . '_' . $step_name;

send_key $shortcut;
send_key 'end';
send_key_until_needlematch $needle_selection, 'up', 5, 1;
if (get_var('Y2UITEST_NCURSES')) {
send_key 'ret';
assert_screen $needle_check;
}
}

1;
10 changes: 6 additions & 4 deletions tests/console/yast2_dns_server.pm
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ use utils;
use version_utils qw(is_leap is_sle);
use y2_common 'continue_info_network_manager_default';
use constant RETRIES => 5;
use yast2_widget_utils 'change_service_configuration';

# Test "yast2 dhcp-server" functionality
# Ensure that all combinations of running/stopped and active/inactive
# can be set
Expand Down Expand Up @@ -99,7 +101,7 @@ sub run {
assert_screen 'yast2-dns-server-start-named-now';
}
else {
$self->change_service_configuration(
change_service_configuration(
after_writing => {start => 'alt-t'},
after_reboot => {start_on_boot => 'alt-a'}
);
Expand Down Expand Up @@ -128,7 +130,7 @@ sub run {
assert_screen 'yast2-service-stopped-enabled';
}
else {
$self->change_service_configuration(after_writing => {stop => 'alt-t'});
change_service_configuration(after_writing => {stop => 'alt-t'});
}
# Cancel yast2 to check the effect
# workaround for single send_key 'alt-c' because it doesn't work.
Expand All @@ -152,7 +154,7 @@ sub run {
wait_screen_change { send_key 'alt-t' };
}
else {
$self->change_service_configuration(after_reboot => {do_not_start => 'alt-a'});
change_service_configuration(after_reboot => {do_not_start => 'alt-a'});
}
send_key 'alt-o';
assert_screen 'root-console', 180;
Expand All @@ -171,7 +173,7 @@ sub run {
assert_screen 'yast2-service-stopped-disabled';
}
else {
$self->change_service_configuration(after_writing => {stop => 'alt-t'});
change_service_configuration(after_writing => {stop => 'alt-t'});
}
# Finish
send_key 'alt-o';
Expand Down
3 changes: 2 additions & 1 deletion tests/console/yast2_ftp.pm
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ use testapi;
use utils;
use version_utils;
use y2logsstep;
use yast2_widget_utils 'change_service_configuration';

sub vsftd_setup_checker {
my $config_ref = pop();
Expand Down Expand Up @@ -91,7 +92,7 @@ sub run {
assert_screen 'ftp_server_when_booting'; # check service start when booting
}
else {
$self->change_service_configuration(
change_service_configuration(
after_writing => {start => 'alt-t'},
after_reboot => {start_on_boot => 'alt-a'}
);
Expand Down
5 changes: 2 additions & 3 deletions tests/console/yast2_http.pm
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,9 @@ use testapi;
use utils 'zypper_call';
use version_utils qw(is_sle is_leap);
use y2_common 'continue_info_network_manager_default';
use yast2_widget_utils 'change_service_configuration';

sub run {
my $self = shift;

select_console 'root-console';
# install http server
zypper_call("-q in yast2-http-server");
Expand Down Expand Up @@ -111,7 +110,7 @@ sub run {
assert_screen 'http_start_apache2';
}
else {
$self->change_service_configuration(
change_service_configuration(
after_writing => {start => 'alt-t'},
after_reboot => {start_on_boot => 'alt-a'}
);
Expand Down
5 changes: 2 additions & 3 deletions tests/console/yast2_proxy.pm
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ use base "console_yasttest";
use testapi;
use utils;
use version_utils qw(is_sle is_leap);
use yast2_widget_utils 'change_service_configuration';

my %sub_menu_needles = (
start_up => 'yast2_proxy_start-up',
Expand Down Expand Up @@ -59,8 +60,6 @@ sub post_fail_hook {
}

sub run {
my $self = shift;

select_console 'root-console';
if (is_sle '15+') {
zypper_call('in squid');
Expand Down Expand Up @@ -89,7 +88,7 @@ sub run {
send_key_until_needlematch 'yast2_proxy_service_start', 'alt-b'; #Start service when booting
}
else {
$self->change_service_configuration(
change_service_configuration(
after_writing => {start => 'alt-f'},
after_reboot => {start_on_boot => 'alt-a'}
);
Expand Down
5 changes: 2 additions & 3 deletions tests/console/yast2_samba.pm
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ use testapi;
use utils;
use version_utils qw(is_sle is_leap is_tumbleweed);
use y2logsstep;
use yast2_widget_utils 'change_service_configuration';

my %ldap_directives = (
fqdn => 'openqa.ldaptest.org',
Expand Down Expand Up @@ -147,8 +148,6 @@ sub setup_ldap_in_samba {
}

sub setup_samba {
my $self = shift;

script_run("yast2 samba-server; echo yast2-samba-server-status-\$? > /dev/$serialdev", 0);

# samba-server configuration for SLE older than 15 or opensuse TW
Expand Down Expand Up @@ -182,7 +181,7 @@ sub setup_samba {
assert_screen 'yast2_samba-server_start-during-boot';
}
else {
$self->change_service_configuration(
change_service_configuration(
after_writing => {start => 'alt-e'},
after_reboot => {start_on_boot => 'alt-a'}
);
Expand Down
5 changes: 2 additions & 3 deletions tests/console/yast2_tftp.pm
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,9 @@ use base "console_yasttest";
use testapi;
use utils;
use version_utils qw(is_sle is_leap is_tumbleweed);
use yast2_widget_utils 'change_service_configuration';

sub run {
my $self = shift;

select_console 'root-console';
zypper_call("in tftp yast2-tftp-server", timeout => 240);
script_run("yast2 tftp-server; echo yast2-tftp-server-status-\$? > /dev/$serialdev", 0);
Expand All @@ -40,7 +39,7 @@ sub run {
$firewall_detail_shortcut = 'alt-i';
}
else {
$self->change_service_configuration(
change_service_configuration(
after_writing => {start => 'alt-t'},
after_reboot => {start_on_demand => 'alt-a'}
);
Expand Down
3 changes: 1 addition & 2 deletions tests/iscsi/iscsi_client.pm
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ use lockapi;
use utils 'turn_off_gnome_screensaver';

sub run {
my ($self) = @_;
x11_start_program('xterm -geometry 160x45+5+5', target_match => 'xterm');
turn_off_gnome_screensaver;
become_root;
Expand All @@ -35,7 +34,7 @@ sub run {
wait_still_screen(2, 10);
assert_screen 'iscsi-initiator-service';
send_key "alt-v"; # go to discovered targets tab
assert_screen 'iscsi-discovered-targets';
assert_screen 'iscsi-discovered-targets', 120;
send_key "alt-d"; # press discovery button
assert_screen 'iscsi-discovery';
send_key "alt-i"; # go to IP address field
Expand Down
9 changes: 8 additions & 1 deletion tests/iscsi/iscsi_server.pm
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,10 @@ use strict;
use testapi;
use mm_network;
use lockapi;
use version_utils 'is_sle';
use version_utils qw(is_sle is_leap);
use mmapi;
use utils qw(zypper_call turn_off_gnome_screensaver);
use yast2_widget_utils 'change_service_configuration';

sub run {
my $self = shift;
Expand All @@ -33,6 +34,12 @@ sub run {
assert_script_run 'dd if=/dev/zero of=/root/iscsi-disk seek=1M bs=8192 count=1'; # create iscsi LUN
type_string "yast2 iscsi-lio-server; echo yast2-iscsi-server-\$? > /dev/$serialdev\n";
assert_screen 'iscsi-lio-server';
unless (is_sle('<15') || is_leap('<15.1')) {
change_service_configuration(
after_writing => {start => 'alt-w'},
after_reboot => {start_on_boot => 'alt-a'}
);
}
send_key 'alt-o'; # open port in firewall
wait_still_screen(2, 10);
assert_screen 'iscsi-target-overview-service-tab';
Expand Down

0 comments on commit 2af518a

Please sign in to comment.