示例#1
0
		Expect(err).NotTo(HaveOccurred())

		depotClient = d.WithLogger(logger)
	})

	Describe("AllocateContainers", func() {
		Context("when allocating a single valid container within executor resource limits", func() {
			var requests []executor.AllocationRequest
			BeforeEach(func() {
				requests = []executor.AllocationRequest{
					newAllocationRequest("guid-1", 512, 512),
				}
			})

			It("should allocate the container", func() {
				errMessageMap, err := depotClient.AllocateContainers(requests)
				Expect(err).NotTo(HaveOccurred())
				Expect(errMessageMap).To(BeEmpty())
				allocatedContainers := allocationStore.List()
				Expect(allocatedContainers).To(HaveLen(len(requests)))
				Expect(allocatedContainers[0].Guid).To(Equal("guid-1"))
				Expect(allocatedContainers[0].State).To(Equal(executor.StateReserved))
			})
		})

		Context("when allocating multiple valid containers", func() {
			var requests []executor.AllocationRequest

			Context("when total required resources are within executor resource limits", func() {
				BeforeEach(func() {
示例#2
0
		}

		os.RemoveAll(cachePath)
	})

	generateGuid := func() string {
		id, err := uuid.NewV4()
		Expect(err).NotTo(HaveOccurred())

		return id.String()
	}

	allocNewContainer := func(request executor.Container) string {
		request.Guid = generateGuid()

		_, err := executorClient.AllocateContainers([]executor.Container{request})
		Expect(err).NotTo(HaveOccurred())

		return request.Guid
	}

	getContainer := func(guid string) executor.Container {
		container, err := executorClient.GetContainer(guid)
		Expect(err).NotTo(HaveOccurred())

		return container
	}

	containerStatePoller := func(guid string) func() executor.State {
		return func() executor.State {
			return getContainer(guid).State