@@ -27,6 +27,8 @@ func Test_controller_syncNetwork(t *testing.T) {
2727 node := "testnode"
2828
2929 defaultNetwork := & util.DefaultNetInfo {}
30+ defaultNetworkRouter := defaultNetwork .GetNetworkScopedGWRouterName (node )
31+ defaultNetworkRouterPort := types .GWRouterToExtSwitchPrefix + defaultNetworkRouter
3032
3133 udn := & multinetworkmocks.NetInfo {}
3234 udn .On ("IsDefault" ).Return (false )
@@ -142,23 +144,28 @@ func Test_controller_syncNetwork(t *testing.T) {
142144 },
143145 link : & netlink.Vrf {Table : unix .RT_TABLE_MAIN },
144146 initial : []libovsdb.TestData {
145- & nbdb.LogicalRouter {Name : defaultNetwork . GetNetworkScopedGWRouterName ( node ) , StaticRoutes : []string {"keep-1" , "keep-2" , "remove" }},
146- & nbdb.LogicalRouterStaticRoute {UUID : "keep-1" , IPPrefix : "1.1.1.0/24" , Nexthop : "1.1.1.1" , ExternalIDs : map [string ]string {controllerExternalIDKey : controllerName }},
147+ & nbdb.LogicalRouter {Name : defaultNetworkRouter , StaticRoutes : []string {"keep-1" , "keep-2" , "remove" }},
148+ & nbdb.LogicalRouterStaticRoute {UUID : "keep-1" , IPPrefix : "1.1.1.0/24" , Nexthop : "1.1.1.1" , OutputPort : & defaultNetworkRouterPort , ExternalIDs : map [string ]string {controllerExternalIDKey : controllerName }},
147149 & nbdb.LogicalRouterStaticRoute {UUID : "keep-2" , IPPrefix : "5.5.5.0/24" , Nexthop : "5.5.5.1" },
148- & nbdb.LogicalRouterStaticRoute {UUID : "remove" , IPPrefix : "6.6.6.0/24" , Nexthop : "6.6.6.1" , ExternalIDs : map [string ]string {controllerExternalIDKey : controllerName }},
150+ & nbdb.LogicalRouterStaticRoute {UUID : "remove" , IPPrefix : "6.6.6.0/24" , Nexthop : "6.6.6.1" , OutputPort : & defaultNetworkRouterPort , ExternalIDs : map [string ]string {controllerExternalIDKey : controllerName }},
151+ & nbdb.LogicalRouter {UUID : "otherRouter" , Name : "otherRouter" , StaticRoutes : []string {"untouched-1" }},
152+ & nbdb.LogicalRouterStaticRoute {UUID : "untouched-1" , IPPrefix : "3.3.3.0/24" , Nexthop : "3.3.3.2" , ExternalIDs : map [string ]string {controllerExternalIDKey : controllerName }},
149153 },
150154 routes : []netlink.Route {
151155 {Dst : ovntesting .MustParseIPNet ("1.1.1.0/24" ), Gw : ovntesting .MustParseIP ("1.1.1.1" )},
152156 {Dst : ovntesting .MustParseIPNet ("2.2.2.0/24" ), Gw : ovntesting .MustParseIP ("2.2.2.1" )},
153157 {Dst : ovntesting .MustParseIPNet ("3.3.3.0/24" ), MultiPath : []* netlink.NexthopInfo {{Gw : ovntesting .MustParseIP ("3.3.3.1" )}, {Gw : ovntesting .MustParseIP ("3.3.3.2" )}}},
154158 },
155159 expected : []libovsdb.TestData {
156- & nbdb.LogicalRouter {UUID : "router" , Name : defaultNetwork . GetNetworkScopedGWRouterName ( node ) , StaticRoutes : []string {"keep-1" , "keep-2" , "add-1" , "add-2" , "add-3" }},
157- & nbdb.LogicalRouterStaticRoute {UUID : "keep-1" , IPPrefix : "1.1.1.0/24" , Nexthop : "1.1.1.1" , ExternalIDs : map [string ]string {controllerExternalIDKey : controllerName }},
160+ & nbdb.LogicalRouter {UUID : "router" , Name : defaultNetworkRouter , StaticRoutes : []string {"keep-1" , "keep-2" , "add-1" , "add-2" , "add-3" }},
161+ & nbdb.LogicalRouterStaticRoute {UUID : "keep-1" , IPPrefix : "1.1.1.0/24" , Nexthop : "1.1.1.1" , OutputPort : & defaultNetworkRouterPort , ExternalIDs : map [string ]string {controllerExternalIDKey : controllerName }},
158162 & nbdb.LogicalRouterStaticRoute {UUID : "keep-2" , IPPrefix : "5.5.5.0/24" , Nexthop : "5.5.5.1" },
159- & nbdb.LogicalRouterStaticRoute {UUID : "add-1" , IPPrefix : "2.2.2.0/24" , Nexthop : "2.2.2.1" , ExternalIDs : map [string ]string {controllerExternalIDKey : controllerName }},
160- & nbdb.LogicalRouterStaticRoute {UUID : "add-2" , IPPrefix : "3.3.3.0/24" , Nexthop : "3.3.3.1" , ExternalIDs : map [string ]string {controllerExternalIDKey : controllerName }},
161- & nbdb.LogicalRouterStaticRoute {UUID : "add-3" , IPPrefix : "3.3.3.0/24" , Nexthop : "3.3.3.2" , ExternalIDs : map [string ]string {controllerExternalIDKey : controllerName }},
163+ & nbdb.LogicalRouterStaticRoute {UUID : "add-1" , IPPrefix : "2.2.2.0/24" , Nexthop : "2.2.2.1" , OutputPort : & defaultNetworkRouterPort , ExternalIDs : map [string ]string {controllerExternalIDKey : controllerName }},
164+ & nbdb.LogicalRouterStaticRoute {UUID : "add-2" , IPPrefix : "3.3.3.0/24" , Nexthop : "3.3.3.1" , OutputPort : & defaultNetworkRouterPort , ExternalIDs : map [string ]string {controllerExternalIDKey : controllerName }},
165+ & nbdb.LogicalRouterStaticRoute {UUID : "add-3" , IPPrefix : "3.3.3.0/24" , Nexthop : "3.3.3.2" , OutputPort : & defaultNetworkRouterPort , ExternalIDs : map [string ]string {controllerExternalIDKey : controllerName }},
166+ & nbdb.LogicalRouter {UUID : "otherRouter" , Name : "otherRouter" , StaticRoutes : []string {"untouched-1" }},
167+ // this route should not be updated as it belongs to a different network
168+ & nbdb.LogicalRouterStaticRoute {UUID : "untouched-1" , IPPrefix : "3.3.3.0/24" , Nexthop : "3.3.3.2" , ExternalIDs : map [string ]string {controllerExternalIDKey : controllerName }},
162169 },
163170 },
164171 }
0 commit comments