github.com/osrg/gobgp@v2.0.0+incompatible/test/scenario_test/rtc_test.py (about)

     1  # Copyright (C) 2016 Nippon Telegraph and Telephone Corporation.
     2  #
     3  # Licensed under the Apache License, Version 2.0 (the "License");
     4  # you may not use this file except in compliance with the License.
     5  # You may obtain a copy of the License at
     6  #
     7  #    http://www.apache.org/licenses/LICENSE-2.0
     8  #
     9  # Unless required by applicable law or agreed to in writing, software
    10  # distributed under the License is distributed on an "AS IS" BASIS,
    11  # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
    12  # implied.
    13  # See the License for the specific language governing permissions and
    14  # limitations under the License.
    15  
    16  from __future__ import absolute_import
    17  
    18  from itertools import combinations
    19  import sys
    20  import time
    21  import unittest
    22  
    23  from fabric.api import local
    24  import nose
    25  
    26  from lib.noseplugin import OptionParser, parser_option
    27  
    28  from lib import base
    29  from lib.base import BGP_FSM_ESTABLISHED
    30  from lib.gobgp import GoBGPContainer
    31  
    32  
    33  class GoBGPTestBase(unittest.TestCase):
    34  
    35      def assert_adv_count(self, src, dst, rf, count):
    36          self.assertEqual(count, len(src.get_adj_rib_out(dst, rf=rf)))
    37          self.assertEqual(count, len(dst.get_adj_rib_in(src, rf=rf)))
    38  
    39      def assert_upd_count(self, src, dst, sent, received):
    40          messages = src.get_neighbor(dst)['state']['messages']
    41          self.assertEqual(messages['sent'].get('update', 0), sent)
    42          self.assertEqual(messages['received'].get('update', 0), received)
    43  
    44      @classmethod
    45      def setUpClass(cls):
    46          # +----+              +----+
    47          # | g1 |----(iBGP)----| g2 |
    48          # +----+              +----+
    49          gobgp_ctn_image_name = parser_option.gobgp_image
    50          base.TEST_PREFIX = parser_option.test_prefix
    51  
    52          g1 = GoBGPContainer(name='g1', asn=65000, router_id='192.168.0.1',
    53                              ctn_image_name=gobgp_ctn_image_name,
    54                              log_level=parser_option.gobgp_log_level)
    55          g2 = GoBGPContainer(name='g2', asn=65000, router_id='192.168.0.2',
    56                              ctn_image_name=gobgp_ctn_image_name,
    57                              log_level=parser_option.gobgp_log_level)
    58  
    59          time.sleep(max(ctn.run() for ctn in [g1, g2]))
    60  
    61          g1.local("gobgp vrf add vrf1 rd 100:100 rt both 100:100")
    62          g1.local("gobgp vrf add vrf2 rd 200:200 rt both 200:200")
    63          g2.local("gobgp vrf add vrf1 rd 100:100 rt both 100:100")
    64          g2.local("gobgp vrf add vrf3 rd 300:300 rt both 300:300")
    65  
    66          g1.local("gobgp vrf vrf1 rib add 10.0.0.0/24")
    67          g1.local("gobgp vrf vrf2 rib add 10.0.0.0/24")
    68          g2.local("gobgp vrf vrf1 rib add 20.0.0.0/24")
    69          g2.local("gobgp vrf vrf3 rib add 20.0.0.0/24")
    70  
    71          cls.g1 = g1
    72          cls.g2 = g2
    73  
    74      # Test the problem which was reported on #1682
    75      # https://github.com/osrg/gobgp/issues/1682
    76      def test_01_neighbor_estabslihed_with_conflict_rtc_config(self):
    77          self.g1.add_peer(self.g2, vpn=True, passwd='rtc', graceful_restart=True)
    78          self.g2.add_peer(self.g1, vpn=False, passwd='rtc', graceful_restart=True)
    79          self.g1.wait_for(expected_state=BGP_FSM_ESTABLISHED, peer=self.g2)
    80  
    81      # test each neighbor state is turned establish
    82      def test_02_neighbor_established(self):
    83          self.g2.update_peer(self.g1, vpn=True, passwd='rtc', graceful_restart=True)
    84          self.g1.wait_for(expected_state=BGP_FSM_ESTABLISHED, peer=self.g2)
    85  
    86      def test_03_check_adj_rib(self):
    87          # VRF<#>  g1   g2
    88          #   1     (*)  (*)
    89          #   2     (*)
    90          #   3          (*)
    91          #
    92          # ( ): Empty VRF  (*): VRF with a route
    93          self.assert_adv_count(self.g1, self.g2, 'rtc', 2)
    94          self.assert_adv_count(self.g1, self.g2, 'ipv4-l3vpn', 1)
    95  
    96          self.assert_adv_count(self.g2, self.g1, 'rtc', 2)
    97          self.assert_adv_count(self.g2, self.g1, 'ipv4-l3vpn', 1)
    98  
    99      def test_04_add_vrf(self):
   100          # VRF<#>  g1   g2
   101          #   1     (*)  (*)
   102          #   2     (*)
   103          #   3     ( )  (*)
   104          self.g1.local("gobgp vrf add vrf3 rd 300:300 rt both 300:300")
   105          time.sleep(1)
   106  
   107          self.assert_adv_count(self.g1, self.g2, 'rtc', 3)
   108          self.assert_adv_count(self.g1, self.g2, 'ipv4-l3vpn', 1)
   109  
   110          self.assert_adv_count(self.g2, self.g1, 'rtc', 2)
   111          self.assert_adv_count(self.g2, self.g1, 'ipv4-l3vpn', 2)
   112  
   113      def test_05_add_route_on_vrf(self):
   114          # VRF<#>  g1   g2
   115          #   1     (*)  (*)
   116          #   2     (*)
   117          #   3     (*)  (*)
   118          self.g1.local("gobgp vrf vrf3 rib add 10.0.0.0/24")
   119          time.sleep(1)
   120  
   121          self.assert_adv_count(self.g1, self.g2, 'rtc', 3)
   122          self.assert_adv_count(self.g1, self.g2, 'ipv4-l3vpn', 2)
   123  
   124          self.assert_adv_count(self.g2, self.g1, 'rtc', 2)
   125          self.assert_adv_count(self.g2, self.g1, 'ipv4-l3vpn', 2)
   126  
   127      def test_06_del_route_on_vrf(self):
   128          # VRF<#>  g1   g2
   129          #   1     (*)  (*)
   130          #   2     (*)
   131          #   3     ( )  (*)
   132          self.g1.local("gobgp vrf vrf3 rib del 10.0.0.0/24")
   133          time.sleep(1)
   134  
   135          self.assert_adv_count(self.g1, self.g2, 'rtc', 3)
   136          self.assert_adv_count(self.g1, self.g2, 'ipv4-l3vpn', 1)
   137  
   138          self.assert_adv_count(self.g2, self.g1, 'rtc', 2)
   139          self.assert_adv_count(self.g2, self.g1, 'ipv4-l3vpn', 2)
   140  
   141      def test_07_del_vrf(self):
   142          # VRF<#>  g1   g2
   143          #   1     (*)  (*)
   144          #   2     (*)
   145          #   3          (*)
   146          self.g1.local("gobgp vrf del vrf3")
   147          time.sleep(1)
   148  
   149          self.assert_adv_count(self.g1, self.g2, 'rtc', 2)
   150          self.assert_adv_count(self.g1, self.g2, 'ipv4-l3vpn', 1)
   151  
   152          self.assert_adv_count(self.g2, self.g1, 'rtc', 2)
   153          self.assert_adv_count(self.g2, self.g1, 'ipv4-l3vpn', 1)
   154  
   155      def test_08_del_vrf_with_route(self):
   156          # VRF<#>  g1   g2
   157          #   1          (*)
   158          #   2     (*)
   159          #   3          (*)
   160          self.g1.local("gobgp vrf del vrf1")
   161          time.sleep(1)
   162  
   163          self.assert_adv_count(self.g1, self.g2, 'rtc', 1)
   164          self.assert_adv_count(self.g1, self.g2, 'ipv4-l3vpn', 0)
   165  
   166          self.assert_adv_count(self.g2, self.g1, 'rtc', 2)
   167          self.assert_adv_count(self.g2, self.g1, 'ipv4-l3vpn', 0)
   168  
   169      def test_09_cleanup(self):
   170          self.g1.local("gobgp vrf del vrf2")
   171          self.g2.local("gobgp vrf del vrf1")
   172          self.g2.local("gobgp vrf del vrf3")
   173  
   174      def test_10_rr_setup(self):
   175          #               +------+
   176          #               |  g3  |
   177          #        +------| (RR) |------+
   178          #        |      +------+      |
   179          #      (iBGP)              (iBGP)
   180          #        |                    |
   181          # +-------------+      +-------------+
   182          # |     g4      |      |     g5      |
   183          # | (RR Client) |      | (RR Client) |
   184          # +-------------+      +-------------+
   185          gobgp_ctn_image_name = parser_option.gobgp_image
   186          g3 = GoBGPContainer(name='g3', asn=65000, router_id='192.168.0.3',
   187                              ctn_image_name=gobgp_ctn_image_name,
   188                              log_level=parser_option.gobgp_log_level)
   189          g4 = GoBGPContainer(name='g4', asn=65000, router_id='192.168.0.4',
   190                              ctn_image_name=gobgp_ctn_image_name,
   191                              log_level=parser_option.gobgp_log_level)
   192          g5 = GoBGPContainer(name='g5', asn=65000, router_id='192.168.0.5',
   193                              ctn_image_name=gobgp_ctn_image_name,
   194                              log_level=parser_option.gobgp_log_level)
   195  
   196          time.sleep(max(ctn.run() for ctn in [g3, g4, g5]))
   197  
   198          g3.add_peer(g4, vpn=True, is_rr_client=True)
   199          g4.add_peer(g3, vpn=True)
   200  
   201          g3.add_peer(g5, vpn=True, is_rr_client=True)
   202          g5.add_peer(g3, vpn=True)
   203  
   204          g3.wait_for(expected_state=BGP_FSM_ESTABLISHED, peer=g4)
   205          g3.wait_for(expected_state=BGP_FSM_ESTABLISHED, peer=g5)
   206  
   207          self.__class__.g3 = g3
   208          self.__class__.g4 = g4
   209          self.__class__.g5 = g5
   210  
   211      def test_11_rr_check_adj_rib_from_rr(self):
   212          # VRF<#>  g3   g4   g5
   213          #   1          ( )  ( )
   214          #   2
   215          #   3
   216          self.g4.local("gobgp vrf add vrf1 rd 100:100 rt both 100:100")
   217          self.g5.local("gobgp vrf add vrf1 rd 100:100 rt both 100:100")
   218          time.sleep(1)
   219  
   220          # Check the counts of the sent UPDATE messages in order to detect the
   221          # infinite RTC UPDATE loop.
   222          # https://github.com/osrg/gobgp/issues/1630
   223          self.assert_upd_count(self.g4, self.g3, sent=1, received=2)
   224          self.assert_upd_count(self.g5, self.g3, sent=1, received=2)
   225  
   226          def check_rtc(client):
   227              rib = self.g3.get_adj_rib_out(client, rf='rtc')
   228              self.assertEqual(1, len(rib))
   229              path = rib[0]
   230              self.assertEqual(self.g3.peers[client]['local_addr'].split('/')[0], path['nexthop'])
   231              ids = [attr['value'] for attr in path['attrs'] if attr['type'] == base.BGP_ATTR_TYPE_ORIGINATOR_ID]
   232              self.assertEqual(1, len(ids))
   233              self.assertEqual(self.g3.router_id, ids[0])
   234  
   235          check_rtc(self.g4)
   236          check_rtc(self.g5)
   237  
   238          # VRF<#>  g3   g4   g5
   239          #   1          (*)  (*)
   240          #   2
   241          #   3
   242          self.g4.local("gobgp vrf vrf1 rib add 40.0.0.0/24")
   243          self.g5.local("gobgp vrf vrf1 rib add 50.0.0.0/24")
   244          time.sleep(1)
   245  
   246          def check_ipv4_l3vpn(client):
   247              rib = self.g3.get_adj_rib_out(client, rf='ipv4-l3vpn')
   248              self.assertEqual(1, len(rib))
   249              path = rib[0]
   250              self.assertNotEqual(self.g3.peers[client]['local_addr'].split('/')[0], path['nexthop'])
   251              ids = [attr['value'] for attr in path['attrs'] if attr['type'] == base.BGP_ATTR_TYPE_ORIGINATOR_ID]
   252              self.assertEqual(1, len(ids))
   253              self.assertNotEqual(client.router_id, ids[0])
   254  
   255          check_ipv4_l3vpn(self.g4)
   256          check_ipv4_l3vpn(self.g5)
   257  
   258      def test_12_rr_add_vrf(self):
   259          # VRF<#>  g3   g4   g5
   260          #   1          (*)  (*)
   261          #   2          ( )
   262          #   3
   263          self.g4.local("gobgp vrf add vrf2 rd 200:200 rt both 200:200")
   264          time.sleep(1)
   265  
   266          self.assert_adv_count(self.g4, self.g3, 'rtc', 2)
   267          self.assert_adv_count(self.g4, self.g3, 'ipv4-l3vpn', 1)
   268  
   269          self.assert_adv_count(self.g3, self.g4, 'rtc', 2)
   270          self.assert_adv_count(self.g3, self.g4, 'ipv4-l3vpn', 1)
   271  
   272          self.assert_adv_count(self.g5, self.g3, 'rtc', 1)
   273          self.assert_adv_count(self.g5, self.g3, 'ipv4-l3vpn', 1)
   274  
   275          self.assert_adv_count(self.g3, self.g5, 'rtc', 2)
   276          self.assert_adv_count(self.g3, self.g5, 'ipv4-l3vpn', 1)
   277  
   278      def test_13_rr_add_route_on_vrf(self):
   279          # VRF<#>  g3   g4   g5
   280          #   1          (*)  (*)
   281          #   2          (*)
   282          #   3
   283          self.g4.local("gobgp vrf vrf2 rib add 40.0.0.0/24")
   284          time.sleep(1)
   285  
   286          self.assert_adv_count(self.g4, self.g3, 'rtc', 2)
   287          self.assert_adv_count(self.g4, self.g3, 'ipv4-l3vpn', 2)
   288  
   289          self.assert_adv_count(self.g3, self.g4, 'rtc', 2)
   290          self.assert_adv_count(self.g3, self.g4, 'ipv4-l3vpn', 1)
   291  
   292          self.assert_adv_count(self.g5, self.g3, 'rtc', 1)
   293          self.assert_adv_count(self.g5, self.g3, 'ipv4-l3vpn', 1)
   294  
   295          self.assert_adv_count(self.g3, self.g5, 'rtc', 2)
   296          self.assert_adv_count(self.g3, self.g5, 'ipv4-l3vpn', 1)
   297  
   298      def test_14_rr_del_vrf_with_route(self):
   299          # VRF<#>  g3   g4   g5
   300          #   1               (*)
   301          #   2          (*)
   302          #   3
   303          self.g4.local("gobgp vrf del vrf1")
   304          time.sleep(1)
   305  
   306          self.assert_adv_count(self.g4, self.g3, 'rtc', 1)
   307          self.assert_adv_count(self.g4, self.g3, 'ipv4-l3vpn', 1)
   308  
   309          self.assert_adv_count(self.g3, self.g4, 'rtc', 2)
   310          self.assert_adv_count(self.g3, self.g4, 'ipv4-l3vpn', 0)
   311  
   312          self.assert_adv_count(self.g5, self.g3, 'rtc', 1)
   313          self.assert_adv_count(self.g5, self.g3, 'ipv4-l3vpn', 1)
   314  
   315          self.assert_adv_count(self.g3, self.g5, 'rtc', 2)
   316          self.assert_adv_count(self.g3, self.g5, 'ipv4-l3vpn', 0)
   317  
   318      def test_15_rr_cleanup(self):
   319          self.g4.local("gobgp vrf del vrf2")
   320          self.g5.local("gobgp vrf del vrf1")
   321  
   322      def test_20_rr_and_non_rr_setup(self):
   323          # +----------+            +----------+
   324          # |    g1    |---(iBGP)---|    g2    |
   325          # | (Non RR  |            | (Non RR  |
   326          # |  Client) |            |  Client) |
   327          # +----------+            +----------+
   328          #      |                        |
   329          #      +--(iBGP)--+  +--(iBGP)--+
   330          #                 |  |
   331          #               +------+
   332          #               |  g3  |
   333          #        +------| (RR) |------+
   334          #        |      +------+      |
   335          #      (iBGP)              (iBGP)
   336          #        |                    |
   337          # +-------------+      +-------------+
   338          # |     g4      |      |     g5      |
   339          # | (RR Client) |      | (RR Client) |
   340          # +-------------+      +-------------+
   341          self.g3.add_peer(self.g1, vpn=True)
   342          self.g1.add_peer(self.g3, vpn=True)
   343          self.g3.add_peer(self.g2, vpn=True)
   344          self.g2.add_peer(self.g3, vpn=True)
   345  
   346          self.g3.wait_for(expected_state=BGP_FSM_ESTABLISHED, peer=self.g1)
   347          self.g3.wait_for(expected_state=BGP_FSM_ESTABLISHED, peer=self.g2)
   348  
   349      def test_21_rr_and_non_rr_add_vrf_on_rr_clients(self):
   350          # VRF<#>  g1   g2   g3   g4   g5
   351          #   1                    (*)  (*)
   352          #   2
   353          #   3
   354          self.g4.local("gobgp vrf add vrf1 rd 100:100 rt both 100:100")
   355          self.g5.local("gobgp vrf add vrf1 rd 100:100 rt both 100:100")
   356          self.g4.local("gobgp vrf vrf1 rib add 40.0.0.0/24")
   357          self.g5.local("gobgp vrf vrf1 rib add 50.0.0.0/24")
   358          time.sleep(1)
   359  
   360          self.assert_adv_count(self.g4, self.g3, 'rtc', 1)
   361          self.assert_adv_count(self.g4, self.g3, 'ipv4-l3vpn', 1)
   362  
   363          self.assert_adv_count(self.g3, self.g1, 'rtc', 1)
   364          self.assert_adv_count(self.g3, self.g1, 'ipv4-l3vpn', 0)
   365  
   366          self.assert_adv_count(self.g1, self.g3, 'rtc', 0)
   367          self.assert_adv_count(self.g1, self.g3, 'ipv4-l3vpn', 0)
   368  
   369          self.assert_adv_count(self.g3, self.g4, 'rtc', 1)
   370          self.assert_adv_count(self.g3, self.g4, 'ipv4-l3vpn', 1)
   371  
   372      def test_22_rr_and_non_rr_add_vrf_on_non_rr_client(self):
   373          # VRF<#>  g1   g2   g3   g4   g5
   374          #   1     (*)            (*)  (*)
   375          #   2
   376          #   3
   377          self.g1.local("gobgp vrf add vrf1 rd 100:100 rt both 100:100")
   378          self.g1.local("gobgp vrf vrf1 rib add 10.0.0.0/24")
   379          time.sleep(1)
   380  
   381          self.assert_adv_count(self.g4, self.g3, 'rtc', 1)
   382          self.assert_adv_count(self.g4, self.g3, 'ipv4-l3vpn', 1)
   383  
   384          self.assert_adv_count(self.g5, self.g3, 'rtc', 1)
   385          self.assert_adv_count(self.g5, self.g3, 'ipv4-l3vpn', 1)
   386  
   387          self.assert_adv_count(self.g3, self.g1, 'rtc', 1)
   388          self.assert_adv_count(self.g3, self.g1, 'ipv4-l3vpn', 2)
   389  
   390          self.assert_adv_count(self.g3, self.g2, 'rtc', 1)
   391          self.assert_adv_count(self.g3, self.g2, 'ipv4-l3vpn', 0)
   392  
   393          self.assert_adv_count(self.g1, self.g3, 'rtc', 1)
   394          self.assert_adv_count(self.g1, self.g3, 'ipv4-l3vpn', 1)
   395  
   396          self.assert_adv_count(self.g2, self.g3, 'rtc', 0)
   397          self.assert_adv_count(self.g2, self.g3, 'ipv4-l3vpn', 0)
   398  
   399          self.assert_adv_count(self.g3, self.g4, 'rtc', 1)
   400          self.assert_adv_count(self.g3, self.g4, 'ipv4-l3vpn', 2)
   401  
   402          self.assert_adv_count(self.g3, self.g5, 'rtc', 1)
   403          self.assert_adv_count(self.g3, self.g5, 'ipv4-l3vpn', 2)
   404  
   405      def test_23_rr_and_non_rr_add_another_vrf_on_non_rr_client(self):
   406          # VRF<#>  g1   g2   g3   g4   g5
   407          #   1     (*)            (*)  (*)
   408          #   2          (*)
   409          #   3
   410          self.g2.local("gobgp vrf add vrf2 rd 200:200 rt both 200:200")
   411          self.g2.local("gobgp vrf vrf2 rib add 20.0.0.0/24")
   412          time.sleep(1)
   413  
   414          self.assert_adv_count(self.g4, self.g3, 'rtc', 1)
   415          self.assert_adv_count(self.g4, self.g3, 'ipv4-l3vpn', 1)
   416  
   417          self.assert_adv_count(self.g5, self.g3, 'rtc', 1)
   418          self.assert_adv_count(self.g5, self.g3, 'ipv4-l3vpn', 1)
   419  
   420          self.assert_adv_count(self.g3, self.g1, 'rtc', 1)
   421          self.assert_adv_count(self.g3, self.g1, 'ipv4-l3vpn', 2)
   422  
   423          self.assert_adv_count(self.g3, self.g2, 'rtc', 1)
   424          self.assert_adv_count(self.g3, self.g2, 'ipv4-l3vpn', 0)
   425  
   426          self.assert_adv_count(self.g1, self.g3, 'rtc', 1)
   427          self.assert_adv_count(self.g1, self.g3, 'ipv4-l3vpn', 1)
   428  
   429          self.assert_adv_count(self.g2, self.g3, 'rtc', 1)
   430          self.assert_adv_count(self.g2, self.g3, 'ipv4-l3vpn', 0)
   431  
   432          self.assert_adv_count(self.g3, self.g4, 'rtc', 2)
   433          self.assert_adv_count(self.g3, self.g4, 'ipv4-l3vpn', 2)
   434  
   435          self.assert_adv_count(self.g3, self.g5, 'rtc', 2)
   436          self.assert_adv_count(self.g3, self.g5, 'ipv4-l3vpn', 2)
   437  
   438      def test_24_rr_and_non_rr_add_another_vrf_on_rr_client(self):
   439          # VRF<#>  g1   g2   g3   g4   g5
   440          #   1     (*)            (*)  (*)
   441          #   2          (*)       (*)
   442          #   3
   443          self.g4.local("gobgp vrf add vrf2 rd 200:200 rt both 200:200")
   444          self.g4.local("gobgp vrf vrf2 rib add 40.0.0.0/24")
   445          time.sleep(1)
   446  
   447          self.assert_adv_count(self.g4, self.g3, 'rtc', 2)
   448          self.assert_adv_count(self.g4, self.g3, 'ipv4-l3vpn', 2)
   449  
   450          self.assert_adv_count(self.g5, self.g3, 'rtc', 1)
   451          self.assert_adv_count(self.g5, self.g3, 'ipv4-l3vpn', 1)
   452  
   453          self.assert_adv_count(self.g3, self.g1, 'rtc', 2)
   454          self.assert_adv_count(self.g3, self.g1, 'ipv4-l3vpn', 2)
   455  
   456          self.assert_adv_count(self.g3, self.g2, 'rtc', 2)
   457          self.assert_adv_count(self.g3, self.g2, 'ipv4-l3vpn', 1)
   458  
   459          self.assert_adv_count(self.g1, self.g3, 'rtc', 1)
   460          self.assert_adv_count(self.g1, self.g3, 'ipv4-l3vpn', 1)
   461  
   462          self.assert_adv_count(self.g2, self.g3, 'rtc', 1)
   463          self.assert_adv_count(self.g2, self.g3, 'ipv4-l3vpn', 1)
   464  
   465          self.assert_adv_count(self.g3, self.g4, 'rtc', 2)
   466          self.assert_adv_count(self.g3, self.g4, 'ipv4-l3vpn', 3)
   467  
   468          self.assert_adv_count(self.g3, self.g5, 'rtc', 2)
   469          self.assert_adv_count(self.g3, self.g5, 'ipv4-l3vpn', 2)
   470  
   471      def test_25_rr_and_non_rr_clenup(self):
   472          self.g1.local("gobgp vrf del vrf1")
   473          self.g2.local("gobgp vrf del vrf2")
   474          self.g4.local("gobgp vrf del vrf1")
   475          self.g4.local("gobgp vrf del vrf2")
   476          self.g5.local("gobgp vrf del vrf1")
   477  
   478      def test_30_ebgp_setup(self):
   479          # +----+              +----+
   480          # | g6 |----(eBGP)----| g7 |
   481          # +----+              +----+
   482          gobgp_ctn_image_name = parser_option.gobgp_image
   483          g6 = GoBGPContainer(name='g6', asn=65001, router_id='192.168.0.6',
   484                              ctn_image_name=gobgp_ctn_image_name,
   485                              log_level=parser_option.gobgp_log_level)
   486          g7 = GoBGPContainer(name='g7', asn=65002, router_id='192.168.0.7',
   487                              ctn_image_name=gobgp_ctn_image_name,
   488                              log_level=parser_option.gobgp_log_level)
   489  
   490          time.sleep(max(ctn.run() for ctn in [g6, g7]))
   491  
   492          g6.local("gobgp vrf add vrf1 rd 100:100 rt both 100:100")
   493          g6.local("gobgp vrf add vrf2 rd 200:200 rt both 200:200")
   494          g7.local("gobgp vrf add vrf1 rd 100:100 rt both 100:100")
   495          g7.local("gobgp vrf add vrf3 rd 300:300 rt both 300:300")
   496  
   497          g6.local("gobgp vrf vrf1 rib add 60.0.0.0/24")
   498          g6.local("gobgp vrf vrf2 rib add 60.0.0.0/24")
   499          g7.local("gobgp vrf vrf1 rib add 70.0.0.0/24")
   500          g7.local("gobgp vrf vrf3 rib add 70.0.0.0/24")
   501  
   502          for a, b in combinations([g6, g7], 2):
   503              a.add_peer(b, vpn=True, passwd='rtc', graceful_restart=True)
   504              b.add_peer(a, vpn=True, passwd='rtc', graceful_restart=True)
   505  
   506          g6.wait_for(expected_state=BGP_FSM_ESTABLISHED, peer=g7)
   507  
   508          self.__class__.g6 = g6
   509          self.__class__.g7 = g7
   510  
   511      def test_31_ebgp_check_adj_rib(self):
   512          # VRF<#>  g6   g7
   513          #   1     (*)  (*)
   514          #   2     (*)
   515          #   3          (*)
   516          self.assert_adv_count(self.g6, self.g7, 'rtc', 2)
   517          self.assert_adv_count(self.g6, self.g7, 'ipv4-l3vpn', 1)
   518  
   519          self.assert_adv_count(self.g7, self.g6, 'rtc', 2)
   520          self.assert_adv_count(self.g7, self.g6, 'ipv4-l3vpn', 1)
   521  
   522      def test_32_ebgp_add_vrf(self):
   523          # VRF<#>  g6   g7
   524          #   1     (*)  (*)
   525          #   2     (*)
   526          #   3     ( )  (*)
   527          self.g6.local("gobgp vrf add vrf3 rd 300:300 rt both 300:300")
   528          time.sleep(1)
   529  
   530          self.assert_adv_count(self.g6, self.g7, 'rtc', 3)
   531          self.assert_adv_count(self.g6, self.g7, 'ipv4-l3vpn', 1)
   532  
   533          self.assert_adv_count(self.g7, self.g6, 'rtc', 2)
   534          self.assert_adv_count(self.g7, self.g6, 'ipv4-l3vpn', 2)
   535  
   536      def test_33_ebgp_add_route_on_vrf(self):
   537          # VRF<#>  g6   g7
   538          #   1     (*)  (*)
   539          #   2     (*)
   540          #   3     (*)  (*)
   541          self.g6.local("gobgp vrf vrf3 rib add 60.0.0.0/24")
   542          time.sleep(1)
   543  
   544          self.assert_adv_count(self.g6, self.g7, 'rtc', 3)
   545          self.assert_adv_count(self.g6, self.g7, 'ipv4-l3vpn', 2)
   546  
   547          self.assert_adv_count(self.g7, self.g6, 'rtc', 2)
   548          self.assert_adv_count(self.g7, self.g6, 'ipv4-l3vpn', 2)
   549  
   550      def test_34_ebgp_del_route_on_vrf(self):
   551          # VRF<#>  g6   g7
   552          #   1     (*)  (*)
   553          #   2     (*)
   554          #   3     ( )  (*)
   555          self.g6.local("gobgp vrf vrf3 rib del 60.0.0.0/24")
   556          time.sleep(1)
   557  
   558          self.assert_adv_count(self.g6, self.g7, 'rtc', 3)
   559          self.assert_adv_count(self.g6, self.g7, 'ipv4-l3vpn', 1)
   560  
   561          self.assert_adv_count(self.g7, self.g6, 'rtc', 2)
   562          self.assert_adv_count(self.g7, self.g6, 'ipv4-l3vpn', 2)
   563  
   564      def test_35_ebgp_del_vrf(self):
   565          # VRF<#>  g6   g7
   566          #   1     (*)  (*)
   567          #   2     (*)
   568          #   3          (*)
   569          self.g6.local("gobgp vrf del vrf3")
   570          time.sleep(1)
   571  
   572          self.assert_adv_count(self.g6, self.g7, 'rtc', 2)
   573          self.assert_adv_count(self.g6, self.g7, 'ipv4-l3vpn', 1)
   574  
   575          self.assert_adv_count(self.g7, self.g6, 'rtc', 2)
   576          self.assert_adv_count(self.g7, self.g6, 'ipv4-l3vpn', 1)
   577  
   578      def test_36_ebgp_del_vrf_with_route(self):
   579          # VRF<#>  g6   g7
   580          #   1          (*)
   581          #   2     (*)
   582          #   3          (*)
   583          self.g6.local("gobgp vrf del vrf1")
   584          time.sleep(1)
   585  
   586          self.assert_adv_count(self.g6, self.g7, 'rtc', 1)
   587          self.assert_adv_count(self.g6, self.g7, 'ipv4-l3vpn', 0)
   588  
   589          self.assert_adv_count(self.g7, self.g6, 'rtc', 2)
   590          self.assert_adv_count(self.g7, self.g6, 'ipv4-l3vpn', 0)
   591  
   592      def test_37_ebgp_cleanup(self):
   593          self.g6.local("gobgp vrf del vrf2")
   594          self.g7.local("gobgp vrf del vrf1")
   595          self.g7.local("gobgp vrf del vrf3")
   596  
   597      def test_40_ibgp_ebgp_setup(self):
   598          # +----------+            +----------+
   599          # |    g1    |---(iBGP)---|    g2    |
   600          # | (Non RR  |            | (Non RR  |
   601          # |  Client) |            |  Client) |
   602          # +----------+            +----------+
   603          #      |                        |
   604          #      +--(iBGP)--+  +--(iBGP)--+
   605          #                 |  |
   606          #               +------+                    +----+              +----+
   607          #               |  g3  |----------(eBGP)----| g6 |----(eBGP)----| g7 |
   608          #        +------| (RR) |------+             +----+              +----+
   609          #        |      +------+      |
   610          #      (iBGP)              (iBGP)
   611          #        |                    |
   612          # +-------------+      +-------------+
   613          # |     g4      |      |     g5      |
   614          # | (RR Client) |      | (RR Client) |
   615          # +-------------+      +-------------+
   616          g1, g2, g3, g4, g5, g6, g7 = (
   617              self.g1, self.g2, self.g3, self.g4, self.g5, self.g6, self.g7)
   618          g3.add_peer(g6, vpn=True)
   619          g6.add_peer(g3, vpn=True)
   620  
   621          g1.local("gobgp vrf add vrf1 rd 100:100 rt both 100:100")
   622          g2.local("gobgp vrf add vrf2 rd 200:200 rt both 200:200")
   623          # g3 (RR)
   624          g4.local("gobgp vrf add vrf1 rd 100:100 rt both 100:100")
   625          g5.local("gobgp vrf add vrf2 rd 200:200 rt both 200:200")
   626          g6.local("gobgp vrf add vrf1 rd 100:100 rt both 100:100")
   627          g7.local("gobgp vrf add vrf3 rd 300:300 rt both 300:300")
   628  
   629          g1.local("gobgp vrf vrf1 rib add 10.0.0.0/24")
   630          g2.local("gobgp vrf vrf2 rib add 20.0.0.0/24")
   631          # g3 (RR)
   632          g4.local("gobgp vrf vrf1 rib add 40.0.0.0/24")
   633          g5.local("gobgp vrf vrf2 rib add 50.0.0.0/24")
   634          g6.local("gobgp vrf vrf1 rib add 60.0.0.0/24")
   635          g7.local("gobgp vrf vrf3 rib add 70.0.0.0/24")
   636  
   637          g3.wait_for(expected_state=BGP_FSM_ESTABLISHED, peer=g6)
   638  
   639      def test_41_ibgp_ebgp_check_adj_rib(self):
   640          # VRF<#>  g1   g2   g3   g4   g5  | g6   g7
   641          #   1     (*)            (*)      | (*)
   642          #   2          (*)            (*) |
   643          #   3                             |      (*)
   644          self.assert_adv_count(self.g3, self.g6, 'rtc', 2)
   645          self.assert_adv_count(self.g3, self.g6, 'ipv4-l3vpn', 2)
   646  
   647          self.assert_adv_count(self.g6, self.g3, 'rtc', 2)
   648          self.assert_adv_count(self.g6, self.g3, 'ipv4-l3vpn', 1)
   649  
   650      def test_42_01_ibgp_ebgp_add_vrf_on_rr_client(self):
   651          # VRF<#>  g1   g2   g3   g4   g5  | g6   g7
   652          #   1     (*)            (*)      | (*)
   653          #   2          (*)            (*) |
   654          #   3                         ( ) |      (*)
   655          self.g5.local("gobgp vrf add vrf3 rd 300:300 rt both 300:300")
   656          time.sleep(1)
   657  
   658          self.assert_adv_count(self.g3, self.g6, 'rtc', 3)
   659          self.assert_adv_count(self.g3, self.g6, 'ipv4-l3vpn', 2)
   660  
   661          self.assert_adv_count(self.g6, self.g3, 'rtc', 2)
   662          self.assert_adv_count(self.g6, self.g3, 'ipv4-l3vpn', 2)
   663  
   664      def test_42_02_ibgp_ebgp_add_route_on_vrf_on_rr_client(self):
   665          # VRF<#>  g1   g2   g3   g4   g5  | g6   g7
   666          #   1     (*)            (*)      | (*)
   667          #   2          (*)            (*) |
   668          #   3                         (*) |      (*)
   669          self.g5.local("gobgp vrf vrf3 rib add 50.0.0.0/24")
   670          time.sleep(1)
   671  
   672          self.assert_adv_count(self.g3, self.g6, 'rtc', 3)
   673          self.assert_adv_count(self.g3, self.g6, 'ipv4-l3vpn', 3)
   674  
   675          self.assert_adv_count(self.g6, self.g3, 'rtc', 2)
   676          self.assert_adv_count(self.g6, self.g3, 'ipv4-l3vpn', 2)
   677  
   678      def test_42_03_ibgp_ebgp_del_route_on_vrf_on_rr_client(self):
   679          # VRF<#>  g1   g2   g3   g4   g5  | g6   g7
   680          #   1     (*)            (*)      | (*)
   681          #   2          (*)            (*) |
   682          #   3                         ( ) |      (*)
   683          self.g5.local("gobgp vrf vrf3 rib del 50.0.0.0/24")
   684          time.sleep(1)
   685  
   686          self.assert_adv_count(self.g3, self.g6, 'rtc', 3)
   687          self.assert_adv_count(self.g3, self.g6, 'ipv4-l3vpn', 2)
   688  
   689          self.assert_adv_count(self.g6, self.g3, 'rtc', 2)
   690          self.assert_adv_count(self.g6, self.g3, 'ipv4-l3vpn', 2)
   691  
   692      def test_42_04_ibgp_ebgp_del_vrf_on_rr_client(self):
   693          # VRF<#>  g1   g2   g3   g4   g5  | g6   g7
   694          #   1     (*)            (*)      | (*)
   695          #   2          (*)            (*) |
   696          #   3                             |      (*)
   697          self.g5.local("gobgp vrf del vrf3")
   698          time.sleep(2)
   699  
   700          self.assert_adv_count(self.g3, self.g6, 'rtc', 2)
   701          self.assert_adv_count(self.g3, self.g6, 'ipv4-l3vpn', 2)
   702  
   703          self.assert_adv_count(self.g6, self.g3, 'rtc', 2)
   704          self.assert_adv_count(self.g6, self.g3, 'ipv4-l3vpn', 1)
   705  
   706      def test_43_01_ibgp_ebgp_add_vrf_on_non_rr_client(self):
   707          # VRF<#>  g1   g2   g3   g4   g5  | g6   g7
   708          #   1     (*)            (*)      | (*)
   709          #   2          (*)            (*) |
   710          #   3     ( )                     |      (*)
   711          self.g1.local("gobgp vrf add vrf3 rd 300:300 rt both 300:300")
   712          time.sleep(1)
   713  
   714          self.assert_adv_count(self.g3, self.g6, 'rtc', 3)
   715          self.assert_adv_count(self.g3, self.g6, 'ipv4-l3vpn', 2)
   716  
   717          self.assert_adv_count(self.g6, self.g3, 'rtc', 2)
   718          self.assert_adv_count(self.g6, self.g3, 'ipv4-l3vpn', 2)
   719  
   720      def test_43_02_ibgp_ebgp_add_route_on_vrf_on_non_rr_client(self):
   721          # VRF<#>  g1   g2   g3   g4   g5  | g6   g7
   722          #   1     (*)            (*)      | (*)
   723          #   2          (*)            (*) |
   724          #   3     (*)                     |      (*)
   725          self.g1.local("gobgp vrf vrf3 rib add 10.0.0.0/24")
   726          time.sleep(1)
   727  
   728          self.assert_adv_count(self.g3, self.g6, 'rtc', 3)
   729          self.assert_adv_count(self.g3, self.g6, 'ipv4-l3vpn', 3)
   730  
   731          self.assert_adv_count(self.g6, self.g3, 'rtc', 2)
   732          self.assert_adv_count(self.g6, self.g3, 'ipv4-l3vpn', 2)
   733  
   734      def test_43_03_ibgp_ebgp_del_route_on_vrf_on_non_rr_client(self):
   735          # VRF<#>  g1   g2   g3   g4   g5  | g6   g7
   736          #   1     (*)            (*)      | (*)
   737          #   2          (*)            (*) |
   738          #   3     ( )                     |      (*)
   739          self.g1.local("gobgp vrf vrf3 rib del 10.0.0.0/24")
   740          time.sleep(1)
   741  
   742          self.assert_adv_count(self.g3, self.g6, 'rtc', 3)
   743          self.assert_adv_count(self.g3, self.g6, 'ipv4-l3vpn', 2)
   744  
   745          self.assert_adv_count(self.g6, self.g3, 'rtc', 2)
   746          self.assert_adv_count(self.g6, self.g3, 'ipv4-l3vpn', 2)
   747  
   748      def test_43_04_ibgp_ebgp_del_vrf_on_non_rr_client(self):
   749          # VRF<#>  g1   g2   g3   g4   g5  | g6   g7
   750          #   1     (*)            (*)      | (*)
   751          #   2          (*)            (*) |
   752          #   3                             |      (*)
   753          self.g1.local("gobgp vrf del vrf3")
   754          time.sleep(2)
   755  
   756          self.assert_adv_count(self.g3, self.g6, 'rtc', 2)
   757          self.assert_adv_count(self.g3, self.g6, 'ipv4-l3vpn', 2)
   758  
   759          self.assert_adv_count(self.g6, self.g3, 'rtc', 2)
   760          self.assert_adv_count(self.g6, self.g3, 'ipv4-l3vpn', 1)
   761  
   762      def test_44_01_ibgp_ebgp_add_vrf_on_ebgp_peer(self):
   763          # VRF<#>  g1   g2   g3   g4   g5  | g6   g7
   764          #   1     (*)            (*)      | (*)
   765          #   2          (*)            (*) |      ( )
   766          #   3                             |      (*)
   767          self.g7.local("gobgp vrf add vrf2 rd 200:200 rt both 200:200")
   768          time.sleep(1)
   769  
   770          self.assert_adv_count(self.g3, self.g6, 'rtc', 2)
   771          self.assert_adv_count(self.g3, self.g6, 'ipv4-l3vpn', 4)
   772  
   773          self.assert_adv_count(self.g6, self.g3, 'rtc', 3)
   774          self.assert_adv_count(self.g6, self.g3, 'ipv4-l3vpn', 1)
   775  
   776      def test_44_02_ibgp_ebgp_add_route_on_ebgp_peer(self):
   777          # VRF<#>  g1   g2   g3   g4   g5  | g6   g7
   778          #   1     (*)            (*)      | (*)
   779          #   2          (*)            (*) |      (*)
   780          #   3                             |      (*)
   781          self.g7.local("gobgp vrf vrf2 rib add 70.0.0.0/24")
   782          time.sleep(1)
   783  
   784          self.assert_adv_count(self.g3, self.g6, 'rtc', 2)
   785          self.assert_adv_count(self.g3, self.g6, 'ipv4-l3vpn', 4)
   786  
   787          self.assert_adv_count(self.g6, self.g3, 'rtc', 3)
   788          self.assert_adv_count(self.g6, self.g3, 'ipv4-l3vpn', 2)
   789  
   790      def test_44_03_ibgp_ebgp_del_route_on_vrf_on_ebgp_peer(self):
   791          # VRF<#>  g1   g2   g3   g4   g5  | g6   g7
   792          #   1     (*)            (*)      | (*)
   793          #   2          (*)            (*) |      ( )
   794          #   3                             |      (*)
   795          self.g7.local("gobgp vrf vrf2 rib del 70.0.0.0/24")
   796          time.sleep(1)
   797  
   798          self.assert_adv_count(self.g3, self.g6, 'rtc', 2)
   799          self.assert_adv_count(self.g3, self.g6, 'ipv4-l3vpn', 4)
   800  
   801          self.assert_adv_count(self.g6, self.g3, 'rtc', 3)
   802          self.assert_adv_count(self.g6, self.g3, 'ipv4-l3vpn', 1)
   803  
   804      def test_44_04_ibgp_ebgp_del_vrf_on_ebgp_peer(self):
   805          # VRF<#>  g1   g2   g3   g4   g5  | g6   g7
   806          #   1     (*)            (*)      | (*)
   807          #   2          (*)            (*) |
   808          #   3                             |      (*)
   809          self.g7.local("gobgp vrf del vrf2")
   810          time.sleep(2)
   811  
   812          self.assert_adv_count(self.g3, self.g6, 'rtc', 2)
   813          self.assert_adv_count(self.g3, self.g6, 'ipv4-l3vpn', 2)
   814  
   815          self.assert_adv_count(self.g6, self.g3, 'rtc', 2)
   816          self.assert_adv_count(self.g6, self.g3, 'ipv4-l3vpn', 1)
   817  
   818      def test_45_ibgp_ebgp_cleanup(self):
   819          self.g1.local("gobgp vrf del vrf1")
   820          self.g2.local("gobgp vrf del vrf2")
   821          self.g4.local("gobgp vrf del vrf1")
   822          self.g5.local("gobgp vrf del vrf2")
   823          self.g6.local("gobgp vrf del vrf1")
   824          self.g7.local("gobgp vrf del vrf3")
   825  
   826      def test_50_rr_addpath_setup(self):
   827          # Test cases for the infinite RTC UPDATE message loop:
   828          # https://github.com/osrg/gobgp/issues/1688#issuecomment-391456615
   829          # https://github.com/osrg/gobgp/pull/1703
   830  
   831          #               +------+
   832          #               |  g3  |
   833          #        +------| (RR) |------+
   834          #        |      +------+      |
   835          # (iBGP+Add-Paths)     (iBGP+Add-Paths)
   836          #        |                    |
   837          # +-------------+      +-------------+
   838          # |     g4      |      |     g5      |
   839          # | (RR Client) |      | (RR Client) |
   840          # +-------------+      +-------------+
   841          g3, g4, g5 = self.g3, self.g4, self.g5
   842  
   843          g3.update_peer(g4, vpn=True, addpath=True, is_rr_client=True)
   844          g4.update_peer(g3, vpn=True, addpath=True)
   845  
   846          g3.update_peer(g5, vpn=True, addpath=True, is_rr_client=True)
   847          g5.update_peer(g3, vpn=True, addpath=True)
   848  
   849          g3.wait_for(expected_state=BGP_FSM_ESTABLISHED, peer=g4)
   850          g3.wait_for(expected_state=BGP_FSM_ESTABLISHED, peer=g5)
   851  
   852      def test_51_rr_addpath_check_adj_rib_from_rr(self):
   853          # VRF<#>  g3   g4   g5
   854          #   1          ( )  ( )
   855          #   2
   856          #   3
   857          self.g4.local("gobgp vrf add vrf1 rd 100:100 rt both 100:100")
   858          self.g5.local("gobgp vrf add vrf1 rd 100:100 rt both 100:100")
   859          time.sleep(1)
   860  
   861          # Check the counts of the sent UPDATE messages in order to detect the
   862          # infinite RTC UPDATE loop.
   863          self.assert_upd_count(self.g4, self.g3, sent=1, received=2)
   864          self.assert_upd_count(self.g5, self.g3, sent=1, received=2)
   865  
   866          def check_rtc(client):
   867              rib = self.g3.get_adj_rib_out(client, rf='rtc')
   868              self.assertEqual(1, len(rib))
   869              path = rib[0]
   870              self.assertEqual(self.g3.peers[client]['local_addr'].split('/')[0], path['nexthop'])
   871              ids = [attr['value'] for attr in path['attrs'] if attr['type'] == base.BGP_ATTR_TYPE_ORIGINATOR_ID]
   872              self.assertEqual(1, len(ids))
   873              self.assertEqual(self.g3.router_id, ids[0])
   874  
   875          check_rtc(self.g4)
   876          check_rtc(self.g5)
   877  
   878          # VRF<#>  g3   g4   g5
   879          #   1          (*)  (*)
   880          #   2
   881          #   3
   882          self.g4.local("gobgp vrf vrf1 rib add 40.0.0.0/24")
   883          self.g5.local("gobgp vrf vrf1 rib add 50.0.0.0/24")
   884          time.sleep(1)
   885  
   886          def check_ipv4_l3vpn(client):
   887              rib = self.g3.get_adj_rib_out(client, rf='ipv4-l3vpn')
   888              self.assertEqual(1, len(rib))
   889              path = rib[0]
   890              self.assertNotEqual(self.g3.peers[client]['local_addr'].split('/')[0], path['nexthop'])
   891              ids = [attr['value'] for attr in path['attrs'] if attr['type'] == base.BGP_ATTR_TYPE_ORIGINATOR_ID]
   892              self.assertEqual(1, len(ids))
   893              self.assertNotEqual(client.router_id, ids[0])
   894  
   895          check_ipv4_l3vpn(self.g4)
   896          check_ipv4_l3vpn(self.g5)
   897  
   898      def test_52_rr_addpath_add_vrf(self):
   899          # VRF<#>  g3   g4   g5
   900          #   1          (*)  (*)
   901          #   2          ( )
   902          #   3
   903          self.g4.local("gobgp vrf add vrf2 rd 200:200 rt both 200:200")
   904          time.sleep(1)
   905  
   906          self.assert_adv_count(self.g4, self.g3, 'rtc', 2)
   907          self.assert_adv_count(self.g4, self.g3, 'ipv4-l3vpn', 1)
   908  
   909          self.assert_adv_count(self.g3, self.g4, 'rtc', 2)
   910          self.assert_adv_count(self.g3, self.g4, 'ipv4-l3vpn', 1)
   911  
   912          self.assert_adv_count(self.g5, self.g3, 'rtc', 1)
   913          self.assert_adv_count(self.g5, self.g3, 'ipv4-l3vpn', 1)
   914  
   915          self.assert_adv_count(self.g3, self.g5, 'rtc', 2)
   916          self.assert_adv_count(self.g3, self.g5, 'ipv4-l3vpn', 1)
   917  
   918      def test_53_rr_addpath_add_route_on_vrf(self):
   919          # VRF<#>  g3   g4   g5
   920          #   1          (*)  (*)
   921          #   2          (*)
   922          #   3
   923          self.g4.local("gobgp vrf vrf2 rib add 40.0.0.0/24")
   924          time.sleep(1)
   925  
   926          self.assert_adv_count(self.g4, self.g3, 'rtc', 2)
   927          self.assert_adv_count(self.g4, self.g3, 'ipv4-l3vpn', 2)
   928  
   929          self.assert_adv_count(self.g3, self.g4, 'rtc', 2)
   930          self.assert_adv_count(self.g3, self.g4, 'ipv4-l3vpn', 1)
   931  
   932          self.assert_adv_count(self.g5, self.g3, 'rtc', 1)
   933          self.assert_adv_count(self.g5, self.g3, 'ipv4-l3vpn', 1)
   934  
   935          self.assert_adv_count(self.g3, self.g5, 'rtc', 2)
   936          self.assert_adv_count(self.g3, self.g5, 'ipv4-l3vpn', 1)
   937  
   938      def test_54_rr_addpath_del_route_on_vrf(self):
   939          # Related issue:
   940          # https://github.com/osrg/gobgp/issues/1688
   941  
   942          # VRF<#>  g3   g4   g5
   943          #   1          ( )  (*)
   944          #   2          (*)
   945          #   3
   946          self.g4.local("gobgp vrf vrf1 rib del 40.0.0.0/24")
   947          time.sleep(1)
   948  
   949          self.assert_adv_count(self.g4, self.g3, 'rtc', 2)
   950          self.assert_adv_count(self.g4, self.g3, 'ipv4-l3vpn', 1)
   951  
   952          self.assert_adv_count(self.g3, self.g4, 'rtc', 2)
   953          self.assert_adv_count(self.g3, self.g4, 'ipv4-l3vpn', 1)
   954  
   955          self.assert_adv_count(self.g5, self.g3, 'rtc', 1)
   956          self.assert_adv_count(self.g5, self.g3, 'ipv4-l3vpn', 1)
   957  
   958          self.assert_adv_count(self.g3, self.g5, 'rtc', 2)
   959          self.assert_adv_count(self.g3, self.g5, 'ipv4-l3vpn', 0)
   960  
   961      def test_55_rr_addpath_del_vrf_with_route(self):
   962          # VRF<#>  g3   g4   g5
   963          #   1               (*)
   964          #   2          (*)
   965          #   3
   966          self.g4.local("gobgp vrf del vrf1")
   967          time.sleep(1)
   968  
   969          self.assert_adv_count(self.g4, self.g3, 'rtc', 1)
   970          self.assert_adv_count(self.g4, self.g3, 'ipv4-l3vpn', 1)
   971  
   972          self.assert_adv_count(self.g3, self.g4, 'rtc', 2)
   973          self.assert_adv_count(self.g3, self.g4, 'ipv4-l3vpn', 0)
   974  
   975          self.assert_adv_count(self.g5, self.g3, 'rtc', 1)
   976          self.assert_adv_count(self.g5, self.g3, 'ipv4-l3vpn', 1)
   977  
   978          self.assert_adv_count(self.g3, self.g5, 'rtc', 2)
   979          self.assert_adv_count(self.g3, self.g5, 'ipv4-l3vpn', 0)
   980  
   981      def test_56_rr_addpath_cleanup(self):
   982          self.g4.local("gobgp vrf del vrf2")
   983          self.g5.local("gobgp vrf del vrf1")
   984  
   985  
   986  if __name__ == '__main__':
   987      output = local("which docker 2>&1 > /dev/null ; echo $?", capture=True)
   988      if int(output) is not 0:
   989          print "docker not found"
   990          sys.exit(1)
   991  
   992      nose.main(argv=sys.argv, addplugins=[OptionParser()],
   993                defaultTest=sys.argv[0])