Ejemplo n.º 1
0
			runRequest = newRunRequest(gardenStoreGuid)
		})

		JustBeforeEach(func() {
			errMessageMap, err := depotClient.AllocateContainers(allocRequests)
			Expect(err).NotTo(HaveOccurred())
			Expect(errMessageMap).To(BeEmpty())
		})

		Context("when the container is valid", func() {
			It("should create garden container, run it, and remove from allocation store", func() {
				Expect(gardenStore.CreateCallCount()).To(Equal(0))
				Expect(gardenStore.RunCallCount()).To(Equal(0))
				Expect(allocationStore.List()).To(HaveLen(1))
				err := depotClient.RunContainer(runRequest)
				Expect(err).NotTo(HaveOccurred())
				Eventually(gardenStore.CreateCallCount).Should(Equal(1))
				Eventually(gardenStore.RunCallCount).Should(Equal(1))
				Eventually(allocationStore.List).Should(BeEmpty())
			})

			It("allocates and drops the container lock", func() {
				initialLockCount := lockManager.LockCallCount()
				initialUnlockCount := lockManager.UnlockCallCount()

				err := depotClient.RunContainer(runRequest)
				Expect(err).NotTo(HaveOccurred())

				Eventually(gardenStore.RunCallCount).Should(Equal(1))
Ejemplo n.º 2
0
					Expect(allocErr).NotTo(HaveOccurred())
					Expect(allocationErrorMap[container.Guid]).To(Equal(executor.ErrInsufficientResourcesAvailable.Error()))
				})
			})

			Describe("running it", func() {
				var runErr error
				var eventSource executor.EventSource

				JustBeforeEach(func() {
					var err error

					eventSource, err = executorClient.SubscribeToEvents()
					Expect(err).NotTo(HaveOccurred())

					runErr = executorClient.RunContainer(guid)
				})

				AfterEach(func() {
					eventSource.Close()
				})

				Context("when the container can be created", func() {
					var gardenContainer garden.Container

					JustBeforeEach(func() {
						gardenContainer = findGardenContainer(guid)
					})

					It("returns no error", func() {
						Expect(runErr).NotTo(HaveOccurred())