def test_icmp_failback(): """ Title: BGP failover/failback Scenario 1: Given: multiple uplinks When: enable BGP on both of them Then: ICMP echo RR should work to a pseudo public IP address Scenario 2: Given: When: inject failure into one of BGP uplinks (failover) Then: ICMP echo RR should work to a pseudo public IP address Scenario 3: Given: When: eject failure (failback) Then: ICMP echo RR should work to a psudo public IP address Scenario 4: Given: When: inject failure into another of BGP uplinks (failover) Then: ICMP echo RR should work to a pseudo public IP address Scenario 5: Given: When: eject failure (failback) Then: ICMP echo RR should work to a pseudo public IP address """ add_bgp([uplink1_session1], route_direct) add_bgp([uplink2_session1], route_direct) ping_to_inet() # BGP #1 and #2 are working failure = PktFailure('quagga1', 'bgp1', 5) failure.inject() try: ping_to_inet() # BGP #1 is lost but continues to work finally: failure.eject() await_internal_route_exported(64513, 64511) ping_to_inet() # BGP #1 is back failure = PktFailure('quagga2', 'bgp1', 5) failure.inject() try: ping_to_inet() # BGP #2 is lost but continues to work except Exception as e: raise e finally: failure.eject() await_internal_route_exported(64513, 64512) ping_to_inet() # BGP #2 is back
def test_icmp_failback(): """ Title: BGP failover/failback Scenario 1: Given: multiple uplinks When: enable BGP on both of them Then: ICMP echo RR should work to a pseudo public IP address Scenario 2: Given: When: inject failure into one of BGP uplinks (failover) Then: ICMP echo RR should work to a pseudo public IP address Scenario 3: Given: When: eject failure (failback) Then: ICMP echo RR should work to a psudo public IP address Scenario 4: Given: When: inject failure into another of BGP uplinks (failover) Then: ICMP echo RR should work to a pseudo public IP address Scenario 5: Given: When: eject failure (failback) Then: ICMP echo RR should work to a pseudo public IP address """ add_bgp_1(route_direct) add_bgp_2(route_direct) ping_inet() # BGP #1 and #2 are working failure = PktFailure('quagga', 'bgp0', 15) failure.inject() try: ping_inet() # BGP #1 is lost finally: failure.eject() ping_inet() # BGP #1 is back failure = PktFailure('quagga', 'bgp1', 15) failure.inject() try: ping_inet() # BGP #2 is lost finally: failure.eject() ping_inet() # BGP #2 is back clear_bgp()
def test_multisession_icmp_failback(): """ Title: BGP session failover/failback Scenario 1: Given: single uplink with multiple sessions When: enable two bgp sessions on the same port Then: ICMP echo RR should work to a pseudo public IP address Scenario 2: Given: When: inject failure into one of BGP session (failover) Then: ICMP echo RR should work to a pseudo public IP address Scenario 3: Given: When: eject failure (failback) Then: ICMP echo RR should work to a psudo public IP address Scenario 4: Given: When: inject failure into the other BGP session (failover) Then: ICMP echo RR should work to a pseudo public IP address Scenario 5: Given: When: eject failure (failback) Then: ICMP echo RR should work to a pseudo public IP address """ add_bgp(uplink1_multisession, route_direct) ping_to_inet() # BGP #1 and #2 are working failure = PktFailure('quagga1', 'bgp1', 5) failure.inject() try: ping_to_inet() # BGP session #1 is lost but continues to work except Exception as e: raise e finally: failure.eject() ping_to_inet() # BGP #1 is back failure = PktFailure('quagga2', 'bgp2', 5) failure.inject() try: ping_to_inet() # BGP session #2 is lost but continues to work finally: failure.eject() ping_to_inet() # BGP #2 is back
def test_multisession_icmp_failback(): """ Title: BGP session failover/failback Scenario 1: Given: single uplink with multiple sessions When: enable two bgp sessions on the same port Then: ICMP echo RR should work to a pseudo public IP address Scenario 2: Given: When: inject failure into one of BGP session (failover) Then: ICMP echo RR should work to a pseudo public IP address Scenario 3: Given: When: eject failure (failback) Then: ICMP echo RR should work to a psudo public IP address Scenario 4: Given: When: inject failure into the other BGP session (failover) Then: ICMP echo RR should work to a pseudo public IP address Scenario 5: Given: When: eject failure (failback) Then: ICMP echo RR should work to a pseudo public IP address """ add_bgp(uplink1_multisession, route_direct) ping_to_inet() # BGP #1 and #2 are working failure = PktFailure('quagga1', 'bgp1', 5) failure.inject() try: ping_to_inet() # BGP session #1 is lost but continues to work finally: failure.eject() ping_to_inet() # BGP #1 is back failure = PktFailure('quagga2', 'bgp2', 5) failure.inject() try: ping_to_inet() # BGP session #2 is lost but continues to work finally: failure.eject() ping_to_inet() # BGP #2 is back
def test_multisession_icmp_failback(): """ Title: BGP session failover/failback Scenario 1: Given: single uplink with multiple sessions When: enable two bgp sessions on the same port Then: ICMP echo RR should work to a pseudo public IP address Scenario 2: Given: When: inject failure into one of BGP session (failover) Then: ICMP echo RR should work to a pseudo public IP address Scenario 3: Given: When: eject failure (failback) Then: ICMP echo RR should work to a psudo public IP address Scenario 4: Given: When: inject failure into the other BGP session (failover) Then: ICMP echo RR should work to a pseudo public IP address Scenario 5: Given: When: eject failure (failback) Then: ICMP echo RR should work to a pseudo public IP address """ data = BM.get_binding_data()['config'] session1 = data['session1'] session2 = data['session2'] multisession = BM.get_binding_data()['config']['multisession'] add_bgp(multisession, route_direct) ping_to_inet() # BGP #1 and #2 are working failure1 = PktFailure(session1['peerHostname'], session1['peerIface'], 5) failure1.inject() try: ping_to_inet() # BGP session #1 is lost but continues to work finally: failure1.eject() ping_to_inet() # BGP #1 is back failure2 = PktFailure(session2['peerHostname'], session2['peerIface'], 5) failure2.inject() try: ping_to_inet() # BGP session #2 is lost but continues to work finally: failure2.eject() ping_to_inet() # BGP #2 is back # Check routes await_router_route(session1, '1.1.1.1', 32, exists=True) await_router_route(session1, '0.0.0.0', 0, exists=True) await_router_route(session2, '1.1.1.1', 32, exists=True) await_router_route(session2, '0.0.0.0', 0, exists=True) # Inject failures again and check routes failure1.inject() try: await_router_route(session1, '1.1.1.1', 32, exists=False) await_router_route(session1, '0.0.0.0', 0, exists=False) await_router_route(session2, '1.1.1.1', 32, exists=True) await_router_route(session2, '0.0.0.0', 0, exists=True) except Exception: failure1.eject() raise failure2.inject() try: await_router_route(session1, '1.1.1.1', 32, exists=False) await_router_route(session1, '0.0.0.0', 0, exists=False) await_router_route(session2, '1.1.1.1', 32, exists=False) await_router_route(session2, '0.0.0.0', 0, exists=False) except Exception: failure2.eject() raise failure1.eject() failure2.eject()
def test_icmp_failback(): """ Title: BGP failover/failback Scenario 1: Given: multiple uplinks When: enable BGP on both of them Then: ICMP echo RR should work to a pseudo public IP address Scenario 2: Given: When: inject failure into one of BGP uplinks (failover) Then: ICMP echo RR should work to a pseudo public IP address Scenario 3: Given: When: eject failure (failback) Then: ICMP echo RR should work to a psudo public IP address Scenario 4: Given: When: inject failure into another of BGP uplinks (failover) Then: ICMP echo RR should work to a pseudo public IP address Scenario 5: Given: When: eject failure (failback) Then: ICMP echo RR should work to a pseudo public IP address """ add_bgp([uplink1_session1], route_direct) add_bgp([uplink2_session1], route_direct) await_router_route(uplink1_session1, '1.1.1.1', 32, exists=True) await_router_route(uplink1_session1, '0.0.0.0', 0, exists=True) await_router_route(uplink2_session1, '1.1.1.1', 32, exists=True) await_router_route(uplink2_session1, '0.0.0.0', 0, exists=True) ping_to_inet() # BGP #1 and #2 are working failure1 = PktFailure(uplink1_session1['peerHostname'], uplink1_session1['peerIface'], 5) failure1.inject() try: await_router_route(uplink1_session1, '1.1.1.1', 32, exists=False) await_router_route(uplink1_session1, '0.0.0.0', 0, exists=False) await_router_route(uplink2_session1, '1.1.1.1', 32, exists=True) await_router_route(uplink2_session1, '0.0.0.0', 0, exists=True) ping_to_inet() # BGP #1 is lost but continues to work finally: failure1.eject() await_internal_route_exported(64513, 64511) ping_to_inet() # BGP #1 is back failure2 = PktFailure(uplink2_session1['peerHostname'], uplink2_session1['peerIface'], 5) failure2.inject() try: await_router_route(uplink1_session1, '1.1.1.1', 32, exists=True) await_router_route(uplink1_session1, '0.0.0.0', 0, exists=True) await_router_route(uplink2_session1, '1.1.1.1', 32, exists=False) await_router_route(uplink2_session1, '0.0.0.0', 0, exists=False) ping_to_inet() # BGP #2 is lost but continues to work finally: failure2.eject() await_internal_route_exported(64513, 64512) ping_to_inet() # BGP #2 is back failure1.inject() failure2.inject() try: await_router_route(uplink1_session1, '1.1.1.1', 32, exists=False) await_router_route(uplink1_session1, '0.0.0.0', 0, exists=False) await_router_route(uplink2_session1, '1.1.1.1', 32, exists=False) await_router_route(uplink2_session1, '0.0.0.0', 0, exists=False) finally: failure1.eject() failure2.eject()