Esempio n. 1
0
							} else {
								return "", "", nil
							}
						}
					})

					It("retries", func() {
						_, _, err := lockPool.AcquireLock()
						Ω(err).ShouldNot(HaveOccurred())
						Ω(fakeLockHandler.GrabAvailableLockCallCount()).Should(Equal(2))
					})
				})

				Context("when grabbing an available lock succeeds", func() {
					BeforeEach(func() {
						fakeLockHandler.GrabAvailableLockReturns("some-lock", "some-ref", nil)
					})

					It("tries to broadcast to the lock pool", func() {
						_, _, err := lockPool.AcquireLock()
						Ω(err).ShouldNot(HaveOccurred())

						Ω(fakeLockHandler.BroadcastLockPoolCallCount()).Should(Equal(1))
					})

					ValidateSharedBehaviorDuringBroadcastFailures(
						func() error {
							_, _, err := lockPool.AcquireLock()
							return err
						}, func(expectedNumberOfInteractions int) {
							Ω(fakeLockHandler.ResetLockCallCount()).Should(Equal(expectedNumberOfInteractions))