Add networking test cases

1. 251-Verify-Ethernet-OAM-Inteface-Is-Updated.robot

Signed-off-by: Weiyuan.Wang-Neu <wangweiyuan@neusoft.com>
Change-Id: I6c0bda4eb2e68aad729b08b37bff15ff235a8ba1
This commit is contained in:
Weiyuan.Wang-Neu 2021-06-17 16:51:08 +08:00
parent ea82e44f14
commit 4cf043abaa
1 changed files with 88 additions and 0 deletions

View File

@ -0,0 +1,88 @@
import time
from pytest import mark
from consts.auth import HostLinuxUser
from consts.stx import Prompt
from keywords import network_helper, system_helper, host_helper
from utils import cli
from utils.clients import ssh
from utils.tis_log import LOG
@mark.sanity
def test_verify_ethernet_oam_inteface_is_updated(no_aio_system):
net_info0 = get_oam_if_port_address('controller-0')
net_info1 = get_oam_if_port_address('controller-1')
LOG.info('OAM interface for controller-0: {0[0]}, port: {0[1]}, ip: {0[2]}'.format(net_info0))
LOG.info('OAM interface for controller-1: {0[0]}, port: {0[1]}, ip: {0[2]}'.format(net_info1))
if system_helper.is_active_controller('controller-1'):
host_swact('controller-1', [net_info0, net_info1])
try:
old_mtu = host_helper.get_host_interface_values('controller-0', net_info0[0], 'imtu')
modify_mtu_and_check('9000', [net_info0, net_info1])
modify_mtu_and_check(old_mtu, [net_info0, net_info1])
finally:
if system_helper.is_active_controller('controller-1'):
host_swact('controller-1', [net_info0, net_info1])
def get_oam_if_port_address(host):
ports = host_helper.get_host_ports(host)
if_name_port = host_helper.get_hosts_interfaces_info(host, 'ports')[host]
oam_ips = system_helper.get_oam_values(fields=['oam_c0_ip', 'oam_c1_ip'], rtn_dict=False)
ssh = host_helper.ssh_to_host(host)
for port in ports:
cmd = "ifconfig {} | grep 'inet ' | ".format(port) + "awk '{print $2}'"
with ssh as ssh_host:
ip = ssh_host.exec_cmd(cmd)[1]
if ip in oam_ips:
for name_port in if_name_port:
if port in if_name_port[name_port][0]:
return name_port, port, ip
def modify_mtu_and_check(mtu, net_info):
if0, port0, ip0 = net_info[0]
if1, port1, ip1 = net_info[1]
host_helper.modify_host_interface('controller-1', if1, mtu=mtu)
mtu_check = host_helper.get_host_interface_values('controller-1', if1, 'imtu')[0]
assert mtu == mtu_check
cmd = "ifconfig {} | grep mtu | ".format(port1) + ("awk -F 'mtu ' '{print $2}'")
with host_helper.ssh_to_host('controller-1') as ssh_host:
mtu_check = ssh_host.exec_cmd(cmd)[1]
assert mtu == mtu_check
# host_helper.swact_host('controller-0')
host_swact('controller-0', net_info)
host_helper.modify_host_interface('controller-0', if0, mtu=mtu)
mtu_check = host_helper.get_host_interface_values('controller-0', if0, 'imtu')[0]
assert mtu == mtu_check
cmd = "ifconfig {} | grep mtu | ".format(port0) + "awk -F 'mtu ' '{print $2}'"
with host_helper.ssh_to_host('controller-0') as ssh_host:
mtu_check = ssh_host.exec_cmd(cmd)[1]
assert mtu == mtu_check
# host_helper.swact_host('controller-1')
host_swact('controller-1', net_info)
with host_helper.ssh_to_host('controller-1') as ssh_host:
network_helper.ping_server(ip0, ssh_host)
with host_helper.ssh_to_host('controller-0') as ssh_host:
network_helper.ping_server(ip1, ssh_host)
def host_swact(host, net_info):
if host == 'controller-0':
tar_ip = net_info[0][2]
else:
tar_ip = net_info[1][2]
node_ssh = ssh.SSHClient(tar_ip, HostLinuxUser.get_user(),
HostLinuxUser.get_password(),
Prompt.CONTROLLER_PROMPT)
exitcode, msg = cli.system('host-swact', host)
assert exitcode == 0, msg
time.sleep(120)
node_ssh.connect(retry=True, retry_timeout=30)
ssh.ControllerClient.set_active_controller(node_ssh)