itIsMissingDomain() It("exits with an error", func() { Eventually(process.Wait(), 2*domainTTL).Should(Receive(HaveOccurred())) }) }) Context("when the bulker initially does not have the lock", func() { var otherSession *consuladapter.Session BeforeEach(func() { heartbeatInterval = 1 * time.Second otherSession = consulRunner.NewSession("other-session") err := otherSession.AcquireLock(locket.LockSchemaPath(bulkerLockName), []byte("something-else")) Expect(err).NotTo(HaveOccurred()) }) JustBeforeEach(func() { process = startBulker(false) }) AfterEach(func() { ginkgomon.Interrupt(process, interruptTimeout) }) itIsMissingDomain() Context("when the lock becomes available", func() { BeforeEach(func() {
Eventually(runner, 5*time.Second).Should(gbytes.Say("acquire-lock-succeeded")) consulRunner.DestroySession("converger") }) It("exits with an error", func() { Eventually(runner, exitDuration).Should(Exit(1)) }) }) Context("when the converger initially does not have the lock", func() { var otherSession *consuladapter.Session BeforeEach(func() { otherSession = consulRunner.NewSession("other-session") err := otherSession.AcquireLock(locket.LockSchemaPath("converge_lock"), []byte("something-else")) Expect(err).NotTo(HaveOccurred()) startConverger() }) itIsInactive() Describe("when the lock becomes available", func() { BeforeEach(func() { otherSession.Destroy() time.Sleep(convergeRepeatInterval + 10*time.Millisecond) }) Describe("when a running task with a dead cell is present", func() { JustBeforeEach(createRunningTaskWithDeadCell)
newSession, err = session.Recreate() Expect(err).NotTo(HaveOccurred()) }) AfterEach(func() { newSession.Destroy() }) It("creates a new session", func() { Expect(newSession.ID()).NotTo(Equal(session.ID())) }) It("can contend for the Lock", func() { errCh := make(chan error, 1) go func() { errCh <- newSession.AcquireLock(lockKey, lockValue) }() Eventually(errCh).Should(Receive(BeNil())) }) }) Context("with another session", func() { It("acquires the lock when released", func() { bsession, err := consuladapter.NewSession("b-session", 20*time.Second, client, sessionMgr) Expect(err).NotTo(HaveOccurred()) defer bsession.Destroy() errChan := make(chan error, 1) go func() { defer GinkgoRecover()
BeforeEach(stopCluster) It("a session can be created", func() { Expect(newSessionErr).NotTo(HaveOccurred()) Expect(session).NotTo(BeNil()) }) }) It("creates a new session", func() { Expect(newSessionErr).NotTo(HaveOccurred()) Expect(session).NotTo(BeNil()) }) Context("when a consul session is created", func() { JustBeforeEach(func() { err := session.AcquireLock("foo", []byte{}) Expect(err).NotTo(HaveOccurred()) }) It("has checks", func() { entries, _, err := client.Session().List(nil) Expect(err).NotTo(HaveOccurred()) session := findSession(session.ID(), entries) Expect(session.Checks).To(ConsistOf(serfCheckID)) }) Context("with no checks", func() { BeforeEach(func() { noChecks = true })