Skip to content

Commit

Permalink
tests: Do not use peerUptime as a measure of if a clear worked
Browse files Browse the repository at this point in the history
The peerUptime data received from a `show bgp ipv4 uni summ json`
gives you the time in seconds since the peer has come up.
The clear_bgp_and_verify function is checking the peerUptime
for before and after and if they are the same then the test
was declaring a clear failure.

The problem with this is of course that the tests can run fast
enough that the peerUptime is the same for before and after the clear.

Modify the test case to use peerUptimeEstablishedEpoch.
This value is the seconds since the epoch since the establishment
of the peer.  This will allow us to know that a clear happened.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
  • Loading branch information
donaldsharp committed Jul 31, 2019
1 parent 2e6f2d6 commit abdb6bc
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions tests/topotests/lib/bgp.py
Original file line number Diff line number Diff line change
Expand Up @@ -932,15 +932,15 @@ def clear_bgp_and_verify(tgen, topo, router):

# Peer up time dictionary
peer_uptime_before_clear_bgp[bgp_neighbor] = \
ipv4_data[neighbor_ip]["peerUptime"]
ipv4_data[neighbor_ip]["peerUptimeEstablishedEpoch"]
else:
ipv6_data = show_bgp_json["ipv6Unicast"][
"peers"]
nh_state = ipv6_data[neighbor_ip]["state"]

# Peer up time dictionary
peer_uptime_before_clear_bgp[bgp_neighbor] = \
ipv6_data[neighbor_ip]["peerUptime"]
ipv6_data[neighbor_ip]["peerUptimeEstablishedEpoch"]

if nh_state == "Established":
no_of_peer += 1
Expand All @@ -953,6 +953,7 @@ def clear_bgp_and_verify(tgen, topo, router):
logger.warning("BGP is not yet Converged for router %s "
"before bgp clear", router)

logger.info(peer_uptime_before_clear_bgp)
# Clearing BGP
logger.info("Clearing BGP neighborship for router %s..", router)
for addr_type in bgp_addr_type.keys():
Expand Down Expand Up @@ -1010,14 +1011,14 @@ def clear_bgp_and_verify(tgen, topo, router):
"peers"]
nh_state = ipv4_data[neighbor_ip]["state"]
peer_uptime_after_clear_bgp[bgp_neighbor] = \
ipv4_data[neighbor_ip]["peerUptime"]
ipv4_data[neighbor_ip]["peerUptimeEstablishedEpoch"]
else:
ipv6_data = show_bgp_json["ipv6Unicast"][
"peers"]
nh_state = ipv6_data[neighbor_ip]["state"]
# Peer up time dictionary
peer_uptime_after_clear_bgp[bgp_neighbor] = \
ipv6_data[neighbor_ip]["peerUptime"]
ipv6_data[neighbor_ip]["peerUptimeEstablishedEpoch"]

if nh_state == "Established":
no_of_peer += 1
Expand All @@ -1030,7 +1031,8 @@ def clear_bgp_and_verify(tgen, topo, router):
logger.warning("BGP is not yet Converged for router %s after"
" bgp clear", router)

# Compariung peerUptime dictionaries
logger.info(peer_uptime_after_clear_bgp)
# Comparing peerUptimeEstablishedEpoch dictionaries
if peer_uptime_before_clear_bgp != peer_uptime_after_clear_bgp:
logger.info("BGP neighborship is reset after clear BGP on router %s",
router)
Expand Down

0 comments on commit abdb6bc

Please sign in to comment.