diff options
author | Brent Baude <bbaude@redhat.com> | 2022-04-02 15:25:19 -0500 |
---|---|---|
committer | Brent Baude <bbaude@redhat.com> | 2022-04-25 13:05:35 -0500 |
commit | 833456e079c31111a15fedaa3ccd7f852e89e508 (patch) | |
tree | 4e06007f5bec3c1cdc763a6b879ecebca5d75a29 /pkg/machine/e2e/init_test.go | |
parent | 6984a0f35704204fa15374aa2c133c4e6e0b366f (diff) | |
download | podman-833456e079c31111a15fedaa3ccd7f852e89e508.tar.gz podman-833456e079c31111a15fedaa3ccd7f852e89e508.tar.bz2 podman-833456e079c31111a15fedaa3ccd7f852e89e508.zip |
Add podman machine test suite
This PR introduces a test suite for podman machine. It can currently be
run on developers' local machines and is not part of the official CI
testing; however, the expectation is that any work on machine should
come with an accompanying test.
At present, the test must be run on Linux. It is untested on Darwin.
There is no Makefile target for the test. It can be run like `ginkgo -v
pkg/machine/test/.`. It should be run as a unprivileged user.
Signed-off-by: Brent Baude <bbaude@redhat.com>
Diffstat (limited to 'pkg/machine/e2e/init_test.go')
-rw-r--r-- | pkg/machine/e2e/init_test.go | 77 |
1 files changed, 77 insertions, 0 deletions
diff --git a/pkg/machine/e2e/init_test.go b/pkg/machine/e2e/init_test.go new file mode 100644 index 000000000..309d460a9 --- /dev/null +++ b/pkg/machine/e2e/init_test.go @@ -0,0 +1,77 @@ +package e2e + +import ( + "time" + + "github.com/containers/podman/v4/pkg/machine" + + . "github.com/onsi/ginkgo" + . "github.com/onsi/gomega" + . "github.com/onsi/gomega/gexec" +) + +var _ = Describe("podman machine init", func() { + var ( + mb *machineTestBuilder + testDir string + ) + + BeforeEach(func() { + testDir, mb = setup() + }) + AfterEach(func() { + teardown(originalHomeDir, testDir, mb) + }) + + It("bad init name", func() { + i := initMachine{} + reallyLongName := "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" + session, err := mb.setName(reallyLongName).setCmd(&i).run() + Expect(err).To(BeNil()) + Expect(session.ExitCode()).To(Equal(125)) + }) + It("simple init", func() { + i := new(initMachine) + session, err := mb.setCmd(i.withImagePath(mb.imagePath)).run() + Expect(err).To(BeNil()) + Expect(session.ExitCode()).To(Equal(0)) + + inspectBefore, ec, err := mb.toQemuInspectInfo() + Expect(err).To(BeNil()) + Expect(ec).To(BeZero()) + + Expect(len(inspectBefore)).To(BeNumerically(">", 0)) + testMachine := inspectBefore[0] + Expect(testMachine.VM.Name).To(Equal(mb.names[0])) + Expect(testMachine.VM.CPUs).To(Equal(uint64(1))) + Expect(testMachine.VM.Memory).To(Equal(uint64(2048))) + + }) + + It("simple init with start", func() { + i := initMachine{} + session, err := mb.setCmd(i.withImagePath(mb.imagePath)).run() + Expect(err).To(BeNil()) + Expect(session.ExitCode()).To(Equal(0)) + + inspectBefore, ec, err := mb.toQemuInspectInfo() + Expect(ec).To(BeZero()) + Expect(len(inspectBefore)).To(BeNumerically(">", 0)) + Expect(err).To(BeNil()) + Expect(len(inspectBefore)).To(BeNumerically(">", 0)) + Expect(inspectBefore[0].VM.Name).To(Equal(mb.names[0])) + + s := startMachine{} + ssession, err := mb.setCmd(s).setTimeout(time.Minute * 10).run() + Expect(err).To(BeNil()) + Expect(ssession).Should(Exit(0)) + + inspectAfter, ec, err := mb.toQemuInspectInfo() + Expect(err).To(BeNil()) + Expect(ec).To(BeZero()) + Expect(len(inspectBefore)).To(BeNumerically(">", 0)) + Expect(len(inspectAfter)).To(BeNumerically(">", 0)) + Expect(inspectAfter[0].State).To(Equal(machine.Running)) + }) + +}) |