コード例 #1
0
		})

		Context("when getting the sandbox namespace fails", func() {
			BeforeEach(func() {
				sandboxRepository.GetReturns(nil, errors.New("potato"))
			})

			It("wraps and propogates the error", func() {
				err := startMonitor.Execute(context)
				Expect(err).To(MatchError("getting sandbox namespace: potato"))
			})
		})

		Context("when the StartMonitor call fails", func() {
			BeforeEach(func() {
				fakeWatcher.StartMonitorReturns(errors.New("banana"))
			})

			It("wraps and propogates the error", func() {
				err := startMonitor.Execute(context)
				Expect(err).To(MatchError("watcher start monitor: banana"))
			})
		})
	})

	Describe("String", func() {
		It("describes itself", func() {
			Expect(startMonitor.String()).To(Equal("ip netns exec some-sandbox ip monitor neigh"))
		})
	})
})
コード例 #2
0
		ns.NameReturns("/some/sbox/path/vni-some-sandbox")
	})

	Describe("Callback", func() {
		It("restart the monitor for the given namespace", func() {
			err := monitorReloader.Callback(ns)
			Expect(err).NotTo(HaveOccurred())

			Expect(watcher.StartMonitorCallCount()).To(Equal(1))
			calledNS, vxlanDev := watcher.StartMonitorArgsForCall(0)
			Expect(calledNS).To(Equal(ns))
			Expect(vxlanDev).To(Equal("vxlansome-sandbox"))
		})

		Context("failure cases", func() {
			It("returns an error when the sandbox name is not valid", func() {
				ns.NameReturns("some-invalid-name")

				err := monitorReloader.Callback(ns)
				Expect(err).To(MatchError("get vxlan name: not a valid sandbox name"))
			})
			It("returns an error when monitor does not start", func() {
				watcher.StartMonitorReturns(errors.New("some-fake-error"))

				err := monitorReloader.Callback(ns)
				Expect(err).To(MatchError("start monitor: some-fake-error"))
			})
		})
	})
})
コード例 #3
0
	AfterEach(func() {
		process.Signal(syscall.SIGINT)
	})

	It("calls StartMonitor with the right arguments", func() {
		Eventually(missWatcher.StartMonitorCallCount).Should(Equal(1))

		n, vxlanName := missWatcher.StartMonitorArgsForCall(0)
		Expect(n).To(Equal(ns))
		Expect(vxlanName).To(Equal("some-vxlan-name"))
	})

	Context("when StartMonitor fails", func() {
		BeforeEach(func() {
			missWatcher.StartMonitorReturns(errors.New("pineapple"))
		})

		It("returns a meaningful error", func() {
			errCh := process.Wait()
			Eventually(errCh).Should(Receive(MatchError("start monitor: pineapple")))
		})

		It("does not close the ready channel", func() {
			Consistently(process.Ready()).ShouldNot(BeClosed())
		})
	})

	It("calls StopMonitor when signaled", func() {
		Eventually(process.Ready()).Should(BeClosed())