From dc3a7e56be146390abaee7783aaadc9a0dc2e3d5 Mon Sep 17 00:00:00 2001 From: Paul Holzinger Date: Mon, 20 Jan 2025 18:45:39 +0100 Subject: [PATCH] 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 --- pkg/machine/e2e/list_test.go | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/pkg/machine/e2e/list_test.go b/pkg/machine/e2e/list_test.go index d6f5042ae3..4ae11064cc 100644 --- a/pkg/machine/e2e/list_test.go +++ b/pkg/machine/e2e/list_test.go @@ -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)) }) })