err := configurer.Apply(config, netnsFD) Expect(err).To(HaveOccurred()) Expect(err).To(MatchError(&configure.VethPairCreationError{Cause: vethCreator.CreateReturns.Err, HostIfcName: "host", ContainerIfcName: "container"})) }) }) Context("when creating the pair succeeds", func() { BeforeEach(func() { vethCreator.CreateReturns.Host = &net.Interface{Name: "the-host"} vethCreator.CreateReturns.Container = &net.Interface{Name: "the-container"} }) It("should set mtu on the host interface", func() { config.HostIntf = "host" config.BridgeName = "bridge" config.Mtu = 123 Expect(configurer.Apply(config, netnsFD)).To(Succeed()) Expect(linkConfigurer.SetMTUCalledWith.Interface).To(Equal(vethCreator.CreateReturns.Host)) Expect(linkConfigurer.SetMTUCalledWith.MTU).To(Equal(123)) }) Context("When setting the mtu fails", func() { It("returns a wrapped error", func() { config.HostIntf = "host" config.BridgeName = "bridge" config.ContainerIntf = "container" config.Mtu = 14 linkConfigurer.SetMTUReturns = errors.New("o no") err := configurer.Apply(config, netnsFD) Expect(err).To(MatchError(&configure.MTUError{Cause: linkConfigurer.SetMTUReturns, Intf: vethCreator.CreateReturns.Host, MTU: 14}))
if iface.Name == "foo" { return cause } return nil } config.ContainerIntf = "foo" err := configurer.Apply(config) Expect(err).To(MatchError(&configure.LinkUpError{Cause: cause, Link: &net.Interface{Name: "foo"}, Role: "container"})) }) }) It("sets the mtu", func() { config.ContainerIntf = "foo" config.Mtu = 1234 Expect(configurer.Apply(config)).To(Succeed()) Expect(linkApplyr.SetMTUCalledWith.Interface).To(Equal(&net.Interface{Name: "foo"})) Expect(linkApplyr.SetMTUCalledWith.MTU).To(Equal(1234)) }) Context("when setting the mtu fails", func() { It("returns a wrapped error", func() { linkApplyr.SetMTUReturns = errors.New("this is NOT the right potato") config.ContainerIntf = "foo" config.Mtu = 1234 err := configurer.Apply(config) Expect(err).To(MatchError(&configure.MTUError{Cause: linkApplyr.SetMTUReturns, Intf: &net.Interface{Name: "foo"}, MTU: 1234})) }) })