Simplify drain test
Test was flaky: drains-0 was already gone when trying to check logs.
Relying on pod stdout has proven to always be flaky. The flakiness was
hidden by the goroutines, which didn't use GinkgoRecover.
package integration_test
import (
- "sync"
-
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
@@ -21,8 +19,7 @@ var _ = Describe("Drain", func() {
When("deleting the deployment", func() {
It("executes the job's drain scripts", func() {
- cm := env.BOSHManifestConfigMap("manifest", bm.NatsSmall)
- cm.Data["manifest"] = bm.Drains
+ cm := env.BOSHManifestConfigMap("manifest", bm.Drains)
tearDown, err := env.CreateConfigMap(env.Namespace, cm)
Expect(err).NotTo(HaveOccurred())
defer func(tdf machine.TearDownFunc) { Expect(tdf()).To(Succeed()) }(tearDown)
@@ -37,34 +34,8 @@ var _ = Describe("Drain", func() {
err = env.WaitForPodReady(env.Namespace, "drains-0")
Expect(err).NotTo(HaveOccurred())
- done := make(chan interface{})
-
- go func() {
- // Check for files created by the drain scripts.
- var preAssertionWg, postAssertionWg sync.WaitGroup
- preAssertionWg.Add(2)
- postAssertionWg.Add(2)
- go func() {
- defer GinkgoRecover()
- preAssertionWg.Done()
- Expect(env.WaitForPodContainerLogMsg(env.Namespace, "drains-0", "delaying-drain-job-drain-watch", "delaying-drain-job.log")).To(BeNil(), "error finding file created by drain script")
- postAssertionWg.Done()
- }()
- go func() {
- defer GinkgoRecover()
- preAssertionWg.Done()
- Expect(env.WaitForPodContainerLogMsg(env.Namespace, "drains-0", "failing-drain-job-drain-watch", "failing-drain-job.log")).To(BeNil(), "error finding file created by drain script")
- postAssertionWg.Done()
- }()
- preAssertionWg.Wait()
- go func() {
_ = env.DeleteBOSHDeployment(env.Namespace, boshDeployment.Name)
- }()
- postAssertionWg.Wait()
- close(done)
- }()
-
- Eventually(done, env.PollTimeout).Should(BeClosed())
+ Expect(env.WaitForPodContainerLogMsg(env.Namespace, "drains-0", "delaying-drain-job-drain-watch", "delaying-drain-job.log")).To(BeNil(), "error finding file created by delaying drain script")
})
})
})
