コード例 #1
0
	Describe("Execute", func() {
		It("it calls StartMonitor inside the HostNamespace", func() {

			hostNS.ExecuteStub = func(callback func(_ *os.File) error) error {
				Expect(fakeWatcher.StartMonitorCallCount()).To(Equal(0))
				callback(nil)
				Expect(fakeWatcher.StartMonitorCallCount()).To(Equal(1))
				return nil
			}

			err := startMonitor.Execute(context)
			Expect(err).NotTo(HaveOccurred())

			Expect(sandboxRepository.GetCallCount()).To(Equal(1))
			Expect(sandboxRepository.GetArgsForCall(0)).To(Equal("some-sandbox"))

			Expect(hostNS.ExecuteCallCount()).To(Equal(1))

			ns, linkName := fakeWatcher.StartMonitorArgsForCall(0)
			Expect(ns).To(Equal(sandboxNS))
			Expect(linkName).To(Equal("some-vxlan-name"))
		})

		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)
コード例 #2
0
			sboxFileName = path.Base(sboxFile.Name())
			Expect(err).NotTo(HaveOccurred())

			namespaceRepo.GetReturns(sboxNamespace, nil)
		})

		It("reads in files from the sanboxNamespaceDir into memory", func() {
			sbox, err := sandboxRepo.Get(sboxFileName)
			Expect(err).To(Equal(sandbox.NotFoundError))
			Expect(sbox).To(BeNil())

			err = sandboxRepo.Load(sboxNamespaceDir)
			Expect(err).NotTo(HaveOccurred())

			Expect(namespaceRepo.GetCallCount()).To(Equal(1))
			Expect(namespaceRepo.GetArgsForCall(0)).To(Equal(sboxFileName))

			sbox, err = sandboxRepo.Get(sboxFileName)
			Expect(err).NotTo(HaveOccurred())
			Expect(sbox).NotTo(BeNil())
		})

		It("locks and unlocks", func() {
			err := sandboxRepo.Load(sboxNamespaceDir)
			Expect(err).NotTo(HaveOccurred())

			Expect(locker.LockCallCount()).To(Equal(1))
			Expect(locker.UnlockCallCount()).To(Equal(1))
		})

		Context("when namespace repo fails to get sandbox", func() {