Adjust machine CPU tests

Machine cpu default has changed to cpus/2, so adjust the tests to reflect that.

Signed-off-by: Ashley Cui <acui@redhat.com>
This commit is contained in:
Ashley Cui committed 2023-09-22 13:11:12 -04:00
1 parent 96142c2f75
commit d8e3057165
2 files changed
+15 -4

No files matched your search

+9 -3
View File
@@ -2,6 +2,7 @@ package e2e_test
import (
"os"
"runtime"
"strconv"
"strings"
"time"
@@ -26,6 +27,11 @@ var _ = Describe("podman machine init", func() {
teardown(originalHomeDir, testDir, mb)
})
cpus := runtime.NumCPU() / 2
if cpus == 0 {
cpus = 1
}
It("bad init name", func() {
i := initMachine{}
reallyLongName := "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
@@ -42,11 +48,11 @@ var _ = Describe("podman machine init", func() {
inspectBefore, ec, err := mb.toQemuInspectInfo()
Expect(err).ToNot(HaveOccurred())
Expect(ec).To(BeZero())
Expect(inspectBefore).ToNot(BeEmpty())
testMachine := inspectBefore[0]
Expect(testMachine.Name).To(Equal(mb.names[0]))
Expect(testMachine.Resources.CPUs).To(Equal(uint64(1)))
Expect(testMachine.Resources.CPUs).To(Equal(uint64(cpus)))
Expect(testMachine.Resources.Memory).To(Equal(uint64(2048)))
})
@@ -91,7 +97,7 @@ var _ = Describe("podman machine init", func() {
Expect(inspectBefore).ToNot(BeEmpty())
testMachine := inspectBefore[0]
Expect(testMachine.Name).To(Equal(mb.names[0]))
Expect(testMachine.Resources.CPUs).To(Equal(uint64(1)))
Expect(testMachine.Resources.CPUs).To(Equal(uint64(cpus)))
Expect(testMachine.Resources.Memory).To(Equal(uint64(2048)))
Expect(testMachine.SSHConfig.RemoteUsername).To((Equal(remoteUsername)))
+6 -1
View File
@@ -1,6 +1,7 @@
package e2e_test
import (
"runtime"
"strconv"
"strings"
@@ -89,10 +90,14 @@ var _ = Describe("podman machine set", func() {
Expect(startSession).To(Exit(0))
ssh2 := sshMachine{}
cpus := runtime.NumCPU() / 2
if cpus == 0 {
cpus = 1
}
sshSession2, err := mb.setName(name).setCmd(ssh2.withSSHCommand([]string{"lscpu", "|", "grep", "\"CPU(s):\"", "|", "head", "-1"})).run()
Expect(err).ToNot(HaveOccurred())
Expect(sshSession2).To(Exit(0))
Expect(sshSession2.outputToString()).To(ContainSubstring("1"))
Expect(sshSession2.outputToString()).To(ContainSubstring(strconv.Itoa(cpus)))
ssh3 := sshMachine{}
sshSession3, err := mb.setName(name).setCmd(ssh3.withSSHCommand([]string{"sudo", "fdisk", "-l", "|", "grep", "Disk"})).run()