mirror of
https://github.com/redhat-developer/odo.git
synced 2025-10-19 03:06:19 +03:00
odo dev --logs (#6957)
* Move logic to pkg/logs * Fix Ctrl-c * odo dev --logs * Add integration test
This commit is contained in:
@@ -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()
|
||||
|
||||
@@ -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() {
|
||||
|
||||
Reference in New Issue
Block a user