diff options
Diffstat (limited to 'pkg/machine/e2e/set_test.go')
-rw-r--r-- | pkg/machine/e2e/set_test.go | 72 |
1 files changed, 18 insertions, 54 deletions
diff --git a/pkg/machine/e2e/set_test.go b/pkg/machine/e2e/set_test.go index 9af29c560..15215a44d 100644 --- a/pkg/machine/e2e/set_test.go +++ b/pkg/machine/e2e/set_test.go @@ -19,7 +19,7 @@ var _ = Describe("podman machine set", func() { teardown(originalHomeDir, testDir, mb) }) - It("set machine cpus", func() { + It("set machine cpus, disk, memory", func() { name := randomString(12) i := new(initMachine) session, err := mb.setName(name).setCmd(i.withImagePath(mb.imagePath)).run() @@ -27,40 +27,11 @@ var _ = Describe("podman machine set", func() { Expect(session).To(Exit(0)) set := setMachine{} - setSession, err := mb.setName(name).setCmd(set.withCPUs(2)).run() + setSession, err := mb.setName(name).setCmd(set.withCPUs(2).withDiskSize(102).withMemory(4000)).run() Expect(err).To(BeNil()) Expect(setSession).To(Exit(0)) - s := new(startMachine) - startSession, err := mb.setCmd(s).run() - Expect(err).To(BeNil()) - Expect(startSession).To(Exit(0)) - - ssh2 := sshMachine{} - sshSession2, err := mb.setName(name).setCmd(ssh2.withSSHComand([]string{"lscpu", "|", "grep", "\"CPU(s):\"", "|", "head", "-1"})).run() - Expect(err).To(BeNil()) - Expect(sshSession2).To(Exit(0)) - Expect(sshSession2.outputToString()).To(ContainSubstring("2")) - - // Setting a running machine results in 125 - runner, err := mb.setName(name).setCmd(set.withCPUs(4)).run() - Expect(err).To(BeNil()) - Expect(runner).To(Exit(125)) - }) - - It("increase machine disk size", func() { - name := randomString(12) - i := new(initMachine) - session, err := mb.setName(name).setCmd(i.withImagePath(mb.imagePath)).run() - Expect(err).To(BeNil()) - Expect(session).To(Exit(0)) - - set := setMachine{} - setSession, err := mb.setName(name).setCmd(set.withDiskSize(102)).run() - Expect(err).To(BeNil()) - Expect(setSession).To(Exit(0)) - - // shrinking disk size iss verboten + // shrinking disk size is verboten shrink, err := mb.setName(name).setCmd(set.withDiskSize(5)).run() Expect(err).To(BeNil()) Expect(shrink).To(Exit(125)) @@ -70,35 +41,28 @@ var _ = Describe("podman machine set", func() { Expect(err).To(BeNil()) Expect(startSession).To(Exit(0)) - ssh2 := sshMachine{} - sshSession2, err := mb.setName(name).setCmd(ssh2.withSSHComand([]string{"sudo", "fdisk", "-l", "|", "grep", "Disk"})).run() - Expect(err).To(BeNil()) - Expect(sshSession2).To(Exit(0)) - Expect(sshSession2.outputToString()).To(ContainSubstring("102 GiB")) - }) - - It("set machine ram", func() { - name := randomString(12) - i := new(initMachine) - session, err := mb.setName(name).setCmd(i.withImagePath(mb.imagePath)).run() + sshCPU := sshMachine{} + CPUsession, err := mb.setName(name).setCmd(sshCPU.withSSHComand([]string{"lscpu", "|", "grep", "\"CPU(s):\"", "|", "head", "-1"})).run() Expect(err).To(BeNil()) - Expect(session).To(Exit(0)) + Expect(CPUsession).To(Exit(0)) + Expect(CPUsession.outputToString()).To(ContainSubstring("2")) - set := setMachine{} - setSession, err := mb.setName(name).setCmd(set.withMemory(4000)).run() + sshDisk := sshMachine{} + diskSession, err := mb.setName(name).setCmd(sshDisk.withSSHComand([]string{"sudo", "fdisk", "-l", "|", "grep", "Disk"})).run() Expect(err).To(BeNil()) - Expect(setSession).To(Exit(0)) + Expect(diskSession).To(Exit(0)) + Expect(diskSession.outputToString()).To(ContainSubstring("102 GiB")) - s := new(startMachine) - startSession, err := mb.setCmd(s).run() + sshMemory := sshMachine{} + memorySession, err := mb.setName(name).setCmd(sshMemory.withSSHComand([]string{"cat", "/proc/meminfo", "|", "numfmt", "--field", "2", "--from-unit=Ki", "--to-unit=Mi", "|", "sed", "'s/ kB/M/g'", "|", "grep", "MemTotal"})).run() Expect(err).To(BeNil()) - Expect(startSession).To(Exit(0)) + Expect(memorySession).To(Exit(0)) + Expect(memorySession.outputToString()).To(ContainSubstring("3824")) - ssh2 := sshMachine{} - sshSession2, err := mb.setName(name).setCmd(ssh2.withSSHComand([]string{"cat", "/proc/meminfo", "|", "numfmt", "--field", "2", "--from-unit=Ki", "--to-unit=Mi", "|", "sed", "'s/ kB/M/g'", "|", "grep", "MemTotal"})).run() + // Setting a running machine results in 125 + runner, err := mb.setName(name).setCmd(set.withCPUs(4)).run() Expect(err).To(BeNil()) - Expect(sshSession2).To(Exit(0)) - Expect(sshSession2.outputToString()).To(ContainSubstring("3824")) + Expect(runner).To(Exit(125)) }) It("no settings should change if no flags", func() { |