Exemplo n.º 1
0
					}, nil
				}
				gardenStore.ListReturns([]executor.Container{executor.Container{Guid: "some-guid"}}, nil)

				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() {
				for i, request := range requests {
					switch i % 2 {
					case 0:
						go depotClient.GetMetrics(request.Guid)
					case 1:
						go depotClient.GetAllMetrics(executor.Tags{})
					}
				}

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

				doneChan <- struct{}{}

				Eventually(gardenStore.MetricsCallCount).Should(Equal(workPoolSettings.MetricsWorkPoolSize + 1))