Esempio n. 1
0
				gardenStore.LookupStub = func(logger lager.Logger, guid string) (executor.Container, error) {
					throttleChan <- struct{}{}
					<-doneChan
					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))
Esempio n. 2
0
		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
		}
	}

	containerEventPoller := func(eventSource executor.EventSource, event *executor.Event) func() executor.EventType {
		return func() executor.EventType {
			var err error
			*event, err = eventSource.Next()