Fix network test for route filter
Isolate test to avoid impact and intermittent failure of other tests
@@ -40,7 +40,6 @@ var _ = Describe("Network", func() {
var ctrl *gomock.Controller
var dummy *netlink.Dummy
var addrList []netlink.Addr
- var staticRoute netlink.Route
var routeList []netlink.Route
var routeAddr netlink.Route
var fakeMac net.HardwareAddr
@@ -69,13 +68,7 @@ var _ = Describe("Network", func() {
fakeAddr = netlink.Addr{IPNet: address}
addrList = []netlink.Addr{fakeAddr}
routeAddr = netlink.Route{Gw: gw}
- staticRoute = netlink.Route{
- Dst: &net.IPNet{IP: net.IPv4(10, 45, 0, 10), Mask: net.CIDRMask(32, 32)},
- Gw: net.IPv4(10, 25, 0, 1),
- }
- gwRoute := netlink.Route{Dst: &net.IPNet{IP: gw, Mask: net.CIDRMask(32, 32)}}
- nicRoute := netlink.Route{Src: address.IP}
- routeList = []netlink.Route{routeAddr, gwRoute, nicRoute, staticRoute}
+ routeList = []netlink.Route{routeAddr}
// Create a bridge
bridgeTest = &netlink.Bridge{
@@ -156,9 +149,17 @@ var _ = Describe("Network", func() {
})
Context("func filterPodNetworkRoutes()", func() {
+ staticRoute := netlink.Route{
+ Dst: &net.IPNet{IP: net.IPv4(10, 45, 0, 10), Mask: net.CIDRMask(32, 32)},
+ Gw: net.IPv4(10, 25, 0, 1),
+ }
+ gwRoute := netlink.Route{Dst: &net.IPNet{IP: net.IPv4(10, 35, 0, 1), Mask: net.CIDRMask(32, 32)}}
+ nicRoute := netlink.Route{Src: net.IPv4(10, 35, 0, 6)}
+ staticRouteList := []netlink.Route{routeAddr, gwRoute, nicRoute, staticRoute}
+
It("should remove default gateway and source IP from routes, leaving others intact", func() {
expected := []netlink.Route{staticRoute}
- Expect(filterPodNetworkRoutes(routeList, testNic)).To(Equal(expected))
+ Expect(filterPodNetworkRoutes(staticRouteList, testNic)).To(Equal(expected))
})
})
