mirror of
https://github.com/containers/podman.git
synced 2025-08-06 19:44:14 +08:00
Merge pull request #15244 from baude/machinememorytests
check memory test based on range
This commit is contained in:
@ -3,7 +3,7 @@ package e2e_test
|
|||||||
import (
|
import (
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"os"
|
"os"
|
||||||
"runtime"
|
"strconv"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/containers/podman/v4/pkg/machine"
|
"github.com/containers/podman/v4/pkg/machine"
|
||||||
@ -80,7 +80,7 @@ var _ = Describe("podman machine init", func() {
|
|||||||
It("machine init with cpus, disk size, memory, timezone", func() {
|
It("machine init with cpus, disk size, memory, timezone", func() {
|
||||||
name := randomString()
|
name := randomString()
|
||||||
i := new(initMachine)
|
i := new(initMachine)
|
||||||
session, err := mb.setName(name).setCmd(i.withImagePath(mb.imagePath).withCPUs(2).withDiskSize(102).withMemory(4000).withTimezone("Pacific/Honolulu")).run()
|
session, err := mb.setName(name).setCmd(i.withImagePath(mb.imagePath).withCPUs(2).withDiskSize(102).withMemory(4096).withTimezone("Pacific/Honolulu")).run()
|
||||||
Expect(err).To(BeNil())
|
Expect(err).To(BeNil())
|
||||||
Expect(session).To(Exit(0))
|
Expect(session).To(Exit(0))
|
||||||
|
|
||||||
@ -102,18 +102,13 @@ var _ = Describe("podman machine init", func() {
|
|||||||
Expect(diskSession.outputToString()).To(ContainSubstring("102 GiB"))
|
Expect(diskSession.outputToString()).To(ContainSubstring("102 GiB"))
|
||||||
|
|
||||||
sshMemory := sshMachine{}
|
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()
|
memorySession, err := mb.setName(name).setCmd(sshMemory.withSSHComand([]string{"cat", "/proc/meminfo", "|", "grep", "-i", "'memtotal'", "|", "grep", "-o", "'[[:digit:]]*'"})).run()
|
||||||
Expect(err).To(BeNil())
|
Expect(err).To(BeNil())
|
||||||
Expect(memorySession).To(Exit(0))
|
Expect(memorySession).To(Exit(0))
|
||||||
switch runtime.GOOS {
|
foundMemory, err := strconv.Atoi(memorySession.outputToString())
|
||||||
// os's handle memory differently
|
Expect(err).To(BeNil())
|
||||||
case "linux":
|
Expect(foundMemory).To(BeNumerically(">", 3800000))
|
||||||
Expect(memorySession.outputToString()).To(ContainSubstring("3822"))
|
Expect(foundMemory).To(BeNumerically("<", 4200000))
|
||||||
case "darwin":
|
|
||||||
Expect(memorySession.outputToString()).To(ContainSubstring("3824"))
|
|
||||||
default:
|
|
||||||
// add windows when testing on that platform
|
|
||||||
}
|
|
||||||
|
|
||||||
sshTimezone := sshMachine{}
|
sshTimezone := sshMachine{}
|
||||||
timezoneSession, err := mb.setName(name).setCmd(sshTimezone.withSSHComand([]string{"date"})).run()
|
timezoneSession, err := mb.setName(name).setCmd(sshTimezone.withSSHComand([]string{"date"})).run()
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package e2e_test
|
package e2e_test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"runtime"
|
"strconv"
|
||||||
|
|
||||||
. "github.com/onsi/ginkgo"
|
. "github.com/onsi/ginkgo"
|
||||||
. "github.com/onsi/gomega"
|
. "github.com/onsi/gomega"
|
||||||
@ -29,7 +29,7 @@ var _ = Describe("podman machine set", func() {
|
|||||||
Expect(session).To(Exit(0))
|
Expect(session).To(Exit(0))
|
||||||
|
|
||||||
set := setMachine{}
|
set := setMachine{}
|
||||||
setSession, err := mb.setName(name).setCmd(set.withCPUs(2).withDiskSize(102).withMemory(4000)).run()
|
setSession, err := mb.setName(name).setCmd(set.withCPUs(2).withDiskSize(102).withMemory(4096)).run()
|
||||||
Expect(err).To(BeNil())
|
Expect(err).To(BeNil())
|
||||||
Expect(setSession).To(Exit(0))
|
Expect(setSession).To(Exit(0))
|
||||||
|
|
||||||
@ -56,18 +56,14 @@ var _ = Describe("podman machine set", func() {
|
|||||||
Expect(diskSession.outputToString()).To(ContainSubstring("102 GiB"))
|
Expect(diskSession.outputToString()).To(ContainSubstring("102 GiB"))
|
||||||
|
|
||||||
sshMemory := sshMachine{}
|
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()
|
memorySession, err := mb.setName(name).setCmd(sshMemory.withSSHComand([]string{"cat", "/proc/meminfo", "|", "grep", "-i", "'memtotal'", "|", "grep", "-o", "'[[:digit:]]*'"})).run()
|
||||||
Expect(err).To(BeNil())
|
Expect(err).To(BeNil())
|
||||||
Expect(memorySession).To(Exit(0))
|
Expect(memorySession).To(Exit(0))
|
||||||
switch runtime.GOOS {
|
foundMemory, err := strconv.Atoi(memorySession.outputToString())
|
||||||
// it seems macos and linux handle memory differently
|
Expect(err).To(BeNil())
|
||||||
case "linux":
|
Expect(foundMemory).To(BeNumerically(">", 3800000))
|
||||||
Expect(memorySession.outputToString()).To(ContainSubstring("3822"))
|
Expect(foundMemory).To(BeNumerically("<", 4200000))
|
||||||
case "darwin":
|
|
||||||
Expect(memorySession.outputToString()).To(ContainSubstring("3824"))
|
|
||||||
default:
|
|
||||||
// windows can go here if we ever run tests there
|
|
||||||
}
|
|
||||||
// Setting a running machine results in 125
|
// Setting a running machine results in 125
|
||||||
runner, err := mb.setName(name).setCmd(set.withCPUs(4)).run()
|
runner, err := mb.setName(name).setCmd(set.withCPUs(4)).run()
|
||||||
Expect(err).To(BeNil())
|
Expect(err).To(BeNil())
|
||||||
|
Reference in New Issue
Block a user