Skip to content

Commit

Permalink
Add dynamic routing test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
asmorodskyi committed Feb 15, 2018
1 parent c4ef240 commit a061b5f
Show file tree
Hide file tree
Showing 12 changed files with 97 additions and 51 deletions.
16 changes: 16 additions & 0 deletions data/wicked/dhcpd-route.conf
@@ -0,0 +1,16 @@
# Reference DHCP server
# Version with one route set
default-lease-time 14400;
ddns-update-style none;

subnet 10.20.30.0 netmask 255.255.255.0
{
range 10.20.30.2 10.20.30.254;
default-lease-time 14400;
max-lease-time 172800;
option domain-name "test";
option domain-name-servers 10.0.2.1, 10.0.2.1;
option routers 10.0.2.2;
filename "/boot/pxelinux.0";
next-server 10.0.2.1;
}
13 changes: 13 additions & 0 deletions lib/main_common.pm
@@ -1,3 +1,15 @@
# 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: Attempt to merge common parts of sle/main.pm and opensuse/main.pm
# Maintainer: Anton Smorodskyi<asmorodskyi@suse.com>

package main_common;
use base Exporter;
use File::Basename;
Expand Down Expand Up @@ -440,6 +452,7 @@ sub boot_hdd_image {
if (get_var('UEFI') && (get_var('BOOTFROM') || get_var('BOOT_HDD_IMAGE'))) {
loadtest "boot/uefi_bootmenu";
}
loadtest "support_server/wait_support_server" if get_var('USE_SUPPORT_SERVER');
loadtest "boot/boot_to_desktop";
}

Expand Down
8 changes: 5 additions & 3 deletions lib/wickedbase.pm
@@ -1,6 +1,6 @@
# SUSE's openQA tests
#
# Copyright © 2017 SUSE LLC
# Copyright © 2017-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 @@ -12,9 +12,9 @@

package wickedbase;

use base 'consoletest';
use base 'opensusebasetest';
use utils 'systemctl';
use testapi qw(assert_script_run upload_logs type_string data_url check_var);
use testapi;

sub assert_wicked_state {
my ($self, %args) = @_;
Expand All @@ -23,6 +23,8 @@ sub assert_wicked_state {
my $status = $args{interfaces_down} ? 'down' : 'up';
assert_script_run("for dev in /sys/class/net/!(lo); do grep \"$status\" \$dev/operstate || (echo \"device \$dev is not $status\" && exit 1) ; done");
assert_script_run("ping -c 4 $args{ping_ip}") if $args{ping_ip};
# this just FYI so we don't want to fail
script_run('ip addr show ' . $args{iface}) if $args{iface};
}

sub get_ip {
Expand Down
2 changes: 1 addition & 1 deletion products/opensuse/main.pm
Expand Up @@ -836,7 +836,7 @@ elsif (get_var("SUPPORT_SERVER")) {
loadtest "support_server/login";
loadtest "support_server/setup";
unless (load_slenkins_tests()) { # either run the slenkins control node or just wait for connections
loadtest "support_server/wait";
loadtest "support_server/wait_children";
}
}
elsif (get_var("WINDOWS")) {
Expand Down
4 changes: 2 additions & 2 deletions products/sle/main.pm
Expand Up @@ -1035,7 +1035,7 @@ sub load_ha_cluster_tests {
loadtest "boot/boot_to_desktop";

# Wait for support server to complete its initialization
loadtest "ha/wait_support_server";
loadtest "support_server/wait_support_server";

# Standard boot and configuration
loadtest "qa_automation/patch_and_reboot" if is_updates_tests;
Expand Down Expand Up @@ -1285,7 +1285,7 @@ elsif (get_var("SUPPORT_SERVER")) {
}
loadtest "ha/barrier_init" if get_var("HA_CLUSTER_SUPPORT_SERVER");
unless (load_slenkins_tests() || get_var("REMOTE_CONTROLLER")) {
loadtest "support_server/wait";
loadtest "support_server/wait_children";
}
}
elsif (get_var("SLEPOS")) {
Expand Down
22 changes: 16 additions & 6 deletions tests/support_server/setup.pm
Expand Up @@ -131,12 +131,8 @@ sub setup_dns_server {
$dns_server_set = 1;
}

sub setup_dhcp_server {
my ($dns, $pxe) = @_;
return if $dhcp_server_set;
my $net_conf = parse_network_configuration();

$setup_script .= "systemctl stop dhcpd\n";
sub dhcpd_conf_genration {
my ($dns, $pxe, $net_conf) = @_;
$setup_script .= "cat >/etc/dhcpd.conf <<EOT\n";
$setup_script .= "default-lease-time 14400;\n";
if ($dns) {
Expand Down Expand Up @@ -184,6 +180,20 @@ sub setup_dhcp_server {
$setup_script .= "}\n";
}
$setup_script .= "EOT\n";
}

sub setup_dhcp_server {
my ($dns, $pxe) = @_;
return if $dhcp_server_set;
my $net_conf = parse_network_configuration();

$setup_script .= "systemctl stop dhcpd\n";
if (get_var('SUPPORT_SERVER_DHPCD_CONFIG')) {
$setup_script .= "curl -f -v " . autoinst_url . "/data" . get_var('SUPPORT_SERVER_DHPCD_CONFIG') . " >/etc/dhcpd.conf \n";
}
else {
dhcpd_conf_genration($dns, $pxe, $net_conf);
}

$setup_script .= "curl -f -v " . autoinst_url . "/data/supportserver/dhcp/sysconfig/dhcpd >/etc/sysconfig/dhcpd \n";
$setup_script .= "NIC_LIST=\"";
Expand Down
@@ -1,4 +1,4 @@
# Copyright (C) 2015 SUSE Linux GmbH
# Copyright (C) 2015-2018 SUSE Linux GmbH
#
# 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 @@ -13,7 +13,8 @@
# 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: supportserver and supportserver generator implementation
# Summary: Main purpose not allow support server to go down
# until all parallel jobs finish what they are doing
# Maintainer: Pavel Sladek <psladek@suse.com>

use strict;
Expand Down
Expand Up @@ -7,8 +7,8 @@
# notice and this notice are preserved. This file is offered as-is,
# without any warranty.

# Summary: Start HA support server and check network connectivity
# Maintainer: Loic Devulder <ldevulder@suse.com>
# Summary: Wait for support server to start
# Maintainer: Loic Devulder <ldevulder@suse.com> , Anton Smorodskyi <asmorodskyi@suse.com>

use base 'opensusebasetest';
use strict;
Expand All @@ -24,7 +24,7 @@ sub run {
mutex_unlock('support_server_ready');

# Now we can wait for barrier to synchronise nodes
barrier_wait('BARRIER_HA_' . get_var('CLUSTER_NAME'));
barrier_wait('BARRIER_HA_' . get_var('CLUSTER_NAME')) if get_var("HA_CLUSTER");
}

1;
Expand Down
30 changes: 17 additions & 13 deletions tests/wicked/basic.pm
@@ -1,6 +1,6 @@
# SUSE's openQA tests
#
# Copyright © 2017 SUSE LLC
# Copyright © 2017-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 @@ -25,36 +25,40 @@ use utils qw(systemctl arrays_differ);

sub run {
my ($self) = @_;
my $iface = script_output('echo $(ls /sys/class/net/ | grep -v lo | head -1)');
type_string("#***Test 1: Bring down the wicked client service***\n");
my $iface = script_output('ls /sys/class/net/ | grep -v lo | head -1');
record_info('Test 1', 'Bring down the wicked client service');
systemctl('stop wicked.service');
$self->assert_wicked_state(wicked_client_down => 1, interfaces_down => 1);
type_string("#***Test 2: Bring up the wicked client service***\n");
record_info('Test 2', 'Bring up the wicked client service');
systemctl('start wicked.service');
$self->assert_wicked_state();
type_string("#***Test 3: Bring down the wicked server service***\n");
record_info('Test 3', 'Bring down the wicked server service');
systemctl('stop wickedd.service');
$self->assert_wicked_state(wicked_daemon_down => 1);
assert_script_run("! ifdown $iface");
type_string("#***Test 4: Bring up the wicked server service***\n");
record_info('Test 4', 'Bring up the wicked server service');
systemctl('start wickedd.service');
$self->assert_wicked_state();
assert_script_run("ifup $iface");
type_string("#***Test 5: List the network interfaces with wicked***\n");
my @wicked_all_ifaces = split("\n", script_output("wicked show --brief all"));
record_info('Test 5', 'List the network interfaces with wicked');
my @wicked_all_ifaces = split("\n", script_output('wicked show --brief all'));
foreach (@wicked_all_ifaces) {
$_ = substr($_, 0, index($_, ' '));
}
my @ls_all_ifaces = split(' ', script_output("ls /sys/class/net/"));
die "Wrong list of interfaces from wicked" if arrays_differ(\@wicked_all_ifaces, \@ls_all_ifaces);
type_string("#***Test 6: Bring an interface down with wicked***\n");
my @ls_all_ifaces = split(' ', script_output('ls /sys/class/net/'));
if (arrays_differ(\@wicked_all_ifaces, \@ls_all_ifaces)) {
diag "expected list of interfaces: @wicked_all_ifaces";
diag "actual list of interfaces: @ls_all_ifaces";
die "Wrong list of interfaces from wicked";
}
record_info('Test 6', 'Bring an interface down with wicked');
assert_script_run("ifdown $iface");
assert_script_run("ping -q -c1 -W1 -I $iface 10.0.2.2 2>&1 | grep -q ' Network is unreachable'");
assert_script_run("! \$(ip address show dev $iface | grep -q 'inet')");
type_string("#***Test 7: Bring an interface up with wicked***\n");
record_info('Test 7', 'Bring an interface up with wicked');
assert_script_run("ifup $iface");
assert_script_run("ping -q -c1 -W1 -I $iface 10.0.2.2");
assert_script_run("ip address show dev $iface | grep -q 'inet'");
validate_script_output("ip address show dev $iface", sub { m/(?=inet)(?=[dhcp])/g; });
$self->save_and_upload_wicked_log();
}

Expand Down
5 changes: 2 additions & 3 deletions tests/wicked/before_test.pm
Expand Up @@ -22,12 +22,11 @@ sub run {
my $enable_command_logging = 'export PROMPT_COMMAND=\'logger -t openQA_CMD "$(history 1 | sed "s/^[ ]*[0-9]\+[ ]*//")"\'';
assert_script_run("echo \"$enable_command_logging\" >> /root/.bashrc");
assert_script_run($enable_command_logging);
type_string("#Preparation for wicked test\n");
type_string("#* Checking that network is up\n");
record_info('INFO', 'Checking that network is up');
systemctl('is-active network');
systemctl('is-active wicked');
assert_script_run('[ -z "$(coredumpctl -1 --no-pager --no-legend)" ]');
type_string("#* Setting debug level for wicked logs\n");
record_info('INFO', 'Setting debug level for wicked logs');
assert_script_run('sed -e "s/^WICKED_DEBUG=.*/WICKED_DEBUG=\"all\"/g" -i /etc/sysconfig/network/config');
assert_script_run('sed -e "s/^WICKED_LOG_LEVEL=.*/WICKED_LOG_LEVEL=\"debug\"/g" -i /etc/sysconfig/network/config');
assert_script_run('cat /etc/sysconfig/network/config');
Expand Down
33 changes: 17 additions & 16 deletions tests/wicked/config_files.pm
Expand Up @@ -24,17 +24,17 @@ use testapi;
our $iface = '';

sub before_scenario {
my ($testname) = @_;
my ($title, $text) = @_;
assert_script_run("ifdown $iface");
assert_script_run("ifbind.sh unbind $iface");
type_string("rm /etc/sysconfig/network/ifcfg-$iface\n");
script_run("rm /etc/sysconfig/network/ifcfg-$iface");
assert_script_run("ifbind.sh bind $iface");
type_string("#***$testname***\n");
record_info($title, $text);
}

sub run {
my ($self) = @_;
$iface = script_output('echo $(ls /sys/class/net/ | grep -v lo | head -1)');
$iface = script_output('ls /sys/class/net/ | grep -v lo | head -1');
$self->get_from_data('wicked/static_address/ifcfg-eth0', "/data/static_address/ifcfg-$iface");
$self->get_from_data('wicked/static_address/static-addresses.xml', "/data/static_address/static-addresses.xml");
$self->get_from_data('wicked/static_address/ifroute-eth0', "/data/static_address/ifroute-$iface");
Expand All @@ -45,30 +45,31 @@ sub run {
assert_script_run("sed -i 's/xxx/$iface/g' /data/static_address/static-addresses.xml");
assert_script_run("sed -i 's/xxx/$iface/g' /data/static_address/static-addresses-and-routes.xml");
assert_script_run("sed -i 's/xxx/$iface/g' /data/dynamic_address/dynamic-addresses.xml");
before_scenario('Test 1: Set up static addresses from legacy ifcfg files');
before_scenario('Test 1', 'Set up static addresses from legacy ifcfg files');
assert_script_run("cp /data/static_address/ifcfg-$iface /etc/sysconfig/network");
assert_script_run("ifup $iface");
$self->assert_wicked_state(ping_ip => '10.0.2.2');
before_scenario('Test 2: Set up static addresses from wicked XML files');
$self->assert_wicked_state(ping_ip => '10.0.2.2', iface => $iface);
before_scenario('Test 2', 'Set up static addresses from wicked XML files');
assert_script_run("wicked ifup --ifconfig /data/static_address/static-addresses.xml $iface");
$self->assert_wicked_state(ping_ip => '10.0.2.2');
before_scenario('Test 3: Set up dynamic addresses from legacy ifcfg files');
$self->assert_wicked_state(ping_ip => '10.0.2.2', iface => $iface);
before_scenario('Test 3', 'Set up dynamic addresses from legacy ifcfg files');
assert_script_run("cp /data/dynamic_address/ifcfg-$iface /etc/sysconfig/network");
assert_script_run("ifup $iface");
$self->assert_wicked_state(ping_ip => '10.0.2.2');
before_scenario('Test 4: Set up dynamic addresses from wicked XML files');
$self->assert_wicked_state(ping_ip => '10.0.2.2', iface => $iface);
before_scenario('Test 4', 'Set up dynamic addresses from wicked XML files');
assert_script_run("wicked ifup --ifconfig /data/static_address/static-addresses.xml $iface");
$self->assert_wicked_state(ping_ip => '10.0.2.2');
before_scenario('Test 5: Set up static routes from legacy ifcfg files');
$self->assert_wicked_state(ping_ip => '10.0.2.2', iface => $iface);
before_scenario('Test 5', 'Set up static routes from legacy ifcfg files');
assert_script_run("cp /data/static_address/ifcfg-$iface /etc/sysconfig/network");
assert_script_run("cp /data/static_address/ifroute-$iface /etc/sysconfig/network");
assert_script_run("ifup $iface");
$self->assert_wicked_state(ping_ip => '10.0.2.2');
$self->assert_wicked_state(ping_ip => '10.0.2.2', iface => $iface);
validate_script_output("ip -4 route show", sub { m/default via 10.0.2.2/ });
assert_script_run('ip -4 route show | grep "default" | grep -v "via' . $iface . '"');
validate_script_output("ip -6 route show", sub { m/default via fd00:cafe:babe::1/ });
before_scenario('Test 6: Set up static routes from wicked XML files');
before_scenario('Test 6', 'Set up static routes from wicked XML files');
assert_script_run("wicked ifup --ifconfig /data/static_address/static-addresses-and-routes.xml $iface");
$self->assert_wicked_state(ping_ip => '10.0.2.2');
$self->assert_wicked_state(ping_ip => '10.0.2.2', iface => $iface);
$self->save_and_upload_wicked_log();
}

Expand Down
4 changes: 2 additions & 2 deletions tests/wicked/risky.pm
@@ -1,6 +1,6 @@
# SUSE's openQA tests
#
# Copyright © 2017 SUSE LLC
# Copyright © 2017-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,7 +21,7 @@ use utils 'systemctl';

sub run {
my ($self) = @_;
type_string("#***Test 1: Create a gre interface from legacy ifcfg files***\n");
record_info('Test 1', 'Create a gre interface from legacy ifcfg files');
$self->setup_static_network($self->get_ip());
my $network_config = '/etc/sysconfig/network/ifcfg-gre1';
$self->get_from_data('wicked/ifcfg-gre1_', $network_config, add_suffix => 1);
Expand Down

0 comments on commit a061b5f

Please sign in to comment.