Пример #1
0
						Expect(bridger.AddCalledWith.Bridge).To(Equal(existingBridge))
					})

					It("brings the host interface up", func() {
						config.BridgeName = "bridge"
						Expect(configurer.Apply(config, netnsFD)).To(Succeed())
						Expect(linkConfigurer.SetUpCalledWith).To(ContainElement(vethCreator.CreateReturns.Host))
					})

					Context("when bringing the host interface up fails", func() {
						It("returns a wrapped error", func() {
							cause := errors.New("there's jam in this sandwich and it's not ok")
							linkConfigurer.SetUpFunc = func(intf *net.Interface) error {
								if vethCreator.CreateReturns.Host == intf {
									return cause
								}

								return nil
							}

							config.BridgeName = "bridge"
							err := configurer.Apply(config, netnsFD)
							Expect(err).To(MatchError(&configure.LinkUpError{Cause: cause, Link: vethCreator.CreateReturns.Host, Role: "host"}))
						})
					})
				})
			})
		})
	})

	Describe("Destroy", func() {
Пример #2
0
				linkApplyr.AddIPReturns["lo"] = errors.New("o no")
				err := configurer.Apply(config)
				ip, subnet, _ := net.ParseCIDR("127.0.0.1/8")
				Expect(err).To(MatchError(&configure.ConfigureLinkError{Cause: errors.New("o no"), Role: "loopback", Interface: lo, IntendedIP: ip, IntendedSubnet: subnet}))
			})
		})

		It("brings it up", func() {
			Expect(configurer.Apply(config)).To(Succeed())
			Expect(linkApplyr.SetUpCalledWith).To(ContainElement(lo))
		})

		Context("when bringing the link up fails", func() {
			It("returns a wrapped error", func() {
				linkApplyr.SetUpFunc = func(intf *net.Interface) error {
					return errors.New("o no")
				}

				err := configurer.Apply(config)
				Expect(err).To(MatchError(&configure.LinkUpError{Cause: errors.New("o no"), Link: lo, Role: "loopback"}))
			})
		})
	})

	Context("when the container interface does not exist", func() {
		BeforeEach(func() {
			linkApplyr.InterfaceByNameFunc = func(name string) (*net.Interface, bool, error) {
				if name == "lo" {
					return &net.Interface{Name: name}, true, nil
				}