Exemple #1
0
					return nil
				}
				gardenStore.StopStub = func(logger lager.Logger, guid string) error {
					throttleChan <- struct{}{}
					<-doneChan
					return nil
				}
			})

			It("throttles the requests to Garden", func() {
				stopContainerCount := 0
				deleteContainerCount := 0
				for i, request := range requests {
					if i%2 == 0 {
						stopContainerCount++
						go depotClient.StopContainer(request.Guid)
					} else {
						deleteContainerCount++
						go depotClient.DeleteContainer(request.Guid)
					}
				}

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

				doneChan <- struct{}{}
Exemple #2
0
					Action: models.WrapAction(&models.RunAction{
						Path: "sh",
						User: "******",
						Args: []string{"-c", "while true; do sleep 1; done"},
					}),
				})

				err := executorClient.RunContainer(guid)
				Expect(err).NotTo(HaveOccurred())

				Eventually(containerStatePoller(guid)).Should(Equal(executor.StateRunning))
			})

			Describe("StopContainer", func() {
				It("does not return an error", func() {
					err := executorClient.StopContainer(guid)
					Expect(err).NotTo(HaveOccurred())
				})

				It("stops the container but does not delete it", func() {
					err := executorClient.StopContainer(guid)
					Expect(err).NotTo(HaveOccurred())

					var container executor.Container
					Eventually(func() executor.State {
						container, err = executorClient.GetContainer(guid)
						Expect(err).NotTo(HaveOccurred())
						return container.State
					}).Should(Equal(executor.StateCompleted))

					Expect(container.RunResult.Stopped).To(BeTrue())