예제 #1
0
					return executor.Container{}, nil
				}
			})

			It("throttles the requests to Garden", func() {
				getContainerCount := 0
				listContainerCount := 0
				getFilesCount := 0
				for i, request := range requests {
					switch i % 3 {
					case 0:
						getContainerCount++
						go depotClient.GetContainer(request.Guid)
					case 1:
						listContainerCount++
						go depotClient.ListContainers(executor.Tags{})
					case 2:
						getFilesCount++
						go depotClient.GetFiles(request.Guid, "/some/path")
					}
				}

				Eventually(func() int {
					return len(throttleChan)
				}).Should(Equal(workPoolSettings.ReadWorkPoolSize))
				Consistently(func() int {
					return len(throttleChan)
				}).Should(Equal(workPoolSettings.ReadWorkPoolSize))

				doneChan <- struct{}{}
예제 #2
0
			})

			JustBeforeEach(func() {
				allocationErrorMap, allocErr = executorClient.AllocateContainers([]executor.Container{container})
			})

			It("does not return an error", func() {
				Expect(allocErr).NotTo(HaveOccurred())
			})

			It("returns an empty error map", func() {
				Expect(allocationErrorMap).To(BeEmpty())
			})

			It("shows up in the container list", func() {
				containers, err := executorClient.ListContainers(nil)
				Expect(err).NotTo(HaveOccurred())
				Expect(containers).To(HaveLen(1))

				Expect(containers[0].State).To(Equal(executor.StateReserved))
				Expect(containers[0].Guid).To(Equal(guid))
				Expect(containers[0].MemoryMB).To(Equal(0))
				Expect(containers[0].DiskMB).To(Equal(0))
				Expect(containers[0].Tags).To(Equal(executor.Tags{"some-tag": "some-value"}))
				Expect(containers[0].State).To(Equal(executor.StateReserved))
				Expect(containers[0].AllocatedAt).To(BeNumerically("~", time.Now().UnixNano(), time.Second))

			})

			Context("when allocated with memory and disk limits", func() {
				BeforeEach(func() {