Exemplo n.º 1
0
			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{}{}

				Eventually(func() int {
					return gardenStore.LookupCallCount() + gardenStore.ListCallCount() + gardenStore.GetFilesCallCount()
				}).Should(Equal(workPoolSettings.ReadWorkPoolSize + 1))
Exemplo n.º 2
0
		Describe("getting files from a container", func() {
			var (
				guid string

				stream    io.ReadCloser
				streamErr error
			)

			Context("when the container hasn't been initialized", func() {
				JustBeforeEach(func() {
					guid = allocNewContainer(executor.Container{
						MemoryMB: 1024,
						DiskMB:   1024,
					})

					stream, streamErr = executorClient.GetFiles(guid, "some/path")
				})

				It("returns an error", func() {
					Expect(streamErr).To(HaveOccurred())
				})
			})

			Context("when the container is running", func() {
				var container garden.Container

				JustBeforeEach(func() {
					guid = allocNewContainer(executor.Container{
						Action: models.WrapAction(&models.RunAction{
							Path: "sh",
							User: "******",