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

tests: Avoid importing unused modules #16227

Merged
merged 1 commit into from
Jun 18, 2024
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion tests/topotests/eigrp_topo1/test_eigrp_topo1.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,6 @@ def test_zebra_ipv4_routingTable():
if tgen.routers_have_failure():
pytest.skip(tgen.errors)

failures = 0
router_list = tgen.routers().values()
for router in router_list:
output = router.vtysh_cmd("show ip route json", isjson=True)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@

import os
import sys
import json
import time
import pytest
import platform
Expand Down Expand Up @@ -69,7 +68,7 @@
verify_attributes_for_evpn_routes,
verify_evpn_routes,
)
from lib.topojson import build_topo_from_json, build_config_from_json
from lib.topojson import build_config_from_json

pytestmark = [pytest.mark.bgpd, pytest.mark.staticd]

Expand Down
2 changes: 0 additions & 2 deletions tests/topotests/fpm_testing_topo1/test_fpm_topo1.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@

"""
import os
import re
import sys
import pytest
import json
Expand All @@ -28,7 +27,6 @@
# Import topogen and topotest helpers
from lib import topotest
from lib.topogen import Topogen, TopoRouter, get_topogen
from lib.topolog import logger


pytestmark = [pytest.mark.fpm, pytest.mark.sharpd]
Expand Down
3 changes: 1 addition & 2 deletions tests/topotests/grpc_basic/test_basic_grpc.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
from lib.common_config import step
from lib.micronet import commander
from lib.topogen import Topogen, TopoRouter
from lib.topolog import logger
from lib.topotest import json_cmp

CWD = os.path.dirname(os.path.realpath(__file__))
Expand Down Expand Up @@ -60,7 +59,7 @@ def tgen(request):
tgen.start_topology()
router_list = tgen.routers()

for rname, router in router_list.items():
for _, router in router_list.items():
router.load_config(TopoRouter.RD_ZEBRA, "zebra.conf", f"-M grpc:{GRPCP_ZEBRA}")
router.load_config(TopoRouter.RD_STATIC, "", f"-M grpc:{GRPCP_STATICD}")
# router.load_config(TopoRouter.RD_BFDD, "", f"-M grpc:{GRPCP_BFDD}")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,13 @@
import sys
import pytest
import json
from time import sleep
from functools import partial

# Save the Current Working Directory to find configuration files.
CWD = os.path.dirname(os.path.realpath(__file__))
sys.path.append(os.path.join(CWD, "../"))

# pylint: disable=C0413
# Import topogen and topotest helpers
from lib import topotest
from lib.common_config import (
retry,
stop_router,
Expand Down
7 changes: 3 additions & 4 deletions tests/topotests/isis_lfa_topo1/test_isis_lfa_topo1.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@
import sys
import pytest
import json
import time
import tempfile
from functools import partial

Expand Down Expand Up @@ -169,7 +168,7 @@ def setup_module(mod):
tgen.start_router()


def teardown_module(mod):
def teardown_module():
"Teardown the pytest environment"
tgen = get_topogen()

Expand Down Expand Up @@ -832,7 +831,7 @@ def _rt2_neigh_down(router):
rname = "rt1"
router = tgen.gears[rname]
test_func = partial(_rt2_neigh_down, router)
success, result = topotest.run_and_expect(test_func, None, count=200, wait=0.05)
_, result = topotest.run_and_expect(test_func, None, count=200, wait=0.05)
assert result is None, 'rt2 neighbor is still present on "{}"'.format(router)

router_compare_json_output(
Expand Down Expand Up @@ -1034,7 +1033,7 @@ def _bfd_down(router):
rname = "rt1"
router = tgen.gears[rname]
test_func = partial(_bfd_down, router)
success, result = topotest.run_and_expect(test_func, None, count=30, wait=0.3)
_, result = topotest.run_and_expect(test_func, None, count=30, wait=0.3)
assert result is None, 'BFD session is still up on "{}"'.format(router)

router_compare_json_output(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ def setup_module(mod):
tgen.start_router()


def teardown_module(mod):
def teardown_module():
"Teardown the pytest environment"
tgen = get_topogen()

Expand Down
2 changes: 1 addition & 1 deletion tests/topotests/isis_rlfa_topo1/test_isis_rlfa_topo1.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ def setup_module(mod):
tgen.start_router()


def teardown_module(mod):
def teardown_module():
"Teardown the pytest environment"
tgen = get_topogen()

Expand Down
2 changes: 1 addition & 1 deletion tests/topotests/isis_snmp/test_isis_snmp.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ def setup_module(mod):
tgen.start_router()


def teardown_module(mod):
def teardown_module():
"Teardown the pytest environment"
tgen = get_topogen()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
import sys
import pytest
import json
import tempfile
from copy import deepcopy
from functools import partial

Expand Down Expand Up @@ -121,7 +120,7 @@ def setup_module(mod):
tgen.start_router()


def teardown_module(mod):
def teardown_module():
"Teardown the pytest environment"
tgen = get_topogen()
tgen.stop_topology()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@
import sys
import pytest
import json
import time
from functools import partial

# Save the Current Working Directory to find configuration files.
Expand All @@ -67,7 +66,6 @@
def build_topo(tgen):
"Build function"

routers = []
for i in range(0, 10):
rt = tgen.add_router("rt{}".format(i))
rt.run("sysctl -w net.ipv4.fib_multipath_hash_policy=1")
Expand Down Expand Up @@ -140,7 +138,7 @@ def setup_module(mod):
tgen.start_router()


def teardown_module(mod):
def teardown_module():
"Teardown the pytest environment"
tgen = get_topogen()
tgen.stop_topology()
Expand Down Expand Up @@ -174,7 +172,7 @@ def _check(name, cmd, expected_file):
logger.info('[+] check {} "{}" {}'.format(name, cmd, expected_file))
tgen = get_topogen()
func = partial(_check, name, cmd, expected_file)
success, result = topotest.run_and_expect(func, None, count=120, wait=0.5)
_, result = topotest.run_and_expect(func, None, count=120, wait=0.5)
assert result is None, "Failed"


Expand Down
4 changes: 2 additions & 2 deletions tests/topotests/isis_sr_te_topo1/test_isis_sr_te_topo1.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ def setup_module(mod):
tgen.start_router()


def teardown_module(mod):
def teardown_module():
"Teardown the pytest environment"
tgen = get_topogen()

Expand Down Expand Up @@ -641,7 +641,7 @@ def test_srte_route_map_with_sr_policy_check_nextop_step5():
)

# (re-)build the SR Policy two times to ensure that reinstalling still works
for i in [1, 2]:
for _ in [1, 2]:
cmp_json_output(
"rt1", "show ip route bgp json", "step5/show_ip_route_bgp_inactive_srte.ref"
)
Expand Down
2 changes: 1 addition & 1 deletion tests/topotests/isis_sr_topo1/test_isis_sr_topo1.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ def setup_module(mod):
tgen.start_router()


def teardown_module(mod):
def teardown_module():
"Teardown the pytest environment"
tgen = get_topogen()

Expand Down
5 changes: 2 additions & 3 deletions tests/topotests/isis_srv6_topo1/test_isis_srv6_topo1.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@
"""

import os
import re
import sys
import json
import functools
Expand Down Expand Up @@ -212,7 +211,7 @@ def setup_module(mod):
tgen.start_router()


def teardown_module(mod):
def teardown_module():
"Teardown the pytest environment"

# Teardown the topology
Expand Down Expand Up @@ -250,7 +249,7 @@ def _check(name, dest_addr, match):
logger.info("[+] check {} {} {}".format(name, dest_addr, match))
tgen = get_topogen()
func = functools.partial(_check, name, dest_addr, match)
success, result = topotest.run_and_expect(func, None, count=10, wait=1)
_, result = topotest.run_and_expect(func, None, count=10, wait=1)
assert result is None, "Failed"


Expand Down
3 changes: 1 addition & 2 deletions tests/topotests/isis_tilfa_topo1/test_isis_tilfa_topo1.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@
import sys
import pytest
import json
import tempfile
from functools import partial
from time import sleep

Expand Down Expand Up @@ -144,7 +143,7 @@ def setup_module(mod):
tgen.start_router()


def teardown_module(mod):
def teardown_module():
"Teardown the pytest environment"
tgen = get_topogen()

Expand Down
16 changes: 8 additions & 8 deletions tests/topotests/isis_topo1/test_isis_topo1.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ def setup_module(mod):
tgen.start_router()


def teardown_module(mod):
def teardown_module():
"Teardown the pytest environment"
tgen = get_topogen()

Expand Down Expand Up @@ -160,7 +160,7 @@ def compare_isis_installed_routes(router, expected):
return topotest.json_cmp(actual, expected)

test_func = functools.partial(compare_isis_installed_routes, router, expected)
(result, diff) = topotest.run_and_expect(test_func, None, wait=1, count=10)
(result, _) = topotest.run_and_expect(test_func, None, wait=1, count=10)
assertmsg = "Router '{}' routes mismatch".format(rname)
assert result, assertmsg

Expand Down Expand Up @@ -205,7 +205,7 @@ def compare_isis_v6_installed_routes(router, expected):
test_func = functools.partial(
compare_isis_v6_installed_routes, router, expected
)
(result, diff) = topotest.run_and_expect(test_func, None, wait=1, count=10)
(result, _) = topotest.run_and_expect(test_func, None, wait=1, count=10)
assertmsg = "Router '{}' routes mismatch".format(rname)
assert result, assertmsg

Expand Down Expand Up @@ -237,7 +237,7 @@ def test_isis_summary_json():
pytest.skip(tgen.errors)

logger.info("Checking 'show isis summary json'")
for rname, router in tgen.routers().items():
for rname, _ in tgen.routers().items():
logger.info("Checking router %s", rname)
json_output = tgen.gears[rname].vtysh_cmd("show isis summary json", isjson=True)
assertmsg = "Test isis summary json failed in '{}' data '{}'".format(
Expand All @@ -257,7 +257,7 @@ def test_isis_interface_json():
pytest.skip(tgen.errors)

logger.info("Checking 'show isis interface json'")
for rname, router in tgen.routers().items():
for rname, _ in tgen.routers().items():
logger.info("Checking router %s", rname)
json_output = tgen.gears[rname].vtysh_cmd(
"show isis interface json", isjson=True
Expand Down Expand Up @@ -294,7 +294,7 @@ def test_isis_neighbor_json():

# tgen.mininet_cli()
logger.info("Checking 'show isis neighbor json'")
for rname, router in tgen.routers().items():
for rname, _ in tgen.routers().items():
logger.info("Checking router %s", rname)
json_output = tgen.gears[rname].vtysh_cmd(
"show isis neighbor json", isjson=True
Expand Down Expand Up @@ -330,7 +330,7 @@ def test_isis_database_json():

# tgen.mininet_cli()
logger.info("Checking 'show isis database json'")
for rname, router in tgen.routers().items():
for rname, _ in tgen.routers().items():
logger.info("Checking router %s", rname)
json_output = tgen.gears[rname].vtysh_cmd(
"show isis database json", isjson=True
Expand Down Expand Up @@ -755,7 +755,7 @@ def dict_merge(dct, merge_dct):
Source:
https://gist.github.com/angstwad/bf22d1822c38a92ec0a9
"""
for k, v in merge_dct.items():
for k, _ in merge_dct.items():
if k in dct and isinstance(dct[k], dict) and topotest.is_mapping(merge_dct[k]):
dict_merge(dct[k], merge_dct[k])
else:
Expand Down
4 changes: 2 additions & 2 deletions tests/topotests/isis_topo1_vrf/test_isis_topo1_vrf.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ def setup_module(mod):
tgen.start_router()


def teardown_module(mod):
def teardown_module():
"Teardown the pytest environment"
tgen = get_topogen()
# move back rx-eth0 to default VRF
Expand Down Expand Up @@ -287,7 +287,7 @@ def dict_merge(dct, merge_dct):
Source:
https://gist.github.com/angstwad/bf22d1822c38a92ec0a9
"""
for k, v in merge_dct.items():
for k, _ in merge_dct.items():
if k in dct and isinstance(dct[k], dict) and topotest.is_mapping(merge_dct[k]):
dict_merge(dct[k], merge_dct[k])
else:
Expand Down
2 changes: 1 addition & 1 deletion tests/topotests/key_sendaccept/test_keychain.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def tgen(request):
tgen.start_topology()

router_list = tgen.routers()
for rname, router in router_list.items():
for _, router in router_list.items():
router.load_frr_config("frr.conf")

tgen.start_router()
Expand Down
2 changes: 1 addition & 1 deletion tests/topotests/ldp_oc_acl_topo1/test_ldp_oc_acl_topo1.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ def setup_module(mod):
tgen.start_router()


def teardown_module(mod):
def teardown_module():
"Teardown the pytest environment"
tgen = get_topogen()

Expand Down
2 changes: 1 addition & 1 deletion tests/topotests/ldp_oc_topo1/test_ldp_oc_topo1.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ def setup_module(mod):
tgen.start_router()


def teardown_module(mod):
def teardown_module():
"Teardown the pytest environment"
tgen = get_topogen()

Expand Down
2 changes: 1 addition & 1 deletion tests/topotests/ldp_snmp/test_ldp_snmp_topo1.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ def setup_module(mod):
tgen.start_router()


def teardown_module(mod):
def teardown_module():
"Teardown the pytest environment"
tgen = get_topogen()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ def setup_module(mod):
tgen.start_router()


def teardown_module(mod):
def teardown_module():
"Teardown the pytest environment"
tgen = get_topogen()

Expand Down
Loading
Loading