pkg/machine/e2e: improve "list machine from all providers"

The test pulls a big disk image every time which is slow. I see no good
way around that. Let's try to use /dev/null as image as we do not have
to run the VM at all and just can pass a NOP file to make the init
command happy.

That pull of that image seems to take over 2m so we safe quite a lot.
Also update the matcher for the slice. BeTrue() produces horrible
errors.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
This commit is contained in:
Paul Holzinger
2025-01-20 18:45:39 +01:00
parent a86034596e
commit dc3a7e56be

View File

@@ -192,8 +192,13 @@ var _ = Describe("podman machine list", func() {
os.Setenv("CONTAINERS_MACHINE_PROVIDER", getOtherProvider())
defer os.Setenv("CONTAINERS_MACHINE_PROVIDER", currprovider)
// this may take a long time - we're not pre-fetching this image
othermach := new(initMachine)
if !isWSL() && !isVmtype(define.HyperVVirt) {
// This would need to fetch a new image as we cannot use the image from the other provider,
// to avoid big pulls which are slow and flaky use /dev/null which works on macos and qemu
// as we never run the image if we do not start it.
othermach.withImage(os.DevNull)
}
session, err := mb.setName("otherprovider").setCmd(othermach).run()
// make sure to remove machine from other provider later
defer func() {
@@ -222,8 +227,7 @@ var _ = Describe("podman machine list", func() {
listNames := listSession.outputToStringSlice()
stripAsterisk(listNames)
Expect(listNames).To(HaveLen(2))
Expect(slices.Contains(listNames, "otherprovider")).To(BeTrue())
Expect(slices.Contains(listNames, name)).To(BeTrue())
Expect(listNames).To(ContainElements("otherprovider", name))
})
})