Exemple #1
0
	})

	Context("when it can't get the lock for the first job", func() {
		BeforeEach(func() {
			locker.AcquireWriteLockImmediatelyStub = func(locks []db.NamedLock) (db.Lock, error) {
				if locker.AcquireWriteLockImmediatelyCallCount() == 1 {
					return nil, errors.New("can't aqcuire lock")
				}
				return lock, nil
			}
		})

		It("follows on to the next job", func() {
			Eventually(locker.AcquireWriteLockImmediatelyCallCount).Should(Equal(2))

			_, job, resources := scheduler.TryNextPendingBuildArgsForCall(0)
			Ω(job).Should(Equal(atc.JobConfig{Name: "some-other-job"}))
			Ω(resources).Should(Equal(initialConfig.Resources))
		})
	})

	It("schedules pending builds", func() {
		Eventually(scheduler.TryNextPendingBuildCallCount).Should(Equal(2))

		_, job, resources := scheduler.TryNextPendingBuildArgsForCall(0)
		Ω(job).Should(Equal(atc.JobConfig{Name: "some-job"}))
		Ω(resources).Should(Equal(initialConfig.Resources))

		_, job, resources = scheduler.TryNextPendingBuildArgsForCall(1)
		Ω(job).Should(Equal(atc.JobConfig{Name: "some-other-job"}))
		Ω(resources).Should(Equal(initialConfig.Resources))
Exemple #2
0
		BeforeEach(func() {
			pipelineDB.LeaseSchedulingReturns(nil, false, errors.New(":3"))
		})

		It("does not do any scheduling", func() {
			Eventually(pipelineDB.LeaseSchedulingCallCount).Should(Equal(2))

			Expect(scheduler.TryNextPendingBuildCallCount()).To(BeZero())
			Expect(scheduler.BuildLatestInputsCallCount()).To(BeZero())
		})
	})

	It("schedules pending builds", func() {
		Eventually(scheduler.TryNextPendingBuildCallCount).Should(Equal(2))

		_, versions, job, resources, resourceTypes := scheduler.TryNextPendingBuildArgsForCall(0)
		Expect(versions).To(Equal(someVersions))
		Expect(job).To(Equal(atc.JobConfig{Name: "some-job"}))
		Expect(resources).To(Equal(initialConfig.Resources))
		Expect(resourceTypes).To(Equal(initialConfig.ResourceTypes))

		_, versions, job, resources, resourceTypes = scheduler.TryNextPendingBuildArgsForCall(1)
		Expect(versions).To(Equal(someVersions))
		Expect(job).To(Equal(atc.JobConfig{Name: "some-other-job"}))
		Expect(resources).To(Equal(initialConfig.Resources))
		Expect(resourceTypes).To(Equal(initialConfig.ResourceTypes))
	})

	It("schedules builds for new inputs using the given versions dataset", func() {
		Eventually(scheduler.BuildLatestInputsCallCount).Should(Equal(2))