|
| 1 | +package e2e_test |
| 2 | + |
| 3 | +import ( |
| 4 | + . "github.com/onsi/ginkgo/v2" |
| 5 | + . "github.com/onsi/gomega" |
| 6 | + . "github.com/onsi/gomega/gexec" |
| 7 | +) |
| 8 | + |
| 9 | +var _ = Describe("podman machine reset", func() { |
| 10 | + var ( |
| 11 | + mb *machineTestBuilder |
| 12 | + testDir string |
| 13 | + ) |
| 14 | + |
| 15 | + BeforeEach(func() { |
| 16 | + testDir, mb = setup() |
| 17 | + }) |
| 18 | + AfterEach(func() { |
| 19 | + teardown(originalHomeDir, testDir, mb) |
| 20 | + }) |
| 21 | + |
| 22 | + It("starting from scratch should not error", func() { |
| 23 | + i := resetMachine{} |
| 24 | + session, err := mb.setCmd(i.withForce()).run() |
| 25 | + Expect(err).ToNot(HaveOccurred()) |
| 26 | + Expect(session).To(Exit(0)) |
| 27 | + }) |
| 28 | + |
| 29 | + It("reset machine with one defined machine", func() { |
| 30 | + name := randomString() |
| 31 | + i := new(initMachine) |
| 32 | + session, err := mb.setName(name).setCmd(i.withImagePath(mb.imagePath)).run() |
| 33 | + Expect(err).ToNot(HaveOccurred()) |
| 34 | + Expect(session).To(Exit(0)) |
| 35 | + |
| 36 | + ls := new(listMachine) |
| 37 | + beforeSession, err := mb.setCmd(ls.withNoHeading()).run() |
| 38 | + Expect(err).ToNot(HaveOccurred()) |
| 39 | + Expect(beforeSession).To(Exit(0)) |
| 40 | + Expect(beforeSession.outputToStringSlice()).To(HaveLen(1)) |
| 41 | + |
| 42 | + reset := resetMachine{} |
| 43 | + resetSession, err := mb.setCmd(reset.withForce()).run() |
| 44 | + Expect(err).ToNot(HaveOccurred()) |
| 45 | + Expect(resetSession).To(Exit(0)) |
| 46 | + |
| 47 | + afterSession, err := mb.setCmd(ls.withNoHeading()).run() |
| 48 | + Expect(err).ToNot(HaveOccurred()) |
| 49 | + Expect(afterSession).To(Exit(0)) |
| 50 | + Expect(afterSession.outputToStringSlice()).To(BeEmpty()) |
| 51 | + }) |
| 52 | + |
| 53 | + It("reset with running machine and other machines idle ", func() { |
| 54 | + name := randomString() |
| 55 | + i := new(initMachine) |
| 56 | + session, err := mb.setName(name).setCmd(i.withImagePath(mb.imagePath).withNow()).run() |
| 57 | + Expect(err).ToNot(HaveOccurred()) |
| 58 | + Expect(session).To(Exit(0)) |
| 59 | + |
| 60 | + ls := new(listMachine) |
| 61 | + beforeSession, err := mb.setCmd(ls.withNoHeading()).run() |
| 62 | + Expect(err).ToNot(HaveOccurred()) |
| 63 | + Expect(beforeSession).To(Exit(0)) |
| 64 | + Expect(beforeSession.outputToStringSlice()).To(HaveLen(1)) |
| 65 | + |
| 66 | + name2 := randomString() |
| 67 | + i2 := new(initMachine) |
| 68 | + session2, err := mb.setName(name2).setCmd(i2.withImagePath(mb.imagePath)).run() |
| 69 | + Expect(err).ToNot(HaveOccurred()) |
| 70 | + Expect(session2).To(Exit(0)) |
| 71 | + |
| 72 | + beforeSession, err = mb.setCmd(ls.withNoHeading()).run() |
| 73 | + Expect(err).ToNot(HaveOccurred()) |
| 74 | + Expect(beforeSession).To(Exit(0)) |
| 75 | + Expect(beforeSession.outputToStringSlice()).To(HaveLen(2)) |
| 76 | + |
| 77 | + reset := resetMachine{} |
| 78 | + resetSession, err := mb.setCmd(reset.withForce()).run() |
| 79 | + Expect(err).ToNot(HaveOccurred()) |
| 80 | + Expect(resetSession).To(Exit(0)) |
| 81 | + |
| 82 | + afterSession, err := mb.setCmd(ls.withNoHeading()).run() |
| 83 | + Expect(err).ToNot(HaveOccurred()) |
| 84 | + Expect(afterSession).To(Exit(0)) |
| 85 | + Expect(afterSession.outputToStringSlice()).To(BeEmpty()) |
| 86 | + }) |
| 87 | + |
| 88 | +}) |
0 commit comments