mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-08-09 07:30:53 +00:00
tests: fix bgp-auth topotest
Individual tests must not depend on each other. In particular, a test can't be sure that the previous test config is applied or cleared. It is definitely not true when a single test is executed, for example: `test_bgp_auth.py::test_prefix_peer_remove_passwords`. This commit makes all tests independent of each other. It also adds a call to check_all_peers_established at the start of "remove_passwords" tests to make sure that we not only block new peers with an incorrect password, but also clean the existing peers. Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
This commit is contained in:
parent
058d0236b6
commit
b32454e10c
@ -299,7 +299,7 @@ def configure(conf_file):
|
|||||||
raise InvalidCLIError("%s" % output)
|
raise InvalidCLIError("%s" % output)
|
||||||
|
|
||||||
|
|
||||||
def clear_bgp(vrf=""):
|
def clear_bgp():
|
||||||
"clear bgp configuration for a vrf"
|
"clear bgp configuration for a vrf"
|
||||||
|
|
||||||
tgen = get_topogen()
|
tgen = get_topogen()
|
||||||
@ -307,27 +307,40 @@ def clear_bgp(vrf=""):
|
|||||||
r2 = tgen.gears["R2"]
|
r2 = tgen.gears["R2"]
|
||||||
r3 = tgen.gears["R3"]
|
r3 = tgen.gears["R3"]
|
||||||
|
|
||||||
router_list = tgen.routers()
|
|
||||||
if vrf == "":
|
|
||||||
r1.vtysh_cmd("conf t\nno router bgp 65001")
|
r1.vtysh_cmd("conf t\nno router bgp 65001")
|
||||||
r2.vtysh_cmd("conf t\nno router bgp 65002")
|
r2.vtysh_cmd("conf t\nno router bgp 65002")
|
||||||
r2.vtysh_cmd("conf t\nno router bgp 65003")
|
r3.vtysh_cmd("conf t\nno router bgp 65003")
|
||||||
else:
|
r1.vtysh_cmd("conf t\nno router bgp 65001 vrf blue")
|
||||||
r1.vtysh_cmd("conf t\nno router bgp 65001 vrf {}".format(vrf))
|
r2.vtysh_cmd("conf t\nno router bgp 65002 vrf blue")
|
||||||
r2.vtysh_cmd("conf t\nno router bgp 65002 vrf {}".format(vrf))
|
r3.vtysh_cmd("conf t\nno router bgp 65003 vrf blue")
|
||||||
r3.vtysh_cmd("conf t\nno router bgp 65003 vrf {}".format(vrf))
|
r1.vtysh_cmd("conf t\nno router bgp 65001 vrf red")
|
||||||
|
r2.vtysh_cmd("conf t\nno router bgp 65002 vrf red")
|
||||||
|
r3.vtysh_cmd("conf t\nno router bgp 65003 vrf red")
|
||||||
|
|
||||||
|
|
||||||
def clear_ospf(vrf=""):
|
def configure_bgp(conf_file):
|
||||||
|
"configure bgp from file"
|
||||||
|
|
||||||
|
clear_bgp()
|
||||||
|
configure(conf_file)
|
||||||
|
|
||||||
|
|
||||||
|
def clear_ospf():
|
||||||
"clear ospf configuration for a vrf"
|
"clear ospf configuration for a vrf"
|
||||||
|
|
||||||
tgen = get_topogen()
|
tgen = get_topogen()
|
||||||
router_list = tgen.routers()
|
router_list = tgen.routers()
|
||||||
for rname, router in router_list.items():
|
for rname, router in router_list.items():
|
||||||
if vrf == "":
|
|
||||||
router.vtysh_cmd("conf t\nno router ospf")
|
router.vtysh_cmd("conf t\nno router ospf")
|
||||||
else:
|
router.vtysh_cmd("conf t\nno router ospf vrf blue")
|
||||||
router.vtysh_cmd("conf t\nno router ospf vrf {}".format(vrf))
|
router.vtysh_cmd("conf t\nno router ospf vrf red")
|
||||||
|
|
||||||
|
|
||||||
|
def configure_ospf(conf_file):
|
||||||
|
"configure bgp from file"
|
||||||
|
|
||||||
|
clear_ospf()
|
||||||
|
configure(conf_file)
|
||||||
|
|
||||||
|
|
||||||
def check_neigh_state(router, peer, state, vrf=""):
|
def check_neigh_state(router, peer, state, vrf=""):
|
||||||
@ -382,6 +395,8 @@ def check_vrf_peer_remove_passwords(vrf="", prefix="no"):
|
|||||||
r2 = tgen.gears["R2"]
|
r2 = tgen.gears["R2"]
|
||||||
r3 = tgen.gears["R3"]
|
r3 = tgen.gears["R3"]
|
||||||
|
|
||||||
|
check_all_peers_established(vrf)
|
||||||
|
|
||||||
r1.vtysh_cmd(
|
r1.vtysh_cmd(
|
||||||
"conf t\nrouter bgp 65001 {}\nno neighbor {} password".format(
|
"conf t\nrouter bgp 65001 {}\nno neighbor {} password".format(
|
||||||
vrf_str(vrf), peer_name("R2", prefix, vrf)
|
vrf_str(vrf), peer_name("R2", prefix, vrf)
|
||||||
@ -511,25 +526,26 @@ def check_vrf_peer_change_passwords(vrf="", prefix="no"):
|
|||||||
def test_default_peer_established():
|
def test_default_peer_established():
|
||||||
"default vrf 3 peers same password"
|
"default vrf 3 peers same password"
|
||||||
|
|
||||||
|
configure_bgp("bgpd.conf")
|
||||||
|
configure_ospf("ospfd.conf")
|
||||||
check_all_peers_established()
|
check_all_peers_established()
|
||||||
clear_bgp()
|
|
||||||
# tgen.mininet_cli()
|
# tgen.mininet_cli()
|
||||||
|
|
||||||
|
|
||||||
def test_default_peer_remove_passwords():
|
def test_default_peer_remove_passwords():
|
||||||
"selectively remove passwords checking state"
|
"selectively remove passwords checking state"
|
||||||
|
|
||||||
configure("bgpd.conf")
|
configure_bgp("bgpd.conf")
|
||||||
|
configure_ospf("ospfd.conf")
|
||||||
check_vrf_peer_remove_passwords()
|
check_vrf_peer_remove_passwords()
|
||||||
clear_bgp()
|
|
||||||
|
|
||||||
|
|
||||||
def test_default_peer_change_passwords():
|
def test_default_peer_change_passwords():
|
||||||
"selectively change passwords checking state"
|
"selectively change passwords checking state"
|
||||||
|
|
||||||
configure("bgpd.conf")
|
configure_bgp("bgpd.conf")
|
||||||
|
configure_ospf("ospfd.conf")
|
||||||
check_vrf_peer_change_passwords()
|
check_vrf_peer_change_passwords()
|
||||||
clear_bgp()
|
|
||||||
|
|
||||||
|
|
||||||
def test_default_prefix_peer_established():
|
def test_default_prefix_peer_established():
|
||||||
@ -539,9 +555,9 @@ def test_default_prefix_peer_established():
|
|||||||
if topotest.version_cmp(platform.release(), "5.3") < 0:
|
if topotest.version_cmp(platform.release(), "5.3") < 0:
|
||||||
return
|
return
|
||||||
|
|
||||||
configure("bgpd_prefix.conf")
|
configure_bgp("bgpd_prefix.conf")
|
||||||
|
configure_ospf("ospfd.conf")
|
||||||
check_all_peers_established()
|
check_all_peers_established()
|
||||||
clear_bgp()
|
|
||||||
# tgen.mininet_cli()
|
# tgen.mininet_cli()
|
||||||
|
|
||||||
|
|
||||||
@ -551,9 +567,10 @@ def test_prefix_peer_remove_passwords():
|
|||||||
# only supported in kernel > 5.3
|
# only supported in kernel > 5.3
|
||||||
if topotest.version_cmp(platform.release(), "5.3") < 0:
|
if topotest.version_cmp(platform.release(), "5.3") < 0:
|
||||||
return
|
return
|
||||||
configure("bgpd_prefix.conf")
|
|
||||||
|
configure_bgp("bgpd_prefix.conf")
|
||||||
|
configure_ospf("ospfd.conf")
|
||||||
check_vrf_peer_remove_passwords(prefix="yes")
|
check_vrf_peer_remove_passwords(prefix="yes")
|
||||||
clear_bgp()
|
|
||||||
|
|
||||||
|
|
||||||
def test_prefix_peer_change_passwords():
|
def test_prefix_peer_change_passwords():
|
||||||
@ -562,38 +579,36 @@ def test_prefix_peer_change_passwords():
|
|||||||
# only supported in kernel > 5.3
|
# only supported in kernel > 5.3
|
||||||
if topotest.version_cmp(platform.release(), "5.3") < 0:
|
if topotest.version_cmp(platform.release(), "5.3") < 0:
|
||||||
return
|
return
|
||||||
configure("bgpd_prefix.conf")
|
|
||||||
|
configure_bgp("bgpd_prefix.conf")
|
||||||
|
configure_ospf("ospfd.conf")
|
||||||
check_vrf_peer_change_passwords(prefix="yes")
|
check_vrf_peer_change_passwords(prefix="yes")
|
||||||
clear_bgp()
|
|
||||||
clear_ospf()
|
|
||||||
|
|
||||||
|
|
||||||
def test_vrf_peer_established():
|
def test_vrf_peer_established():
|
||||||
"default vrf 3 peers same password with VRF config"
|
"default vrf 3 peers same password with VRF config"
|
||||||
|
|
||||||
# clean routers and load vrf config
|
# clean routers and load vrf config
|
||||||
configure("bgpd_vrf.conf")
|
configure_bgp("bgpd_vrf.conf")
|
||||||
configure("ospfd_vrf.conf")
|
configure_ospf("ospfd_vrf.conf")
|
||||||
|
|
||||||
check_all_peers_established("blue")
|
check_all_peers_established("blue")
|
||||||
clear_bgp("blue")
|
|
||||||
# tgen.mininet_cli()
|
# tgen.mininet_cli()
|
||||||
|
|
||||||
|
|
||||||
def test_vrf_peer_remove_passwords():
|
def test_vrf_peer_remove_passwords():
|
||||||
"selectively remove passwords checking state with VRF config"
|
"selectively remove passwords checking state with VRF config"
|
||||||
|
|
||||||
configure("bgpd_vrf.conf")
|
configure_bgp("bgpd_vrf.conf")
|
||||||
|
configure_ospf("ospfd_vrf.conf")
|
||||||
check_vrf_peer_remove_passwords(vrf="blue")
|
check_vrf_peer_remove_passwords(vrf="blue")
|
||||||
clear_bgp("blue")
|
|
||||||
|
|
||||||
|
|
||||||
def test_vrf_peer_change_passwords():
|
def test_vrf_peer_change_passwords():
|
||||||
"selectively change passwords checking state with VRF config"
|
"selectively change passwords checking state with VRF config"
|
||||||
|
|
||||||
configure("bgpd_vrf.conf")
|
configure_bgp("bgpd_vrf.conf")
|
||||||
|
configure_ospf("ospfd_vrf.conf")
|
||||||
check_vrf_peer_change_passwords(vrf="blue")
|
check_vrf_peer_change_passwords(vrf="blue")
|
||||||
clear_bgp("blue")
|
|
||||||
|
|
||||||
|
|
||||||
def test_vrf_prefix_peer_established():
|
def test_vrf_prefix_peer_established():
|
||||||
@ -601,12 +616,11 @@ def test_vrf_prefix_peer_established():
|
|||||||
|
|
||||||
# only supported in kernel > 5.3
|
# only supported in kernel > 5.3
|
||||||
if topotest.version_cmp(platform.release(), "5.3") < 0:
|
if topotest.version_cmp(platform.release(), "5.3") < 0:
|
||||||
clear_bgp("blue")
|
|
||||||
return
|
return
|
||||||
|
|
||||||
configure("bgpd_vrf_prefix.conf")
|
configure_bgp("bgpd_vrf_prefix.conf")
|
||||||
|
configure_ospf("ospfd_vrf.conf")
|
||||||
check_all_peers_established("blue")
|
check_all_peers_established("blue")
|
||||||
clear_bgp("blue")
|
|
||||||
|
|
||||||
|
|
||||||
def test_vrf_prefix_peer_remove_passwords():
|
def test_vrf_prefix_peer_remove_passwords():
|
||||||
@ -616,65 +630,54 @@ def test_vrf_prefix_peer_remove_passwords():
|
|||||||
if topotest.version_cmp(platform.release(), "5.3") < 0:
|
if topotest.version_cmp(platform.release(), "5.3") < 0:
|
||||||
return
|
return
|
||||||
|
|
||||||
configure("bgpd_vrf_prefix.conf")
|
configure_bgp("bgpd_vrf_prefix.conf")
|
||||||
|
configure_ospf("ospfd_vrf.conf")
|
||||||
check_vrf_peer_remove_passwords(vrf="blue", prefix="yes")
|
check_vrf_peer_remove_passwords(vrf="blue", prefix="yes")
|
||||||
clear_bgp("blue")
|
|
||||||
|
|
||||||
|
|
||||||
def test_vrf_prefix_peer_change_passwords():
|
def test_vrf_prefix_peer_change_passwords():
|
||||||
"selectively change passwords checking state with VRF prefix config"
|
"selectively change passwords checking state with VRF prefix config"
|
||||||
|
|
||||||
tgen = get_topogen()
|
|
||||||
r1 = tgen.gears["R1"]
|
|
||||||
r2 = tgen.gears["R2"]
|
|
||||||
r3 = tgen.gears["R3"]
|
|
||||||
|
|
||||||
# only supported in kernel > 5.3
|
# only supported in kernel > 5.3
|
||||||
if topotest.version_cmp(platform.release(), "5.3") < 0:
|
if topotest.version_cmp(platform.release(), "5.3") < 0:
|
||||||
clear_ospf("blue")
|
|
||||||
return
|
return
|
||||||
|
|
||||||
configure("bgpd_vrf_prefix.conf")
|
configure_bgp("bgpd_vrf_prefix.conf")
|
||||||
|
configure_ospf("ospfd_vrf.conf")
|
||||||
check_vrf_peer_change_passwords(vrf="blue", prefix="yes")
|
check_vrf_peer_change_passwords(vrf="blue", prefix="yes")
|
||||||
clear_bgp("blue")
|
|
||||||
clear_ospf("blue")
|
|
||||||
|
|
||||||
|
|
||||||
def test_multiple_vrf_peer_established():
|
def test_multiple_vrf_peer_established():
|
||||||
"default vrf 3 peers same password with multiple VRFs"
|
"default vrf 3 peers same password with multiple VRFs"
|
||||||
|
|
||||||
configure("bgpd_multi_vrf.conf")
|
configure_bgp("bgpd_multi_vrf.conf")
|
||||||
configure("ospfd_multi_vrf.conf")
|
configure_ospf("ospfd_multi_vrf.conf")
|
||||||
check_all_peers_established("blue")
|
check_all_peers_established("blue")
|
||||||
check_all_peers_established("red")
|
check_all_peers_established("red")
|
||||||
clear_bgp("blue")
|
|
||||||
clear_bgp("red")
|
|
||||||
# tgen.mininet_cli()
|
# tgen.mininet_cli()
|
||||||
|
|
||||||
|
|
||||||
def test_multiple_vrf_peer_remove_passwords():
|
def test_multiple_vrf_peer_remove_passwords():
|
||||||
"selectively remove passwords checking state with multiple VRFs"
|
"selectively remove passwords checking state with multiple VRFs"
|
||||||
|
|
||||||
configure("bgpd_multi_vrf.conf")
|
configure_bgp("bgpd_multi_vrf.conf")
|
||||||
|
configure_ospf("ospfd_multi_vrf.conf")
|
||||||
check_vrf_peer_remove_passwords("blue")
|
check_vrf_peer_remove_passwords("blue")
|
||||||
check_all_peers_established("red")
|
check_all_peers_established("red")
|
||||||
check_vrf_peer_remove_passwords("red")
|
check_vrf_peer_remove_passwords("red")
|
||||||
check_all_peers_established("blue")
|
check_all_peers_established("blue")
|
||||||
clear_bgp("blue")
|
|
||||||
clear_bgp("red")
|
|
||||||
# tgen.mininet_cli()
|
# tgen.mininet_cli()
|
||||||
|
|
||||||
|
|
||||||
def test_multiple_vrf_peer_change_passwords():
|
def test_multiple_vrf_peer_change_passwords():
|
||||||
"selectively change passwords checking state with multiple VRFs"
|
"selectively change passwords checking state with multiple VRFs"
|
||||||
|
|
||||||
configure("bgpd_multi_vrf.conf")
|
configure_bgp("bgpd_multi_vrf.conf")
|
||||||
|
configure_ospf("ospfd_multi_vrf.conf")
|
||||||
check_vrf_peer_change_passwords("blue")
|
check_vrf_peer_change_passwords("blue")
|
||||||
check_all_peers_established("red")
|
check_all_peers_established("red")
|
||||||
check_vrf_peer_change_passwords("red")
|
check_vrf_peer_change_passwords("red")
|
||||||
check_all_peers_established("blue")
|
check_all_peers_established("blue")
|
||||||
clear_bgp("blue")
|
|
||||||
clear_bgp("red")
|
|
||||||
# tgen.mininet_cli()
|
# tgen.mininet_cli()
|
||||||
|
|
||||||
|
|
||||||
@ -685,12 +688,10 @@ def test_multiple_vrf_prefix_peer_established():
|
|||||||
if topotest.version_cmp(platform.release(), "5.3") < 0:
|
if topotest.version_cmp(platform.release(), "5.3") < 0:
|
||||||
return
|
return
|
||||||
|
|
||||||
configure("bgpd_multi_vrf.conf")
|
configure_bgp("bgpd_multi_vrf_prefix.conf")
|
||||||
configure("ospfd_multi_vrf.conf")
|
configure_ospf("ospfd_multi_vrf.conf")
|
||||||
check_all_peers_established("blue")
|
check_all_peers_established("blue")
|
||||||
check_all_peers_established("red")
|
check_all_peers_established("red")
|
||||||
clear_bgp("blue")
|
|
||||||
clear_bgp("red")
|
|
||||||
# tgen.mininet_cli()
|
# tgen.mininet_cli()
|
||||||
|
|
||||||
|
|
||||||
@ -701,14 +702,12 @@ def test_multiple_vrf_prefix_peer_remove_passwords():
|
|||||||
if topotest.version_cmp(platform.release(), "5.3") < 0:
|
if topotest.version_cmp(platform.release(), "5.3") < 0:
|
||||||
return
|
return
|
||||||
|
|
||||||
configure("bgpd_multi_vrf_prefix.conf")
|
configure_bgp("bgpd_multi_vrf_prefix.conf")
|
||||||
tgen = get_topogen()
|
configure_ospf("ospfd_multi_vrf.conf")
|
||||||
check_vrf_peer_remove_passwords(vrf="blue", prefix="yes")
|
check_vrf_peer_remove_passwords(vrf="blue", prefix="yes")
|
||||||
check_all_peers_established("red")
|
check_all_peers_established("red")
|
||||||
check_vrf_peer_remove_passwords(vrf="red", prefix="yes")
|
check_vrf_peer_remove_passwords(vrf="red", prefix="yes")
|
||||||
check_all_peers_established("blue")
|
check_all_peers_established("blue")
|
||||||
clear_bgp("blue")
|
|
||||||
clear_bgp("red")
|
|
||||||
# tgen.mininet_cli()
|
# tgen.mininet_cli()
|
||||||
|
|
||||||
|
|
||||||
@ -717,21 +716,14 @@ def test_multiple_vrf_prefix_peer_change_passwords():
|
|||||||
|
|
||||||
# only supported in kernel > 5.3
|
# only supported in kernel > 5.3
|
||||||
if topotest.version_cmp(platform.release(), "5.3") < 0:
|
if topotest.version_cmp(platform.release(), "5.3") < 0:
|
||||||
clear_bgp("blue")
|
|
||||||
clear_bgp("red")
|
|
||||||
clear_ospf("blue")
|
|
||||||
clear_ospf("red")
|
|
||||||
return
|
return
|
||||||
|
|
||||||
configure("bgpd_multi_vrf_prefix.conf")
|
configure_bgp("bgpd_multi_vrf_prefix.conf")
|
||||||
|
configure_ospf("ospfd_multi_vrf.conf")
|
||||||
check_vrf_peer_change_passwords(vrf="blue", prefix="yes")
|
check_vrf_peer_change_passwords(vrf="blue", prefix="yes")
|
||||||
check_all_peers_established("red")
|
check_all_peers_established("red")
|
||||||
check_vrf_peer_change_passwords(vrf="red", prefix="yes")
|
check_vrf_peer_change_passwords(vrf="red", prefix="yes")
|
||||||
check_all_peers_established("blue")
|
check_all_peers_established("blue")
|
||||||
clear_bgp("blue")
|
|
||||||
clear_bgp("red")
|
|
||||||
clear_ospf("blue")
|
|
||||||
clear_ospf("red")
|
|
||||||
# tgen.mininet_cli()
|
# tgen.mininet_cli()
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user