Skip to content

Commit c64c677

Browse files
committed
Rewrite hanging test in Ginkgo v2 style
The `logs -f` test was periodically hanging in CI. The likely reason appears to be that the test is not written in the async style expected by Ginkgo v2. In particular, the `<-session.Exited` would hang.
1 parent 34bf68e commit c64c677

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

src/bpm/integration/logs_test.go

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import (
2020
"os"
2121
"os/exec"
2222
"path/filepath"
23+
"time"
2324

2425
. "github.com/onsi/ginkgo/v2"
2526
. "github.com/onsi/gomega"
@@ -108,16 +109,16 @@ var _ = Describe("logs", func() {
108109
command = exec.Command(bpmPath, "logs", job, "-f")
109110
})
110111

111-
It("streams the logs until it receives a SIGINT signal", func() {
112+
It("streams the logs until it receives a SIGINT signal", func(ctx SpecContext) {
112113
session, err := gexec.Start(command, GinkgoWriter, GinkgoWriter)
113114
Expect(err).ShouldNot(HaveOccurred())
114-
session.Out.Detect("Logging Line #100 to STDOUT\n")
115-
session.Out.CancelDetects()
116115

117-
Consistently(session).ShouldNot(gexec.Exit())
116+
Eventually(session.Out).WithContext(ctx).Should(gbytes.Say("Logging Line #100 to STDOUT\n"))
117+
Consistently(session).WithContext(ctx).ShouldNot(gexec.Exit())
118118
session.Interrupt()
119-
<-session.Exited
120-
})
119+
120+
Eventually(session).WithContext(ctx).Should(gexec.Exit())
121+
}, SpecTimeout(10*time.Second))
121122
})
122123

123124
Context("when the -n flag is specified", func() {

0 commit comments

Comments
 (0)