Update test for failed container garbage collection
@@ -42,7 +42,7 @@ var _ = Describe("BuildFactory", func() {
})
})
- Describe("MarkNonInterceptibleBuilds", func() {
+ FDescribe("MarkNonInterceptibleBuilds", func() {
Context("one-off builds", func() {
DescribeTable("completed and within grace period",
func(status db.BuildStatus, matcher types.GomegaMatcher) {
@@ -209,62 +209,31 @@ var _ = Describe("BuildFactory", func() {
Expect(i).To(BeTrue())
})
})
- Context("failed builds gc'd", func() {
- DescribeTable("completed and within grace period",
- func(status db.BuildStatus, matcher types.GomegaMatcher) {
- b, err := defaultJob.CreateBuild()
+ Context("GC failed builds", func() {
+ It("marks failed builds non-interceptible after failed-grace-period", func() {
+ buildFactory = db.NewBuildFactory(dbConn, lockFactory, 0, 2*time.Second)
+ build, err := defaultJob.CreateBuild()
Expect(err).NotTo(HaveOccurred())
- var i bool
- err = b.Finish(status)
+ err = build.Finish(db.BuildStatusFailed)
Expect(err).NotTo(HaveOccurred())
err = buildFactory.MarkNonInterceptibleBuilds()
Expect(err).NotTo(HaveOccurred())
- i, err = b.Interceptible()
- Expect(err).NotTo(HaveOccurred())
- Expect(i).To(matcher)
- },
- Entry("succeeded is interceptible", db.BuildStatusSucceeded, BeTrue()),
- Entry("aborted is interceptible", db.BuildStatusAborted, BeTrue()),
- Entry("errored is interceptible", db.BuildStatusErrored, BeTrue()),
- Entry("failed is interceptible", db.BuildStatusFailed, BeFalse()),
- )
- DescribeTable("completed and past the grace period",
- func(status db.BuildStatus, matcher types.GomegaMatcher) {
- //set grace period to 0 for this test
- buildFactory = db.NewBuildFactory(dbConn, lockFactory, 0, 1)
- b, err := defaultTeam.CreateOneOffBuild()
- Expect(err).NotTo(HaveOccurred())
-
var i bool
- err = b.Finish(status)
+ i, err = build.Interceptible()
Expect(err).NotTo(HaveOccurred())
+ Expect(i).To(BeTrue())
- err = buildFactory.MarkNonInterceptibleBuilds()
- Expect(err).NotTo(HaveOccurred())
-
- i, err = b.Interceptible()
- Expect(err).NotTo(HaveOccurred())
- Expect(i).NotTo(matcher)
- },
- Entry("succeeded is non-interceptible", db.BuildStatusSucceeded, BeFalse()),
- Entry("aborted is non-interceptible", db.BuildStatusAborted, BeFalse()),
- Entry("errored is non-interceptible", db.BuildStatusErrored, BeFalse()),
- Entry("failed is non-interceptible", db.BuildStatusFailed, BeFalse()),
- )
-
- It("non-completed is interceptible", func() {
- b, err := defaultTeam.CreateOneOffBuild()
- Expect(err).NotTo(HaveOccurred())
+ time.Sleep(3 * time.Second) // Wait for second-granularity, better method?
- var i bool
err = buildFactory.MarkNonInterceptibleBuilds()
Expect(err).NotTo(HaveOccurred())
- i, err = b.Interceptible()
+
+ i, err = build.Interceptible()
Expect(err).NotTo(HaveOccurred())
- Expect(i).To(BeTrue())
+ Expect(i).To(BeFalse())
})
})
})
