Exemple #1
0
		})
	})

	Describe("RemainingResources", func() {
		var requests []executor.AllocationRequest
		BeforeEach(func() {
			requests = []executor.AllocationRequest{
				newAllocationRequest("guid-1", defaultMemoryMB, defaultDiskMB),
				newAllocationRequest("guid-2", defaultMemoryMB, defaultDiskMB),
				newAllocationRequest("guid-3", defaultMemoryMB, defaultDiskMB),
			}
		})

		Context("when no containers are running or allocated", func() {
			It("should return the total resources", func() {
				Expect(depotClient.RemainingResources()).To(Equal(resources))
			})
		})

		Context("when some containers are running", func() {
			BeforeEach(func() {
				running := requests[0]
				errMessageMap, err := depotClient.AllocateContainers(requests[1:])
				Expect(err).NotTo(HaveOccurred())
				Expect(errMessageMap).To(BeEmpty())

				gardenStore.ListReturns([]executor.Container{
					newRunningContainer(newRunRequest(running.Guid), running.Resource),
				}, nil)
			})
Exemple #2
0
			Context("when allocated with memory and disk limits", func() {
				BeforeEach(func() {
					container.MemoryMB = 256
					container.DiskMB = 256
				})

				It("returns the limits on the container", func() {
					containers, err := executorClient.ListContainers(nil)
					Expect(err).NotTo(HaveOccurred())
					Expect(containers).To(HaveLen(1))
					Expect(containers[0].MemoryMB).To(Equal(256))
					Expect(containers[0].DiskMB).To(Equal(256))
				})

				It("reduces the capacity by the amount reserved", func() {
					Expect(executorClient.RemainingResources()).To(Equal(executor.ExecutorResources{
						MemoryMB:   int(gardenCapacity.MemoryInBytes/1024/1024) - 256,
						DiskMB:     int(gardenCapacity.DiskInBytes/1024/1024) - 256,
						Containers: int(gardenCapacity.MaxContainers) - 1,
					}))
				})
			})

			Context("when the requested CPU weight is > 100", func() {
				BeforeEach(func() {
					container.CPUWeight = 101
				})

				It("returns an error", func() {
					Expect(allocErr).NotTo(HaveOccurred())
					Expect(allocationErrorMap[container.Guid]).To(Equal(executor.ErrLimitsInvalid.Error()))