Skip to content

Commit

Permalink
[tests] Fix LGTM errors in tests folder (#1545)
Browse files Browse the repository at this point in the history
Signed-off-by: Danny Allen <daall@microsoft.com>
  • Loading branch information
daall authored Apr 6, 2020
1 parent 5796f2e commit af6a644
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 21 deletions.
4 changes: 2 additions & 2 deletions tests/common/fixtures/advanced_reboot.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ def __validateAndBuildSadList(self):
if 'vlan_port_down' in item:
assert itemCnt <= self.vlanMaxCnt, (
'Vlan count is greater than or equal to number of Vlan interfaces. '
'Current val = {0} Max val = {}'
'Current val = {0} Max val = {1}'
).format(itemCnt, self.vlanMaxCnt)
if 'routing' in item:
assert itemCnt <= self.hostMaxCnt, (
Expand Down Expand Up @@ -216,7 +216,7 @@ def __prepareTestbedSshKeys(self, dutUsername, dutIp):
logger.info('Remove old keys from ptfhost')
self.ptfhost.shell('rm -f /root/.ssh/id_rsa*')
try:
result = self.ptfhost.shell('stat /root/.ssh/known_hosts')
self.ptfhost.shell('stat /root/.ssh/known_hosts')
except RunAnsibleModuleFail:
pass # files does not exist
else:
Expand Down
23 changes: 4 additions & 19 deletions tests/test_everflow_testbed.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import os
import time
from ansible_host import AnsibleHost
import pytest
from ptf_runner import ptf_runner
from abc import ABCMeta, abstractmethod
from abc import abstractmethod
import ipaddr as ipaddress

BASE_DIR = os.path.dirname(os.path.realpath(__file__))
Expand Down Expand Up @@ -168,21 +167,17 @@ def add_route(duthost, prefix, nexthop):
duthost: fixture that have duthost information
prefix: Ip prefix
nexthop: nexthop
return:pass
"""
duthost.shell("vtysh -c 'configure terminal' -c 'ip route {} {}'".format(prefix, nexthop))
pass

def remove_route(duthost, prefix, nexthop):
"""
utility to remove route
duthost: fixture that have duthost information
prefix: Ip prefix
nexthop: nexthop
return:pass
"""
duthost.shell("vtysh -c 'configure terminal' -c 'no ip route {} {}'".format(prefix, nexthop))
pass

def get_neighbor_info(duthost, dest_port, resolved = True):

Expand Down Expand Up @@ -242,7 +237,7 @@ def setup_mirror_session(self, duthost):


@abstractmethod
def setup_acl_table():
def setup_acl_table(self, duthost, setup_info, setup_mirror_session):
"""
setup the acl table
return:pass
Expand All @@ -251,7 +246,7 @@ def setup_acl_table():


@abstractmethod
def mirror_type():
def mirror_type(self):
"""
used to parametrized test cases on mirror type
:param request: pytest request object
Expand All @@ -260,7 +255,7 @@ def mirror_type():
pass

@abstractmethod
def acl_stage():
def acl_stage(self):
"""
get the acl stage
return:pass
Expand All @@ -271,7 +266,6 @@ def acl_stage():
def test_everflow_case1(self, duthost, setup_info, setup_mirror_session, dest_port_type, partial_ptf_runner):
""" Test on Resolved route, unresolved route, best prefix match route creation and removal flows """

rx_port = setup_info[dest_port_type]['src_port']
rx_port_ptf_id = setup_info[dest_port_type] ['src_port_ptf_id']
tx_port = setup_info[dest_port_type]['dest_port'][0]
tx_port_ptf_id = setup_info[dest_port_type]['dest_port_ptf_id'][0]
Expand Down Expand Up @@ -325,7 +319,6 @@ def test_everflow_case2(self, duthost, setup_info, setup_mirror_session, dest_po
"""Test case 2 - Change neighbor MAC address.
Verify that session destination MAC address is changed after neighbor MAC address update."""

rx_port = setup_info[dest_port_type]['src_port']
rx_port_ptf_id = setup_info[dest_port_type] ['src_port_ptf_id']
tx_port = setup_info[dest_port_type]['dest_port'][0]
tx_port_ptf_id = setup_info[dest_port_type]['dest_port_ptf_id'][0]
Expand Down Expand Up @@ -365,10 +358,8 @@ def test_everflow_case3(self, duthost, setup_info, setup_mirror_session, dest_po
"""Test case 3 - ECMP route change (remove next hop not used by session).
Verify that after removal of next hop that was used by session from ECMP route session state is active."""

rx_port = setup_info[dest_port_type]['src_port']
rx_port_ptf_id = setup_info[dest_port_type] ['src_port_ptf_id']
tx_port = setup_info[dest_port_type]['dest_port'][0]
tx_port_ptf_id = setup_info[dest_port_type]['dest_port_ptf_id'][0]
peer_ip, peer_mac = get_neighbor_info(duthost, tx_port)
peer_ip0 = peer_ip

Expand Down Expand Up @@ -419,7 +410,6 @@ def test_everflow_case4(self, duthost, setup_info, setup_mirror_session, dest_po
"""Test case 4 - ECMP route change (remove next hop used by session).
Verify that removal of next hop that is not used by session doesn't cause DST port and MAC change."""

rx_port = setup_info[dest_port_type]['src_port']
rx_port_ptf_id = setup_info[dest_port_type] ['src_port_ptf_id']
tx_port = setup_info[dest_port_type]['dest_port'][0]
tx_port_ptf_id = setup_info[dest_port_type]['dest_port_ptf_id'][0]
Expand All @@ -435,19 +425,16 @@ def test_everflow_case4(self, duthost, setup_info, setup_mirror_session, dest_po
dst_ports = tx_port_ptf_id)

tx_port = setup_info[dest_port_type]['dest_port'][1]
tx_port_ptf_id = setup_info[dest_port_type]['dest_port_ptf_id'][1]
peer_ip, peer_mac = get_neighbor_info(duthost, tx_port)
peer_ip1 = peer_ip

add_route(duthost, setup_mirror_session['session_prefixes'][0], peer_ip)

tx_port = setup_info[dest_port_type]['dest_port'][2]
tx_port_ptf_id = setup_info[dest_port_type]['dest_port_ptf_id'][2]
peer_ip, peer_mac = get_neighbor_info(duthost, tx_port)
peer_ip2 = peer_ip

add_route(duthost, setup_mirror_session['session_prefixes'][0], peer_ip)


time.sleep(3)

Expand Down Expand Up @@ -479,7 +466,6 @@ def test_everflow_case5(self, duthost, setup_info, setup_mirror_session, dest_po

"""Test case 5 - Policer enforced DSCP value/mask test"""

rx_port = setup_info[dest_port_type]['src_port']
rx_port_ptf_id = setup_info[dest_port_type] ['src_port_ptf_id']
tx_port = setup_info[dest_port_type]['dest_port'][0]
tx_port_ptf_id = setup_info[dest_port_type]['dest_port_ptf_id'][0]
Expand Down Expand Up @@ -523,7 +509,6 @@ def test_everflow_case6(self, duthost, setup_info, setup_mirror_session, dest_po

""" Test Case 6 - ARP/ND packet mirroring"""

rx_port = setup_info[dest_port_type]['src_port']
rx_port_ptf_id = setup_info[dest_port_type] ['src_port_ptf_id']
tx_port = setup_info[dest_port_type]['dest_port'][0]
tx_port_ptf_id = setup_info[dest_port_type]['dest_port_ptf_id'][0]
Expand Down

0 comments on commit af6a644

Please sign in to comment.