mirror of
https://github.com/containers/podman.git
synced 2026-03-30 20:43:40 -04:00
Podman machine reset is a new command that will "reset" your podman
machine environment. Reset is defined as:
* Stop and Remove all VMs
* Remove the following directories:
- configuration dir i.e. ~/.config/containers/podman/machine/qemu
- data dir i.e. ~/.local/.share/containers/podman/machine/qemu
When deleting, if errors are encountered, they will be batched and spit
out at the end. Podman will try to proceed even in error in doing what
it was told.
Signed-off-by: Brent Baude <bbaude@redhat.com>
89 lines
2.5 KiB
Go
89 lines
2.5 KiB
Go
package e2e_test
|
|
|
|
import (
|
|
. "github.com/onsi/ginkgo/v2"
|
|
. "github.com/onsi/gomega"
|
|
. "github.com/onsi/gomega/gexec"
|
|
)
|
|
|
|
var _ = Describe("podman machine reset", func() {
|
|
var (
|
|
mb *machineTestBuilder
|
|
testDir string
|
|
)
|
|
|
|
BeforeEach(func() {
|
|
testDir, mb = setup()
|
|
})
|
|
AfterEach(func() {
|
|
teardown(originalHomeDir, testDir, mb)
|
|
})
|
|
|
|
It("starting from scratch should not error", func() {
|
|
i := resetMachine{}
|
|
session, err := mb.setCmd(i.withForce()).run()
|
|
Expect(err).ToNot(HaveOccurred())
|
|
Expect(session).To(Exit(0))
|
|
})
|
|
|
|
It("reset machine with one defined machine", func() {
|
|
name := randomString()
|
|
i := new(initMachine)
|
|
session, err := mb.setName(name).setCmd(i.withImagePath(mb.imagePath)).run()
|
|
Expect(err).ToNot(HaveOccurred())
|
|
Expect(session).To(Exit(0))
|
|
|
|
ls := new(listMachine)
|
|
beforeSession, err := mb.setCmd(ls.withNoHeading()).run()
|
|
Expect(err).ToNot(HaveOccurred())
|
|
Expect(beforeSession).To(Exit(0))
|
|
Expect(beforeSession.outputToStringSlice()).To(HaveLen(1))
|
|
|
|
reset := resetMachine{}
|
|
resetSession, err := mb.setCmd(reset.withForce()).run()
|
|
Expect(err).ToNot(HaveOccurred())
|
|
Expect(resetSession).To(Exit(0))
|
|
|
|
afterSession, err := mb.setCmd(ls.withNoHeading()).run()
|
|
Expect(err).ToNot(HaveOccurred())
|
|
Expect(afterSession).To(Exit(0))
|
|
Expect(afterSession.outputToStringSlice()).To(BeEmpty())
|
|
})
|
|
|
|
It("reset with running machine and other machines idle ", func() {
|
|
name := randomString()
|
|
i := new(initMachine)
|
|
session, err := mb.setName(name).setCmd(i.withImagePath(mb.imagePath).withNow()).run()
|
|
Expect(err).ToNot(HaveOccurred())
|
|
Expect(session).To(Exit(0))
|
|
|
|
ls := new(listMachine)
|
|
beforeSession, err := mb.setCmd(ls.withNoHeading()).run()
|
|
Expect(err).ToNot(HaveOccurred())
|
|
Expect(beforeSession).To(Exit(0))
|
|
Expect(beforeSession.outputToStringSlice()).To(HaveLen(1))
|
|
|
|
name2 := randomString()
|
|
i2 := new(initMachine)
|
|
session2, err := mb.setName(name2).setCmd(i2.withImagePath(mb.imagePath)).run()
|
|
Expect(err).ToNot(HaveOccurred())
|
|
Expect(session2).To(Exit(0))
|
|
|
|
beforeSession, err = mb.setCmd(ls.withNoHeading()).run()
|
|
Expect(err).ToNot(HaveOccurred())
|
|
Expect(beforeSession).To(Exit(0))
|
|
Expect(beforeSession.outputToStringSlice()).To(HaveLen(2))
|
|
|
|
reset := resetMachine{}
|
|
resetSession, err := mb.setCmd(reset.withForce()).run()
|
|
Expect(err).ToNot(HaveOccurred())
|
|
Expect(resetSession).To(Exit(0))
|
|
|
|
afterSession, err := mb.setCmd(ls.withNoHeading()).run()
|
|
Expect(err).ToNot(HaveOccurred())
|
|
Expect(afterSession).To(Exit(0))
|
|
Expect(afterSession.outputToStringSlice()).To(BeEmpty())
|
|
})
|
|
|
|
})
|