Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wsl: enable machine init tests #20158

Merged
merged 1 commit into from
Sep 28, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 16 additions & 16 deletions pkg/machine/e2e/init_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,10 @@ var _ = Describe("podman machine init", func() {

testMachine := inspectBefore[0]
Expect(testMachine.Name).To(Equal(mb.names[0]))
Expect(testMachine.Resources.CPUs).To(Equal(uint64(cpus)))
Expect(testMachine.Resources.Memory).To(Equal(uint64(2048)))

if testProvider.VMType() != machine.WSLVirt { // WSL hardware specs are hardcoded
Expect(testMachine.Resources.CPUs).To(Equal(uint64(cpus)))
Expect(testMachine.Resources.Memory).To(Equal(uint64(2048)))
}
})

It("simple init with start", func() {
Expand Down Expand Up @@ -97,13 +98,16 @@ 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(cpus)))
Expect(testMachine.Resources.Memory).To(Equal(uint64(2048)))
Expect(testMachine.SSHConfig.RemoteUsername).To((Equal(remoteUsername)))
if testProvider.VMType() != machine.WSLVirt { // memory and cpus something we cannot set with WSL
Expect(testMachine.Resources.CPUs).To(Equal(uint64(cpus)))
Expect(testMachine.Resources.Memory).To(Equal(uint64(2048)))
}
Expect(testMachine.SSHConfig.RemoteUsername).To(Equal(remoteUsername))

})

It("machine init with cpus, disk size, memory, timezone", func() {
skipIfWSL("setting hardware resource numbers and timezone are not supported on WSL")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How does it behave on WSL? Does it error out? Any chance we can test against the expected behavior?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i have created #20175 for this, ok?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

name := randomString()
i := new(initMachine)
session, err := mb.setName(name).setCmd(i.withImagePath(mb.imagePath).withCPUs(2).withDiskSize(102).withMemory(4096).withTimezone("Pacific/Honolulu")).run()
Expand Down Expand Up @@ -147,6 +151,7 @@ var _ = Describe("podman machine init", func() {
if testProvider.VMType() == machine.HyperVVirt {
Skip("volumes are not supported on hyperv yet")
}
skipIfWSL("WSL volumes are much different. This test will not pass as is")

tmpDir, err := os.MkdirTemp("", "")
Expect(err).ToNot(HaveOccurred())
Expand All @@ -157,20 +162,15 @@ var _ = Describe("podman machine init", func() {

name := randomString()
i := new(initMachine)
session, err := mb.setName(name).setCmd(i.withImagePath(mb.imagePath).withVolume(mount)).run()
session, err := mb.setName(name).setCmd(i.withImagePath(mb.imagePath).withVolume(mount).withNow()).run()
Expect(err).ToNot(HaveOccurred())
Expect(session).To(Exit(0))

s := new(startMachine)
startSession, err := mb.setCmd(s).run()
Expect(err).ToNot(HaveOccurred())
Expect(startSession).To(Exit(0))

ssh2 := sshMachine{}
sshSession2, err := mb.setName(name).setCmd(ssh2.withSSHCommand([]string{"ls /testmountdir"})).run()
ssh := sshMachine{}
sshSession, err := mb.setName(name).setCmd(ssh.withSSHCommand([]string{"ls /testmountdir"})).run()
Expect(err).ToNot(HaveOccurred())
Expect(sshSession2).To(Exit(0))
Expect(sshSession2.outputToString()).To(ContainSubstring("example"))
Expect(sshSession).To(Exit(0))
Expect(sshSession.outputToString()).To(ContainSubstring("example"))
})

It("machine init rootless docker.sock check", func() {
Expand Down