mirror of https://github.com/containers/podman.git
Merge pull request #20144 from baude/wslenableset
wsl machine tests: set
This commit is contained in:
commit
a2434a9d37
|
@ -201,3 +201,19 @@ func (matcher *ValidJSONMatcher) FailureMessage(actual interface{}) (message str
|
||||||
func (matcher *ValidJSONMatcher) NegatedFailureMessage(actual interface{}) (message string) {
|
func (matcher *ValidJSONMatcher) NegatedFailureMessage(actual interface{}) (message string) {
|
||||||
return format.Message(actual, "to _not_ be valid JSON")
|
return format.Message(actual, "to _not_ be valid JSON")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func skipIfVmtype(vmType machine.VMType, message string) {
|
||||||
|
if testProvider.VMType() == vmType {
|
||||||
|
Skip(message)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func skipIfNotVmtype(vmType machine.VMType, message string) {
|
||||||
|
if testProvider.VMType() != vmType {
|
||||||
|
Skip(message)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func skipIfWSL(message string) {
|
||||||
|
skipIfVmtype(machine.WSLVirt, message)
|
||||||
|
}
|
||||||
|
|
|
@ -25,6 +25,7 @@ var _ = Describe("podman machine set", func() {
|
||||||
})
|
})
|
||||||
|
|
||||||
It("set machine cpus, disk, memory", func() {
|
It("set machine cpus, disk, memory", func() {
|
||||||
|
skipIfWSL("WSL cannot change set properties of disk, processor, or memory")
|
||||||
name := randomString()
|
name := randomString()
|
||||||
i := new(initMachine)
|
i := new(initMachine)
|
||||||
session, err := mb.setName(name).setCmd(i.withImagePath(mb.imagePath)).run()
|
session, err := mb.setName(name).setCmd(i.withImagePath(mb.imagePath)).run()
|
||||||
|
@ -73,7 +74,33 @@ var _ = Describe("podman machine set", func() {
|
||||||
Expect(runner).To(Exit(125))
|
Expect(runner).To(Exit(125))
|
||||||
})
|
})
|
||||||
|
|
||||||
|
It("wsl cannot change disk, memory, processor", func() {
|
||||||
|
skipIfNotVmtype(machine.WSLVirt, "tests are only for WSL provider")
|
||||||
|
name := randomString()
|
||||||
|
i := new(initMachine)
|
||||||
|
session, err := mb.setName(name).setCmd(i.withImagePath(mb.imagePath)).run()
|
||||||
|
Expect(err).ToNot(HaveOccurred())
|
||||||
|
Expect(session).To(Exit(0))
|
||||||
|
|
||||||
|
setMem := setMachine{}
|
||||||
|
setMemSession, err := mb.setName(name).setCmd(setMem.withMemory(4096)).run()
|
||||||
|
Expect(err).ToNot(HaveOccurred())
|
||||||
|
Expect(setMemSession).To(Exit(125))
|
||||||
|
Expect(setMemSession.errorToString()).To(ContainSubstring("changing memory not supported for WSL machines"))
|
||||||
|
|
||||||
|
setProc := setMachine{}
|
||||||
|
setProcSession, err := mb.setName(name).setCmd(setProc.withCPUs(2)).run()
|
||||||
|
Expect(err).ToNot(HaveOccurred())
|
||||||
|
Expect(setProcSession.errorToString()).To(ContainSubstring("changing CPUs not supported for WSL machines"))
|
||||||
|
|
||||||
|
setDisk := setMachine{}
|
||||||
|
setDiskSession, err := mb.setName(name).setCmd(setDisk.withDiskSize(102)).run()
|
||||||
|
Expect(err).ToNot(HaveOccurred())
|
||||||
|
Expect(setDiskSession.errorToString()).To(ContainSubstring("changing disk size not supported for WSL machines"))
|
||||||
|
})
|
||||||
|
|
||||||
It("no settings should change if no flags", func() {
|
It("no settings should change if no flags", func() {
|
||||||
|
skipIfWSL("WSL cannot change set properties of disk, processor, or memory")
|
||||||
name := randomString()
|
name := randomString()
|
||||||
i := new(initMachine)
|
i := new(initMachine)
|
||||||
session, err := mb.setName(name).setCmd(i.withImagePath(mb.imagePath)).run()
|
session, err := mb.setName(name).setCmd(i.withImagePath(mb.imagePath)).run()
|
||||||
|
|
|
@ -1082,7 +1082,7 @@ func (v *MachineVM) Set(_ string, opts machine.SetOptions) ([]error, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if opts.DiskSize != nil {
|
if opts.DiskSize != nil {
|
||||||
setErrors = append(setErrors, errors.New("changing Disk Size not supported for WSL machines"))
|
setErrors = append(setErrors, errors.New("changing disk size not supported for WSL machines"))
|
||||||
}
|
}
|
||||||
|
|
||||||
if opts.UserModeNetworking != nil && *opts.UserModeNetworking != v.UserModeNetworking {
|
if opts.UserModeNetworking != nil && *opts.UserModeNetworking != v.UserModeNetworking {
|
||||||
|
@ -1105,8 +1105,15 @@ func (v *MachineVM) Set(_ string, opts machine.SetOptions) ([]error, error) {
|
||||||
v.UserModeNetworking = *opts.UserModeNetworking
|
v.UserModeNetworking = *opts.UserModeNetworking
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
err := v.writeConfig()
|
||||||
|
if err != nil {
|
||||||
|
setErrors = append(setErrors, err)
|
||||||
|
}
|
||||||
|
|
||||||
return setErrors, v.writeConfig()
|
if len(setErrors) > 0 {
|
||||||
|
return setErrors, setErrors[0]
|
||||||
|
}
|
||||||
|
return setErrors, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (v *MachineVM) Start(name string, opts machine.StartOptions) error {
|
func (v *MachineVM) Start(name string, opts machine.StartOptions) error {
|
||||||
|
|
Loading…
Reference in New Issue