summaryrefslogtreecommitdiff
path: root/pkg/machine/e2e/init_test.go
diff options
context:
space:
mode:
authorAshley Cui <acui@redhat.com>2022-05-05 16:45:30 -0400
committerAshley Cui <acui@redhat.com>2022-05-10 14:56:13 -0400
commitc7c00ce55199c1e569953a4a03055268ecca147e (patch)
tree82b78e412618b1fd4a8f6aeea0c9719af0d9e633 /pkg/machine/e2e/init_test.go
parent28588235d2051bf673d528c293261f926fad0d92 (diff)
downloadpodman-c7c00ce55199c1e569953a4a03055268ecca147e.tar.gz
podman-c7c00ce55199c1e569953a4a03055268ecca147e.tar.bz2
podman-c7c00ce55199c1e569953a4a03055268ecca147e.zip
Add more machine tests
Add more machine tests for flags in init, inspect, and list. Signed-off-by: Ashley Cui <acui@redhat.com>
Diffstat (limited to 'pkg/machine/e2e/init_test.go')
-rw-r--r--pkg/machine/e2e/init_test.go65
1 files changed, 65 insertions, 0 deletions
diff --git a/pkg/machine/e2e/init_test.go b/pkg/machine/e2e/init_test.go
index 304122738..6949eb0af 100644
--- a/pkg/machine/e2e/init_test.go
+++ b/pkg/machine/e2e/init_test.go
@@ -1,6 +1,8 @@
package e2e
import (
+ "io/ioutil"
+ "os"
"time"
"github.com/containers/podman/v4/pkg/machine"
@@ -74,4 +76,67 @@ var _ = Describe("podman machine init", func() {
Expect(inspectAfter[0].State).To(Equal(machine.Running))
})
+ It("machine init with cpus, disk size, memory, timezone", func() {
+ name := randomString(12)
+ i := new(initMachine)
+ session, err := mb.setName(name).setCmd(i.withImagePath(mb.imagePath).withCPUs(2).withDiskSize(102).withMemory(4000).withTimezone("Pacific/Honolulu")).run()
+ Expect(err).To(BeNil())
+ Expect(session).To(Exit(0))
+
+ s := new(startMachine)
+ startSession, err := mb.setCmd(s).run()
+ Expect(err).To(BeNil())
+ Expect(startSession).To(Exit(0))
+
+ sshCPU := sshMachine{}
+ CPUsession, err := mb.setName(name).setCmd(sshCPU.withSSHComand([]string{"lscpu", "|", "grep", "\"CPU(s):\"", "|", "head", "-1"})).run()
+ Expect(err).To(BeNil())
+ Expect(CPUsession).To(Exit(0))
+ Expect(CPUsession.outputToString()).To(ContainSubstring("2"))
+
+ sshDisk := sshMachine{}
+ diskSession, err := mb.setName(name).setCmd(sshDisk.withSSHComand([]string{"sudo", "fdisk", "-l", "|", "grep", "Disk"})).run()
+ Expect(err).To(BeNil())
+ Expect(diskSession).To(Exit(0))
+ Expect(diskSession.outputToString()).To(ContainSubstring("102 GiB"))
+
+ 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(memorySession).To(Exit(0))
+ Expect(memorySession.outputToString()).To(ContainSubstring("3824"))
+
+ sshTimezone := sshMachine{}
+ timezoneSession, err := mb.setName(name).setCmd(sshTimezone.withSSHComand([]string{"date"})).run()
+ Expect(err).To(BeNil())
+ Expect(timezoneSession).To(Exit(0))
+ Expect(timezoneSession.outputToString()).To(ContainSubstring("HST"))
+ })
+
+ It("machine init with volume", func() {
+ tmpDir, err := ioutil.TempDir("", "")
+ Expect(err).To(BeNil())
+ _, err = ioutil.TempFile(tmpDir, "example")
+ Expect(err).To(BeNil())
+ mount := tmpDir + ":/testmountdir"
+ defer os.RemoveAll(tmpDir)
+
+ name := randomString(12)
+ i := new(initMachine)
+ session, err := mb.setName(name).setCmd(i.withImagePath(mb.imagePath).withVolume(mount)).run()
+ Expect(err).To(BeNil())
+ Expect(session).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{"ls /testmountdir"})).run()
+ Expect(err).To(BeNil())
+ Expect(sshSession2).To(Exit(0))
+ Expect(sshSession2.outputToString()).To(ContainSubstring("example"))
+ })
+
})