Exemplo n.º 1
0
		var container *fakes.FakeContainer

		resources := linux_backend.LinuxContainerSpec{ID: "something"}

		JustBeforeEach(func() {
			container = new(fakes.FakeContainer)
			container.HandleReturns("some-handle")
			container.ResourceSpecReturns(resources)

			containerRepo.Add(container)
		})

		It("removes the given container's resoureces from the pool", func() {
			Expect(fakeResourcePool.ReleaseCallCount()).To(Equal(0))

			err := linuxBackend.Destroy("some-handle")
			Expect(err).ToNot(HaveOccurred())

			Expect(fakeResourcePool.ReleaseCallCount()).To(Equal(1))
			Expect(fakeResourcePool.ReleaseArgsForCall(0)).To(Equal(resources))
		})

		It("unregisters the container", func() {
			err := linuxBackend.Destroy("some-handle")
			Expect(err).ToNot(HaveOccurred())

			_, err = linuxBackend.Lookup("some-handle")
			Expect(err).To(HaveOccurred())
			Expect(err).To(MatchError(garden.ContainerNotFoundError{"some-handle"}))
		})
Exemplo n.º 2
0
			BeforeEach(func() {
				releaseCh = make(chan bool)

				fakeResourcePool.ReleaseStub = func(spec linux_backend.LinuxContainerSpec) error {
					releaseCh <- true
					<-releaseCh
					return nil
				}
			})

			JustBeforeEach(func() {
				go func() {
					defer GinkgoRecover()

					Expect(linuxBackend.Destroy("container-2")).To(Succeed())
				}()

				Eventually(releaseCh).Should(Receive())
			})

			It("should wait", func() {
				stopCh := make(chan struct{})
				go func() {
					linuxBackend.Stop()
					close(stopCh)
				}()

				Consistently(stopCh, "500ms").ShouldNot(BeClosed())
				close(releaseCh)
				Eventually(stopCh).Should(BeClosed())