mirror of
https://github.com/podman-container-tools/podman.git
synced 2026-09-16 12:47:52 +00:00
pkg/machine/e2e: inline stop running machine
Instead of having to start a new machine again here just drop the test and do the stop check as part of another test which already has a machine running. Signed-off-by: Paul Holzinger <pholzing@redhat.com>
This commit is contained in:
parent
9002dce687
commit
49aec99596
2 changed files with 22 additions and 33 deletions
|
|
@ -28,7 +28,7 @@ var _ = Describe("podman machine start", func() {
|
|||
Expect(session.errorToString()).To(ContainSubstring("VM does not exist"))
|
||||
})
|
||||
|
||||
It("start machine already started", func() {
|
||||
It("start machine already started and stop machine already stopped", func() {
|
||||
name := randomString()
|
||||
i := new(initMachine)
|
||||
machineTestBuilderInit := mb.setName(name).setCmd(i.withImage(mb.imagePath))
|
||||
|
|
@ -36,6 +36,7 @@ var _ = Describe("podman machine start", func() {
|
|||
Expect(err).ToNot(HaveOccurred())
|
||||
Expect(session).To(Exit(0))
|
||||
|
||||
starttime := time.Now()
|
||||
s := new(startMachine)
|
||||
// suppress output with no info and check for that.
|
||||
startSession, err := mb.setCmd(s.withNoInfo()).run()
|
||||
|
|
@ -52,6 +53,26 @@ var _ = Describe("podman machine start", func() {
|
|||
Expect(err).ToNot(HaveOccurred())
|
||||
Expect(startSession).To(Exit(125))
|
||||
Expect(startSession.errorToString()).To(ContainSubstring(fmt.Sprintf("Error: unable to start %q: already running", machineTestBuilderInit.name)))
|
||||
|
||||
stop := new(stopMachine)
|
||||
stopSession, err := mb.setCmd(stop).run()
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
Expect(stopSession).To(Exit(0))
|
||||
|
||||
// Stopping it again should not result in an error
|
||||
stopAgain, err := mb.setCmd(stop).run()
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
Expect(stopAgain).To(Exit(0))
|
||||
Expect(stopAgain.outputToString()).To(ContainSubstring(fmt.Sprintf("Machine \"%s\" stopped successfully", name)))
|
||||
|
||||
// Stopping a machine should update the last up time
|
||||
inspect := new(inspectMachine)
|
||||
inspectSession, err := mb.setName(name).setCmd(inspect.withFormat("{{.LastUp.Format \"2006-01-02T15:04:05Z07:00\"}}")).run()
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
Expect(inspectSession).To(Exit(0))
|
||||
lastupTime, err := time.Parse(time.RFC3339, inspectSession.outputToString())
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
Expect(lastupTime).To(BeTemporally(">", starttime))
|
||||
})
|
||||
|
||||
It("start machine with conflict on SSH port", func() {
|
||||
|
|
|
|||
|
|
@ -1,9 +1,6 @@
|
|||
package e2e_test
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
. "github.com/onsi/ginkgo/v2"
|
||||
. "github.com/onsi/gomega"
|
||||
. "github.com/onsi/gomega/gexec"
|
||||
|
|
@ -17,33 +14,4 @@ var _ = Describe("podman machine stop", func() {
|
|||
Expect(err).ToNot(HaveOccurred())
|
||||
Expect(session).To(Exit(125))
|
||||
})
|
||||
|
||||
It("Stop running machine", func() {
|
||||
name := randomString()
|
||||
i := new(initMachine)
|
||||
starttime := time.Now()
|
||||
session, err := mb.setName(name).setCmd(i.withImage(mb.imagePath).withNow()).run()
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
Expect(session).To(Exit(0))
|
||||
|
||||
stop := new(stopMachine)
|
||||
stopSession, err := mb.setCmd(stop).run()
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
Expect(stopSession).To(Exit(0))
|
||||
|
||||
// Stopping it again should not result in an error
|
||||
stopAgain, err := mb.setCmd(stop).run()
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
Expect(stopAgain).To(Exit(0))
|
||||
Expect(stopAgain.outputToString()).To(ContainSubstring(fmt.Sprintf("Machine \"%s\" stopped successfully", name)))
|
||||
|
||||
// Stopping a machine should update the last up time
|
||||
inspect := new(inspectMachine)
|
||||
inspectSession, err := mb.setName(name).setCmd(inspect.withFormat("{{.LastUp.Format \"2006-01-02T15:04:05Z07:00\"}}")).run()
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
Expect(inspectSession).To(Exit(0))
|
||||
lastupTime, err := time.Parse(time.RFC3339, inspectSession.outputToString())
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
Expect(lastupTime).To(BeTemporally(">", starttime))
|
||||
})
|
||||
})
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue