odo dev --logs (#6957)

* Move logic to pkg/logs

* Fix Ctrl-c

* odo dev --logs

* Add integration test
This commit is contained in:
Philippe Martin
2023-07-07 16:58:56 +02:00
committed by GitHub
parent ebe003ede0
commit 9624721ed3
6 changed files with 250 additions and 138 deletions

View File

@@ -133,6 +133,7 @@ type DevSessionOpts struct {
StartAPIServer bool
APIServerPort int
SyncGitDir bool
ShowLogs bool
}
// StartDevMode starts a dev session with `odo dev`
@@ -170,6 +171,9 @@ func StartDevMode(options DevSessionOpts) (devSession DevSession, err error) {
if options.SyncGitDir {
args = append(args, "--sync-git-dir")
}
if options.ShowLogs {
args = append(args, "--logs")
}
args = append(args, options.CmdlineArgs...)
cmd := Cmd("odo", args...)
cmd.Cmd.Stdin = c.Tty()

View File

@@ -224,6 +224,37 @@ var _ = Describe("odo logs command tests", func() {
})
}))
})
When("running in Dev mode with --logs", helper.LabelPodmanIf(podman, func() {
var devSession helper.DevSession
BeforeEach(func() {
var err error
devSession, err = helper.StartDevMode(helper.DevSessionOpts{
RunOnPodman: podman,
ShowLogs: true,
})
Expect(err).ToNot(HaveOccurred())
if !podman {
// We need to wait for the pod deployed as a Kubernetes component
Eventually(func() bool {
return areAllPodsRunning()
}).Should(Equal(true))
}
})
AfterEach(func() {
devSession.Stop()
devSession.WaitEnd()
})
It("1. should successfully show logs of the running component", func() {
Expect(devSession.StdOut).To(ContainSubstring("--> Logs for"))
Expect(devSession.StdOut).To(ContainSubstring("runtime: Server running"))
if !podman {
Expect(devSession.StdOut).To(ContainSubstring("main: "))
}
})
}))
}
When("running in Deploy mode", func() {