Skip to content

Commit

Permalink
tests: Refactoring FRR test suites
Browse files Browse the repository at this point in the history
Signed-off-by: y-bharath14 <[email protected]>
  • Loading branch information
y-bharath14 committed Jul 10, 2024
1 parent ebf05b4 commit 895ae47
Show file tree
Hide file tree
Showing 101 changed files with 64 additions and 306 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@
required_linux_kernel_version,
)

from lib.topolog import logger
import json

fatal_error = ""
Expand Down Expand Up @@ -153,7 +152,6 @@ def test_error_messages_vtysh():
print("\n\n** Check for error messages on VTYSH")
print("******************************************\n")

failures = 0
for i in range(1, 2):
#
# First checking Standard Output
Expand Down
2 changes: 0 additions & 2 deletions tests/topotests/babel_topo1/test_babel_topo1.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
"""

import os
import re
import sys
import pytest
import json
Expand Down Expand Up @@ -130,7 +129,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:
assertmsg = "Zebra IPv4 Routing Table verification failed for router {}".format(
Expand Down
1 change: 0 additions & 1 deletion tests/topotests/bfd_ospf_topo1/test_bfd_ospf_topo1.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@
import sys
import pytest
import json
from time import sleep
from functools import partial

# Save the Current Working Directory to find configuration files.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
import os
import sys
import json
import functools
from functools import partial
import pytest

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

# pylint: disable=C0413
from lib import topotest
from lib.topogen import Topogen, TopoRouter, get_topogen
from lib.topogen import Topogen, get_topogen

pytestmark = [pytest.mark.bgpd]

Expand Down
1 change: 0 additions & 1 deletion tests/topotests/bgp_aigp/test_bgp_aigp.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
# pylint: disable=C0413
from lib import topotest
from lib.topogen import Topogen, TopoRouter, get_topogen
from lib.common_config import step

pytestmark = [pytest.mark.bgpd]

Expand Down
3 changes: 1 addition & 2 deletions tests/topotests/bgp_as_allow_in/test_bgp_as_allow_in.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
import os
import sys
import time
import json
import pytest

# Save the Current Working Directory to find configuration files.
Expand Down Expand Up @@ -59,7 +58,7 @@
create_router_bgp,
verify_bgp_rib,
)
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
13 changes: 3 additions & 10 deletions tests/topotests/bgp_auth/bgp_auth_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,16 +34,9 @@

import json
import os
import platform
import sys
from time import sleep

from lib import common_config, topotest
from lib.common_config import (
save_initial_config_on_routers,
reset_with_new_configs,
)
from lib.topogen import Topogen, TopoRouter, get_topogen

from lib import common_config
from lib.topogen import get_topogen

CWD = os.path.dirname(os.path.realpath(__file__))

Expand Down
4 changes: 1 addition & 3 deletions tests/topotests/bgp_auth/test_bgp_auth1.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,12 @@
"""
# pylint: disable=C0413

import json
import os
import platform
import sys
from time import sleep

import pytest
from lib import common_config, topotest
from lib import topotest
from lib.common_config import (
save_initial_config_on_routers,
reset_with_new_configs,
Expand Down
4 changes: 1 addition & 3 deletions tests/topotests/bgp_auth/test_bgp_auth2.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,12 @@
"""
# pylint: disable=C0413

import json
import os
import platform
import sys
from time import sleep

import pytest
from lib import common_config, topotest
from lib import topotest
from lib.common_config import (
save_initial_config_on_routers,
reset_with_new_configs,
Expand Down
4 changes: 1 addition & 3 deletions tests/topotests/bgp_auth/test_bgp_auth3.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,12 @@
"""
# pylint: disable=C0413

import json
import os
import platform
import sys
from time import sleep

import pytest
from lib import common_config, topotest
from lib import topotest
from lib.common_config import (
save_initial_config_on_routers,
reset_with_new_configs,
Expand Down
4 changes: 1 addition & 3 deletions tests/topotests/bgp_auth/test_bgp_auth4.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,12 @@
"""
# pylint: disable=C0413

import json
import os
import platform
import sys
from time import sleep

import pytest
from lib import common_config, topotest
from lib import topotest
from lib.common_config import (
save_initial_config_on_routers,
reset_with_new_configs,
Expand Down
1 change: 0 additions & 1 deletion tests/topotests/bgp_bmp/test_bgp_bmp.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
from ipaddress import ip_network
import json
import os
import platform
import pytest
import sys

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

# Save the Current Working Directory to find configuration files.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,6 @@ def test_bgp_no_export_local_as_communities_p0(request):
)

for comm_type in ["no-export", "local-AS"]:

step("Create a route-map on R1 to set community as {}".format(comm_type))

seq_id = 10
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
"""

import os
import re
import sys
import json
import pytest
Expand All @@ -24,7 +23,7 @@

# pylint: disable=C0413
from lib import topotest
from lib.topogen import Topogen, TopoRouter, get_topogen
from lib.topogen import Topogen, get_topogen
from lib.common_config import step


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
#

import os
import re
import sys
import json
import pytest
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
import time
import pytest
import datetime
from copy import deepcopy
from lib.topolog import logger
from time import sleep

Expand Down Expand Up @@ -214,7 +213,6 @@ def get_rib_route_uptime(tgen, addr_type, dut, input_dict):

logger.info("Entering lib API: get_rib_route_uptime()")
route_time = []
out_route_dict = {}
router_list = tgen.routers()
for routerInput in input_dict.keys():
for router, rnode in router_list.items():
Expand All @@ -234,7 +232,6 @@ def get_rib_route_uptime(tgen, addr_type, dut, input_dict):

for static_route in static_routes:
if "vrf" in static_route and static_route["vrf"] is not None:

logger.info(
"[DUT: {}]: Verifying routes for VRF:"
" {}".format(router, static_route["vrf"])
Expand Down Expand Up @@ -307,7 +304,6 @@ def get_best_path_route_in_FIB(tgen, topo, dut, network):
on failure : return error message with boolean False
"""
is_ipv4_best_path_found = False
is_ipv6_best_path_found = False
rnode = tgen.routers()[dut]
ipv4_show_bgp_json = run_frr_cmd(rnode, "sh ip bgp json ", isjson=True)
ipv6_show_bgp_json = run_frr_cmd(
Expand Down Expand Up @@ -1575,7 +1571,7 @@ def ping_router():
ipv_dict = get_best_path_route_in_FIB(tgen, topo, dut="r2", network=network)
dut_links = topo["routers"]["r1"]["links"]
active_interface = None
for key, values in dut_links.items():
for key, _ in dut_links.items():
ipv4_address = dut_links[key]["ipv4"].split("/")[0]
ipv6_address = dut_links[key]["ipv6"].split("/")[0]
if ipv_dict["ipv4"] == ipv4_address and ipv_dict["ipv6"] == ipv6_address:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@
import sys
import time
import pytest
from time import sleep
from copy import deepcopy
from lib.topolog import logger

# pylint: disable=C0413
Expand All @@ -30,32 +28,18 @@

from lib.bgp import (
verify_bgp_convergence,
verify_graceful_restart,
create_router_bgp,
verify_router_id,
modify_as_number,
verify_as_numbers,
clear_bgp_and_verify,
clear_bgp,
verify_bgp_rib,
get_prefix_count_route,
get_dut_as_number,
verify_rib_default_route,
verify_fib_default_route,
verify_bgp_advertised_routes_from_neighbor,
verify_bgp_received_routes_from_neighbor,
)
from lib.common_config import (
interface_status,
verify_prefix_lists,
verify_fib_routes,
kill_router_daemons,
start_router_daemons,
shutdown_bringup_interface,
step,
required_linux_kernel_version,
stop_router,
start_router,
create_route_maps,
create_prefix_lists,
get_frr_ipv6_linklocal,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@
import sys
import time
import pytest
from time import sleep
from copy import deepcopy
from lib.topolog import logger

# pylint: disable=C0413
Expand All @@ -31,30 +29,21 @@
verify_bgp_convergence,
verify_graceful_restart,
create_router_bgp,
verify_router_id,
modify_as_number,
verify_as_numbers,
clear_bgp_and_verify,
clear_bgp,
verify_bgp_rib,
get_prefix_count_route,
get_dut_as_number,
verify_rib_default_route,
verify_fib_default_route,
verify_bgp_advertised_routes_from_neighbor,
verify_bgp_received_routes_from_neighbor,
)
from lib.common_config import (
interface_status,
verify_prefix_lists,
verify_fib_routes,
kill_router_daemons,
start_router_daemons,
shutdown_bringup_interface,
step,
required_linux_kernel_version,
stop_router,
start_router,
create_route_maps,
create_prefix_lists,
get_frr_ipv6_linklocal,
Expand All @@ -65,7 +54,6 @@
reset_config_on_routers,
create_static_routes,
check_router_status,
delete_route_maps,
)


Expand Down
18 changes: 0 additions & 18 deletions tests/topotests/bgp_default_originate/test_default_orginate_vrf.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@
import sys
import time
import pytest
from time import sleep
from copy import deepcopy
from lib.topolog import logger

# pylint: disable=C0413
Expand All @@ -22,32 +20,17 @@

from lib.bgp import (
verify_bgp_convergence,
verify_graceful_restart,
create_router_bgp,
verify_router_id,
modify_as_number,
verify_as_numbers,
clear_bgp_and_verify,
clear_bgp,
verify_bgp_rib,
get_prefix_count_route,
get_dut_as_number,
verify_rib_default_route,
verify_fib_default_route,
verify_bgp_advertised_routes_from_neighbor,
verify_bgp_received_routes_from_neighbor,
)
from lib.common_config import (
interface_status,
verify_prefix_lists,
verify_rib,
kill_router_daemons,
start_router_daemons,
shutdown_bringup_interface,
step,
required_linux_kernel_version,
stop_router,
start_router,
create_route_maps,
create_prefix_lists,
get_frr_ipv6_linklocal,
Expand All @@ -58,7 +41,6 @@
reset_config_on_routers,
create_static_routes,
check_router_status,
delete_route_maps,
)

pytestmark = [pytest.mark.bgpd, pytest.mark.staticd]
Expand Down
Loading

0 comments on commit 895ae47

Please sign in to comment.