Ejemplo n.º 1
0
	}

	Describe("Throttling", func() {
		var (
			throttleChan chan struct{}
			doneChan     chan struct{}
			fakeStep     *fakes.FakeStep
		)

		BeforeEach(func() {
			throttleChan = make(chan struct{}, numOfConcurrentMonitorSteps)
			doneChan = make(chan struct{}, 1)
			fakeStep = new(fakes.FakeStep)
			fakeStep.PerformStub = func() error {
				throttleChan <- struct{}{}
				<-doneChan
				return nil
			}
			checkFunc = func() steps.Step {
				return fakeStep
			}

		})

		AfterEach(func() {
			step.Cancel()
		})

		It("throttles concurrent health check", func() {
			for i := 0; i < 5; i++ {
				go step.Perform()
Ejemplo n.º 2
0
				Expect(subStep2.CancelCallCount()).To(Equal(1))
			})
		})

		Context("when one of the substeps exits without failure", func() {
			var (
				cancelledError, err error
				errCh               chan error
			)

			BeforeEach(func() {
				cancelledError = errors.New("I was cancelled yo.")
				cancelled2 := make(chan bool, 1)

				subStep1.PerformStub = func() error {
					return nil
				}

				subStep2.PerformStub = func() error {
					<-cancelled2
					return cancelledError
				}

				subStep2.CancelStub = func() {
					cancelled2 <- true
				}
			})

			JustBeforeEach(func() {
				errCh = make(chan error)