<s> """<STR_LIT>""" <EOL> import logging <EOL> import mock <EOL> from testtools import TestCase <EOL> from bagpipe . bgp . tests import BaseTestBagPipeBGP , RT1 , RT2 , RT3 , NLRI1 , NLRI2 , NH1 , NH2 <EOL> from bagpipe . bgp . engine import RouteEvent <EOL> from bagpipe . bgp . engine import RouteEntry <EOL> from bagpipe . bgp . engine import Subscription <EOL> from bagpipe . bgp . engine import Unsubscription <EOL> from bagpipe . bgp . engine . worker import Worker <EOL> from bagpipe . bgp . engine . bgp_peer_worker import BGPPeerWorker <EOL> from bagpipe . bgp . engine . route_table_manager import RouteTableManager <EOL> from bagpipe . bgp . engine . route_table_manager import Match <EOL> from bagpipe . bgp . engine . route_table_manager import WorkerCleanupEvent <EOL> from bagpipe . exabgp . message . update . attributes import Attributes <EOL> from bagpipe . exabgp . structure . address import AFI , SAFI <EOL> log = logging . getLogger ( ) <EOL> MATCH1 = Match ( AFI ( AFI . ipv4 ) , SAFI ( SAFI . mpls_vpn ) , RT1 ) <EOL> MATCH2 = Match ( AFI ( AFI . ipv4 ) , SAFI ( SAFI . mpls_vpn ) , RT2 ) <EOL> MATCH3 = Match ( AFI ( AFI . ipv4 ) , SAFI ( SAFI . mpls_vpn ) , RT3 ) <EOL> class TestRouteTableManager ( TestCase , BaseTestBagPipeBGP ) : <EOL> def setUp ( self ) : <EOL> super ( TestRouteTableManager , self ) . setUp ( ) <EOL> self . routeTableManager = RouteTableManager ( ) <EOL> self . routeTableManager . start ( ) <EOL> self . setEventTargetWorker ( self . routeTableManager ) <EOL> def tearDown ( self ) : <EOL> super ( TestRouteTableManager , self ) . tearDown ( ) <EOL> self . routeTableManager . stop ( ) <EOL> self . routeTableManager . join ( ) <EOL> def _newworker ( self , workerName , workerType ) : <EOL> worker = mock . Mock ( spec = workerType ) <EOL> worker . name = workerName <EOL> worker . enqueue = mock . Mock ( ) <EOL> return worker <EOL> def _workerSubscriptions ( self , worker , rts , <EOL> afi = AFI ( AFI . ipv4 ) , safi = SAFI ( SAFI . mpls_vpn ) ) : <EOL> for rt in rts : <EOL> subscribe = Subscription ( afi , safi , rt , worker ) <EOL> self . routeTableManager . enqueue ( subscribe ) <EOL> def _workerUnsubscriptions ( self , worker , rts , <EOL> afi = AFI ( AFI . ipv4 ) , safi = SAFI ( SAFI . mpls_vpn ) ) : <EOL> for rt in rts : <EOL> unsubscribe = Unsubscription ( afi , safi , rt , worker ) <EOL> self . routeTableManager . enqueue ( unsubscribe ) <EOL> def _checkSubscriptions ( self , worker , matches ) : <EOL> for match in matches : <EOL> subs = self . routeTableManager . getWorkerSubscriptions ( worker ) <EOL> self . assertIn ( match , subs , "<STR_LIT>" ) <EOL> def _checkUnsubscriptions ( self , worker , matches ) : <EOL> for match in matches : <EOL> subs = self . routeTableManager . getWorkerSubscriptions ( worker ) <EOL> self . assertNotIn ( match , subs , "<STR_LIT>" ) <EOL> def _checkCalls ( self , worker , entry ) : <EOL> self . assertTrue ( <EOL> entry in self . routeTableManager . getWorkerRouteEntries ( worker ) , <EOL> "<STR_LIT>" ) <EOL> def _checkNoRouteEntry ( self , worker , entry ) : <EOL> self . assertTrue ( <EOL> entry not in self . routeTableManager . getWorkerRouteEntries ( worker ) , <EOL> "<STR_LIT>" ) <EOL> def _checkEventsCalls ( self , events , advertisedRoutes , withdrawnNLRIs ) : <EOL> '''<STR_LIT>''' <EOL> for ( callArgs , _ ) in events : <EOL> if ( callArgs [ <NUM_LIT:0> ] . type == RouteEvent . ADVERTISE ) : <EOL> self . assertIn ( callArgs [ <NUM_LIT:0> ] . routeEntry , advertisedRoutes , <EOL> "<STR_LIT>" ) <EOL> advertisedRoutes . remove ( callArgs [ <NUM_LIT:0> ] . routeEntry ) <EOL> else : <EOL> self . assertIn ( callArgs [ <NUM_LIT:0> ] . routeEntry . nlri , withdrawnNLRIs , <EOL> "<STR_LIT>" ) <EOL> withdrawnNLRIs . remove ( callArgs [ <NUM_LIT:0> ] . routeEntry . nlri ) <EOL> self . assertEqual ( <NUM_LIT:0> , len ( advertisedRoutes ) , "<STR_LIT>" ) <EOL> self . assertEqual ( <NUM_LIT:0> , len ( withdrawnNLRIs ) , "<STR_LIT>" ) <EOL> def testA1_SubscriptionsWithNoRouteTosynthesize ( self ) : <EOL> worker1 = self . _newworker ( "<STR_LIT>" , Worker ) <EOL> self . _workerSubscriptions ( worker1 , [ RT1 , RT2 ] ) <EOL> self . _wait ( ) <EOL> self . _checkSubscriptions ( worker1 , [ MATCH1 , MATCH2 ] ) <EOL> def testA2_SubscriptionsWithRouteTosynthesize ( self ) : <EOL> bgpPeerWorker1 = self . _newworker ( "<STR_LIT>" , BGPPeerWorker ) <EOL> evt1 = self . _newRouteEvent ( RouteEvent . ADVERTISE , NLRI1 , <EOL> [ RT1 , RT2 ] , bgpPeerWorker1 , NH1 ) <EOL> evt2 = self . _newRouteEvent ( RouteEvent . ADVERTISE , NLRI2 , <EOL> [ RT2 ] , bgpPeerWorker1 , NH1 ) <EOL> self . _workerSubscriptions ( bgpPeerWorker1 , [ RT1 ] ) <EOL> worker1 = self . _newworker ( "<STR_LIT>" , Worker ) <EOL> self . _workerSubscriptions ( worker1 , [ RT1 , RT2 ] ) <EOL> worker2 = self . _newworker ( "<STR_LIT>" , Worker ) <EOL> self . _workerSubscriptions ( worker2 , [ RT1 ] ) <EOL> worker3 = self . _newworker ( "<STR_LIT>" , Worker ) <EOL> self . _workerSubscriptions ( worker3 , [ RT3 ] ) <EOL> bgpPeerWorker2 = self . _newworker ( "<STR_LIT>" , BGPPeerWorker ) <EOL> self . _workerSubscriptions ( bgpPeerWorker2 , [ RT1 ] ) <EOL> self . _wait ( ) <EOL> self . assertEqual ( <NUM_LIT:0> , bgpPeerWorker1 . enqueue . call_count , <EOL> "<STR_LIT>" ) <EOL> self . assertEqual ( <NUM_LIT:0> , worker3 . enqueue . call_count , <EOL> "<STR_LIT>" ) <EOL> self . assertEqual ( <NUM_LIT:0> , bgpPeerWorker2 . enqueue . call_count , <EOL> "<STR_LIT>" ) <EOL> self . assertEqual ( <NUM_LIT:2> , worker1 . enqueue . call_count , <EOL> "<STR_LIT>" ) <EOL> self . _checkEventsCalls ( worker1 . enqueue . call_args_list , <EOL> [ evt1 . routeEntry , evt2 . routeEntry ] , [ ] ) <EOL> self . assertEqual ( <NUM_LIT:1> , worker2 . enqueue . call_count , <EOL> "<STR_LIT>" ) <EOL> self . _checkEventsCalls ( <EOL> worker2 . enqueue . call_args_list , [ evt1 . routeEntry ] , [ ] ) <EOL> def testA3_ReSubscription ( self ) : <EOL> bgpPeerWorker1 = self . _newworker ( <EOL> "<STR_LIT>" , BGPPeerWorker ) <EOL> routeEvent = self . _newRouteEvent ( RouteEvent . ADVERTISE , NLRI1 , <EOL> [ RT1 , RT2 ] , bgpPeerWorker1 , NH1 ) <EOL> worker1 = self . _newworker ( "<STR_LIT>" , Worker ) <EOL> self . _workerSubscriptions ( worker1 , [ RT1 , RT2 ] ) <EOL> self . _workerSubscriptions ( worker1 , [ RT1 ] ) <EOL> worker2 = self . _newworker ( "<STR_LIT>" , Worker ) <EOL> self . _workerSubscriptions ( worker2 , [ RT1 ] ) <EOL> self . _workerSubscriptions ( worker2 , [ RT2 ] ) <EOL> self . _wait ( ) <EOL> self . assertEqual ( <NUM_LIT:1> , worker1 . enqueue . call_count , <EOL> "<STR_LIT>" ) <EOL> self . _checkEventsCalls ( worker1 . enqueue . call_args_list , <EOL> [ routeEvent . routeEntry ] , [ ] ) <EOL> self . assertEqual ( <NUM_LIT:1> , worker2 . enqueue . call_count , <EOL> "<STR_LIT>" ) <EOL> self . _checkEventsCalls ( worker2 . enqueue . call_args_list , <EOL> [ routeEvent . routeEntry ] , [ ] ) <EOL> def testB1_UnsubscriptionWithNoRouteTosynthesize ( self ) : <EOL> worker1 = self . _newworker ( "<STR_LIT>" , Worker ) <EOL> self . _workerSubscriptions ( worker1 , [ RT1 , RT2 ] ) <EOL> bgpPeerWorker1 = self . _newworker ( "<STR_LIT>" , BGPPeerWorker ) <EOL> self . _workerSubscriptions ( bgpPeerWorker1 , [ RT1 , RT2 ] ) <EOL> self . _workerUnsubscriptions ( worker1 , [ RT1 ] ) <EOL> self . _workerUnsubscriptions ( bgpPeerWorker1 , [ RT1 , RT2 ] ) <EOL> self . _wait ( ) <EOL> self . _checkUnsubscriptions ( worker1 , [ MATCH1 ] ) <EOL> self . _checkSubscriptions ( worker1 , [ MATCH2 ] ) <EOL> self . _checkUnsubscriptions ( bgpPeerWorker1 , [ MATCH1 , MATCH2 ] ) <EOL> def testB2_UnsubscriptionWithRouteTosynthesize ( self ) : <EOL> bgpPeerWorker1 = self . _newworker ( <EOL> "<STR_LIT>" , BGPPeerWorker ) <EOL> evt1 = self . _newRouteEvent ( RouteEvent . ADVERTISE , NLRI1 , [ RT1 , RT2 ] , <EOL> bgpPeerWorker1 , NH1 ) <EOL> evt2 = self . _newRouteEvent ( RouteEvent . ADVERTISE , NLRI2 , [ RT2 ] , <EOL> bgpPeerWorker1 , NH1 ) <EOL> self . _workerSubscriptions ( bgpPeerWorker1 , [ RT1 ] ) <EOL> worker1 = self . _newworker ( "<STR_LIT>" , Worker ) <EOL> self . _workerSubscriptions ( worker1 , [ RT1 , RT2 ] ) <EOL> worker2 = self . _newworker ( "<STR_LIT>" , Worker ) <EOL> self . _workerSubscriptions ( worker2 , [ RT2 ] ) <EOL> worker3 = self . _newworker ( "<STR_LIT>" , Worker ) <EOL> self . _workerSubscriptions ( worker3 , [ RT3 ] ) <EOL> bgpPeerWorker2 = self . _newworker ( "<STR_LIT>" , BGPPeerWorker ) <EOL> self . _workerSubscriptions ( bgpPeerWorker2 , [ RT1 ] ) <EOL> self . _workerUnsubscriptions ( bgpPeerWorker1 , [ RT1 ] ) <EOL> self . _workerUnsubscriptions ( worker1 , [ RT1 ] ) <EOL> self . _workerUnsubscriptions ( worker2 , [ RT2 ] ) <EOL> self . _workerUnsubscriptions ( worker3 , [ RT3 ] ) <EOL> self . _workerUnsubscriptions ( bgpPeerWorker2 , [ RT1 ] ) <EOL> self . _wait ( ) <EOL> self . assertEqual ( <NUM_LIT:0> , bgpPeerWorker1 . enqueue . call_count , <EOL> "<STR_LIT>" ) <EOL> self . assertEqual ( <NUM_LIT:0> , worker3 . enqueue . call_count , <EOL> "<STR_LIT>" ) <EOL> self . assertEqual ( <NUM_LIT:0> , bgpPeerWorker2 . enqueue . call_count , <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" ) <EOL> self . assertEqual ( <NUM_LIT:2> , worker1 . enqueue . call_count , <EOL> "<STR_LIT>" ) <EOL> self . _checkEventsCalls ( worker1 . enqueue . call_args_list , <EOL> [ evt1 . routeEntry , evt2 . routeEntry ] , [ ] ) <EOL> self . assertEqual ( <NUM_LIT:4> , worker2 . enqueue . call_count , <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" ) <EOL> self . _checkEventsCalls ( worker2 . enqueue . call_args_list , <EOL> [ evt1 . routeEntry , evt2 . routeEntry ] , <EOL> [ evt1 . routeEntry . nlri , evt2 . routeEntry . nlri ] ) <EOL> def testB3_UnsubscriptionNotRegistered ( self ) : <EOL> worker1 = self . _newworker ( "<STR_LIT>" , Worker ) <EOL> self . _workerSubscriptions ( worker1 , [ RT1 ] ) <EOL> self . _workerUnsubscriptions ( worker1 , [ RT2 ] ) <EOL> bgpPeerWorker1 = self . _newworker ( "<STR_LIT>" , BGPPeerWorker ) <EOL> self . _workerUnsubscriptions ( bgpPeerWorker1 , [ RT1 , RT2 ] ) <EOL> self . _wait ( ) <EOL> self . _checkSubscriptions ( worker1 , [ MATCH1 ] ) <EOL> self . _checkUnsubscriptions ( bgpPeerWorker1 , [ MATCH1 , MATCH2 ] ) <EOL> def testC1_routeAdvertiseByWorkerWithoutPropagation ( self ) : <EOL> worker1 = self . _newworker ( "<STR_LIT>" , Worker ) <EOL> routeEvent = self . _newRouteEvent ( RouteEvent . ADVERTISE , NLRI1 , <EOL> [ RT1 , RT2 ] , worker1 , NH1 ) <EOL> self . _checkCalls ( worker1 , routeEvent . routeEntry ) <EOL> def testC2_routeWithdrawByWorkerWithoutPropagation ( self ) : <EOL> worker1 = self . _newworker ( "<STR_LIT>" , Worker ) <EOL> self . _newRouteEvent ( RouteEvent . ADVERTISE , NLRI1 , <EOL> [ RT1 , RT2 ] , worker1 , NH1 ) <EOL> routeEvent = self . _newRouteEvent ( RouteEvent . WITHDRAW , NLRI1 , <EOL> [ RT1 ] , worker1 , NH1 ) <EOL> self . _checkNoRouteEntry ( worker1 , routeEvent . routeEntry ) <EOL> def testC3_routeAdvertiseByBGPPeerWithPropagation ( self ) : <EOL> worker1 = self . _newworker ( "<STR_LIT>" , Worker ) <EOL> self . _workerSubscriptions ( worker1 , [ RT1 ] ) <EOL> worker2 = self . _newworker ( "<STR_LIT>" , Worker ) <EOL> self . _workerSubscriptions ( worker2 , [ RT2 ] ) <EOL> bgpPeerWorker1 = self . _newworker ( "<STR_LIT>" , BGPPeerWorker ) <EOL> self . _workerSubscriptions ( bgpPeerWorker1 , [ RT1 , RT2 ] ) <EOL> bgpPeerWorker2 = self . _newworker ( "<STR_LIT>" , BGPPeerWorker ) <EOL> self . _workerSubscriptions ( bgpPeerWorker2 , [ RT1 , RT2 ] ) <EOL> routeEvent = self . _newRouteEvent ( RouteEvent . ADVERTISE , NLRI1 , <EOL> [ RT1 ] , bgpPeerWorker1 , NH1 ) <EOL> self . assertEqual ( <NUM_LIT:1> , worker1 . enqueue . call_count , <EOL> "<STR_LIT>" ) <EOL> self . _checkEventsCalls ( worker1 . enqueue . call_args_list , <EOL> [ routeEvent . routeEntry ] , [ ] ) <EOL> self . assertEqual ( <NUM_LIT:0> , worker2 . enqueue . call_count , <EOL> "<STR_LIT>" ) <EOL> self . assertEqual ( <NUM_LIT:0> , bgpPeerWorker1 . enqueue . call_count , <EOL> "<STR_LIT>" ) <EOL> self . assertEqual ( <NUM_LIT:0> , bgpPeerWorker2 . enqueue . call_count , <EOL> "<STR_LIT>" ) <EOL> def testC4_routeWithdrawByPeerWorkerWithPropagation ( self ) : <EOL> worker1 = self . _newworker ( "<STR_LIT>" , Worker ) <EOL> self . _workerSubscriptions ( worker1 , [ RT1 ] ) <EOL> worker2 = self . _newworker ( "<STR_LIT>" , Worker ) <EOL> self . _workerSubscriptions ( worker2 , [ RT2 ] ) <EOL> worker3 = self . _newworker ( "<STR_LIT>" , Worker ) <EOL> self . _workerSubscriptions ( worker3 , [ RT3 ] ) <EOL> bgpPeerWorker1 = self . _newworker ( "<STR_LIT>" , BGPPeerWorker ) <EOL> self . _workerSubscriptions ( bgpPeerWorker1 , [ RT1 ] ) <EOL> bgpPeerWorker2 = self . _newworker ( "<STR_LIT>" , BGPPeerWorker ) <EOL> self . _workerSubscriptions ( bgpPeerWorker2 , [ RT2 ] ) <EOL> routeEventA = self . _newRouteEvent ( RouteEvent . ADVERTISE , NLRI1 , <EOL> [ RT1 , RT2 ] , bgpPeerWorker1 , NH1 ) <EOL> routeEventW = self . _newRouteEvent ( RouteEvent . WITHDRAW , NLRI1 , <EOL> [ ] , bgpPeerWorker1 , NH1 ) <EOL> self . assertEqual ( <NUM_LIT:2> , worker1 . enqueue . call_count , <EOL> "<STR_LIT>" ) <EOL> self . _checkEventsCalls ( worker1 . enqueue . call_args_list , <EOL> [ routeEventA . routeEntry ] , <EOL> [ routeEventW . routeEntry . nlri ] ) <EOL> self . assertEqual ( <NUM_LIT:2> , worker2 . enqueue . call_count , <EOL> "<STR_LIT>" ) <EOL> self . _checkEventsCalls ( worker2 . enqueue . call_args_list , <EOL> [ routeEventA . routeEntry ] , <EOL> [ routeEventW . routeEntry . nlri ] ) <EOL> self . assertEqual ( <NUM_LIT:0> , worker3 . enqueue . call_count , <EOL> "<STR_LIT>" ) <EOL> self . assertEqual ( <NUM_LIT:0> , bgpPeerWorker1 . enqueue . call_count , <EOL> "<STR_LIT>" ) <EOL> self . assertEqual ( <NUM_LIT:0> , bgpPeerWorker2 . enqueue . call_count , <EOL> "<STR_LIT>" ) <EOL> def testC5_routeUpdateByBGPPeerWithWithdrawPropagation ( self ) : <EOL> worker1 = self . _newworker ( "<STR_LIT>" , Worker ) <EOL> self . _workerSubscriptions ( worker1 , [ RT1 ] ) <EOL> worker2 = self . _newworker ( "<STR_LIT>" , Worker ) <EOL> self . _workerSubscriptions ( worker2 , [ RT2 ] ) <EOL> worker3 = self . _newworker ( "<STR_LIT>" , Worker ) <EOL> self . _workerSubscriptions ( worker3 , [ RT3 ] ) <EOL> bgpPeerWorker1 = self . _newworker ( <EOL> "<STR_LIT>" , BGPPeerWorker ) <EOL> evt1 = self . _newRouteEvent ( RouteEvent . ADVERTISE , NLRI1 , <EOL> [ RT1 , RT2 , RT3 ] , bgpPeerWorker1 , NH1 ) <EOL> evt2 = self . _newRouteEvent ( RouteEvent . ADVERTISE , NLRI1 , <EOL> [ RT1 , RT2 ] , bgpPeerWorker1 , NH2 ) <EOL> self . assertEqual ( <NUM_LIT:0> , bgpPeerWorker1 . enqueue . call_count , <EOL> "<STR_LIT>" ) <EOL> self . assertEqual ( <NUM_LIT:2> , worker1 . enqueue . call_count , <EOL> "<STR_LIT>" ) <EOL> self . _checkEventsCalls ( worker1 . enqueue . call_args_list , <EOL> [ evt1 . routeEntry , evt2 . routeEntry ] , [ ] ) <EOL> self . assertEqual ( <NUM_LIT:2> , worker2 . enqueue . call_count , <EOL> "<STR_LIT>" ) <EOL> self . _checkEventsCalls ( worker2 . enqueue . call_args_list , <EOL> [ evt1 . routeEntry , evt2 . routeEntry ] , [ ] ) <EOL> self . assertEqual ( <NUM_LIT:2> , worker3 . enqueue . call_count , <EOL> "<STR_LIT>" ) <EOL> self . _checkEventsCalls ( worker3 . enqueue . call_args_list , <EOL> [ evt1 . routeEntry ] , [ evt1 . routeEntry . nlri ] ) <EOL> def testC6_routeReadvertised ( self ) : <EOL> worker1 = self . _newworker ( "<STR_LIT>" , Worker ) <EOL> self . _workerSubscriptions ( worker1 , [ RT1 , RT2 , RT3 ] ) <EOL> bgpPeerWorker1 = self . _newworker ( "<STR_LIT>" , BGPPeerWorker ) <EOL> evt1 = self . _newRouteEvent ( RouteEvent . ADVERTISE , NLRI1 , [ RT1 , RT2 ] , <EOL> bgpPeerWorker1 , NH1 ) <EOL> self . _newRouteEvent ( RouteEvent . ADVERTISE , NLRI1 , [ RT1 , RT2 ] , <EOL> bgpPeerWorker1 , NH1 ) <EOL> self . assertEqual ( <NUM_LIT:0> , bgpPeerWorker1 . enqueue . call_count , <EOL> "<STR_LIT>" ) <EOL> self . assertEqual ( <NUM_LIT:1> , worker1 . enqueue . call_count , <EOL> "<STR_LIT>" ) <EOL> self . _checkEventsCalls ( worker1 . enqueue . call_args_list , <EOL> [ evt1 . routeEntry ] , [ ] ) <EOL> def testC7_routeWithdrawNotRegistered ( self ) : <EOL> worker1 = self . _newworker ( "<STR_LIT>" , Worker ) <EOL> self . _workerSubscriptions ( worker1 , [ RT1 , RT2 ] ) <EOL> bgpPeerWorker1 = self . _newworker ( <EOL> "<STR_LIT>" , BGPPeerWorker ) <EOL> evt1 = self . _newRouteEvent ( RouteEvent . ADVERTISE , NLRI1 , [ RT1 , RT2 ] , <EOL> bgpPeerWorker1 , NH1 ) <EOL> self . _newRouteEvent ( RouteEvent . WITHDRAW , NLRI2 , [ ] , <EOL> bgpPeerWorker1 , NH1 ) <EOL> self . _wait ( ) <EOL> self . assertEqual ( <NUM_LIT:1> , worker1 . enqueue . call_count , <EOL> "<STR_LIT>" ) <EOL> self . _checkEventsCalls ( worker1 . enqueue . call_args_list , <EOL> [ evt1 . routeEntry ] , [ ] ) <EOL> self . assertEqual ( <NUM_LIT:0> , bgpPeerWorker1 . enqueue . call_count , <EOL> "<STR_LIT>" ) <EOL> def testD1_WorkerCleanup ( self ) : <EOL> worker1 = self . _newworker ( "<STR_LIT>" , Worker ) <EOL> self . _workerSubscriptions ( worker1 , [ RT1 ] ) <EOL> worker2 = self . _newworker ( "<STR_LIT>" , Worker ) <EOL> self . _workerSubscriptions ( worker2 , [ RT2 ] ) <EOL> bgpPeerWorker1 = self . _newworker ( <EOL> "<STR_LIT>" , BGPPeerWorker ) <EOL> self . _workerSubscriptions ( bgpPeerWorker1 , [ RT1 , RT2 ] ) <EOL> evt1 = self . _newRouteEvent ( RouteEvent . ADVERTISE , NLRI1 , [ RT1 , RT2 ] , <EOL> bgpPeerWorker1 , NH1 ) <EOL> evt2 = self . _newRouteEvent ( RouteEvent . ADVERTISE , NLRI2 , [ RT2 ] , <EOL> bgpPeerWorker1 , NH1 ) <EOL> self . routeTableManager . enqueue ( WorkerCleanupEvent ( bgpPeerWorker1 ) ) <EOL> self . _wait ( ) <EOL> self . _checkUnsubscriptions ( bgpPeerWorker1 , [ MATCH1 , MATCH2 ] ) <EOL> self . assertEqual ( <NUM_LIT:2> , worker1 . enqueue . call_count , <EOL> "<STR_LIT>" ) <EOL> self . _checkEventsCalls ( worker1 . enqueue . call_args_list , <EOL> [ evt1 . routeEntry ] , [ evt1 . routeEntry . nlri ] ) <EOL> self . assertEqual ( <NUM_LIT:4> , worker2 . enqueue . call_count , <EOL> "<STR_LIT>" ) <EOL> self . _checkEventsCalls ( worker2 . enqueue . call_args_list , <EOL> [ evt1 . routeEntry , evt2 . routeEntry ] , <EOL> [ evt1 . routeEntry . nlri , evt2 . routeEntry . nlri ] ) <EOL> self . _checkNoRouteEntry ( bgpPeerWorker1 , evt1 . routeEntry ) <EOL> self . _checkNoRouteEntry ( bgpPeerWorker1 , evt2 . routeEntry ) <EOL> def testE1_DumpState ( self ) : <EOL> bgpPeerWorker1 = self . _newworker ( "<STR_LIT>" , BGPPeerWorker ) <EOL> self . _newRouteEvent ( RouteEvent . ADVERTISE , NLRI1 , <EOL> [ RT1 , RT2 ] , bgpPeerWorker1 , NH1 ) <EOL> self . _newRouteEvent ( RouteEvent . ADVERTISE , NLRI2 , <EOL> [ RT2 ] , bgpPeerWorker1 , NH1 ) <EOL> self . _workerSubscriptions ( bgpPeerWorker1 , [ RT1 ] ) <EOL> worker1 = self . _newworker ( "<STR_LIT>" , Worker ) <EOL> self . _workerSubscriptions ( worker1 , [ RT1 , RT2 ] ) <EOL> worker2 = self . _newworker ( "<STR_LIT>" , Worker ) <EOL> self . _workerSubscriptions ( worker2 , [ RT1 ] ) <EOL> worker3 = self . _newworker ( "<STR_LIT>" , Worker ) <EOL> self . _workerSubscriptions ( worker3 , [ RT3 ] ) <EOL> self . _wait ( ) <EOL> self . routeTableManager . _dumpState ( ) <EOL> def testF1_testEmptyRT ( self ) : <EOL> w1 = self . _newworker ( "<STR_LIT>" , Worker ) <EOL> subscribe = Subscription ( AFI ( AFI . ipv4 ) , <EOL> SAFI ( SAFI . mpls_vpn ) , <EOL> None , w1 ) <EOL> self . routeTableManager . enqueue ( subscribe ) <EOL> w2 = self . _newworker ( "<STR_LIT>" , Worker ) <EOL> routeEvent = RouteEvent ( RouteEvent . ADVERTISE , RouteEntry ( <EOL> AFI ( AFI . ipv4 ) , SAFI ( SAFI . mpls_vpn ) , None , NLRI1 , Attributes ( ) , w2 ) , w2 ) <EOL> self . routeTableManager . enqueue ( routeEvent ) <EOL> self . _wait ( ) <EOL> self . assertEqual ( <NUM_LIT:1> , w1 . enqueue . call_count , <EOL> "<STR_LIT>" ) </s>
