From 829a1cd0bee0a2663d4100cc8265c564c86622c6 Mon Sep 17 00:00:00 2001 From: Nikita Korolev Date: Fri, 13 Mar 2026 11:23:06 +0300 Subject: [PATCH 01/34] use precreated cvi for tests Signed-off-by: Nikita Korolev --- test/e2e/e2e_test.go | 4 +- test/e2e/internal/object/precreated_cvi.go | 61 ++++++++++++++ test/e2e/suite_cvi.go | 93 ++++++++++++++++++++++ test/e2e/vm/migration.go | 30 ++----- test/e2e/vm/power_state.go | 11 +-- test/e2e/vmop/restore.go | 11 +-- 6 files changed, 169 insertions(+), 41 deletions(-) create mode 100644 test/e2e/internal/object/precreated_cvi.go create mode 100644 test/e2e/suite_cvi.go diff --git a/test/e2e/e2e_test.go b/test/e2e/e2e_test.go index cd692a315e..a6e109c54e 100644 --- a/test/e2e/e2e_test.go +++ b/test/e2e/e2e_test.go @@ -41,9 +41,11 @@ func TestE2E(t *testing.T) { var _ = SynchronizedBeforeSuite(func() { controller.NewBeforeProcess1Body() legacy.NewBeforeProcess1Body() + bootstrapPrecreatedCVIs() }, func() {}) var _ = SynchronizedAfterSuite(func() {}, func() { - DeferCleanup(legacy.NewAfterAllProcessBody) + cleanupPrecreatedCVIs() + legacy.NewAfterAllProcessBody() controller.NewAfterAllProcessBody() }) diff --git a/test/e2e/internal/object/precreated_cvi.go b/test/e2e/internal/object/precreated_cvi.go new file mode 100644 index 0000000000..1b18c43468 --- /dev/null +++ b/test/e2e/internal/object/precreated_cvi.go @@ -0,0 +1,61 @@ +/* +Copyright 2026 Flant JSC + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package object + +import ( + "github.com/deckhouse/virtualization-controller/pkg/builder/cvi" + "github.com/deckhouse/virtualization/api/core/v1alpha2" +) + +const ( + PrecreatedCVIAlpineUEFI = "v12n-e2e-alpine-uefi" + PrecreatedCVIAlpineBIOS = "v12n-e2e-alpine-bios" + PrecreatedCVIAlpineUEFIPerf = "v12n-e2e-alpine-uefi-perf" + PrecreatedCVIAlpineBIOSPerf = "v12n-e2e-alpine-bios-perf" + PrecreatedCVIUbuntu = "v12n-e2e-ubuntu" + PrecreatedCVIContainerImage = "v12n-e2e-container-image" + PrecreatedCVITestDataQCOW = "v12n-e2e-testdata-qcow" + PrecreatedCVITestDataISO = "v12n-e2e-testdata-iso" +) + +// PrecreatedClusterVirtualImages returns the suite-wide CVIs shared by e2e tests. +func PrecreatedClusterVirtualImages() []*v1alpha2.ClusterVirtualImage { + return []*v1alpha2.ClusterVirtualImage{ + newPrecreatedHTTPCVI(PrecreatedCVIAlpineUEFI, ImageURLAlpineUEFI), + newPrecreatedHTTPCVI(PrecreatedCVIAlpineBIOS, ImageURLAlpineBIOS), + newPrecreatedHTTPCVI(PrecreatedCVIAlpineUEFIPerf, ImagesURLAlpineUEFIPerf), + newPrecreatedHTTPCVI(PrecreatedCVIAlpineBIOSPerf, ImagesURLAlpineBIOSPerf), + newPrecreatedHTTPCVI(PrecreatedCVIUbuntu, ImageURLUbuntu), + newPrecreatedContainerImageCVI(PrecreatedCVIContainerImage, ImageURLContainerImage), + newPrecreatedHTTPCVI(PrecreatedCVITestDataQCOW, ImageTestDataQCOW), + newPrecreatedHTTPCVI(PrecreatedCVITestDataISO, ImageTestDataISO), + } +} + +func newPrecreatedHTTPCVI(name, imageURL string) *v1alpha2.ClusterVirtualImage { + return cvi.New( + cvi.WithName(name), + cvi.WithDataSourceHTTP(imageURL, nil, nil), + ) +} + +func newPrecreatedContainerImageCVI(name, imageURL string) *v1alpha2.ClusterVirtualImage { + return cvi.New( + cvi.WithName(name), + cvi.WithDataSourceContainerImage(imageURL, v1alpha2.ImagePullSecret{}, nil), + ) +} diff --git a/test/e2e/suite_cvi.go b/test/e2e/suite_cvi.go new file mode 100644 index 0000000000..40e1ea73a5 --- /dev/null +++ b/test/e2e/suite_cvi.go @@ -0,0 +1,93 @@ +/* +Copyright 2026 Flant JSC + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package e2e + +import ( + "context" + + . "github.com/onsi/ginkgo/v2" + . "github.com/onsi/gomega" + k8serrors "k8s.io/apimachinery/pkg/api/errors" + crclient "sigs.k8s.io/controller-runtime/pkg/client" + + "github.com/deckhouse/virtualization/api/core/v1alpha2" + "github.com/deckhouse/virtualization/test/e2e/internal/config" + "github.com/deckhouse/virtualization/test/e2e/internal/framework" + "github.com/deckhouse/virtualization/test/e2e/internal/object" + "github.com/deckhouse/virtualization/test/e2e/internal/util" +) + +const precreatedCVILabel = "v12n-e2e-precreated" + +func bootstrapPrecreatedCVIs() { + GinkgoHelper() + + ctx := context.Background() + for _, cvi := range object.PrecreatedClusterVirtualImages() { + Expect(createOrReusePrecreatedCVI(ctx, cvi)).NotTo(HaveOccurred()) + } + + util.UntilObjectPhase(string(v1alpha2.ImageReady), framework.LongTimeout, precreatedClusterVirtualImagesAsObjects()...) +} + +func cleanupPrecreatedCVIs() { + GinkgoHelper() + + if !config.IsCleanUpNeeded() { + return + } + + ctx := context.Background() + for _, cvi := range object.PrecreatedClusterVirtualImages() { + err := framework.GetClients().GenericClient().Delete(ctx, cvi) + Expect(err == nil || k8serrors.IsNotFound(err)).To(BeTrue(), "failed to delete precreated CVI %q: %v", cvi.Name, err) + } +} + +func createOrReusePrecreatedCVI(ctx context.Context, cvi *v1alpha2.ClusterVirtualImage) error { + setPrecreatedCVILabel(cvi) + + err := framework.GetClients().GenericClient().Create(ctx, cvi) + if err == nil { + return nil + } + + if !k8serrors.IsAlreadyExists(err) { + return err + } + + return framework.GetClients().GenericClient().Get(ctx, crclient.ObjectKeyFromObject(cvi), cvi) +} + +func precreatedClusterVirtualImagesAsObjects() []crclient.Object { + cvis := object.PrecreatedClusterVirtualImages() + objs := make([]crclient.Object, 0, len(cvis)) + for _, cvi := range cvis { + objs = append(objs, cvi) + } + + return objs +} + +func setPrecreatedCVILabel(cvi *v1alpha2.ClusterVirtualImage) { + labels := cvi.GetLabels() + if labels == nil { + labels = make(map[string]string) + } + labels[precreatedCVILabel] = "true" + cvi.SetLabels(labels) +} diff --git a/test/e2e/vm/migration.go b/test/e2e/vm/migration.go index ace366f2bb..7894b1cc63 100644 --- a/test/e2e/vm/migration.go +++ b/test/e2e/vm/migration.go @@ -28,7 +28,6 @@ import ( "k8s.io/utils/ptr" crclient "sigs.k8s.io/controller-runtime/pkg/client" - "github.com/deckhouse/virtualization-controller/pkg/builder/cvi" "github.com/deckhouse/virtualization-controller/pkg/builder/vd" "github.com/deckhouse/virtualization-controller/pkg/builder/vi" "github.com/deckhouse/virtualization-controller/pkg/builder/vm" @@ -54,15 +53,12 @@ var _ = Describe("VirtualMachineMigration", func() { vmUEFI *v1alpha2.VirtualMachine // Hotplug: disks and images attached via VMBDAs - vdHotplugBIOS *v1alpha2.VirtualDisk - vdHotplugUEFI *v1alpha2.VirtualDisk - viHotplugBIOS *v1alpha2.VirtualImage - viHotplugUEFI *v1alpha2.VirtualImage - cviHotplugBIOS *v1alpha2.ClusterVirtualImage - cviHotplugUEFI *v1alpha2.ClusterVirtualImage - - vmbdas []*v1alpha2.VirtualMachineBlockDeviceAttachment - allObjects []crclient.Object + vdHotplugBIOS *v1alpha2.VirtualDisk + vdHotplugUEFI *v1alpha2.VirtualDisk + viHotplugBIOS *v1alpha2.VirtualImage + viHotplugUEFI *v1alpha2.VirtualImage + vmbdas []*v1alpha2.VirtualMachineBlockDeviceAttachment + allObjects []crclient.Object vmopMigrateBIOS *v1alpha2.VirtualMachineOperation vmopMigrateUEFI *v1alpha2.VirtualMachineOperation @@ -165,15 +161,6 @@ var _ = Describe("VirtualMachineMigration", func() { vi.WithStorage(v1alpha2.StorageContainerRegistry), ) - cviHotplugBIOS = cvi.New( - cvi.WithName("cvi-hotplug-bios"), - cvi.WithDataSourceHTTP(object.ImageTestDataQCOW, nil, nil), - ) - cviHotplugUEFI = cvi.New( - cvi.WithName("cvi-hotplug-uefi"), - cvi.WithDataSourceHTTP(object.ImageTestDataQCOW, nil, nil), - ) - vmbdaVdBIOS := vmbda.New( vmbda.WithName("vmbda-vd-bios"), vmbda.WithNamespace(f.Namespace().Name), @@ -201,13 +188,13 @@ var _ = Describe("VirtualMachineMigration", func() { vmbdaCviBIOS := vmbda.New( vmbda.WithName("vmbda-cvi-bios"), vmbda.WithNamespace(f.Namespace().Name), - vmbda.WithBlockDeviceRef(v1alpha2.VMBDAObjectRefKindClusterVirtualImage, cviHotplugBIOS.Name), + vmbda.WithBlockDeviceRef(v1alpha2.VMBDAObjectRefKindClusterVirtualImage, object.PrecreatedCVITestDataQCOW), vmbda.WithVirtualMachineName(vmBIOS.Name), ) vmbdaCviUEFI := vmbda.New( vmbda.WithName("vmbda-cvi-uefi"), vmbda.WithNamespace(f.Namespace().Name), - vmbda.WithBlockDeviceRef(v1alpha2.VMBDAObjectRefKindClusterVirtualImage, cviHotplugUEFI.Name), + vmbda.WithBlockDeviceRef(v1alpha2.VMBDAObjectRefKindClusterVirtualImage, object.PrecreatedCVITestDataQCOW), vmbda.WithVirtualMachineName(vmUEFI.Name), ) vmbdas = []*v1alpha2.VirtualMachineBlockDeviceAttachment{ @@ -217,7 +204,6 @@ var _ = Describe("VirtualMachineMigration", func() { allObjects = append([]crclient.Object{ vdRootBIOS, vdBlankBIOS, vmBIOS, vdRootUEFI, vdBlankUEFI, vmUEFI, vdHotplugBIOS, vdHotplugUEFI, viHotplugBIOS, viHotplugUEFI, - cviHotplugBIOS, cviHotplugUEFI, }, toObjects(vmbdas)...) err := f.CreateWithDeferredDeletion(context.Background(), allObjects...) Expect(err).NotTo(HaveOccurred()) diff --git a/test/e2e/vm/power_state.go b/test/e2e/vm/power_state.go index 717972d4ca..1edfd62c13 100644 --- a/test/e2e/vm/power_state.go +++ b/test/e2e/vm/power_state.go @@ -26,7 +26,6 @@ import ( "k8s.io/utils/ptr" crclient "sigs.k8s.io/controller-runtime/pkg/client" - cvibuilder "github.com/deckhouse/virtualization-controller/pkg/builder/cvi" vdbuilder "github.com/deckhouse/virtualization-controller/pkg/builder/vd" vibuilder "github.com/deckhouse/virtualization-controller/pkg/builder/vi" vmbuilder "github.com/deckhouse/virtualization-controller/pkg/builder/vm" @@ -61,7 +60,7 @@ var _ = Describe("PowerState", func() { By("Environment preparation", func() { t.GenerateResources(runPolicy) err := f.CreateWithDeferredDeletion( - context.Background(), t.CVI, t.VI, t.VDRoot, t.VDBlank, t.VM, t.VMBDA, + context.Background(), t.VI, t.VDRoot, t.VDBlank, t.VM, t.VMBDA, ) Expect(err).NotTo(HaveOccurred()) @@ -195,7 +194,6 @@ var _ = Describe("PowerState", func() { type powerStateTest struct { Framework *framework.Framework - CVI *v1alpha2.ClusterVirtualImage VI *v1alpha2.VirtualImage VM *v1alpha2.VirtualMachine VDRoot *v1alpha2.VirtualDisk @@ -210,11 +208,6 @@ func newPowerStateTest(f *framework.Framework) *powerStateTest { } func (t *powerStateTest) GenerateResources(runPolicy v1alpha2.RunPolicy) { - t.CVI = cvibuilder.New( - cvibuilder.WithName(fmt.Sprintf("%s-cvi", t.Framework.Namespace().Name)), - cvibuilder.WithDataSourceHTTP(object.ImageTestDataISO, nil, nil), - ) - t.VI = vibuilder.New( vibuilder.WithName("vi"), vibuilder.WithNamespace(t.Framework.Namespace().Name), @@ -251,7 +244,7 @@ func (t *powerStateTest) GenerateResources(runPolicy v1alpha2.RunPolicy) { }, v1alpha2.BlockDeviceSpecRef{ Kind: v1alpha2.ClusterImageDevice, - Name: t.CVI.Name, + Name: object.PrecreatedCVITestDataISO, }, v1alpha2.BlockDeviceSpecRef{ Kind: v1alpha2.ImageDevice, diff --git a/test/e2e/vmop/restore.go b/test/e2e/vmop/restore.go index 1f9511869c..15b19b8602 100644 --- a/test/e2e/vmop/restore.go +++ b/test/e2e/vmop/restore.go @@ -30,7 +30,6 @@ import ( "k8s.io/utils/ptr" crclient "sigs.k8s.io/controller-runtime/pkg/client" - cvibuilder "github.com/deckhouse/virtualization-controller/pkg/builder/cvi" vdbuilder "github.com/deckhouse/virtualization-controller/pkg/builder/vd" vibuilder "github.com/deckhouse/virtualization-controller/pkg/builder/vi" vmbuilder "github.com/deckhouse/virtualization-controller/pkg/builder/vm" @@ -90,7 +89,7 @@ var _ = Describe("VirtualMachineOperationRestore", label.Slow(), func() { By("Environment preparation", func() { t.GenerateResources(restoreMode, restartApprovalMode, runPolicy) err := f.CreateWithDeferredDeletion( - context.Background(), t.CVI, t.VI, t.VDRoot, t.VDBlank, t.VM, t.VMBDA, t.VDBlankWithNoFstabEntry, t.VMBDAWithNoFstabEntry, + context.Background(), t.VI, t.VDRoot, t.VDBlank, t.VM, t.VMBDA, t.VDBlankWithNoFstabEntry, t.VMBDAWithNoFstabEntry, ) Expect(err).NotTo(HaveOccurred()) if t.VM.Spec.RunPolicy == v1alpha2.ManualPolicy { @@ -242,7 +241,6 @@ var _ = Describe("VirtualMachineOperationRestore", label.Slow(), func() { }) type restoreModeTest struct { - CVI *v1alpha2.ClusterVirtualImage VI *v1alpha2.VirtualImage VDRoot *v1alpha2.VirtualDisk VDBlank *v1alpha2.VirtualDisk @@ -265,11 +263,6 @@ func newRestoreTest(f *framework.Framework) *restoreModeTest { } func (t *restoreModeTest) GenerateResources(restoreMode v1alpha2.SnapshotOperationMode, restartApprovalMode v1alpha2.RestartApprovalMode, runPolicy v1alpha2.RunPolicy) { - t.CVI = cvibuilder.New( - cvibuilder.WithName(fmt.Sprintf("%s-cvi", t.Framework.Namespace().Name)), - cvibuilder.WithDataSourceHTTP(object.ImageTestDataISO, nil, nil), - ) - t.VI = vibuilder.New( vibuilder.WithName("vi"), vibuilder.WithNamespace(t.Framework.Namespace().Name), @@ -343,7 +336,7 @@ runcmd: }, v1alpha2.BlockDeviceSpecRef{ Kind: v1alpha2.ClusterImageDevice, - Name: t.CVI.Name, + Name: object.PrecreatedCVITestDataISO, }, v1alpha2.BlockDeviceSpecRef{ Kind: v1alpha2.ImageDevice, From dd6e6a61e0028c78aa2f07dbcdb2319504752ec3 Mon Sep 17 00:00:00 2001 From: Nikita Korolev Date: Fri, 13 Mar 2026 11:24:04 +0300 Subject: [PATCH 02/34] add seccomp curl pod Signed-off-by: Nikita Korolev --- test/e2e/vm/connectivity.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/test/e2e/vm/connectivity.go b/test/e2e/vm/connectivity.go index a7612f448e..327aac26bf 100644 --- a/test/e2e/vm/connectivity.go +++ b/test/e2e/vm/connectivity.go @@ -258,6 +258,17 @@ func (t *VMConnectivityTest) GenerateEnvironmentResources() { Image: framework.GetConfig().HelperImages.CurlImage, Command: []string{"sleep"}, Args: []string{"10000"}, + SecurityContext: &corev1.SecurityContext{ + AllowPrivilegeEscalation: ptr.To(false), + RunAsNonRoot: ptr.To(true), + RunAsUser: ptr.To(int64(1000)), + Capabilities: &corev1.Capabilities{ + Drop: []corev1.Capability{"ALL"}, + }, + SeccompProfile: &corev1.SeccompProfile{ + Type: corev1.SeccompProfileTypeRuntimeDefault, + }, + }, }, }, }, From 0a598723516a9171a63d532a1aab74d726aa9261 Mon Sep 17 00:00:00 2001 From: Nikita Korolev Date: Fri, 13 Mar 2026 11:58:38 +0300 Subject: [PATCH 03/34] add info cvi created Signed-off-by: Nikita Korolev --- test/e2e/suite_cvi.go | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/test/e2e/suite_cvi.go b/test/e2e/suite_cvi.go index 40e1ea73a5..65c2823ce4 100644 --- a/test/e2e/suite_cvi.go +++ b/test/e2e/suite_cvi.go @@ -18,6 +18,7 @@ package e2e import ( "context" + "fmt" . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" @@ -38,10 +39,21 @@ func bootstrapPrecreatedCVIs() { ctx := context.Background() for _, cvi := range object.PrecreatedClusterVirtualImages() { - Expect(createOrReusePrecreatedCVI(ctx, cvi)).NotTo(HaveOccurred()) + By(fmt.Sprintf("Create or reuse precreated CVI %q in the cluster", cvi.Name)) + created, err := createOrReusePrecreatedCVI(ctx, cvi) + Expect(err).NotTo(HaveOccurred()) + if created { + By(fmt.Sprintf("Precreated CVI %q has been created", cvi.Name)) + continue + } + By(fmt.Sprintf("Precreated CVI %q already exists and will be reused", cvi.Name)) } + By("Wait until all precreated CVIs are ready") util.UntilObjectPhase(string(v1alpha2.ImageReady), framework.LongTimeout, precreatedClusterVirtualImagesAsObjects()...) + for _, cvi := range object.PrecreatedClusterVirtualImages() { + By(fmt.Sprintf("Precreated CVI %q is ready", cvi.Name)) + } } func cleanupPrecreatedCVIs() { @@ -58,19 +70,19 @@ func cleanupPrecreatedCVIs() { } } -func createOrReusePrecreatedCVI(ctx context.Context, cvi *v1alpha2.ClusterVirtualImage) error { +func createOrReusePrecreatedCVI(ctx context.Context, cvi *v1alpha2.ClusterVirtualImage) (bool, error) { setPrecreatedCVILabel(cvi) err := framework.GetClients().GenericClient().Create(ctx, cvi) if err == nil { - return nil + return true, nil } if !k8serrors.IsAlreadyExists(err) { - return err + return false, err } - return framework.GetClients().GenericClient().Get(ctx, crclient.ObjectKeyFromObject(cvi), cvi) + return false, framework.GetClients().GenericClient().Get(ctx, crclient.ObjectKeyFromObject(cvi), cvi) } func precreatedClusterVirtualImagesAsObjects() []crclient.Object { From 6b4371c1fc4f3b8df00edc330c9219f97b3a4120 Mon Sep 17 00:00:00 2001 From: Nikita Korolev Date: Fri, 13 Mar 2026 13:15:30 +0300 Subject: [PATCH 04/34] refactor complex test Signed-off-by: Nikita Korolev --- test/e2e/internal/object/const.go | 1 + test/e2e/internal/object/precreated_cvi.go | 2 ++ test/e2e/legacy/complex.go | 11 ----------- .../legacy/testdata/complex-test/kustomization.yaml | 1 - .../complex-test/vd/vd-from-cvi-alpine-http.yaml | 2 +- .../complex-test/vd/vd-from-cvi-alpine-registry.yaml | 2 +- .../complex-test/vi/vi-from-cvi-alpine-http.yaml | 2 +- .../vm/overlays/with-mounted-cvi/kustomization.yaml | 2 +- 8 files changed, 7 insertions(+), 16 deletions(-) diff --git a/test/e2e/internal/object/const.go b/test/e2e/internal/object/const.go index 1214aab7cd..4217d66c2b 100644 --- a/test/e2e/internal/object/const.go +++ b/test/e2e/internal/object/const.go @@ -23,6 +23,7 @@ const ( ImagesURLAlpineBIOSPerf = "https://89d64382-20df-4581-8cc7-80df331f67fa.selstorage.ru/alpine/alpine-3-21-bios-perf.qcow2" ImageURLUbuntu = "https://89d64382-20df-4581-8cc7-80df331f67fa.selstorage.ru/ubuntu/ubuntu-24.04-minimal-cloudimg-amd64.qcow2" ImageURLContainerImage = "cr.yandex/crpvs5j3nh1mi2tpithr/e2e/alpine/alpine-image:latest" + ImageURLLegacyContainerImage = "cr.yandex/crpvs5j3nh1mi2tpithr/e2e/alpine/alpine-3-20:latest" // No bootable ImageTestDataQCOW = "https://89d64382-20df-4581-8cc7-80df331f67fa.selstorage.ru/test/test.qcow2" ImageTestDataISO = "https://89d64382-20df-4581-8cc7-80df331f67fa.selstorage.ru/test/test.iso" diff --git a/test/e2e/internal/object/precreated_cvi.go b/test/e2e/internal/object/precreated_cvi.go index 1b18c43468..f411ecce1f 100644 --- a/test/e2e/internal/object/precreated_cvi.go +++ b/test/e2e/internal/object/precreated_cvi.go @@ -28,6 +28,7 @@ const ( PrecreatedCVIAlpineBIOSPerf = "v12n-e2e-alpine-bios-perf" PrecreatedCVIUbuntu = "v12n-e2e-ubuntu" PrecreatedCVIContainerImage = "v12n-e2e-container-image" + PrecreatedCVILegacyRegistry = "v12n-e2e-legacy-registry" PrecreatedCVITestDataQCOW = "v12n-e2e-testdata-qcow" PrecreatedCVITestDataISO = "v12n-e2e-testdata-iso" ) @@ -41,6 +42,7 @@ func PrecreatedClusterVirtualImages() []*v1alpha2.ClusterVirtualImage { newPrecreatedHTTPCVI(PrecreatedCVIAlpineBIOSPerf, ImagesURLAlpineBIOSPerf), newPrecreatedHTTPCVI(PrecreatedCVIUbuntu, ImageURLUbuntu), newPrecreatedContainerImageCVI(PrecreatedCVIContainerImage, ImageURLContainerImage), + newPrecreatedContainerImageCVI(PrecreatedCVILegacyRegistry, ImageURLLegacyContainerImage), newPrecreatedHTTPCVI(PrecreatedCVITestDataQCOW, ImageTestDataQCOW), newPrecreatedHTTPCVI(PrecreatedCVITestDataISO, ImageTestDataISO), } diff --git a/test/e2e/legacy/complex.go b/test/e2e/legacy/complex.go index f453d5bf44..7d4be53a26 100644 --- a/test/e2e/legacy/complex.go +++ b/test/e2e/legacy/complex.go @@ -95,17 +95,6 @@ var _ = Describe("ComplexTest", Ordered, func() { }) }) - Context("When cluster virtual images are applied", func() { - It("checks CVIs phases", func() { - By(fmt.Sprintf("CVIs should be in %s phases", PhaseReady)) - WaitPhaseByLabel(kc.ResourceCVI, PhaseReady, kc.WaitOptions{ - Labels: testCaseLabel, - Namespace: ns, - Timeout: MaxWaitTimeout, - }) - }) - }) - Context("When virtual machine classes are applied", func() { It("checks VMClasses phases", func() { By(fmt.Sprintf("VMClasses should be in %s phases", PhaseReady)) diff --git a/test/e2e/legacy/testdata/complex-test/kustomization.yaml b/test/e2e/legacy/testdata/complex-test/kustomization.yaml index 513374bd51..117a17ee55 100644 --- a/test/e2e/legacy/testdata/complex-test/kustomization.yaml +++ b/test/e2e/legacy/testdata/complex-test/kustomization.yaml @@ -5,7 +5,6 @@ namePrefix: pr-number-or-commit-hash- resources: - ns.yaml - vmc.yaml - - cvi - vi - vd - vm diff --git a/test/e2e/legacy/testdata/complex-test/vd/vd-from-cvi-alpine-http.yaml b/test/e2e/legacy/testdata/complex-test/vd/vd-from-cvi-alpine-http.yaml index 932d037197..eb9c497f58 100644 --- a/test/e2e/legacy/testdata/complex-test/vd/vd-from-cvi-alpine-http.yaml +++ b/test/e2e/legacy/testdata/complex-test/vd/vd-from-cvi-alpine-http.yaml @@ -10,4 +10,4 @@ spec: type: ObjectRef objectRef: kind: ClusterVirtualImage - name: cvi-alpine-http + name: v12n-e2e-alpine-bios diff --git a/test/e2e/legacy/testdata/complex-test/vd/vd-from-cvi-alpine-registry.yaml b/test/e2e/legacy/testdata/complex-test/vd/vd-from-cvi-alpine-registry.yaml index c6546b51a1..37ff0e357d 100644 --- a/test/e2e/legacy/testdata/complex-test/vd/vd-from-cvi-alpine-registry.yaml +++ b/test/e2e/legacy/testdata/complex-test/vd/vd-from-cvi-alpine-registry.yaml @@ -10,4 +10,4 @@ spec: type: ObjectRef objectRef: kind: ClusterVirtualImage - name: cvi-alpine-registry + name: v12n-e2e-legacy-registry diff --git a/test/e2e/legacy/testdata/complex-test/vi/vi-from-cvi-alpine-http.yaml b/test/e2e/legacy/testdata/complex-test/vi/vi-from-cvi-alpine-http.yaml index 8de3cac5fe..58f2bb09e6 100644 --- a/test/e2e/legacy/testdata/complex-test/vi/vi-from-cvi-alpine-http.yaml +++ b/test/e2e/legacy/testdata/complex-test/vi/vi-from-cvi-alpine-http.yaml @@ -9,4 +9,4 @@ spec: type: ObjectRef objectRef: kind: ClusterVirtualImage - name: cvi-alpine-http + name: v12n-e2e-alpine-bios diff --git a/test/e2e/legacy/testdata/complex-test/vm/overlays/with-mounted-cvi/kustomization.yaml b/test/e2e/legacy/testdata/complex-test/vm/overlays/with-mounted-cvi/kustomization.yaml index 4486400e07..b72053755c 100644 --- a/test/e2e/legacy/testdata/complex-test/vm/overlays/with-mounted-cvi/kustomization.yaml +++ b/test/e2e/legacy/testdata/complex-test/vm/overlays/with-mounted-cvi/kustomization.yaml @@ -9,7 +9,7 @@ patches: path: /spec/blockDeviceRefs/- value: { "kind": "ClusterVirtualImage", - "name": "cvi-alpine-registry" + "name": "v12n-e2e-legacy-registry" } target: kind: VirtualMachine From 3905c132cc6bcaa16484327f9160112ec2e0c558 Mon Sep 17 00:00:00 2001 From: Nikita Korolev Date: Mon, 16 Mar 2026 16:58:09 +0300 Subject: [PATCH 05/34] try cvi for legacy Signed-off-by: Nikita Korolev --- test/e2e/internal/label/label.go | 4 ++++ test/e2e/internal/object/const.go | 14 ++++++++------ test/e2e/internal/object/precreated_cvi.go | 4 ++++ test/e2e/legacy/affinity_toleration.go | 3 ++- test/e2e/legacy/complex.go | 3 ++- test/e2e/legacy/image_hotplug.go | 17 ++--------------- .../complex-test/cvi/cvi-alpine-http.yaml | 10 ---------- .../complex-test/cvi/cvi-alpine-registry.yaml | 10 ---------- .../cvi/cvi-from-cvi-alpine-http.yaml | 11 ----------- .../cvi/cvi-from-vi-alpine-http.yaml | 12 ------------ .../complex-test/cvi/kustomization.yaml | 7 ------- .../testdata/vm-migration/cvi/cvi-cirros.yaml | 9 --------- .../vm-migration/cvi/kustomization.yaml | 4 ---- .../testdata/vm-migration/kustomization.yaml | 1 - .../vm/overlays/with-cvi/kustomization.yaml | 2 +- test/e2e/legacy/vd_snapshots.go | 3 ++- test/e2e/legacy/vm_disk_attachment.go | 3 ++- test/e2e/legacy/vm_disk_resizing.go | 3 ++- test/e2e/legacy/vm_evacuation.go | 3 ++- test/e2e/legacy/vm_label_annotation.go | 3 ++- test/e2e/legacy/vm_migration_cancel.go | 3 ++- test/e2e/legacy/vm_version.go | 3 ++- 22 files changed, 37 insertions(+), 95 deletions(-) delete mode 100644 test/e2e/legacy/testdata/complex-test/cvi/cvi-alpine-http.yaml delete mode 100644 test/e2e/legacy/testdata/complex-test/cvi/cvi-alpine-registry.yaml delete mode 100644 test/e2e/legacy/testdata/complex-test/cvi/cvi-from-cvi-alpine-http.yaml delete mode 100644 test/e2e/legacy/testdata/complex-test/cvi/cvi-from-vi-alpine-http.yaml delete mode 100644 test/e2e/legacy/testdata/complex-test/cvi/kustomization.yaml delete mode 100644 test/e2e/legacy/testdata/vm-migration/cvi/cvi-cirros.yaml delete mode 100644 test/e2e/legacy/testdata/vm-migration/cvi/kustomization.yaml diff --git a/test/e2e/internal/label/label.go b/test/e2e/internal/label/label.go index bcf5a51abf..fab1a9bdb9 100644 --- a/test/e2e/internal/label/label.go +++ b/test/e2e/internal/label/label.go @@ -27,3 +27,7 @@ func Slow() Labels { func TPM() Labels { return Label("TPM") } + +func Legacy() Labels { + return Label("Legacy") +} diff --git a/test/e2e/internal/object/const.go b/test/e2e/internal/object/const.go index 4217d66c2b..15edbc37e8 100644 --- a/test/e2e/internal/object/const.go +++ b/test/e2e/internal/object/const.go @@ -17,13 +17,15 @@ limitations under the License. package object const ( - ImageURLAlpineUEFI = "https://89d64382-20df-4581-8cc7-80df331f67fa.selstorage.ru/alpine/alpine-3-23-3-uefi-base.qcow2" - ImageURLAlpineBIOS = "https://89d64382-20df-4581-8cc7-80df331f67fa.selstorage.ru/alpine/alpine-3-23-3-bios-base.qcow2" - ImagesURLAlpineUEFIPerf = "https://89d64382-20df-4581-8cc7-80df331f67fa.selstorage.ru/alpine/alpine-3-21-uefi-perf.qcow2" - ImagesURLAlpineBIOSPerf = "https://89d64382-20df-4581-8cc7-80df331f67fa.selstorage.ru/alpine/alpine-3-21-bios-perf.qcow2" - ImageURLUbuntu = "https://89d64382-20df-4581-8cc7-80df331f67fa.selstorage.ru/ubuntu/ubuntu-24.04-minimal-cloudimg-amd64.qcow2" - ImageURLContainerImage = "cr.yandex/crpvs5j3nh1mi2tpithr/e2e/alpine/alpine-image:latest" + ImageURLAlpineUEFI = "https://89d64382-20df-4581-8cc7-80df331f67fa.selstorage.ru/alpine/alpine-3-23-3-uefi-base.qcow2" + ImageURLAlpineBIOS = "https://89d64382-20df-4581-8cc7-80df331f67fa.selstorage.ru/alpine/alpine-3-23-3-bios-base.qcow2" + ImagesURLAlpineUEFIPerf = "https://89d64382-20df-4581-8cc7-80df331f67fa.selstorage.ru/alpine/alpine-3-21-uefi-perf.qcow2" + ImagesURLAlpineBIOSPerf = "https://89d64382-20df-4581-8cc7-80df331f67fa.selstorage.ru/alpine/alpine-3-21-bios-perf.qcow2" + ImageURLUbuntu = "https://89d64382-20df-4581-8cc7-80df331f67fa.selstorage.ru/ubuntu/ubuntu-24.04-minimal-cloudimg-amd64.qcow2" + ImageURLContainerImage = "cr.yandex/crpvs5j3nh1mi2tpithr/e2e/alpine/alpine-image:latest" ImageURLLegacyContainerImage = "cr.yandex/crpvs5j3nh1mi2tpithr/e2e/alpine/alpine-3-20:latest" + ImageURLCirros = "https://89d64382-20df-4581-8cc7-80df331f67fa.selstorage.ru/cirros/cirros-0.5.1.qcow2" + ImageURLUbuntuISO = "https://89d64382-20df-4581-8cc7-80df331f67fa.selstorage.ru/ubuntu/ubuntu-24.04.2-live-server-amd64.iso" // No bootable ImageTestDataQCOW = "https://89d64382-20df-4581-8cc7-80df331f67fa.selstorage.ru/test/test.qcow2" ImageTestDataISO = "https://89d64382-20df-4581-8cc7-80df331f67fa.selstorage.ru/test/test.iso" diff --git a/test/e2e/internal/object/precreated_cvi.go b/test/e2e/internal/object/precreated_cvi.go index f411ecce1f..098ff78d6f 100644 --- a/test/e2e/internal/object/precreated_cvi.go +++ b/test/e2e/internal/object/precreated_cvi.go @@ -27,8 +27,10 @@ const ( PrecreatedCVIAlpineUEFIPerf = "v12n-e2e-alpine-uefi-perf" PrecreatedCVIAlpineBIOSPerf = "v12n-e2e-alpine-bios-perf" PrecreatedCVIUbuntu = "v12n-e2e-ubuntu" + PrecreatedCVIUbuntuISO = "v12n-e2e-ubuntu-iso" PrecreatedCVIContainerImage = "v12n-e2e-container-image" PrecreatedCVILegacyRegistry = "v12n-e2e-legacy-registry" + PrecreatedCVICirros = "v12n-e2e-cirros" PrecreatedCVITestDataQCOW = "v12n-e2e-testdata-qcow" PrecreatedCVITestDataISO = "v12n-e2e-testdata-iso" ) @@ -41,8 +43,10 @@ func PrecreatedClusterVirtualImages() []*v1alpha2.ClusterVirtualImage { newPrecreatedHTTPCVI(PrecreatedCVIAlpineUEFIPerf, ImagesURLAlpineUEFIPerf), newPrecreatedHTTPCVI(PrecreatedCVIAlpineBIOSPerf, ImagesURLAlpineBIOSPerf), newPrecreatedHTTPCVI(PrecreatedCVIUbuntu, ImageURLUbuntu), + newPrecreatedHTTPCVI(PrecreatedCVIUbuntuISO, ImageURLUbuntuISO), newPrecreatedContainerImageCVI(PrecreatedCVIContainerImage, ImageURLContainerImage), newPrecreatedContainerImageCVI(PrecreatedCVILegacyRegistry, ImageURLLegacyContainerImage), + newPrecreatedHTTPCVI(PrecreatedCVICirros, ImageURLCirros), newPrecreatedHTTPCVI(PrecreatedCVITestDataQCOW, ImageTestDataQCOW), newPrecreatedHTTPCVI(PrecreatedCVITestDataISO, ImageTestDataISO), } diff --git a/test/e2e/legacy/affinity_toleration.go b/test/e2e/legacy/affinity_toleration.go index 3ac178784d..d89c310abe 100644 --- a/test/e2e/legacy/affinity_toleration.go +++ b/test/e2e/legacy/affinity_toleration.go @@ -31,9 +31,10 @@ import ( "github.com/deckhouse/virtualization/api/core/v1alpha2" "github.com/deckhouse/virtualization/api/core/v1alpha2/vmcondition" kc "github.com/deckhouse/virtualization/test/e2e/internal/kubectl" + "github.com/deckhouse/virtualization/test/e2e/internal/label" ) -var _ = Describe("VirtualMachineAffinityAndToleration", Ordered, func() { +var _ = Describe("VirtualMachineAffinityAndToleration", Ordered, label.Legacy(), func() { const ( nodeLabelKey = "kubernetes.io/hostname" masterLabelKey = "node.deckhouse.io/group" diff --git a/test/e2e/legacy/complex.go b/test/e2e/legacy/complex.go index 7d4be53a26..d661ad0b94 100644 --- a/test/e2e/legacy/complex.go +++ b/test/e2e/legacy/complex.go @@ -28,6 +28,7 @@ import ( "github.com/deckhouse/virtualization/test/e2e/internal/config" "github.com/deckhouse/virtualization/test/e2e/internal/framework" kc "github.com/deckhouse/virtualization/test/e2e/internal/kubectl" + "github.com/deckhouse/virtualization/test/e2e/internal/label" "github.com/deckhouse/virtualization/test/e2e/internal/util" ) @@ -36,7 +37,7 @@ const ( antiAffinityLabel = "anti-affinity" ) -var _ = Describe("ComplexTest", Ordered, func() { +var _ = Describe("ComplexTest", Ordered, label.Legacy(), func() { var ( testCaseLabel = map[string]string{"testcase": "complex-test"} hasNoConsumerLabel = map[string]string{"hasNoConsumer": "complex-test"} diff --git a/test/e2e/legacy/image_hotplug.go b/test/e2e/legacy/image_hotplug.go index fff208775b..403311b1f7 100644 --- a/test/e2e/legacy/image_hotplug.go +++ b/test/e2e/legacy/image_hotplug.go @@ -31,9 +31,10 @@ import ( "github.com/deckhouse/virtualization/test/e2e/internal/d8" "github.com/deckhouse/virtualization/test/e2e/internal/framework" kc "github.com/deckhouse/virtualization/test/e2e/internal/kubectl" + "github.com/deckhouse/virtualization/test/e2e/internal/label" ) -var _ = Describe("ImageHotplug", Ordered, func() { +var _ = Describe("ImageHotplug", Ordered, label.Legacy(), func() { const ( viCount = 2 cviCount = 2 @@ -59,13 +60,6 @@ var _ = Describe("ImageHotplug", Ordered, func() { ns, err = kustomize.GetNamespace(kustomization) Expect(err).NotTo(HaveOccurred(), "%w", err) - res := kubectl.Delete(kc.DeleteOptions{ - IgnoreNotFound: true, - Labels: testCaseLabel, - Resource: kc.ResourceCVI, - }) - Expect(res.Error()).NotTo(HaveOccurred()) - CreateNamespace(ns) }) @@ -92,13 +86,6 @@ var _ = Describe("ImageHotplug", Ordered, func() { Timeout: MaxWaitTimeout, }) }) - By(fmt.Sprintf("`ClusterVirtualImages` should be in the %q phase", v1alpha2.ImageReady), func() { - WaitPhaseByLabel(kc.ResourceCVI, PhaseReady, kc.WaitOptions{ - Labels: testCaseLabel, - Namespace: ns, - Timeout: MaxWaitTimeout, - }) - }) By(fmt.Sprintf("`VirtualDisk` should be in the %q phase", v1alpha2.DiskReady), func() { WaitPhaseByLabel(kc.ResourceVD, PhaseReady, kc.WaitOptions{ Labels: testCaseLabel, diff --git a/test/e2e/legacy/testdata/complex-test/cvi/cvi-alpine-http.yaml b/test/e2e/legacy/testdata/complex-test/cvi/cvi-alpine-http.yaml deleted file mode 100644 index 3826b75660..0000000000 --- a/test/e2e/legacy/testdata/complex-test/cvi/cvi-alpine-http.yaml +++ /dev/null @@ -1,10 +0,0 @@ ---- -apiVersion: virtualization.deckhouse.io/v1alpha2 -kind: ClusterVirtualImage -metadata: - name: cvi-alpine-http -spec: - dataSource: - type: HTTP - http: - url: https://89d64382-20df-4581-8cc7-80df331f67fa.selstorage.ru/alpine/alpine-3-23-3-bios-base.qcow2 diff --git a/test/e2e/legacy/testdata/complex-test/cvi/cvi-alpine-registry.yaml b/test/e2e/legacy/testdata/complex-test/cvi/cvi-alpine-registry.yaml deleted file mode 100644 index 1ed794c4a7..0000000000 --- a/test/e2e/legacy/testdata/complex-test/cvi/cvi-alpine-registry.yaml +++ /dev/null @@ -1,10 +0,0 @@ ---- -apiVersion: virtualization.deckhouse.io/v1alpha2 -kind: ClusterVirtualImage -metadata: - name: cvi-alpine-registry -spec: - dataSource: - type: ContainerImage - containerImage: - image: cr.yandex/crpvs5j3nh1mi2tpithr/e2e/alpine/alpine-3-20:latest diff --git a/test/e2e/legacy/testdata/complex-test/cvi/cvi-from-cvi-alpine-http.yaml b/test/e2e/legacy/testdata/complex-test/cvi/cvi-from-cvi-alpine-http.yaml deleted file mode 100644 index ef2d273df0..0000000000 --- a/test/e2e/legacy/testdata/complex-test/cvi/cvi-from-cvi-alpine-http.yaml +++ /dev/null @@ -1,11 +0,0 @@ ---- -apiVersion: virtualization.deckhouse.io/v1alpha2 -kind: ClusterVirtualImage -metadata: - name: cvi-from-cvi-alpine-http -spec: - dataSource: - type: ObjectRef - objectRef: - kind: ClusterVirtualImage - name: cvi-alpine-http diff --git a/test/e2e/legacy/testdata/complex-test/cvi/cvi-from-vi-alpine-http.yaml b/test/e2e/legacy/testdata/complex-test/cvi/cvi-from-vi-alpine-http.yaml deleted file mode 100644 index 82a6b78511..0000000000 --- a/test/e2e/legacy/testdata/complex-test/cvi/cvi-from-vi-alpine-http.yaml +++ /dev/null @@ -1,12 +0,0 @@ ---- -apiVersion: virtualization.deckhouse.io/v1alpha2 -kind: ClusterVirtualImage -metadata: - name: cvi-from-vi-alpine-http -spec: - dataSource: - type: ObjectRef - objectRef: - kind: VirtualImage - name: vi-alpine-http - namespace: testcases diff --git a/test/e2e/legacy/testdata/complex-test/cvi/kustomization.yaml b/test/e2e/legacy/testdata/complex-test/cvi/kustomization.yaml deleted file mode 100644 index e29a962fb2..0000000000 --- a/test/e2e/legacy/testdata/complex-test/cvi/kustomization.yaml +++ /dev/null @@ -1,7 +0,0 @@ -apiVersion: kustomize.config.k8s.io/v1beta1 -kind: Kustomization -resources: - - cvi-alpine-http.yaml - - cvi-alpine-registry.yaml - - cvi-from-vi-alpine-http.yaml - - cvi-from-cvi-alpine-http.yaml diff --git a/test/e2e/legacy/testdata/vm-migration/cvi/cvi-cirros.yaml b/test/e2e/legacy/testdata/vm-migration/cvi/cvi-cirros.yaml deleted file mode 100644 index b672ece2cf..0000000000 --- a/test/e2e/legacy/testdata/vm-migration/cvi/cvi-cirros.yaml +++ /dev/null @@ -1,9 +0,0 @@ -apiVersion: virtualization.deckhouse.io/v1alpha2 -kind: ClusterVirtualImage -metadata: - name: cvi-cirros -spec: - dataSource: - type: "HTTP" - http: - url: "https://89d64382-20df-4581-8cc7-80df331f67fa.selstorage.ru/cirros/cirros-0.5.1.qcow2" diff --git a/test/e2e/legacy/testdata/vm-migration/cvi/kustomization.yaml b/test/e2e/legacy/testdata/vm-migration/cvi/kustomization.yaml deleted file mode 100644 index bda7b362a8..0000000000 --- a/test/e2e/legacy/testdata/vm-migration/cvi/kustomization.yaml +++ /dev/null @@ -1,4 +0,0 @@ -apiVersion: kustomize.config.k8s.io/v1beta1 -kind: Kustomization -resources: - - cvi-cirros.yaml diff --git a/test/e2e/legacy/testdata/vm-migration/kustomization.yaml b/test/e2e/legacy/testdata/vm-migration/kustomization.yaml index a05cabd5db..0ef3f36322 100644 --- a/test/e2e/legacy/testdata/vm-migration/kustomization.yaml +++ b/test/e2e/legacy/testdata/vm-migration/kustomization.yaml @@ -4,7 +4,6 @@ namespace: testcases namePrefix: pr-number-or-commit-hash- resources: - vi - - cvi - vm - ns.yaml configurations: diff --git a/test/e2e/legacy/testdata/vm-migration/vm/overlays/with-cvi/kustomization.yaml b/test/e2e/legacy/testdata/vm-migration/vm/overlays/with-cvi/kustomization.yaml index 6bb34356af..3b3d2fee7e 100644 --- a/test/e2e/legacy/testdata/vm-migration/vm/overlays/with-cvi/kustomization.yaml +++ b/test/e2e/legacy/testdata/vm-migration/vm/overlays/with-cvi/kustomization.yaml @@ -11,7 +11,7 @@ patches: path: /spec/blockDeviceRefs/- value: { "kind": "ClusterVirtualImage", - "name": "cvi-cirros" + "name": "v12n-e2e-cirros" } target: kind: VirtualMachine diff --git a/test/e2e/legacy/vd_snapshots.go b/test/e2e/legacy/vd_snapshots.go index 97f40fe34f..313f4ad735 100644 --- a/test/e2e/legacy/vd_snapshots.go +++ b/test/e2e/legacy/vd_snapshots.go @@ -33,6 +33,7 @@ import ( "github.com/deckhouse/virtualization/api/core/v1alpha2/vmcondition" "github.com/deckhouse/virtualization/test/e2e/internal/config" kc "github.com/deckhouse/virtualization/test/e2e/internal/kubectl" + "github.com/deckhouse/virtualization/test/e2e/internal/label" "github.com/deckhouse/virtualization/test/e2e/internal/util" ) @@ -42,7 +43,7 @@ const ( frozenReasonPollingInterval = 1 * time.Second ) -var _ = Describe("VirtualDiskSnapshots", Ordered, func() { +var _ = Describe("VirtualDiskSnapshots", Ordered, label.Legacy(), func() { var ( testCaseLabel = map[string]string{"testcase": "vd-snapshots", "id": namePrefix} attachedVirtualDiskLabel = map[string]string{"attachedVirtualDisk": ""} diff --git a/test/e2e/legacy/vm_disk_attachment.go b/test/e2e/legacy/vm_disk_attachment.go index e91890ec01..288fee2c04 100644 --- a/test/e2e/legacy/vm_disk_attachment.go +++ b/test/e2e/legacy/vm_disk_attachment.go @@ -29,6 +29,7 @@ import ( "github.com/deckhouse/virtualization/test/e2e/internal/d8" "github.com/deckhouse/virtualization/test/e2e/internal/framework" kc "github.com/deckhouse/virtualization/test/e2e/internal/kubectl" + "github.com/deckhouse/virtualization/test/e2e/internal/label" "github.com/deckhouse/virtualization/test/e2e/internal/util" ) @@ -36,7 +37,7 @@ const unacceptableCount = -1000 var APIVersion = v1alpha2.SchemeGroupVersion.String() -var _ = Describe("VirtualDiskAttachment", Ordered, func() { +var _ = Describe("VirtualDiskAttachment", Ordered, label.Legacy(), func() { var ( testCaseLabel = map[string]string{"testcase": "vm-disk-attachment"} hasNoConsumerLabel = map[string]string{"hasNoConsumer": "vm-disk-attachment"} diff --git a/test/e2e/legacy/vm_disk_resizing.go b/test/e2e/legacy/vm_disk_resizing.go index 8acf5d2adf..6495049cef 100644 --- a/test/e2e/legacy/vm_disk_resizing.go +++ b/test/e2e/legacy/vm_disk_resizing.go @@ -33,9 +33,10 @@ import ( "github.com/deckhouse/virtualization/test/e2e/internal/d8" "github.com/deckhouse/virtualization/test/e2e/internal/framework" kc "github.com/deckhouse/virtualization/test/e2e/internal/kubectl" + "github.com/deckhouse/virtualization/test/e2e/internal/label" ) -var _ = Describe("VirtualDiskResizing", Ordered, func() { +var _ = Describe("VirtualDiskResizing", Ordered, label.Legacy(), func() { const ( vmCount = 1 diskCount = 3 diff --git a/test/e2e/legacy/vm_evacuation.go b/test/e2e/legacy/vm_evacuation.go index 55e2e717fb..2ee9bb0369 100644 --- a/test/e2e/legacy/vm_evacuation.go +++ b/test/e2e/legacy/vm_evacuation.go @@ -32,9 +32,10 @@ import ( "github.com/deckhouse/virtualization/test/e2e/internal/config" "github.com/deckhouse/virtualization/test/e2e/internal/framework" kc "github.com/deckhouse/virtualization/test/e2e/internal/kubectl" + "github.com/deckhouse/virtualization/test/e2e/internal/label" ) -var _ = Describe("VirtualMachineEvacuation", Ordered, func() { +var _ = Describe("VirtualMachineEvacuation", Ordered, label.Legacy(), func() { testCaseLabel := map[string]string{"testcase": "vm-evacuation"} kubeClient := framework.GetClients().KubeClient() var ns string diff --git a/test/e2e/legacy/vm_label_annotation.go b/test/e2e/legacy/vm_label_annotation.go index 456030d112..e879b6b721 100644 --- a/test/e2e/legacy/vm_label_annotation.go +++ b/test/e2e/legacy/vm_label_annotation.go @@ -26,12 +26,13 @@ import ( "github.com/deckhouse/virtualization/api/core/v1alpha2" kc "github.com/deckhouse/virtualization/test/e2e/internal/kubectl" + "github.com/deckhouse/virtualization/test/e2e/internal/label" ) // TODO: When this test case is refactored with the new end-to-end test framework, // it should check labels and annotations on all resources: KVVM, KVVMI, and Pod. // KVVM must contain propagated metadata in the spec.template.metadata field. -var _ = Describe("VirtualMachineLabelAndAnnotation", Ordered, func() { +var _ = Describe("VirtualMachineLabelAndAnnotation", Ordered, label.Legacy(), func() { const ( specialKey = "specialKey" specialValue = "specialValue" diff --git a/test/e2e/legacy/vm_migration_cancel.go b/test/e2e/legacy/vm_migration_cancel.go index e202288baa..e0be0f185a 100644 --- a/test/e2e/legacy/vm_migration_cancel.go +++ b/test/e2e/legacy/vm_migration_cancel.go @@ -30,9 +30,10 @@ import ( "github.com/deckhouse/virtualization/test/e2e/internal/d8" "github.com/deckhouse/virtualization/test/e2e/internal/framework" kc "github.com/deckhouse/virtualization/test/e2e/internal/kubectl" + "github.com/deckhouse/virtualization/test/e2e/internal/label" ) -var _ = Describe("VirtualMachineCancelMigration", Ordered, func() { +var _ = Describe("VirtualMachineCancelMigration", Ordered, label.Legacy(), func() { testCaseLabel := map[string]string{"testcase": "vm-migration-cancel"} var ns string diff --git a/test/e2e/legacy/vm_version.go b/test/e2e/legacy/vm_version.go index 3ec93361a1..f67f3a24e9 100644 --- a/test/e2e/legacy/vm_version.go +++ b/test/e2e/legacy/vm_version.go @@ -24,9 +24,10 @@ import ( "github.com/deckhouse/virtualization/api/core/v1alpha2" kc "github.com/deckhouse/virtualization/test/e2e/internal/kubectl" + "github.com/deckhouse/virtualization/test/e2e/internal/label" ) -var _ = Describe("VirtualMachineVersions", Ordered, func() { +var _ = Describe("VirtualMachineVersions", Ordered, label.Legacy(), func() { testCaseLabel := map[string]string{"testcase": "vm-versions"} var ns string From af5aaf7da3b73b62ffe56185ee562a985e27aa32 Mon Sep 17 00:00:00 2001 From: Nikita Korolev Date: Mon, 16 Mar 2026 18:42:49 +0300 Subject: [PATCH 06/34] affinity-tolleration to cvi Signed-off-by: Nikita Korolev --- test/e2e/legacy/affinity_toleration.go | 7 ------- .../testdata/affinity-toleration/kustomization.yaml | 1 - .../affinity-toleration/vi/kustomization.yaml | 4 ---- .../affinity-toleration/vi/vi-alpine-http.yaml | 11 ----------- .../testdata/affinity-toleration/vm/base/vd-root.yaml | 4 ++-- 5 files changed, 2 insertions(+), 25 deletions(-) delete mode 100644 test/e2e/legacy/testdata/affinity-toleration/vi/kustomization.yaml delete mode 100644 test/e2e/legacy/testdata/affinity-toleration/vi/vi-alpine-http.yaml diff --git a/test/e2e/legacy/affinity_toleration.go b/test/e2e/legacy/affinity_toleration.go index d89c310abe..c83900e74b 100644 --- a/test/e2e/legacy/affinity_toleration.go +++ b/test/e2e/legacy/affinity_toleration.go @@ -80,13 +80,6 @@ var _ = Describe("VirtualMachineAffinityAndToleration", Ordered, label.Legacy(), }) It("checks the resources phase", func() { - By(fmt.Sprintf("`VirtualImages` should be in the %q phase", v1alpha2.ImageReady), func() { - WaitPhaseByLabel(kc.ResourceVI, PhaseReady, kc.WaitOptions{ - Labels: testCaseLabel, - Namespace: ns, - Timeout: MaxWaitTimeout, - }) - }) By(fmt.Sprintf("`VirtualMachineClasses` should be in %s phases", v1alpha2.ClassPhaseReady), func() { WaitPhaseByLabel(kc.ResourceVMClass, PhaseReady, kc.WaitOptions{ Labels: testCaseLabel, diff --git a/test/e2e/legacy/testdata/affinity-toleration/kustomization.yaml b/test/e2e/legacy/testdata/affinity-toleration/kustomization.yaml index b926264feb..29eb528cd6 100644 --- a/test/e2e/legacy/testdata/affinity-toleration/kustomization.yaml +++ b/test/e2e/legacy/testdata/affinity-toleration/kustomization.yaml @@ -5,7 +5,6 @@ namePrefix: pr-number-or-commit-hash- resources: - ns.yaml - vmc.yaml - - vi - vm configurations: - transformer.yaml diff --git a/test/e2e/legacy/testdata/affinity-toleration/vi/kustomization.yaml b/test/e2e/legacy/testdata/affinity-toleration/vi/kustomization.yaml deleted file mode 100644 index b807d8e2d2..0000000000 --- a/test/e2e/legacy/testdata/affinity-toleration/vi/kustomization.yaml +++ /dev/null @@ -1,4 +0,0 @@ -apiVersion: kustomize.config.k8s.io/v1beta1 -kind: Kustomization -resources: - - vi-alpine-http.yaml diff --git a/test/e2e/legacy/testdata/affinity-toleration/vi/vi-alpine-http.yaml b/test/e2e/legacy/testdata/affinity-toleration/vi/vi-alpine-http.yaml deleted file mode 100644 index 43bc57dd27..0000000000 --- a/test/e2e/legacy/testdata/affinity-toleration/vi/vi-alpine-http.yaml +++ /dev/null @@ -1,11 +0,0 @@ ---- -apiVersion: virtualization.deckhouse.io/v1alpha2 -kind: VirtualImage -metadata: - name: vi-alpine-http -spec: - storage: ContainerRegistry - dataSource: - type: HTTP - http: - url: https://89d64382-20df-4581-8cc7-80df331f67fa.selstorage.ru/alpine/alpine-3-23-3-uefi-base.qcow2 diff --git a/test/e2e/legacy/testdata/affinity-toleration/vm/base/vd-root.yaml b/test/e2e/legacy/testdata/affinity-toleration/vm/base/vd-root.yaml index c2bf54f1ff..7442dd263a 100644 --- a/test/e2e/legacy/testdata/affinity-toleration/vm/base/vd-root.yaml +++ b/test/e2e/legacy/testdata/affinity-toleration/vm/base/vd-root.yaml @@ -9,5 +9,5 @@ spec: dataSource: type: ObjectRef objectRef: - kind: VirtualImage - name: vi-alpine-http + kind: ClusterVirtualImage + name: v12n-e2e-alpine-uefi From a69696cd458fde04db9d2c5e6dd83546c5217ad1 Mon Sep 17 00:00:00 2001 From: Nikita Korolev Date: Mon, 16 Mar 2026 18:47:53 +0300 Subject: [PATCH 07/34] disk-resizing to cvi Signed-off-by: Nikita Korolev --- .../legacy/testdata/disk-resizing/base/vd-root.yaml | 4 ++-- .../legacy/testdata/disk-resizing/kustomization.yaml | 1 - .../testdata/disk-resizing/vi/kustomization.yaml | 4 ---- .../testdata/disk-resizing/vi/vi-alpine-http.yaml | 11 ----------- test/e2e/legacy/vm_disk_resizing.go | 12 ------------ 5 files changed, 2 insertions(+), 30 deletions(-) delete mode 100644 test/e2e/legacy/testdata/disk-resizing/vi/kustomization.yaml delete mode 100644 test/e2e/legacy/testdata/disk-resizing/vi/vi-alpine-http.yaml diff --git a/test/e2e/legacy/testdata/disk-resizing/base/vd-root.yaml b/test/e2e/legacy/testdata/disk-resizing/base/vd-root.yaml index 0f98ff3633..b4f9cd0c2c 100644 --- a/test/e2e/legacy/testdata/disk-resizing/base/vd-root.yaml +++ b/test/e2e/legacy/testdata/disk-resizing/base/vd-root.yaml @@ -9,5 +9,5 @@ spec: dataSource: type: ObjectRef objectRef: - kind: VirtualImage - name: vi-alpine-http + kind: ClusterVirtualImage + name: v12n-e2e-alpine-uefi-perf diff --git a/test/e2e/legacy/testdata/disk-resizing/kustomization.yaml b/test/e2e/legacy/testdata/disk-resizing/kustomization.yaml index 404986a0f4..a30957df4a 100644 --- a/test/e2e/legacy/testdata/disk-resizing/kustomization.yaml +++ b/test/e2e/legacy/testdata/disk-resizing/kustomization.yaml @@ -5,7 +5,6 @@ namePrefix: pr-number-or-commit-hash- resources: - ns.yaml - overlays/automatic-with-hotplug - - vi configurations: - transformer.yaml labels: diff --git a/test/e2e/legacy/testdata/disk-resizing/vi/kustomization.yaml b/test/e2e/legacy/testdata/disk-resizing/vi/kustomization.yaml deleted file mode 100644 index b807d8e2d2..0000000000 --- a/test/e2e/legacy/testdata/disk-resizing/vi/kustomization.yaml +++ /dev/null @@ -1,4 +0,0 @@ -apiVersion: kustomize.config.k8s.io/v1beta1 -kind: Kustomization -resources: - - vi-alpine-http.yaml diff --git a/test/e2e/legacy/testdata/disk-resizing/vi/vi-alpine-http.yaml b/test/e2e/legacy/testdata/disk-resizing/vi/vi-alpine-http.yaml deleted file mode 100644 index abac06b48c..0000000000 --- a/test/e2e/legacy/testdata/disk-resizing/vi/vi-alpine-http.yaml +++ /dev/null @@ -1,11 +0,0 @@ ---- -apiVersion: virtualization.deckhouse.io/v1alpha2 -kind: VirtualImage -metadata: - name: vi-alpine-http -spec: - storage: ContainerRegistry - dataSource: - type: HTTP - http: - url: https://89d64382-20df-4581-8cc7-80df331f67fa.selstorage.ru/alpine/alpine-3-21-uefi-perf.qcow2 diff --git a/test/e2e/legacy/vm_disk_resizing.go b/test/e2e/legacy/vm_disk_resizing.go index 6495049cef..0615c3e8d1 100644 --- a/test/e2e/legacy/vm_disk_resizing.go +++ b/test/e2e/legacy/vm_disk_resizing.go @@ -70,18 +70,6 @@ var _ = Describe("VirtualDiskResizing", Ordered, label.Legacy(), func() { }) }) - Context("When the virtual images are applied", func() { - It("checks `VirtualImages` phase", func() { - By(fmt.Sprintf("`VirtualImages` should be in the %q phases", v1alpha2.ImageReady), func() { - WaitPhaseByLabel(kc.ResourceVI, string(v1alpha2.ImageReady), kc.WaitOptions{ - Labels: testCaseLabel, - Namespace: ns, - Timeout: MaxWaitTimeout, - }) - }) - }) - }) - Context("When the virtual disks are applied", func() { It("checks `VirtualDisks` phase", func() { By(fmt.Sprintf("`VirtualDisks` should be in the %q phases", v1alpha2.DiskReady), func() { From bf93fa3b1e48f4aa3540645aa12c19b4dde649a5 Mon Sep 17 00:00:00 2001 From: Nikita Korolev Date: Mon, 16 Mar 2026 18:48:19 +0300 Subject: [PATCH 08/34] temporary comment delete cvi Signed-off-by: Nikita Korolev --- test/e2e/e2e_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/e2e/e2e_test.go b/test/e2e/e2e_test.go index a6e109c54e..b71f50b1bc 100644 --- a/test/e2e/e2e_test.go +++ b/test/e2e/e2e_test.go @@ -45,7 +45,7 @@ var _ = SynchronizedBeforeSuite(func() { }, func() {}) var _ = SynchronizedAfterSuite(func() {}, func() { - cleanupPrecreatedCVIs() + // cleanupPrecreatedCVIs() legacy.NewAfterAllProcessBody() controller.NewAfterAllProcessBody() }) From 9863ef05ce4f6a37e8cb1fff8b824890beee3095 Mon Sep 17 00:00:00 2001 From: Nikita Korolev Date: Mon, 16 Mar 2026 19:39:06 +0300 Subject: [PATCH 09/34] image-hotplug use precreated cvi Signed-off-by: Nikita Korolev --- test/e2e/legacy/image_hotplug.go | 14 +++++++------- .../image-hotplug/cvi/cvi-alpine-http.yaml | 10 ---------- .../image-hotplug/cvi/cvi-ubuntu-2404-iso.yaml | 10 ---------- .../testdata/image-hotplug/cvi/kustomization.yaml | 5 ----- .../testdata/image-hotplug/kustomization.yaml | 1 - test/e2e/suite_cvi.go | 15 +++++++++++++++ 6 files changed, 22 insertions(+), 33 deletions(-) delete mode 100644 test/e2e/legacy/testdata/image-hotplug/cvi/cvi-alpine-http.yaml delete mode 100644 test/e2e/legacy/testdata/image-hotplug/cvi/cvi-ubuntu-2404-iso.yaml delete mode 100644 test/e2e/legacy/testdata/image-hotplug/cvi/kustomization.yaml diff --git a/test/e2e/legacy/image_hotplug.go b/test/e2e/legacy/image_hotplug.go index 403311b1f7..6165e2ae26 100644 --- a/test/e2e/legacy/image_hotplug.go +++ b/test/e2e/legacy/image_hotplug.go @@ -30,6 +30,7 @@ import ( "github.com/deckhouse/virtualization/test/e2e/internal/config" "github.com/deckhouse/virtualization/test/e2e/internal/d8" "github.com/deckhouse/virtualization/test/e2e/internal/framework" + "github.com/deckhouse/virtualization/test/e2e/internal/object" kc "github.com/deckhouse/virtualization/test/e2e/internal/kubectl" "github.com/deckhouse/virtualization/test/e2e/internal/label" ) @@ -133,14 +134,13 @@ var _ = Describe("ImageHotplug", Ordered, label.Legacy(), func() { } }) By("`ClusterVirtualImages`", func() { - cviObjs := &v1alpha2.ClusterVirtualImageList{} - err := GetObjects(v1alpha2.ClusterVirtualImageResource, cviObjs, kc.GetOptions{ - Labels: testCaseLabel, - Namespace: ns, - }) - Expect(err).NotTo(HaveOccurred(), "failed to get `ClusterVirtualImages`: %s", err) + // Get precreated CVIs by name (they are created in bootstrap) + cviNames := []string{object.PrecreatedCVIAlpineBIOSPerf, object.PrecreatedCVIUbuntuISO} + for _, cviName := range cviNames { + cviObj := &v1alpha2.ClusterVirtualImage{} + err := GetObject(kc.ResourceCVI, cviName, cviObj, kc.GetOptions{}) + Expect(err).NotTo(HaveOccurred(), "failed to get CVI %q: %s", cviName, err) - for _, cviObj := range cviObjs.Items { imageBlockDevices = append(imageBlockDevices, Image{ Kind: cviObj.Kind, Name: cviObj.Name, diff --git a/test/e2e/legacy/testdata/image-hotplug/cvi/cvi-alpine-http.yaml b/test/e2e/legacy/testdata/image-hotplug/cvi/cvi-alpine-http.yaml deleted file mode 100644 index 3642c4ded9..0000000000 --- a/test/e2e/legacy/testdata/image-hotplug/cvi/cvi-alpine-http.yaml +++ /dev/null @@ -1,10 +0,0 @@ ---- -apiVersion: virtualization.deckhouse.io/v1alpha2 -kind: ClusterVirtualImage -metadata: - name: cvi-alpine-http -spec: - dataSource: - type: HTTP - http: - url: https://89d64382-20df-4581-8cc7-80df331f67fa.selstorage.ru/alpine/alpine-3-21-bios-perf.qcow2 diff --git a/test/e2e/legacy/testdata/image-hotplug/cvi/cvi-ubuntu-2404-iso.yaml b/test/e2e/legacy/testdata/image-hotplug/cvi/cvi-ubuntu-2404-iso.yaml deleted file mode 100644 index 43dfa50383..0000000000 --- a/test/e2e/legacy/testdata/image-hotplug/cvi/cvi-ubuntu-2404-iso.yaml +++ /dev/null @@ -1,10 +0,0 @@ ---- -apiVersion: virtualization.deckhouse.io/v1alpha2 -kind: ClusterVirtualImage -metadata: - name: cvi-ubuntu-2404-iso -spec: - dataSource: - type: HTTP - http: - url: https://89d64382-20df-4581-8cc7-80df331f67fa.selstorage.ru/ubuntu/ubuntu-24.04.2-live-server-amd64.iso diff --git a/test/e2e/legacy/testdata/image-hotplug/cvi/kustomization.yaml b/test/e2e/legacy/testdata/image-hotplug/cvi/kustomization.yaml deleted file mode 100644 index 0806b261ea..0000000000 --- a/test/e2e/legacy/testdata/image-hotplug/cvi/kustomization.yaml +++ /dev/null @@ -1,5 +0,0 @@ -apiVersion: kustomize.config.k8s.io/v1beta1 -kind: Kustomization -resources: - - cvi-alpine-http.yaml - - cvi-ubuntu-2404-iso.yaml diff --git a/test/e2e/legacy/testdata/image-hotplug/kustomization.yaml b/test/e2e/legacy/testdata/image-hotplug/kustomization.yaml index de34bd39a7..a642cb0684 100644 --- a/test/e2e/legacy/testdata/image-hotplug/kustomization.yaml +++ b/test/e2e/legacy/testdata/image-hotplug/kustomization.yaml @@ -5,7 +5,6 @@ namePrefix: pr-number-or-commit-hash- resources: - ns.yaml - vi - - cvi - overlays/image-hotplug configurations: - transformer.yaml diff --git a/test/e2e/suite_cvi.go b/test/e2e/suite_cvi.go index 65c2823ce4..401f2b6696 100644 --- a/test/e2e/suite_cvi.go +++ b/test/e2e/suite_cvi.go @@ -34,6 +34,9 @@ import ( const precreatedCVILabel = "v12n-e2e-precreated" +// Additional labels to add to precreated CVIs (e.g., for test discovery) +var precreatedCVITestLabels = make(map[string]string) + func bootstrapPrecreatedCVIs() { GinkgoHelper() @@ -56,6 +59,14 @@ func bootstrapPrecreatedCVIs() { } } +// AddTestLabelsToPrecreatedCVI adds additional labels to precreated CVIs for test discovery. +// Must be called before applying kustomize in tests that use precreated CVIs. +func AddTestLabelsToPrecreatedCVI(labels map[string]string) { + for k, v := range labels { + precreatedCVITestLabels[k] = v + } +} + func cleanupPrecreatedCVIs() { GinkgoHelper() @@ -101,5 +112,9 @@ func setPrecreatedCVILabel(cvi *v1alpha2.ClusterVirtualImage) { labels = make(map[string]string) } labels[precreatedCVILabel] = "true" + // Add test-specific labels for test discovery + for k, v := range precreatedCVITestLabels { + labels[k] = v + } cvi.SetLabels(labels) } From 89b4c330814835873ca090a7ffb5742f261d6923 Mon Sep 17 00:00:00 2001 From: Nikita Korolev Date: Mon, 16 Mar 2026 19:40:39 +0300 Subject: [PATCH 10/34] add label lowcase Signed-off-by: Nikita Korolev --- test/e2e/internal/label/label.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/e2e/internal/label/label.go b/test/e2e/internal/label/label.go index fab1a9bdb9..f234e996e1 100644 --- a/test/e2e/internal/label/label.go +++ b/test/e2e/internal/label/label.go @@ -29,5 +29,5 @@ func TPM() Labels { } func Legacy() Labels { - return Label("Legacy") + return Label("Legacy", "legacy") } From 454361605eec68cab0fea027c6b3dcb2eb01d51b Mon Sep 17 00:00:00 2001 From: Nikita Korolev Date: Mon, 16 Mar 2026 21:33:47 +0300 Subject: [PATCH 11/34] vd-snapshots pre created cvi Signed-off-by: Nikita Korolev --- .../legacy/testdata/vd-snapshots/kustomization.yaml | 1 - .../testdata/vd-snapshots/vd/vd-alpine-http.yaml | 7 ++++--- .../testdata/vd-snapshots/vi/kustomization.yaml | 4 ---- .../testdata/vd-snapshots/vi/vi-alpine-http.yaml | 11 ----------- .../legacy/testdata/vd-snapshots/vm/base/vd-root.yaml | 4 ++-- test/e2e/legacy/vd_snapshots.go | 11 ----------- 6 files changed, 6 insertions(+), 32 deletions(-) delete mode 100644 test/e2e/legacy/testdata/vd-snapshots/vi/kustomization.yaml delete mode 100644 test/e2e/legacy/testdata/vd-snapshots/vi/vi-alpine-http.yaml diff --git a/test/e2e/legacy/testdata/vd-snapshots/kustomization.yaml b/test/e2e/legacy/testdata/vd-snapshots/kustomization.yaml index 692b0657fb..724e6e1681 100644 --- a/test/e2e/legacy/testdata/vd-snapshots/kustomization.yaml +++ b/test/e2e/legacy/testdata/vd-snapshots/kustomization.yaml @@ -5,7 +5,6 @@ namePrefix: commit- resources: - ns.yaml - vd - - vi - vm configurations: - transformer.yaml diff --git a/test/e2e/legacy/testdata/vd-snapshots/vd/vd-alpine-http.yaml b/test/e2e/legacy/testdata/vd-snapshots/vd/vd-alpine-http.yaml index 164c5ae812..1e06d9d929 100644 --- a/test/e2e/legacy/testdata/vd-snapshots/vd/vd-alpine-http.yaml +++ b/test/e2e/legacy/testdata/vd-snapshots/vd/vd-alpine-http.yaml @@ -5,9 +5,10 @@ metadata: name: vd-alpine-http spec: dataSource: - type: HTTP - http: - url: https://89d64382-20df-4581-8cc7-80df331f67fa.selstorage.ru/alpine/alpine-3-23-3-bios-base.qcow2 + type: ObjectRef + objectRef: + kind: ClusterVirtualImage + name: v12n-e2e-alpine-bios persistentVolumeClaim: storageClassName: "{{ .STORAGE_CLASS_NAME }}" size: 350Mi diff --git a/test/e2e/legacy/testdata/vd-snapshots/vi/kustomization.yaml b/test/e2e/legacy/testdata/vd-snapshots/vi/kustomization.yaml deleted file mode 100644 index b807d8e2d2..0000000000 --- a/test/e2e/legacy/testdata/vd-snapshots/vi/kustomization.yaml +++ /dev/null @@ -1,4 +0,0 @@ -apiVersion: kustomize.config.k8s.io/v1beta1 -kind: Kustomization -resources: - - vi-alpine-http.yaml diff --git a/test/e2e/legacy/testdata/vd-snapshots/vi/vi-alpine-http.yaml b/test/e2e/legacy/testdata/vd-snapshots/vi/vi-alpine-http.yaml deleted file mode 100644 index 43bc57dd27..0000000000 --- a/test/e2e/legacy/testdata/vd-snapshots/vi/vi-alpine-http.yaml +++ /dev/null @@ -1,11 +0,0 @@ ---- -apiVersion: virtualization.deckhouse.io/v1alpha2 -kind: VirtualImage -metadata: - name: vi-alpine-http -spec: - storage: ContainerRegistry - dataSource: - type: HTTP - http: - url: https://89d64382-20df-4581-8cc7-80df331f67fa.selstorage.ru/alpine/alpine-3-23-3-uefi-base.qcow2 diff --git a/test/e2e/legacy/testdata/vd-snapshots/vm/base/vd-root.yaml b/test/e2e/legacy/testdata/vd-snapshots/vm/base/vd-root.yaml index c2bf54f1ff..7442dd263a 100644 --- a/test/e2e/legacy/testdata/vd-snapshots/vm/base/vd-root.yaml +++ b/test/e2e/legacy/testdata/vd-snapshots/vm/base/vd-root.yaml @@ -9,5 +9,5 @@ spec: dataSource: type: ObjectRef objectRef: - kind: VirtualImage - name: vi-alpine-http + kind: ClusterVirtualImage + name: v12n-e2e-alpine-uefi diff --git a/test/e2e/legacy/vd_snapshots.go b/test/e2e/legacy/vd_snapshots.go index 313f4ad735..a7a0c9897f 100644 --- a/test/e2e/legacy/vd_snapshots.go +++ b/test/e2e/legacy/vd_snapshots.go @@ -87,17 +87,6 @@ var _ = Describe("VirtualDiskSnapshots", Ordered, label.Legacy(), func() { }) }) - Context("When virtual images are applied:", func() { - It("checks VIs phases", func() { - By(fmt.Sprintf("VIs should be in %s phases", PhaseReady)) - WaitPhaseByLabel(kc.ResourceVI, PhaseReady, kc.WaitOptions{ - Labels: testCaseLabel, - Namespace: ns, - Timeout: MaxWaitTimeout, - }) - }) - }) - Context("When virtual disks are applied:", func() { It("checks VDs phases", func() { By(fmt.Sprintf("VDs should be in %s phases", PhaseReady)) From 1de418078ae9ce9fbeb087486806a16da31a81ca Mon Sep 17 00:00:00 2001 From: Nikita Korolev Date: Mon, 16 Mar 2026 21:35:19 +0300 Subject: [PATCH 12/34] vm-evacuation pre created cvi Signed-off-by: Nikita Korolev --- .../legacy/testdata/vm-evacuation/kustomization.yaml | 1 - .../testdata/vm-evacuation/vi/kustomization.yaml | 5 ----- .../vm-evacuation/vi/vi-alpine-http-bios.yaml | 11 ----------- .../vm-evacuation/vi/vi-alpine-http-uefi.yaml | 11 ----------- .../testdata/vm-evacuation/vm/base/vd-root.yaml | 4 ++-- .../vm/overlays/migration-bios/vd.image.patch.yaml | 4 ++-- .../vm/overlays/migration-uefi/vd.image.patch.yaml | 4 ++-- 7 files changed, 6 insertions(+), 34 deletions(-) delete mode 100644 test/e2e/legacy/testdata/vm-evacuation/vi/kustomization.yaml delete mode 100644 test/e2e/legacy/testdata/vm-evacuation/vi/vi-alpine-http-bios.yaml delete mode 100644 test/e2e/legacy/testdata/vm-evacuation/vi/vi-alpine-http-uefi.yaml diff --git a/test/e2e/legacy/testdata/vm-evacuation/kustomization.yaml b/test/e2e/legacy/testdata/vm-evacuation/kustomization.yaml index eeefcc8725..2930a85896 100644 --- a/test/e2e/legacy/testdata/vm-evacuation/kustomization.yaml +++ b/test/e2e/legacy/testdata/vm-evacuation/kustomization.yaml @@ -3,7 +3,6 @@ kind: Kustomization namespace: testcases namePrefix: pr-number-or-commit-hash- resources: - - vi - vm - ns.yaml configurations: diff --git a/test/e2e/legacy/testdata/vm-evacuation/vi/kustomization.yaml b/test/e2e/legacy/testdata/vm-evacuation/vi/kustomization.yaml deleted file mode 100644 index f9c61289fc..0000000000 --- a/test/e2e/legacy/testdata/vm-evacuation/vi/kustomization.yaml +++ /dev/null @@ -1,5 +0,0 @@ -apiVersion: kustomize.config.k8s.io/v1beta1 -kind: Kustomization -resources: - - vi-alpine-http-bios.yaml - - vi-alpine-http-uefi.yaml diff --git a/test/e2e/legacy/testdata/vm-evacuation/vi/vi-alpine-http-bios.yaml b/test/e2e/legacy/testdata/vm-evacuation/vi/vi-alpine-http-bios.yaml deleted file mode 100644 index 681822ea6c..0000000000 --- a/test/e2e/legacy/testdata/vm-evacuation/vi/vi-alpine-http-bios.yaml +++ /dev/null @@ -1,11 +0,0 @@ ---- -apiVersion: virtualization.deckhouse.io/v1alpha2 -kind: VirtualImage -metadata: - name: vi-alpine-http-bios -spec: - storage: ContainerRegistry - dataSource: - type: HTTP - http: - url: https://89d64382-20df-4581-8cc7-80df331f67fa.selstorage.ru/alpine/alpine-3-23-3-bios-base.qcow2 diff --git a/test/e2e/legacy/testdata/vm-evacuation/vi/vi-alpine-http-uefi.yaml b/test/e2e/legacy/testdata/vm-evacuation/vi/vi-alpine-http-uefi.yaml deleted file mode 100644 index c210fb37a5..0000000000 --- a/test/e2e/legacy/testdata/vm-evacuation/vi/vi-alpine-http-uefi.yaml +++ /dev/null @@ -1,11 +0,0 @@ ---- -apiVersion: virtualization.deckhouse.io/v1alpha2 -kind: VirtualImage -metadata: - name: vi-alpine-http-uefi -spec: - storage: ContainerRegistry - dataSource: - type: HTTP - http: - url: https://89d64382-20df-4581-8cc7-80df331f67fa.selstorage.ru/alpine/alpine-3-23-3-uefi-base.qcow2 diff --git a/test/e2e/legacy/testdata/vm-evacuation/vm/base/vd-root.yaml b/test/e2e/legacy/testdata/vm-evacuation/vm/base/vd-root.yaml index c2bf54f1ff..3c66723071 100644 --- a/test/e2e/legacy/testdata/vm-evacuation/vm/base/vd-root.yaml +++ b/test/e2e/legacy/testdata/vm-evacuation/vm/base/vd-root.yaml @@ -9,5 +9,5 @@ spec: dataSource: type: ObjectRef objectRef: - kind: VirtualImage - name: vi-alpine-http + kind: ClusterVirtualImage + name: v12n-e2e-alpine-bios diff --git a/test/e2e/legacy/testdata/vm-evacuation/vm/overlays/migration-bios/vd.image.patch.yaml b/test/e2e/legacy/testdata/vm-evacuation/vm/overlays/migration-bios/vd.image.patch.yaml index 0805403f38..6d7b3e4063 100644 --- a/test/e2e/legacy/testdata/vm-evacuation/vm/overlays/migration-bios/vd.image.patch.yaml +++ b/test/e2e/legacy/testdata/vm-evacuation/vm/overlays/migration-bios/vd.image.patch.yaml @@ -6,5 +6,5 @@ spec: dataSource: type: ObjectRef objectRef: - kind: VirtualImage - name: vi-alpine-http-bios + kind: ClusterVirtualImage + name: v12n-e2e-alpine-bios diff --git a/test/e2e/legacy/testdata/vm-evacuation/vm/overlays/migration-uefi/vd.image.patch.yaml b/test/e2e/legacy/testdata/vm-evacuation/vm/overlays/migration-uefi/vd.image.patch.yaml index fb750b7a46..6c1a1ad8c9 100644 --- a/test/e2e/legacy/testdata/vm-evacuation/vm/overlays/migration-uefi/vd.image.patch.yaml +++ b/test/e2e/legacy/testdata/vm-evacuation/vm/overlays/migration-uefi/vd.image.patch.yaml @@ -6,5 +6,5 @@ spec: dataSource: type: ObjectRef objectRef: - kind: VirtualImage - name: vi-alpine-http-uefi + kind: ClusterVirtualImage + name: v12n-e2e-alpine-uefi From ddfbca084e8364fa708e0899112060258c2736a7 Mon Sep 17 00:00:00 2001 From: Nikita Korolev Date: Mon, 16 Mar 2026 21:35:58 +0300 Subject: [PATCH 13/34] vm-disk-attachment pre created cvi Signed-off-by: Nikita Korolev --- .../testdata/vm-disk-attachment/base/vd-root.yaml | 4 ++-- .../testdata/vm-disk-attachment/kustomization.yaml | 1 - .../testdata/vm-disk-attachment/vi/kustomization.yaml | 4 ---- .../vm-disk-attachment/vi/vi-alpine-http.yaml | 11 ----------- test/e2e/legacy/vm_disk_attachment.go | 11 ----------- 5 files changed, 2 insertions(+), 29 deletions(-) delete mode 100644 test/e2e/legacy/testdata/vm-disk-attachment/vi/kustomization.yaml delete mode 100644 test/e2e/legacy/testdata/vm-disk-attachment/vi/vi-alpine-http.yaml diff --git a/test/e2e/legacy/testdata/vm-disk-attachment/base/vd-root.yaml b/test/e2e/legacy/testdata/vm-disk-attachment/base/vd-root.yaml index 0f98ff3633..5623d567ed 100644 --- a/test/e2e/legacy/testdata/vm-disk-attachment/base/vd-root.yaml +++ b/test/e2e/legacy/testdata/vm-disk-attachment/base/vd-root.yaml @@ -9,5 +9,5 @@ spec: dataSource: type: ObjectRef objectRef: - kind: VirtualImage - name: vi-alpine-http + kind: ClusterVirtualImage + name: v12n-e2e-alpine-uefi diff --git a/test/e2e/legacy/testdata/vm-disk-attachment/kustomization.yaml b/test/e2e/legacy/testdata/vm-disk-attachment/kustomization.yaml index 168c3f3d3e..d8a3bc44a9 100644 --- a/test/e2e/legacy/testdata/vm-disk-attachment/kustomization.yaml +++ b/test/e2e/legacy/testdata/vm-disk-attachment/kustomization.yaml @@ -5,7 +5,6 @@ namePrefix: pr-number-or-commit-hash- resources: - ns.yaml - overlays/vm - - vi configurations: - transformer.yaml labels: diff --git a/test/e2e/legacy/testdata/vm-disk-attachment/vi/kustomization.yaml b/test/e2e/legacy/testdata/vm-disk-attachment/vi/kustomization.yaml deleted file mode 100644 index b807d8e2d2..0000000000 --- a/test/e2e/legacy/testdata/vm-disk-attachment/vi/kustomization.yaml +++ /dev/null @@ -1,4 +0,0 @@ -apiVersion: kustomize.config.k8s.io/v1beta1 -kind: Kustomization -resources: - - vi-alpine-http.yaml diff --git a/test/e2e/legacy/testdata/vm-disk-attachment/vi/vi-alpine-http.yaml b/test/e2e/legacy/testdata/vm-disk-attachment/vi/vi-alpine-http.yaml deleted file mode 100644 index 43bc57dd27..0000000000 --- a/test/e2e/legacy/testdata/vm-disk-attachment/vi/vi-alpine-http.yaml +++ /dev/null @@ -1,11 +0,0 @@ ---- -apiVersion: virtualization.deckhouse.io/v1alpha2 -kind: VirtualImage -metadata: - name: vi-alpine-http -spec: - storage: ContainerRegistry - dataSource: - type: HTTP - http: - url: https://89d64382-20df-4581-8cc7-80df331f67fa.selstorage.ru/alpine/alpine-3-23-3-uefi-base.qcow2 diff --git a/test/e2e/legacy/vm_disk_attachment.go b/test/e2e/legacy/vm_disk_attachment.go index 288fee2c04..ae56403c9c 100644 --- a/test/e2e/legacy/vm_disk_attachment.go +++ b/test/e2e/legacy/vm_disk_attachment.go @@ -77,17 +77,6 @@ var _ = Describe("VirtualDiskAttachment", Ordered, label.Legacy(), func() { }) }) - Context("When virtual images are applied", func() { - It("checks VIs phases", func() { - By(fmt.Sprintf("VIs should be in %s phases", PhaseReady)) - WaitPhaseByLabel(kc.ResourceVI, PhaseReady, kc.WaitOptions{ - Labels: testCaseLabel, - Namespace: ns, - Timeout: MaxWaitTimeout, - }) - }) - }) - Context("When virtual disks are applied", func() { It("checks VDs phases", func() { By(fmt.Sprintf("VDs with consumers should be in %s phases", PhaseReady)) From b59c389e6c911e67963b3633be0a5e72abbb0af3 Mon Sep 17 00:00:00 2001 From: Nikita Korolev Date: Mon, 16 Mar 2026 21:36:33 +0300 Subject: [PATCH 14/34] vm-label-annotation pre created cvi Signed-off-by: Nikita Korolev --- .../testdata/vm-label-annotation/base/vd-root.yaml | 4 ++-- .../testdata/vm-label-annotation/kustomization.yaml | 1 - .../vm-label-annotation/vi/kustomization.yaml | 4 ---- .../vm-label-annotation/vi/vi-alpine-http.yaml | 11 ----------- test/e2e/legacy/vm_label_annotation.go | 11 ----------- 5 files changed, 2 insertions(+), 29 deletions(-) delete mode 100644 test/e2e/legacy/testdata/vm-label-annotation/vi/kustomization.yaml delete mode 100644 test/e2e/legacy/testdata/vm-label-annotation/vi/vi-alpine-http.yaml diff --git a/test/e2e/legacy/testdata/vm-label-annotation/base/vd-root.yaml b/test/e2e/legacy/testdata/vm-label-annotation/base/vd-root.yaml index 0f98ff3633..5623d567ed 100644 --- a/test/e2e/legacy/testdata/vm-label-annotation/base/vd-root.yaml +++ b/test/e2e/legacy/testdata/vm-label-annotation/base/vd-root.yaml @@ -9,5 +9,5 @@ spec: dataSource: type: ObjectRef objectRef: - kind: VirtualImage - name: vi-alpine-http + kind: ClusterVirtualImage + name: v12n-e2e-alpine-uefi diff --git a/test/e2e/legacy/testdata/vm-label-annotation/kustomization.yaml b/test/e2e/legacy/testdata/vm-label-annotation/kustomization.yaml index 28ddbfe9e9..c29f74e133 100644 --- a/test/e2e/legacy/testdata/vm-label-annotation/kustomization.yaml +++ b/test/e2e/legacy/testdata/vm-label-annotation/kustomization.yaml @@ -4,7 +4,6 @@ namespace: testcases namePrefix: pr-number-or-commit-hash- resources: - ns.yaml - - vi - overlays/vm-label-annotation configurations: - transformer.yaml diff --git a/test/e2e/legacy/testdata/vm-label-annotation/vi/kustomization.yaml b/test/e2e/legacy/testdata/vm-label-annotation/vi/kustomization.yaml deleted file mode 100644 index b807d8e2d2..0000000000 --- a/test/e2e/legacy/testdata/vm-label-annotation/vi/kustomization.yaml +++ /dev/null @@ -1,4 +0,0 @@ -apiVersion: kustomize.config.k8s.io/v1beta1 -kind: Kustomization -resources: - - vi-alpine-http.yaml diff --git a/test/e2e/legacy/testdata/vm-label-annotation/vi/vi-alpine-http.yaml b/test/e2e/legacy/testdata/vm-label-annotation/vi/vi-alpine-http.yaml deleted file mode 100644 index 43bc57dd27..0000000000 --- a/test/e2e/legacy/testdata/vm-label-annotation/vi/vi-alpine-http.yaml +++ /dev/null @@ -1,11 +0,0 @@ ---- -apiVersion: virtualization.deckhouse.io/v1alpha2 -kind: VirtualImage -metadata: - name: vi-alpine-http -spec: - storage: ContainerRegistry - dataSource: - type: HTTP - http: - url: https://89d64382-20df-4581-8cc7-80df331f67fa.selstorage.ru/alpine/alpine-3-23-3-uefi-base.qcow2 diff --git a/test/e2e/legacy/vm_label_annotation.go b/test/e2e/legacy/vm_label_annotation.go index e879b6b721..da3eaaa936 100644 --- a/test/e2e/legacy/vm_label_annotation.go +++ b/test/e2e/legacy/vm_label_annotation.go @@ -66,17 +66,6 @@ var _ = Describe("VirtualMachineLabelAndAnnotation", Ordered, label.Legacy(), fu }) }) - Context("When virtual images are applied", func() { - It("checks VIs phases", func() { - By(fmt.Sprintf("VIs should be in %s phases", PhaseReady)) - WaitPhaseByLabel(kc.ResourceVI, PhaseReady, kc.WaitOptions{ - Labels: testCaseLabel, - Namespace: ns, - Timeout: MaxWaitTimeout, - }) - }) - }) - Context("When virtual disks are applied", func() { It("checks VDs phases", func() { By(fmt.Sprintf("VDs should be in %s phases", PhaseReady)) From 6a3a4374839873865dc58df5cdce5bee989dc83c Mon Sep 17 00:00:00 2001 From: Nikita Korolev Date: Mon, 16 Mar 2026 21:37:17 +0300 Subject: [PATCH 15/34] vm-migration-cancel pre created cvi Signed-off-by: Nikita Korolev --- .../testdata/vm-migration-cancel/kustomization.yaml | 1 - .../vm-migration-cancel/vi/kustomization.yaml | 5 ----- .../vm-migration-cancel/vi/vi-alpine-http-bios.yaml | 11 ----------- .../vm-migration-cancel/vi/vi-alpine-http-uefi.yaml | 11 ----------- .../testdata/vm-migration-cancel/vm/base/vd-root.yaml | 4 ++-- .../vm/overlays/migration-bios/vd.image.patch.yaml | 4 ++-- .../vm/overlays/migration-uefi/vd.image.patch.yaml | 4 ++-- 7 files changed, 6 insertions(+), 34 deletions(-) delete mode 100644 test/e2e/legacy/testdata/vm-migration-cancel/vi/kustomization.yaml delete mode 100644 test/e2e/legacy/testdata/vm-migration-cancel/vi/vi-alpine-http-bios.yaml delete mode 100644 test/e2e/legacy/testdata/vm-migration-cancel/vi/vi-alpine-http-uefi.yaml diff --git a/test/e2e/legacy/testdata/vm-migration-cancel/kustomization.yaml b/test/e2e/legacy/testdata/vm-migration-cancel/kustomization.yaml index 3f8073239d..6064a3a5cc 100644 --- a/test/e2e/legacy/testdata/vm-migration-cancel/kustomization.yaml +++ b/test/e2e/legacy/testdata/vm-migration-cancel/kustomization.yaml @@ -3,7 +3,6 @@ kind: Kustomization namespace: testcases namePrefix: pr-number-or-commit-hash- resources: - - vi - vm - ns.yaml configurations: diff --git a/test/e2e/legacy/testdata/vm-migration-cancel/vi/kustomization.yaml b/test/e2e/legacy/testdata/vm-migration-cancel/vi/kustomization.yaml deleted file mode 100644 index f9c61289fc..0000000000 --- a/test/e2e/legacy/testdata/vm-migration-cancel/vi/kustomization.yaml +++ /dev/null @@ -1,5 +0,0 @@ -apiVersion: kustomize.config.k8s.io/v1beta1 -kind: Kustomization -resources: - - vi-alpine-http-bios.yaml - - vi-alpine-http-uefi.yaml diff --git a/test/e2e/legacy/testdata/vm-migration-cancel/vi/vi-alpine-http-bios.yaml b/test/e2e/legacy/testdata/vm-migration-cancel/vi/vi-alpine-http-bios.yaml deleted file mode 100644 index 681822ea6c..0000000000 --- a/test/e2e/legacy/testdata/vm-migration-cancel/vi/vi-alpine-http-bios.yaml +++ /dev/null @@ -1,11 +0,0 @@ ---- -apiVersion: virtualization.deckhouse.io/v1alpha2 -kind: VirtualImage -metadata: - name: vi-alpine-http-bios -spec: - storage: ContainerRegistry - dataSource: - type: HTTP - http: - url: https://89d64382-20df-4581-8cc7-80df331f67fa.selstorage.ru/alpine/alpine-3-23-3-bios-base.qcow2 diff --git a/test/e2e/legacy/testdata/vm-migration-cancel/vi/vi-alpine-http-uefi.yaml b/test/e2e/legacy/testdata/vm-migration-cancel/vi/vi-alpine-http-uefi.yaml deleted file mode 100644 index c210fb37a5..0000000000 --- a/test/e2e/legacy/testdata/vm-migration-cancel/vi/vi-alpine-http-uefi.yaml +++ /dev/null @@ -1,11 +0,0 @@ ---- -apiVersion: virtualization.deckhouse.io/v1alpha2 -kind: VirtualImage -metadata: - name: vi-alpine-http-uefi -spec: - storage: ContainerRegistry - dataSource: - type: HTTP - http: - url: https://89d64382-20df-4581-8cc7-80df331f67fa.selstorage.ru/alpine/alpine-3-23-3-uefi-base.qcow2 diff --git a/test/e2e/legacy/testdata/vm-migration-cancel/vm/base/vd-root.yaml b/test/e2e/legacy/testdata/vm-migration-cancel/vm/base/vd-root.yaml index c2bf54f1ff..3c66723071 100644 --- a/test/e2e/legacy/testdata/vm-migration-cancel/vm/base/vd-root.yaml +++ b/test/e2e/legacy/testdata/vm-migration-cancel/vm/base/vd-root.yaml @@ -9,5 +9,5 @@ spec: dataSource: type: ObjectRef objectRef: - kind: VirtualImage - name: vi-alpine-http + kind: ClusterVirtualImage + name: v12n-e2e-alpine-bios diff --git a/test/e2e/legacy/testdata/vm-migration-cancel/vm/overlays/migration-bios/vd.image.patch.yaml b/test/e2e/legacy/testdata/vm-migration-cancel/vm/overlays/migration-bios/vd.image.patch.yaml index 0805403f38..6d7b3e4063 100644 --- a/test/e2e/legacy/testdata/vm-migration-cancel/vm/overlays/migration-bios/vd.image.patch.yaml +++ b/test/e2e/legacy/testdata/vm-migration-cancel/vm/overlays/migration-bios/vd.image.patch.yaml @@ -6,5 +6,5 @@ spec: dataSource: type: ObjectRef objectRef: - kind: VirtualImage - name: vi-alpine-http-bios + kind: ClusterVirtualImage + name: v12n-e2e-alpine-bios diff --git a/test/e2e/legacy/testdata/vm-migration-cancel/vm/overlays/migration-uefi/vd.image.patch.yaml b/test/e2e/legacy/testdata/vm-migration-cancel/vm/overlays/migration-uefi/vd.image.patch.yaml index fb750b7a46..6c1a1ad8c9 100644 --- a/test/e2e/legacy/testdata/vm-migration-cancel/vm/overlays/migration-uefi/vd.image.patch.yaml +++ b/test/e2e/legacy/testdata/vm-migration-cancel/vm/overlays/migration-uefi/vd.image.patch.yaml @@ -6,5 +6,5 @@ spec: dataSource: type: ObjectRef objectRef: - kind: VirtualImage - name: vi-alpine-http-uefi + kind: ClusterVirtualImage + name: v12n-e2e-alpine-uefi From c8e70b6589571ac033415121862d99313c321127 Mon Sep 17 00:00:00 2001 From: Nikita Korolev Date: Mon, 16 Mar 2026 21:37:42 +0300 Subject: [PATCH 16/34] vm-versions pre created cvi Signed-off-by: Nikita Korolev --- test/e2e/legacy/testdata/vm-versions/vd/vd-root.yaml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/test/e2e/legacy/testdata/vm-versions/vd/vd-root.yaml b/test/e2e/legacy/testdata/vm-versions/vd/vd-root.yaml index 9d26f1e2a5..11db56f25c 100644 --- a/test/e2e/legacy/testdata/vm-versions/vd/vd-root.yaml +++ b/test/e2e/legacy/testdata/vm-versions/vd/vd-root.yaml @@ -7,6 +7,7 @@ spec: persistentVolumeClaim: size: 512Mi dataSource: - type: HTTP - http: - url: https://89d64382-20df-4581-8cc7-80df331f67fa.selstorage.ru/alpine/alpine-3-23-3-uefi-base.qcow2 + type: ObjectRef + objectRef: + kind: ClusterVirtualImage + name: v12n-e2e-alpine-uefi From caa77f5780d28cfd3d1cf07bc7d82aa51cf282c5 Mon Sep 17 00:00:00 2001 From: Nikita Korolev Date: Mon, 16 Mar 2026 22:47:11 +0300 Subject: [PATCH 17/34] data_export to precreate cvi Signed-off-by: Nikita Korolev --- test/e2e/blockdevice/data_exports.go | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/test/e2e/blockdevice/data_exports.go b/test/e2e/blockdevice/data_exports.go index bc3223d755..b6fab5fb78 100644 --- a/test/e2e/blockdevice/data_exports.go +++ b/test/e2e/blockdevice/data_exports.go @@ -80,13 +80,7 @@ var _ = Describe("DataExports", label.Slow(), func() { ) By("Creating root and data disks", func() { - vdRoot = vdbuilder.New( - vdbuilder.WithName("vd-root"), - vdbuilder.WithNamespace(f.Namespace().Name), - vdbuilder.WithDataSourceHTTP(&v1alpha2.DataSourceHTTP{ - URL: object.ImageURLUbuntu, - }), - ) + vdRoot = object.NewVDFromCVI("vd-root", f.Namespace().Name, object.PrecreatedCVIUbuntu) vdData = vdbuilder.New( vdbuilder.WithName("vd-data"), From 789460e3725694668f8ec82b0039e54ba2687e94 Mon Sep 17 00:00:00 2001 From: Nikita Korolev Date: Mon, 16 Mar 2026 22:48:10 +0300 Subject: [PATCH 18/34] virtual_disk_provisioning precreate cvi Signed-off-by: Nikita Korolev --- .../blockdevice/virtual_disk_provisioning.go | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-) diff --git a/test/e2e/blockdevice/virtual_disk_provisioning.go b/test/e2e/blockdevice/virtual_disk_provisioning.go index 0e717f88f7..73a67babbf 100644 --- a/test/e2e/blockdevice/virtual_disk_provisioning.go +++ b/test/e2e/blockdevice/virtual_disk_provisioning.go @@ -25,7 +25,6 @@ import ( "k8s.io/utils/ptr" vdbuilder "github.com/deckhouse/virtualization-controller/pkg/builder/vd" - vibuilder "github.com/deckhouse/virtualization-controller/pkg/builder/vi" vmbuilder "github.com/deckhouse/virtualization-controller/pkg/builder/vm" "github.com/deckhouse/virtualization/api/core/v1alpha2" "github.com/deckhouse/virtualization/test/e2e/internal/framework" @@ -55,13 +54,8 @@ var _ = Describe("VirtualDiskProvisioning", func() { vm *v1alpha2.VirtualMachine ) - By("Creating VirtualImage", func() { - vi = vibuilder.New( - vibuilder.WithName("vi"), - vibuilder.WithNamespace(f.Namespace().Name), - vibuilder.WithDataSourceHTTP(object.ImageURLAlpineUEFI, nil, nil), - vibuilder.WithStorage(v1alpha2.StoragePersistentVolumeClaim), - ) + By("Creating VirtualImage from precreated CVI", func() { + vi = object.NewGeneratedVIFromCVI("vi-", f.Namespace().Name, object.PrecreatedCVIAlpineUEFI) err := f.CreateWithDeferredDeletion(context.Background(), vi) Expect(err).NotTo(HaveOccurred()) @@ -72,12 +66,7 @@ var _ = Describe("VirtualDiskProvisioning", func() { }) By("Creating VirtualDisk", func() { - vd = vdbuilder.New( - vdbuilder.WithName("vd"), - vdbuilder.WithNamespace(f.Namespace().Name), - vdbuilder.WithSize(ptr.To(resource.MustParse("350Mi"))), - vdbuilder.WithDataSourceObjectRefFromVI(vi), - ) + vd = object.NewVDFromVI("vd", f.Namespace().Name, vi, vdbuilder.WithSize(ptr.To(resource.MustParse("350Mi")))) err := f.CreateWithDeferredDeletion(context.Background(), vd) Expect(err).NotTo(HaveOccurred()) From 406c2073303258e7954890d65425e4515f8fe0d9 Mon Sep 17 00:00:00 2001 From: Nikita Korolev Date: Mon, 16 Mar 2026 22:48:52 +0300 Subject: [PATCH 19/34] modify object Signed-off-by: Nikita Korolev --- test/e2e/internal/object/vd.go | 10 ++++++++++ test/e2e/internal/object/vi.go | 11 +++++++++++ 2 files changed, 21 insertions(+) diff --git a/test/e2e/internal/object/vd.go b/test/e2e/internal/object/vd.go index e37beb9298..65eceb6d18 100644 --- a/test/e2e/internal/object/vd.go +++ b/test/e2e/internal/object/vd.go @@ -66,3 +66,13 @@ func NewHTTPVDAlpineUEFIPerf(name, namespace string, opts ...vd.Option) *v1alpha baseOpts = append(baseOpts, opts...) return vd.New(baseOpts...) } + +func NewVDFromCVI(name, namespace, cviName string, opts ...vd.Option) *v1alpha2.VirtualDisk { + baseOpts := []vd.Option{ + vd.WithName(name), + vd.WithNamespace(namespace), + vd.WithDataSourceObjectRef(v1alpha2.VirtualDiskObjectRefKindClusterVirtualImage, cviName), + } + baseOpts = append(baseOpts, opts...) + return vd.New(baseOpts...) +} diff --git a/test/e2e/internal/object/vi.go b/test/e2e/internal/object/vi.go index 288b94bf18..3e23d3d153 100644 --- a/test/e2e/internal/object/vi.go +++ b/test/e2e/internal/object/vi.go @@ -57,3 +57,14 @@ func NewGeneratedContainerImageVI(prefix, namespace string, opts ...vi.Option) * baseOpts = append(baseOpts, opts...) return vi.New(baseOpts...) } + +func NewGeneratedVIFromCVI(prefix, namespace, cviName string, opts ...vi.Option) *v1alpha2.VirtualImage { + baseOpts := []vi.Option{ + vi.WithGenerateName(prefix), + vi.WithNamespace(namespace), + vi.WithStorage(v1alpha2.StorageContainerRegistry), + vi.WithDataSourceObjectRef(v1alpha2.VirtualImageObjectRefKindClusterVirtualImage, cviName), + } + baseOpts = append(baseOpts, opts...) + return vi.New(baseOpts...) +} From 391e7be4be127b22d1297e3c77d7849ab81444b0 Mon Sep 17 00:00:00 2001 From: Nikita Korolev Date: Tue, 17 Mar 2026 10:14:42 +0300 Subject: [PATCH 20/34] refactor label Legacy Signed-off-by: Nikita Korolev --- test/e2e/internal/label/label.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/e2e/internal/label/label.go b/test/e2e/internal/label/label.go index f234e996e1..fab1a9bdb9 100644 --- a/test/e2e/internal/label/label.go +++ b/test/e2e/internal/label/label.go @@ -29,5 +29,5 @@ func TPM() Labels { } func Legacy() Labels { - return Label("Legacy", "legacy") + return Label("Legacy") } From 35220af49581328fa604dafca0deac179e4843ba Mon Sep 17 00:00:00 2001 From: Nikita Korolev Date: Tue, 17 Mar 2026 15:39:24 +0300 Subject: [PATCH 21/34] refactor predefined cvi funcs Signed-off-by: Nikita Korolev --- test/e2e/e2e_test.go | 5 +- test/e2e/internal/config/cleanup.go | 22 ++++ test/e2e/internal/precreatedcvi/manager.go | 126 +++++++++++++++++++++ test/e2e/legacy/legacy.go | 3 + test/e2e/suite_cvi.go | 95 +--------------- 5 files changed, 158 insertions(+), 93 deletions(-) create mode 100644 test/e2e/internal/precreatedcvi/manager.go diff --git a/test/e2e/e2e_test.go b/test/e2e/e2e_test.go index b71f50b1bc..cee161cb4f 100644 --- a/test/e2e/e2e_test.go +++ b/test/e2e/e2e_test.go @@ -44,8 +44,9 @@ var _ = SynchronizedBeforeSuite(func() { bootstrapPrecreatedCVIs() }, func() {}) -var _ = SynchronizedAfterSuite(func() {}, func() { - // cleanupPrecreatedCVIs() +var _ = SynchronizedAfterSuite(func() { + cleanupPrecreatedCVIs() +}, func() { legacy.NewAfterAllProcessBody() controller.NewAfterAllProcessBody() }) diff --git a/test/e2e/internal/config/cleanup.go b/test/e2e/internal/config/cleanup.go index b393c46608..17d0cc835e 100644 --- a/test/e2e/internal/config/cleanup.go +++ b/test/e2e/internal/config/cleanup.go @@ -25,6 +25,28 @@ import ( // PostCleanUpEnv defines an environment variable used to explicitly request the deletion of created/used resources. const PostCleanUpEnv = "POST_CLEANUP" +// PrecreatedCVICleanupEnv defines an environment variable to explicitly enable deletion of precreated CVIs after the suite. +// +// By default, precreated CVIs are not deleted: they are shared across runs and may be reused. +// Set PRECREATED_CVI_CLEANUP=yes to delete them after the suite; unset, empty, or "no" means no deletion. +const PrecreatedCVICleanupEnv = "PRECREATED_CVI_CLEANUP" + +func CheckPrecreatedCVICleanupOption() error { + env := os.Getenv(PrecreatedCVICleanupEnv) + switch env { + case "yes", "no", "": + return nil + default: + return fmt.Errorf("invalid value for %s env: %q (allowed: \"\", \"yes\", \"no\")", PrecreatedCVICleanupEnv, env) + } +} + +// IsPrecreatedCVICleanupNeeded returns true only when PRECREATED_CVI_CLEANUP is explicitly set to "yes". +// Default (unset, empty, or "no"): precreated CVIs are not deleted after the suite. +func IsPrecreatedCVICleanupNeeded() bool { + return os.Getenv(PrecreatedCVICleanupEnv) == "yes" +} + func CheckWithPostCleanUpOption() error { env := os.Getenv(PostCleanUpEnv) switch env { diff --git a/test/e2e/internal/precreatedcvi/manager.go b/test/e2e/internal/precreatedcvi/manager.go new file mode 100644 index 0000000000..dff7d471c9 --- /dev/null +++ b/test/e2e/internal/precreatedcvi/manager.go @@ -0,0 +1,126 @@ +/* +Copyright 2026 Flant JSC + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Package precreatedcvi provides suite-level lifecycle (bootstrap and cleanup) for +// precreated ClusterVirtualImages used by e2e tests. +package precreatedcvi + +import ( + "context" + "fmt" + + . "github.com/onsi/ginkgo/v2" + . "github.com/onsi/gomega" + k8serrors "k8s.io/apimachinery/pkg/api/errors" + crclient "sigs.k8s.io/controller-runtime/pkg/client" + + "github.com/deckhouse/virtualization/api/core/v1alpha2" + "github.com/deckhouse/virtualization/test/e2e/internal/config" + "github.com/deckhouse/virtualization/test/e2e/internal/framework" + "github.com/deckhouse/virtualization/test/e2e/internal/object" + "github.com/deckhouse/virtualization/test/e2e/internal/util" +) + +const labelKey = "v12n-e2e-precreated" + +// PrecreatedCVIManager runs bootstrap and cleanup of precreated CVIs for the e2e suite. +// The list of CVIs is loaded once during Bootstrap and reused in Cleanup. +type PrecreatedCVIManager struct { + cvis []*v1alpha2.ClusterVirtualImage +} + +// NewPrecreatedCVIManager returns a new precreated CVI manager. +func NewPrecreatedCVIManager() *PrecreatedCVIManager { + return &PrecreatedCVIManager{} +} + +// Bootstrap creates or reuses precreated CVIs in the cluster, then waits until all are ready. +// Call once from SynchronizedBeforeSuite (process 1). +func (m *PrecreatedCVIManager) Bootstrap(ctx context.Context) { + GinkgoHelper() + + m.cvis = object.PrecreatedClusterVirtualImages() + + for _, cvi := range m.cvis { + By(fmt.Sprintf("Create or reuse precreated CVI %q in the cluster", cvi.Name)) + created, err := m.createOrReuse(ctx, cvi) + Expect(err).NotTo(HaveOccurred()) + if created { + By(fmt.Sprintf("Precreated CVI %q has been created", cvi.Name)) + } else { + By(fmt.Sprintf("Precreated CVI %q already exists and will be reused", cvi.Name)) + } + } + + By("Wait until all precreated CVIs are ready") + util.UntilObjectPhase(string(v1alpha2.ImageReady), framework.LongTimeout, m.cvisAsObjects()...) + + for _, cvi := range m.cvis { + By(fmt.Sprintf("Precreated CVI %q is ready", cvi.Name)) + } +} + +// Cleanup deletes precreated CVIs when both POST_CLEANUP and PRECREATED_CVI_CLEANUP allow it. +// Call from SynchronizedAfterSuite (process 1). Uses the same CVI list as Bootstrap; if Bootstrap +// was not run, the list is loaded from object so that cleanup can still run. +func (m *PrecreatedCVIManager) Cleanup(ctx context.Context) { + GinkgoHelper() + + if !config.IsCleanUpNeeded() { + return + } + if !config.IsPrecreatedCVICleanupNeeded() { + return + } + + if len(m.cvis) == 0 { + m.cvis = object.PrecreatedClusterVirtualImages() + } + + f := framework.NewFramework("") + err := f.Delete(ctx, m.cvisAsObjects()...) + Expect(err).NotTo(HaveOccurred(), "Failed to delete precreated CVIs") +} + +func (m *PrecreatedCVIManager) createOrReuse(ctx context.Context, cvi *v1alpha2.ClusterVirtualImage) (bool, error) { + applyLabel(cvi) + + err := framework.GetClients().GenericClient().Create(ctx, cvi) + if err == nil { + return true, nil + } + if !k8serrors.IsAlreadyExists(err) { + return false, err + } + return false, framework.GetClients().GenericClient().Get(ctx, crclient.ObjectKeyFromObject(cvi), cvi) +} + +func (m *PrecreatedCVIManager) cvisAsObjects() []crclient.Object { + objs := make([]crclient.Object, 0, len(m.cvis)) + for _, cvi := range m.cvis { + objs = append(objs, cvi) + } + return objs +} + +func applyLabel(cvi *v1alpha2.ClusterVirtualImage) { + labels := cvi.GetLabels() + if labels == nil { + labels = make(map[string]string) + } + labels[labelKey] = "true" + cvi.SetLabels(labels) +} diff --git a/test/e2e/legacy/legacy.go b/test/e2e/legacy/legacy.go index 119e535c0a..a9b264846f 100644 --- a/test/e2e/legacy/legacy.go +++ b/test/e2e/legacy/legacy.go @@ -72,6 +72,9 @@ func configure() (err error) { if err = config.CheckWithPostCleanUpOption(); err != nil { return err } + if err = config.CheckPrecreatedCVICleanupOption(); err != nil { + return err + } conf = framework.GetConfig() defer framework.SetConfig(conf) diff --git a/test/e2e/suite_cvi.go b/test/e2e/suite_cvi.go index 401f2b6696..18a5b8f0c7 100644 --- a/test/e2e/suite_cvi.go +++ b/test/e2e/suite_cvi.go @@ -18,103 +18,16 @@ package e2e import ( "context" - "fmt" - . "github.com/onsi/ginkgo/v2" - . "github.com/onsi/gomega" - k8serrors "k8s.io/apimachinery/pkg/api/errors" - crclient "sigs.k8s.io/controller-runtime/pkg/client" - - "github.com/deckhouse/virtualization/api/core/v1alpha2" - "github.com/deckhouse/virtualization/test/e2e/internal/config" - "github.com/deckhouse/virtualization/test/e2e/internal/framework" - "github.com/deckhouse/virtualization/test/e2e/internal/object" - "github.com/deckhouse/virtualization/test/e2e/internal/util" + "github.com/deckhouse/virtualization/test/e2e/internal/precreatedcvi" ) -const precreatedCVILabel = "v12n-e2e-precreated" - -// Additional labels to add to precreated CVIs (e.g., for test discovery) -var precreatedCVITestLabels = make(map[string]string) +var precreatedCVIManager = precreatedcvi.NewPrecreatedCVIManager() func bootstrapPrecreatedCVIs() { - GinkgoHelper() - - ctx := context.Background() - for _, cvi := range object.PrecreatedClusterVirtualImages() { - By(fmt.Sprintf("Create or reuse precreated CVI %q in the cluster", cvi.Name)) - created, err := createOrReusePrecreatedCVI(ctx, cvi) - Expect(err).NotTo(HaveOccurred()) - if created { - By(fmt.Sprintf("Precreated CVI %q has been created", cvi.Name)) - continue - } - By(fmt.Sprintf("Precreated CVI %q already exists and will be reused", cvi.Name)) - } - - By("Wait until all precreated CVIs are ready") - util.UntilObjectPhase(string(v1alpha2.ImageReady), framework.LongTimeout, precreatedClusterVirtualImagesAsObjects()...) - for _, cvi := range object.PrecreatedClusterVirtualImages() { - By(fmt.Sprintf("Precreated CVI %q is ready", cvi.Name)) - } -} - -// AddTestLabelsToPrecreatedCVI adds additional labels to precreated CVIs for test discovery. -// Must be called before applying kustomize in tests that use precreated CVIs. -func AddTestLabelsToPrecreatedCVI(labels map[string]string) { - for k, v := range labels { - precreatedCVITestLabels[k] = v - } + precreatedCVIManager.Bootstrap(context.Background()) } func cleanupPrecreatedCVIs() { - GinkgoHelper() - - if !config.IsCleanUpNeeded() { - return - } - - ctx := context.Background() - for _, cvi := range object.PrecreatedClusterVirtualImages() { - err := framework.GetClients().GenericClient().Delete(ctx, cvi) - Expect(err == nil || k8serrors.IsNotFound(err)).To(BeTrue(), "failed to delete precreated CVI %q: %v", cvi.Name, err) - } -} - -func createOrReusePrecreatedCVI(ctx context.Context, cvi *v1alpha2.ClusterVirtualImage) (bool, error) { - setPrecreatedCVILabel(cvi) - - err := framework.GetClients().GenericClient().Create(ctx, cvi) - if err == nil { - return true, nil - } - - if !k8serrors.IsAlreadyExists(err) { - return false, err - } - - return false, framework.GetClients().GenericClient().Get(ctx, crclient.ObjectKeyFromObject(cvi), cvi) -} - -func precreatedClusterVirtualImagesAsObjects() []crclient.Object { - cvis := object.PrecreatedClusterVirtualImages() - objs := make([]crclient.Object, 0, len(cvis)) - for _, cvi := range cvis { - objs = append(objs, cvi) - } - - return objs -} - -func setPrecreatedCVILabel(cvi *v1alpha2.ClusterVirtualImage) { - labels := cvi.GetLabels() - if labels == nil { - labels = make(map[string]string) - } - labels[precreatedCVILabel] = "true" - // Add test-specific labels for test discovery - for k, v := range precreatedCVITestLabels { - labels[k] = v - } - cvi.SetLabels(labels) + precreatedCVIManager.Cleanup(context.Background()) } From bea156b95d3e0284ad3241217cb29d36f641aed5 Mon Sep 17 00:00:00 2001 From: Nikita Korolev Date: Thu, 26 Mar 2026 11:13:40 +0300 Subject: [PATCH 22/34] simple replace http vd to cvi [p1] Signed-off-by: Nikita Korolev --- test/e2e/vm/configuration.go | 7 +------ test/e2e/vm/connectivity.go | 18 ++---------------- test/e2e/vm/live_migration_tcp_session.go | 14 ++------------ test/e2e/vm/sizing_policy.go | 7 +------ test/e2e/vm/target_migration.go | 3 ++- test/e2e/vm/usb.go | 9 +-------- 6 files changed, 9 insertions(+), 49 deletions(-) diff --git a/test/e2e/vm/configuration.go b/test/e2e/vm/configuration.go index a255c6e76f..3454ef83ee 100644 --- a/test/e2e/vm/configuration.go +++ b/test/e2e/vm/configuration.go @@ -123,13 +123,8 @@ func NewConfigurationTest(f *framework.Framework) *configurationTest { } func (t *configurationTest) GenerateResources(restartApprovalMode v1alpha2.RestartApprovalMode) { - t.VDRoot = vdbuilder.New( - vdbuilder.WithName("vd-root"), - vdbuilder.WithNamespace(t.Framework.Namespace().Name), + t.VDRoot = object.NewVDFromCVI("vd-root", t.Framework.Namespace().Name, object.PrecreatedCVIAlpineBIOS, vdbuilder.WithSize(ptr.To(resource.MustParse("350Mi"))), - vdbuilder.WithDataSourceHTTP(&v1alpha2.DataSourceHTTP{ - URL: object.ImageURLAlpineBIOS, - }), ) t.VDBlank = vdbuilder.New( diff --git a/test/e2e/vm/connectivity.go b/test/e2e/vm/connectivity.go index 327aac26bf..65c2454b6f 100644 --- a/test/e2e/vm/connectivity.go +++ b/test/e2e/vm/connectivity.go @@ -31,7 +31,6 @@ import ( "k8s.io/utils/ptr" crclient "sigs.k8s.io/controller-runtime/pkg/client" - vdbuilder "github.com/deckhouse/virtualization-controller/pkg/builder/vd" vmbuilder "github.com/deckhouse/virtualization-controller/pkg/builder/vm" "github.com/deckhouse/virtualization/api/core/v1alpha2" "github.com/deckhouse/virtualization/test/e2e/internal/executor" @@ -156,21 +155,8 @@ func NewVMConnectivityTest(f *framework.Framework) *VMConnectivityTest { } func (t *VMConnectivityTest) GenerateEnvironmentResources() { - t.VDa = vdbuilder.New( - vdbuilder.WithName("vd-a"), - vdbuilder.WithNamespace(t.Framework.Namespace().Name), - vdbuilder.WithDataSourceHTTP(&v1alpha2.DataSourceHTTP{ - URL: object.ImageURLAlpineBIOS, - }), - ) - - t.VDb = vdbuilder.New( - vdbuilder.WithName("vd-b"), - vdbuilder.WithNamespace(t.Framework.Namespace().Name), - vdbuilder.WithDataSourceHTTP(&v1alpha2.DataSourceHTTP{ - URL: object.ImageURLAlpineBIOS, - }), - ) + t.VDa = object.NewVDFromCVI("vd-a", t.Framework.Namespace().Name, object.PrecreatedCVIAlpineBIOS) + t.VDb = object.NewVDFromCVI("vd-b", t.Framework.Namespace().Name, object.PrecreatedCVIAlpineBIOS) t.VMa = vmbuilder.New( vmbuilder.WithName("vm-a"), diff --git a/test/e2e/vm/live_migration_tcp_session.go b/test/e2e/vm/live_migration_tcp_session.go index 92ad45e721..f955d16dd1 100644 --- a/test/e2e/vm/live_migration_tcp_session.go +++ b/test/e2e/vm/live_migration_tcp_session.go @@ -70,24 +70,14 @@ var _ = Describe("VirtualMachineLiveMigrationTCPSession", func() { It("checks the TCP session when the virtual machine is migrated", func() { By("Environment preparation", func() { - iperfServerDisk := vd.New( - vd.WithName(iperfServerName), - vd.WithNamespace(f.Namespace().Name), + iperfServerDisk := object.NewVDFromCVI(iperfServerName, f.Namespace().Name, object.PrecreatedCVIAlpineUEFI, vd.WithSize(ptr.To(resource.MustParse("400Mi"))), vd.WithStorageClass(&storageClass.Name), - vd.WithDataSourceHTTP(&v1alpha2.DataSourceHTTP{ - URL: object.ImageURLAlpineUEFI, - }), ) - iperfClientDisk := vd.New( - vd.WithName(iperfClientName), - vd.WithNamespace(f.Namespace().Name), + iperfClientDisk := object.NewVDFromCVI(iperfClientName, f.Namespace().Name, object.PrecreatedCVIAlpineUEFI, vd.WithSize(ptr.To(resource.MustParse("500Mi"))), vd.WithStorageClass(&storageClass.Name), - vd.WithDataSourceHTTP(&v1alpha2.DataSourceHTTP{ - URL: object.ImageURLAlpineUEFI, - }), ) iperfServer = newVirtualMachine(iperfServerName, f.Namespace().Name, iperfServerDisk, object.PerfCloudInit) diff --git a/test/e2e/vm/sizing_policy.go b/test/e2e/vm/sizing_policy.go index b9684c8b7c..45b9445151 100644 --- a/test/e2e/vm/sizing_policy.go +++ b/test/e2e/vm/sizing_policy.go @@ -136,13 +136,8 @@ func newSizingPolicyTest(f *framework.Framework) *sizingPolicyTest { } func (t *sizingPolicyTest) GenerateSizingPolicyResources(vmClassName, vmClassNameInVM string) { - t.VD = vdbuilder.New( - vdbuilder.WithName("vd"), - vdbuilder.WithNamespace(t.Framework.Namespace().Name), + t.VD = object.NewVDFromCVI("vd", t.Framework.Namespace().Name, object.PrecreatedCVIAlpineBIOS, vdbuilder.WithSize(ptr.To(resource.MustParse("350Mi"))), - vdbuilder.WithDataSourceHTTP(&v1alpha2.DataSourceHTTP{ - URL: object.ImageURLAlpineBIOS, - }), ) t.VM = vmbuilder.New( diff --git a/test/e2e/vm/target_migration.go b/test/e2e/vm/target_migration.go index d7c415473e..6c884ee9e6 100644 --- a/test/e2e/vm/target_migration.go +++ b/test/e2e/vm/target_migration.go @@ -59,9 +59,10 @@ var _ = Describe("TargetMigration", func() { It("checks if a VirtualMachine can be migrated to the target Node", func() { By("Environment preparation", func() { - virtualDisk := object.NewHTTPVDAlpineBIOS( + virtualDisk := object.NewVDFromCVI( "vd-root", f.Namespace().Name, + object.PrecreatedCVIAlpineBIOS, ) virtualMachine = object.NewMinimalVM( diff --git a/test/e2e/vm/usb.go b/test/e2e/vm/usb.go index d5a0e08ad8..e57528265a 100644 --- a/test/e2e/vm/usb.go +++ b/test/e2e/vm/usb.go @@ -28,7 +28,6 @@ import ( "k8s.io/utils/ptr" crclient "sigs.k8s.io/controller-runtime/pkg/client" - vdbuilder "github.com/deckhouse/virtualization-controller/pkg/builder/vd" vmbuilder "github.com/deckhouse/virtualization-controller/pkg/builder/vm" "github.com/deckhouse/virtualization/api/core/v1alpha2" "github.com/deckhouse/virtualization/test/e2e/internal/framework" @@ -197,13 +196,7 @@ func (t *VMUSBTest) GenerateEnvironmentResources() { usbNodeName := t.NodeUSBDevice.Status.NodeName Expect(usbNodeName).NotTo(BeEmpty(), "USB device must have a node assigned") - t.VD = vdbuilder.New( - vdbuilder.WithName("vd-usb-test"), - vdbuilder.WithNamespace(t.Framework.Namespace().Name), - vdbuilder.WithDataSourceHTTP(&v1alpha2.DataSourceHTTP{ - URL: object.ImageURLAlpineBIOS, - }), - ) + t.VD = object.NewVDFromCVI("vd-usb-test", t.Framework.Namespace().Name, object.PrecreatedCVIAlpineBIOS) t.VM = vmbuilder.New( vmbuilder.WithName("vm-usb-test"), From e7e66d27a423927c3c131b467c0585b46dacf398 Mon Sep 17 00:00:00 2001 From: Nikita Korolev Date: Thu, 26 Mar 2026 11:19:04 +0300 Subject: [PATCH 23/34] vd and vi to cvi [p2] Signed-off-by: Nikita Korolev --- test/e2e/vm/migration.go | 18 ++++-------------- test/e2e/vm/power_state.go | 9 ++------- test/e2e/vmop/restore.go | 9 ++------- 3 files changed, 8 insertions(+), 28 deletions(-) diff --git a/test/e2e/vm/migration.go b/test/e2e/vm/migration.go index 7894b1cc63..5a424ebb6d 100644 --- a/test/e2e/vm/migration.go +++ b/test/e2e/vm/migration.go @@ -76,13 +76,8 @@ var _ = Describe("VirtualMachineMigration", func() { It("verifies that migrations are successful", func() { By("Environment preparation", func() { - vdRootBIOS = vd.New( - vd.WithName("vd-root-bios"), - vd.WithNamespace(f.Namespace().Name), + vdRootBIOS = object.NewVDFromCVI("vd-root-bios", f.Namespace().Name, object.PrecreatedCVIUbuntu, vd.WithSize(ptr.To(resource.MustParse("10Gi"))), - vd.WithDataSourceHTTP(&v1alpha2.DataSourceHTTP{ - URL: object.ImageURLUbuntu, - }), ) vdBlankBIOS = vd.New( vd.WithName("vd-blank-bios"), @@ -90,13 +85,8 @@ var _ = Describe("VirtualMachineMigration", func() { vd.WithSize(ptr.To(resource.MustParse("100Mi"))), ) - vdRootUEFI = vd.New( - vd.WithName("vd-root-uefi"), - vd.WithNamespace(f.Namespace().Name), + vdRootUEFI = object.NewVDFromCVI("vd-root-uefi", f.Namespace().Name, object.PrecreatedCVIAlpineUEFI, vd.WithSize(ptr.To(resource.MustParse("10Gi"))), - vd.WithDataSourceHTTP(&v1alpha2.DataSourceHTTP{ - URL: object.ImageURLAlpineUEFI, - }), ) vdBlankUEFI = vd.New( vd.WithName("vd-blank-uefi"), @@ -151,13 +141,13 @@ var _ = Describe("VirtualMachineMigration", func() { viHotplugBIOS = vi.New( vi.WithName("vi-hotplug-bios"), vi.WithNamespace(f.Namespace().Name), - vi.WithDataSourceHTTP(object.ImageTestDataQCOW, nil, nil), + vi.WithDataSourceObjectRef(v1alpha2.VirtualImageObjectRefKindClusterVirtualImage, object.PrecreatedCVITestDataQCOW), vi.WithStorage(v1alpha2.StorageContainerRegistry), ) viHotplugUEFI = vi.New( vi.WithName("vi-hotplug-uefi"), vi.WithNamespace(f.Namespace().Name), - vi.WithDataSourceHTTP(object.ImageTestDataQCOW, nil, nil), + vi.WithDataSourceObjectRef(v1alpha2.VirtualImageObjectRefKindClusterVirtualImage, object.PrecreatedCVITestDataQCOW), vi.WithStorage(v1alpha2.StorageContainerRegistry), ) diff --git a/test/e2e/vm/power_state.go b/test/e2e/vm/power_state.go index 1edfd62c13..1e3b722967 100644 --- a/test/e2e/vm/power_state.go +++ b/test/e2e/vm/power_state.go @@ -211,17 +211,12 @@ func (t *powerStateTest) GenerateResources(runPolicy v1alpha2.RunPolicy) { t.VI = vibuilder.New( vibuilder.WithName("vi"), vibuilder.WithNamespace(t.Framework.Namespace().Name), - vibuilder.WithDataSourceHTTP(object.ImageTestDataQCOW, nil, nil), + vibuilder.WithDataSourceObjectRef(v1alpha2.VirtualImageObjectRefKindClusterVirtualImage, object.PrecreatedCVITestDataQCOW), vibuilder.WithStorage(v1alpha2.StorageContainerRegistry), ) - t.VDRoot = vdbuilder.New( - vdbuilder.WithName("vd-root"), - vdbuilder.WithNamespace(t.Framework.Namespace().Name), + t.VDRoot = object.NewVDFromCVI("vd-root", t.Framework.Namespace().Name, object.PrecreatedCVIAlpineBIOS, vdbuilder.WithSize(ptr.To(resource.MustParse("350Mi"))), - vdbuilder.WithDataSourceHTTP(&v1alpha2.DataSourceHTTP{ - URL: object.ImageURLAlpineBIOS, - }), ) t.VDBlank = vdbuilder.New( diff --git a/test/e2e/vmop/restore.go b/test/e2e/vmop/restore.go index 15b19b8602..ed361e9a55 100644 --- a/test/e2e/vmop/restore.go +++ b/test/e2e/vmop/restore.go @@ -266,16 +266,11 @@ func (t *restoreModeTest) GenerateResources(restoreMode v1alpha2.SnapshotOperati t.VI = vibuilder.New( vibuilder.WithName("vi"), vibuilder.WithNamespace(t.Framework.Namespace().Name), - vibuilder.WithDataSourceHTTP(object.ImageTestDataQCOW, nil, nil), + vibuilder.WithDataSourceObjectRef(v1alpha2.VirtualImageObjectRefKindClusterVirtualImage, object.PrecreatedCVITestDataQCOW), vibuilder.WithStorage(v1alpha2.StorageContainerRegistry), ) - t.VDRoot = vdbuilder.New( - vdbuilder.WithName("vd-root"), - vdbuilder.WithNamespace(t.Framework.Namespace().Name), - vdbuilder.WithDataSourceHTTP(&v1alpha2.DataSourceHTTP{ - URL: object.ImageURLUbuntu, - }), + t.VDRoot = object.NewVDFromCVI("vd-root", t.Framework.Namespace().Name, object.PrecreatedCVIUbuntu, vdbuilder.WithAnnotation(resourceAnnotationName, resourceAnnotationValue), vdbuilder.WithLabel(resourceLabelName, resourceLabelValue), ) From e5e0c1acdf3cc976cba9343849bd125861458123 Mon Sep 17 00:00:00 2001 From: Nikita Korolev Date: Thu, 26 Mar 2026 11:34:26 +0300 Subject: [PATCH 24/34] volume migration vi to cvi [p3] Signed-off-by: Nikita Korolev --- test/e2e/vm/volume_migration_local_disks.go | 2 +- test/e2e/vm/volume_migration_storage_class_changed.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/test/e2e/vm/volume_migration_local_disks.go b/test/e2e/vm/volume_migration_local_disks.go index 84d2a8ce3a..779a0ca0fa 100644 --- a/test/e2e/vm/volume_migration_local_disks.go +++ b/test/e2e/vm/volume_migration_local_disks.go @@ -70,7 +70,7 @@ var _ = Describe("RWOVirtualDiskMigration", decoratorsForVolumeMigrations(), fun DeferCleanup(f.After) - newVI := object.NewGeneratedHTTPVIAlpineBIOSPerf("volume-migration-local-disks-", f.Namespace().Name) + newVI := object.NewGeneratedVIFromCVI("volume-migration-local-disks-", f.Namespace().Name, object.PrecreatedCVIAlpineBIOSPerf) newVI, err := f.VirtClient().VirtualImages(f.Namespace().Name).Create(context.Background(), newVI, metav1.CreateOptions{}) Expect(err).NotTo(HaveOccurred()) f.DeferDelete(newVI) diff --git a/test/e2e/vm/volume_migration_storage_class_changed.go b/test/e2e/vm/volume_migration_storage_class_changed.go index 8c69f54cbe..fc8aab32e8 100644 --- a/test/e2e/vm/volume_migration_storage_class_changed.go +++ b/test/e2e/vm/volume_migration_storage_class_changed.go @@ -68,7 +68,7 @@ var _ = Describe("StorageClassMigration", decoratorsForVolumeMigrations(), func( DeferCleanup(f.After) - newVI := object.NewGeneratedHTTPVIAlpineBIOS("volume-migration-storage-class-changed-", f.Namespace().Name) + newVI := object.NewGeneratedVIFromCVI("volume-migration-storage-class-changed-", f.Namespace().Name, object.PrecreatedCVIAlpineBIOS) newVI, err = f.VirtClient().VirtualImages(f.Namespace().Name).Create(context.Background(), newVI, metav1.CreateOptions{}) Expect(err).NotTo(HaveOccurred()) f.DeferDelete(newVI) From 8e270a8d9e73063f7dc7b3b6a160e8af8c84f968 Mon Sep 17 00:00:00 2001 From: Nikita Korolev Date: Thu, 26 Mar 2026 12:04:34 +0300 Subject: [PATCH 25/34] snapshot vi to cvi [p4] Signed-off-by: Nikita Korolev --- test/e2e/snapshot/vmsop.go | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/test/e2e/snapshot/vmsop.go b/test/e2e/snapshot/vmsop.go index b1541aa5bb..07462079f2 100644 --- a/test/e2e/snapshot/vmsop.go +++ b/test/e2e/snapshot/vmsop.go @@ -67,13 +67,8 @@ var _ = Describe("VMSOPCreateVirtualMachine", Ordered, func() { It("should prepare environment", func() { By("create vm", func() { - vd = vdbuilder.New( - vdbuilder.WithName("vd-root"), - vdbuilder.WithNamespace(f.Namespace().Name), + vd = object.NewVDFromCVI("vd-root", f.Namespace().Name, object.PrecreatedCVIAlpineBIOS, vdbuilder.WithSize(ptr.To(resource.MustParse("10Gi"))), - vdbuilder.WithDataSourceHTTP(&v1alpha2.DataSourceHTTP{ - URL: object.ImageURLAlpineBIOS, - }), ) vm = object.NewMinimalVM("vmsop-origin-", f.Namespace().Name, From 46e2cddcf3016799012e501d9472c5e38aa7ec16 Mon Sep 17 00:00:00 2001 From: Nikita Korolev Date: Thu, 26 Mar 2026 12:57:33 +0300 Subject: [PATCH 26/34] cvi for network tests [p5] Signed-off-by: Nikita Korolev --- test/e2e/vm/additional_network_interfaces.go | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/test/e2e/vm/additional_network_interfaces.go b/test/e2e/vm/additional_network_interfaces.go index 4dea980d5e..650bc73ffb 100644 --- a/test/e2e/vm/additional_network_interfaces.go +++ b/test/e2e/vm/additional_network_interfaces.go @@ -84,10 +84,10 @@ var _ = Describe("VirtualMachineAdditionalNetworkInterfaces", func() { By("Environment preparation", func() { ns := f.Namespace().Name - vdFooRoot = object.NewHTTPVDAlpineUEFIPerf("vd-foo-root", ns, + vdFooRoot = object.NewVDFromCVI("vd-foo-root", ns, object.PrecreatedCVIAlpineUEFIPerf, vd.WithSize(ptr.To(resource.MustParse("512Mi"))), ) - vdBarRoot = object.NewHTTPVDAlpineUEFIPerf("vd-bar-root", ns, + vdBarRoot = object.NewVDFromCVI("vd-bar-root", ns, object.PrecreatedCVIAlpineUEFIPerf, vd.WithSize(ptr.To(resource.MustParse("512Mi"))), ) @@ -174,13 +174,7 @@ var _ = Describe("VirtualMachineAdditionalNetworkInterfaces", func() { By("Create VM with Main network and two additional ClusterNetworks", func() { ns := f.Namespace().Name - vdRoot = vd.New( - vd.WithName("vd-root"), - vd.WithNamespace(ns), - vd.WithDataSourceHTTP(&v1alpha2.DataSourceHTTP{ - URL: object.ImageURLUbuntu, - }), - ) + vdRoot = object.NewVDFromCVI("vd-root", ns, object.PrecreatedCVIUbuntu) vm = buildVMWithNetworks("vm", ns, vdRoot.Name, "192.168.1.20", true) vm.Spec.Networks = append(vm.Spec.Networks, v1alpha2.NetworksSpec{ From c07d389713cfe53ad5b99459ba6461c40f5c7d2b Mon Sep 17 00:00:00 2001 From: Nikita Korolev Date: Thu, 26 Mar 2026 13:24:47 +0300 Subject: [PATCH 27/34] tpm to cvi [p6] Signed-off-by: Nikita Korolev --- test/e2e/internal/object/const.go | 1 + test/e2e/internal/object/precreated_cvi.go | 2 ++ test/e2e/vm/tpm.go | 9 ++------- 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/test/e2e/internal/object/const.go b/test/e2e/internal/object/const.go index 15edbc37e8..7a9c5c6026 100644 --- a/test/e2e/internal/object/const.go +++ b/test/e2e/internal/object/const.go @@ -26,6 +26,7 @@ const ( ImageURLLegacyContainerImage = "cr.yandex/crpvs5j3nh1mi2tpithr/e2e/alpine/alpine-3-20:latest" ImageURLCirros = "https://89d64382-20df-4581-8cc7-80df331f67fa.selstorage.ru/cirros/cirros-0.5.1.qcow2" ImageURLUbuntuISO = "https://89d64382-20df-4581-8cc7-80df331f67fa.selstorage.ru/ubuntu/ubuntu-24.04.2-live-server-amd64.iso" + ImageURLDebian = "https://89d64382-20df-4581-8cc7-80df331f67fa.selstorage.ru/debian/debian-12-with-tpm2-tools-amd64-20250814-2204.qcow2" // No bootable ImageTestDataQCOW = "https://89d64382-20df-4581-8cc7-80df331f67fa.selstorage.ru/test/test.qcow2" ImageTestDataISO = "https://89d64382-20df-4581-8cc7-80df331f67fa.selstorage.ru/test/test.iso" diff --git a/test/e2e/internal/object/precreated_cvi.go b/test/e2e/internal/object/precreated_cvi.go index 098ff78d6f..f5471ec756 100644 --- a/test/e2e/internal/object/precreated_cvi.go +++ b/test/e2e/internal/object/precreated_cvi.go @@ -31,6 +31,7 @@ const ( PrecreatedCVIContainerImage = "v12n-e2e-container-image" PrecreatedCVILegacyRegistry = "v12n-e2e-legacy-registry" PrecreatedCVICirros = "v12n-e2e-cirros" + PrecreatedCVIDebian = "v12n-e2e-debian" PrecreatedCVITestDataQCOW = "v12n-e2e-testdata-qcow" PrecreatedCVITestDataISO = "v12n-e2e-testdata-iso" ) @@ -47,6 +48,7 @@ func PrecreatedClusterVirtualImages() []*v1alpha2.ClusterVirtualImage { newPrecreatedContainerImageCVI(PrecreatedCVIContainerImage, ImageURLContainerImage), newPrecreatedContainerImageCVI(PrecreatedCVILegacyRegistry, ImageURLLegacyContainerImage), newPrecreatedHTTPCVI(PrecreatedCVICirros, ImageURLCirros), + newPrecreatedHTTPCVI(PrecreatedCVIDebian, ImageURLDebian), newPrecreatedHTTPCVI(PrecreatedCVITestDataQCOW, ImageTestDataQCOW), newPrecreatedHTTPCVI(PrecreatedCVITestDataISO, ImageTestDataISO), } diff --git a/test/e2e/vm/tpm.go b/test/e2e/vm/tpm.go index 95c792c6e0..31fcface2f 100644 --- a/test/e2e/vm/tpm.go +++ b/test/e2e/vm/tpm.go @@ -30,6 +30,7 @@ import ( "github.com/deckhouse/virtualization/api/core/v1alpha2" "github.com/deckhouse/virtualization/test/e2e/internal/framework" "github.com/deckhouse/virtualization/test/e2e/internal/label" + "github.com/deckhouse/virtualization/test/e2e/internal/object" "github.com/deckhouse/virtualization/test/e2e/internal/util" ) @@ -46,7 +47,6 @@ var _ = Describe("VMCheckTPM", label.TPM(), func() { By("Create a VM with the TPM module.") const ( expectedTPMVersion = "2.0" - imageURLDebian12 = "https://89d64382-20df-4581-8cc7-80df331f67fa.selstorage.ru/debian/debian-12-with-tpm2-tools-amd64-20250814-2204.qcow2" vdsize = "4.4Gi" bootLoader = "EFI" osType = "Windows" @@ -67,13 +67,8 @@ runcmd: ` ) - vdRoot := vd.New( - vd.WithName("vd-root"), + vdRoot := object.NewVDFromCVI("vd-root", f.Namespace().Name, object.PrecreatedCVIDebian, vd.WithSize(ptr.To(resource.MustParse(vdsize))), - vd.WithNamespace(f.Namespace().Name), - vd.WithDataSourceHTTP(&v1alpha2.DataSourceHTTP{ - URL: imageURLDebian12, - }), ) vmTPM := vm.New( vm.WithName("vm-with-tpm"), From 9d781c07f04c0b76a4cd1b039f4217ca5144f979 Mon Sep 17 00:00:00 2001 From: Nikita Korolev Date: Thu, 26 Mar 2026 19:43:04 +0300 Subject: [PATCH 28/34] fix cvi notification Signed-off-by: Nikita Korolev --- test/e2e/internal/precreatedcvi/manager.go | 26 +++++++++++++--------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/test/e2e/internal/precreatedcvi/manager.go b/test/e2e/internal/precreatedcvi/manager.go index dff7d471c9..c222467df6 100644 --- a/test/e2e/internal/precreatedcvi/manager.go +++ b/test/e2e/internal/precreatedcvi/manager.go @@ -54,23 +54,29 @@ func (m *PrecreatedCVIManager) Bootstrap(ctx context.Context) { m.cvis = object.PrecreatedClusterVirtualImages() + var created, reused []string for _, cvi := range m.cvis { - By(fmt.Sprintf("Create or reuse precreated CVI %q in the cluster", cvi.Name)) - created, err := m.createOrReuse(ctx, cvi) + wasCreated, err := m.createOrReuse(ctx, cvi) Expect(err).NotTo(HaveOccurred()) - if created { - By(fmt.Sprintf("Precreated CVI %q has been created", cvi.Name)) + if wasCreated { + created = append(created, cvi.Name) } else { - By(fmt.Sprintf("Precreated CVI %q already exists and will be reused", cvi.Name)) + reused = append(reused, cvi.Name) } } - By("Wait until all precreated CVIs are ready") - util.UntilObjectPhase(string(v1alpha2.ImageReady), framework.LongTimeout, m.cvisAsObjects()...) - - for _, cvi := range m.cvis { - By(fmt.Sprintf("Precreated CVI %q is ready", cvi.Name)) + if len(created) > 0 { + for _, name := range created { + By(fmt.Sprintf("Precreated CVI %q has been created", name)) + } } + if len(reused) > 0 { + By(fmt.Sprintf("Reusing %d precreated CVIs that already exist in the cluster", len(reused))) + } + + By(fmt.Sprintf("Wait until all %d precreated CVIs are ready", len(m.cvis))) + util.UntilObjectPhase(string(v1alpha2.ImageReady), framework.LongTimeout, m.cvisAsObjects()...) + By(fmt.Sprintf("All %d precreated CVIs are ready", len(m.cvis))) } // Cleanup deletes precreated CVIs when both POST_CLEANUP and PRECREATED_CVI_CLEANUP allow it. From 3555920734e4cf99b5c8b35bbf10b5303bd3253c Mon Sep 17 00:00:00 2001 From: Nikita Korolev Date: Fri, 27 Mar 2026 12:29:23 +0300 Subject: [PATCH 29/34] add cloud init for ubuntu and alpine Signed-off-by: Nikita Korolev --- test/e2e/blockdevice/data_exports.go | 2 +- test/e2e/internal/object/const.go | 20 ++++++++++++++------ test/e2e/internal/object/vm.go | 2 +- test/e2e/vm/additional_network_interfaces.go | 7 +++++-- test/e2e/vm/configuration.go | 2 +- test/e2e/vm/live_migration_tcp_session.go | 2 +- test/e2e/vm/migration.go | 4 ++-- test/e2e/vm/power_state.go | 2 +- test/e2e/vm/sizing_policy.go | 2 +- test/e2e/vm/usb.go | 2 +- 10 files changed, 28 insertions(+), 17 deletions(-) diff --git a/test/e2e/blockdevice/data_exports.go b/test/e2e/blockdevice/data_exports.go index b6fab5fb78..2d1a43051a 100644 --- a/test/e2e/blockdevice/data_exports.go +++ b/test/e2e/blockdevice/data_exports.go @@ -105,7 +105,7 @@ var _ = Describe("DataExports", label.Slow(), func() { v1alpha2.BlockDeviceSpecRef{Kind: v1alpha2.DiskDevice, Name: vdData.Name}, ), vmbuilder.WithRunPolicy(v1alpha2.AlwaysOnUnlessStoppedManually), - vmbuilder.WithProvisioningUserData(object.DefaultCloudInit), + vmbuilder.WithProvisioningUserData(object.UbuntuCloudInit), ) err := f.CreateWithDeferredDeletion(context.Background(), vm) diff --git a/test/e2e/internal/object/const.go b/test/e2e/internal/object/const.go index 7a9c5c6026..f30a37442e 100644 --- a/test/e2e/internal/object/const.go +++ b/test/e2e/internal/object/const.go @@ -26,24 +26,27 @@ const ( ImageURLLegacyContainerImage = "cr.yandex/crpvs5j3nh1mi2tpithr/e2e/alpine/alpine-3-20:latest" ImageURLCirros = "https://89d64382-20df-4581-8cc7-80df331f67fa.selstorage.ru/cirros/cirros-0.5.1.qcow2" ImageURLUbuntuISO = "https://89d64382-20df-4581-8cc7-80df331f67fa.selstorage.ru/ubuntu/ubuntu-24.04.2-live-server-amd64.iso" - ImageURLDebian = "https://89d64382-20df-4581-8cc7-80df331f67fa.selstorage.ru/debian/debian-12-with-tpm2-tools-amd64-20250814-2204.qcow2" + ImageURLDebian = "https://89d64382-20df-4581-8cc7-80df331f67fa.selstorage.ru/debian/debian-12-with-tpm2-tools-amd64-20250814-2204.qcow2" // No bootable ImageTestDataQCOW = "https://89d64382-20df-4581-8cc7-80df331f67fa.selstorage.ru/test/test.qcow2" ImageTestDataISO = "https://89d64382-20df-4581-8cc7-80df331f67fa.selstorage.ru/test/test.iso" Mi256 = 256 * 1024 * 1024 DefaultVMClass = "generic" - cloudInitBase = `#cloud-config + cloudInitBasePackages = `#cloud-config package_update: true packages: - qemu-guest-agent - curl - bash - sudo - - iputils - util-linux - iperf3 - jq +` + cloudInitUbuntuPackages = ` - iputils-ping +` + cloudInitAlpinePackages = ` - iputils ` cloudInitUsers = ` users: @@ -57,12 +60,17 @@ users: # testcases - ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIFxcXHmwaGnJ8scJaEN5RzklBPZpVSic4GdaAsKjQoeA your_email@example.com ` - cloudInitDefaultRuncmd = ` + cloudInitAlpineRuncmd = ` runcmd: - "rc-update add qemu-guest-agent && rc-service qemu-guest-agent start" +` + cloudInitUbuntuRuncmd = ` +runcmd: +- "systemctl enable --now qemu-guest-agent" ` - DefaultCloudInit = cloudInitBase + cloudInitUsers + cloudInitDefaultRuncmd + AlpineCloudInit = cloudInitBasePackages + cloudInitAlpinePackages + cloudInitUsers + cloudInitAlpineRuncmd + UbuntuCloudInit = cloudInitBasePackages + cloudInitUbuntuPackages + cloudInitUsers + cloudInitUbuntuRuncmd cloudInitPerfWriteFiles = ` write_files: @@ -107,7 +115,7 @@ runcmd: - "rc-update add sshd && rc-service sshd start" ` - PerfCloudInit = cloudInitBase + cloudInitPerfWriteFiles + cloudInitUsers + cloudInitPerfRuncmd + PerfCloudInit = cloudInitBasePackages + cloudInitAlpinePackages + cloudInitPerfWriteFiles + cloudInitUsers + cloudInitPerfRuncmd DefaultSSHPrivateKey = `-----BEGIN OPENSSH PRIVATE KEY----- b3BlbnNzaC1rZXktdjEAAAAABG5vbmUAAAAEbm9uZQAAAAAAAAABAAAAMwAAAAtzc2gtZW QyNTUxOQAAACBcXFx5sGhpyfLHCWhDeUc5JQT2aVUonOBnWgLCo0KHgAAAAKDCANDUwgDQ diff --git a/test/e2e/internal/object/vm.go b/test/e2e/internal/object/vm.go index 386c7b543f..12abd5232d 100644 --- a/test/e2e/internal/object/vm.go +++ b/test/e2e/internal/object/vm.go @@ -31,7 +31,7 @@ func NewMinimalVM(prefix, namespace string, opts ...vm.Option) *v1alpha2.Virtual vm.WithCPU(1, ptr.To("20%")), vm.WithMemory(*resource.NewQuantity(Mi256, resource.BinarySI)), vm.WithLiveMigrationPolicy(v1alpha2.AlwaysSafeMigrationPolicy), - vm.WithProvisioningUserData(DefaultCloudInit), + vm.WithProvisioningUserData(AlpineCloudInit), } baseOpts = append(baseOpts, opts...) return vm.New(baseOpts...) diff --git a/test/e2e/vm/additional_network_interfaces.go b/test/e2e/vm/additional_network_interfaces.go index 650bc73ffb..3c5b529e7f 100644 --- a/test/e2e/vm/additional_network_interfaces.go +++ b/test/e2e/vm/additional_network_interfaces.go @@ -159,6 +159,8 @@ var _ = Describe("VirtualMachineAdditionalNetworkInterfaces", func() { ) Describe("verifies interface name persistence after removing middle ClusterNetwork", func() { + cloudInitOpt := vm.WithProvisioningUserData(object.UbuntuCloudInit) + var ( vdRoot *v1alpha2.VirtualDisk vm *v1alpha2.VirtualMachine @@ -176,7 +178,7 @@ var _ = Describe("VirtualMachineAdditionalNetworkInterfaces", func() { vdRoot = object.NewVDFromCVI("vd-root", ns, object.PrecreatedCVIUbuntu) - vm = buildVMWithNetworks("vm", ns, vdRoot.Name, "192.168.1.20", true) + vm = buildVMWithNetworks("vm", ns, vdRoot.Name, "192.168.1.20", true, cloudInitOpt) vm.Spec.Networks = append(vm.Spec.Networks, v1alpha2.NetworksSpec{ Type: v1alpha2.NetworksTypeClusterNetwork, Name: util.ClusterNetworkName(secondAdditionalInterfaceVLANID), @@ -238,7 +240,7 @@ var _ = Describe("VirtualMachineAdditionalNetworkInterfaces", func() { // buildVMWithNetworks creates a VM with optional Main + ClusterNetwork. // If hasMain is false, only ClusterNetwork is added (VM without Main network). // The additional network interface is eth1 when hasMain is true, eth0 otherwise. -func buildVMWithNetworks(name, ns, vdRootName, additionalIP string, hasMain bool) *v1alpha2.VirtualMachine { +func buildVMWithNetworks(name, ns, vdRootName, additionalIP string, hasMain bool, extraOpts ...vm.Option) *v1alpha2.VirtualMachine { opts := []vm.Option{ vm.WithName(name), vm.WithNamespace(ns), @@ -265,6 +267,7 @@ func buildVMWithNetworks(name, ns, vdRootName, additionalIP string, hasMain bool Name: util.ClusterNetworkName(additionalInterfaceVLANID), }), ) + opts = append(opts, extraOpts...) return vm.New(opts...) } diff --git a/test/e2e/vm/configuration.go b/test/e2e/vm/configuration.go index 3454ef83ee..46e3e9ef97 100644 --- a/test/e2e/vm/configuration.go +++ b/test/e2e/vm/configuration.go @@ -140,7 +140,7 @@ func (t *configurationTest) GenerateResources(restartApprovalMode v1alpha2.Resta vmbuilder.WithMemory(resource.MustParse(initialMemorySize)), vmbuilder.WithLiveMigrationPolicy(v1alpha2.AlwaysSafeMigrationPolicy), vmbuilder.WithVirtualMachineClass(object.DefaultVMClass), - vmbuilder.WithProvisioningUserData(object.DefaultCloudInit), + vmbuilder.WithProvisioningUserData(object.AlpineCloudInit), vmbuilder.WithBlockDeviceRefs( v1alpha2.BlockDeviceSpecRef{ Kind: v1alpha2.DiskDevice, diff --git a/test/e2e/vm/live_migration_tcp_session.go b/test/e2e/vm/live_migration_tcp_session.go index f955d16dd1..d350d5f31d 100644 --- a/test/e2e/vm/live_migration_tcp_session.go +++ b/test/e2e/vm/live_migration_tcp_session.go @@ -81,7 +81,7 @@ var _ = Describe("VirtualMachineLiveMigrationTCPSession", func() { ) iperfServer = newVirtualMachine(iperfServerName, f.Namespace().Name, iperfServerDisk, object.PerfCloudInit) - iperfClient = newVirtualMachine(iperfClientName, f.Namespace().Name, iperfClientDisk, object.DefaultCloudInit) + iperfClient = newVirtualMachine(iperfClientName, f.Namespace().Name, iperfClientDisk, object.AlpineCloudInit) err := f.CreateWithDeferredDeletion(context.Background(), iperfServerDisk, iperfClientDisk, iperfServer, iperfClient) Expect(err).NotTo(HaveOccurred()) diff --git a/test/e2e/vm/migration.go b/test/e2e/vm/migration.go index 5a424ebb6d..f5d59fabf9 100644 --- a/test/e2e/vm/migration.go +++ b/test/e2e/vm/migration.go @@ -105,7 +105,7 @@ var _ = Describe("VirtualMachineMigration", func() { }, ), vm.WithBootloader(v1alpha2.BIOS), - vm.WithProvisioningUserData(object.DefaultCloudInit), + vm.WithProvisioningUserData(object.UbuntuCloudInit), vm.WithLiveMigrationPolicy(v1alpha2.PreferSafeMigrationPolicy), vm.WithName("vm-bios"), ) @@ -121,7 +121,7 @@ var _ = Describe("VirtualMachineMigration", func() { }, ), vm.WithBootloader(v1alpha2.EFI), - vm.WithProvisioningUserData(object.DefaultCloudInit), + vm.WithProvisioningUserData(object.AlpineCloudInit), vm.WithLiveMigrationPolicy(v1alpha2.PreferSafeMigrationPolicy), vm.WithName("vm-uefi"), ) diff --git a/test/e2e/vm/power_state.go b/test/e2e/vm/power_state.go index 1e3b722967..d44abd75a1 100644 --- a/test/e2e/vm/power_state.go +++ b/test/e2e/vm/power_state.go @@ -248,7 +248,7 @@ func (t *powerStateTest) GenerateResources(runPolicy v1alpha2.RunPolicy) { ), vmbuilder.WithRestartApprovalMode(v1alpha2.Manual), vmbuilder.WithRunPolicy(runPolicy), - vmbuilder.WithProvisioningUserData(object.DefaultCloudInit), + vmbuilder.WithProvisioningUserData(object.AlpineCloudInit), ) t.VMBDA = vmbdabuilder.New( diff --git a/test/e2e/vm/sizing_policy.go b/test/e2e/vm/sizing_policy.go index 45b9445151..0cf1d4d20b 100644 --- a/test/e2e/vm/sizing_policy.go +++ b/test/e2e/vm/sizing_policy.go @@ -151,7 +151,7 @@ func (t *sizingPolicyTest) GenerateSizingPolicyResources(vmClassName, vmClassNam vmbuilder.WithCPU(1, ptr.To("5%")), vmbuilder.WithMemory(resource.MustParse("1Gi")), vmbuilder.WithLiveMigrationPolicy(v1alpha2.AlwaysSafeMigrationPolicy), - vmbuilder.WithProvisioningUserData(object.DefaultCloudInit), + vmbuilder.WithProvisioningUserData(object.AlpineCloudInit), ) t.VMClass = &v1alpha3.VirtualMachineClass{ diff --git a/test/e2e/vm/usb.go b/test/e2e/vm/usb.go index e57528265a..977abc50e5 100644 --- a/test/e2e/vm/usb.go +++ b/test/e2e/vm/usb.go @@ -204,7 +204,7 @@ func (t *VMUSBTest) GenerateEnvironmentResources() { vmbuilder.WithCPU(1, ptr.To("100%")), vmbuilder.WithMemory(resource.MustParse("512Mi")), vmbuilder.WithVirtualMachineClass(object.DefaultVMClass), - vmbuilder.WithProvisioningUserData(object.DefaultCloudInit), + vmbuilder.WithProvisioningUserData(object.AlpineCloudInit), vmbuilder.WithLiveMigrationPolicy(v1alpha2.AlwaysSafeMigrationPolicy), vmbuilder.WithBlockDeviceRefs(v1alpha2.BlockDeviceSpecRef{Kind: v1alpha2.DiskDevice, Name: t.VD.Name}), vmbuilder.WithUSBDevices([]v1alpha2.USBDeviceSpecRef{{Name: t.NodeUSBDevice.Name}}), From f9065c3ee6e0bead7827431356e4533de05081b4 Mon Sep 17 00:00:00 2001 From: Nikita Korolev Date: Fri, 27 Mar 2026 16:25:11 +0300 Subject: [PATCH 30/34] refactor constants Signed-off-by: Nikita Korolev --- test/e2e/internal/object/const.go | 36 ++++++++++++---------- test/e2e/internal/object/precreated_cvi.go | 4 +-- test/e2e/internal/object/vd.go | 12 -------- test/e2e/internal/object/vi.go | 13 -------- 4 files changed, 22 insertions(+), 43 deletions(-) diff --git a/test/e2e/internal/object/const.go b/test/e2e/internal/object/const.go index f30a37442e..bbc90dcbca 100644 --- a/test/e2e/internal/object/const.go +++ b/test/e2e/internal/object/const.go @@ -16,22 +16,27 @@ limitations under the License. package object +const imageBaseURL = "https://89d64382-20df-4581-8cc7-80df331f67fa.selstorage.ru" + const ( - ImageURLAlpineUEFI = "https://89d64382-20df-4581-8cc7-80df331f67fa.selstorage.ru/alpine/alpine-3-23-3-uefi-base.qcow2" - ImageURLAlpineBIOS = "https://89d64382-20df-4581-8cc7-80df331f67fa.selstorage.ru/alpine/alpine-3-23-3-bios-base.qcow2" - ImagesURLAlpineUEFIPerf = "https://89d64382-20df-4581-8cc7-80df331f67fa.selstorage.ru/alpine/alpine-3-21-uefi-perf.qcow2" - ImagesURLAlpineBIOSPerf = "https://89d64382-20df-4581-8cc7-80df331f67fa.selstorage.ru/alpine/alpine-3-21-bios-perf.qcow2" - ImageURLUbuntu = "https://89d64382-20df-4581-8cc7-80df331f67fa.selstorage.ru/ubuntu/ubuntu-24.04-minimal-cloudimg-amd64.qcow2" + ImageURLAlpineUEFI = imageBaseURL + "/alpine/alpine-3-23-3-uefi-base.qcow2" + ImageURLAlpineBIOS = imageBaseURL + "/alpine/alpine-3-23-3-bios-base.qcow2" + ImageURLAlpineUEFIPerf = imageBaseURL + "/alpine/alpine-3-21-uefi-perf.qcow2" + ImageURLAlpineBIOSPerf = imageBaseURL + "/alpine/alpine-3-21-bios-perf.qcow2" + ImageURLUbuntu = imageBaseURL + "/ubuntu/ubuntu-24.04-minimal-cloudimg-amd64.qcow2" + ImageURLUbuntuISO = imageBaseURL + "/ubuntu/ubuntu-24.04.2-live-server-amd64.iso" + ImageURLCirros = imageBaseURL + "/cirros/cirros-0.5.1.qcow2" + ImageURLDebian = imageBaseURL + "/debian/debian-12-with-tpm2-tools-amd64-20250814-2204.qcow2" + ImageURLContainerImage = "cr.yandex/crpvs5j3nh1mi2tpithr/e2e/alpine/alpine-image:latest" ImageURLLegacyContainerImage = "cr.yandex/crpvs5j3nh1mi2tpithr/e2e/alpine/alpine-3-20:latest" - ImageURLCirros = "https://89d64382-20df-4581-8cc7-80df331f67fa.selstorage.ru/cirros/cirros-0.5.1.qcow2" - ImageURLUbuntuISO = "https://89d64382-20df-4581-8cc7-80df331f67fa.selstorage.ru/ubuntu/ubuntu-24.04.2-live-server-amd64.iso" - ImageURLDebian = "https://89d64382-20df-4581-8cc7-80df331f67fa.selstorage.ru/debian/debian-12-with-tpm2-tools-amd64-20250814-2204.qcow2" - // No bootable - ImageTestDataQCOW = "https://89d64382-20df-4581-8cc7-80df331f67fa.selstorage.ru/test/test.qcow2" - ImageTestDataISO = "https://89d64382-20df-4581-8cc7-80df331f67fa.selstorage.ru/test/test.iso" - Mi256 = 256 * 1024 * 1024 - DefaultVMClass = "generic" + + // Not bootable + ImageTestDataQCOW = imageBaseURL + "/test/test.qcow2" + ImageTestDataISO = imageBaseURL + "/test/test.iso" + + Mi256 = 256 * 1024 * 1024 + DefaultVMClass = "generic" cloudInitBasePackages = `#cloud-config package_update: true @@ -125,7 +130,6 @@ BPZpVSic4GdaAsKjQoeAAAAAFnlvdXJfZW1haWxAZXhhbXBsZS5jb20BAgMEBQYH -----END OPENSSH PRIVATE KEY----- ` - DefaultSSHPublicKey = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIFxcXHmwaGnJ8scJaEN5RzklBPZpVSic4GdaAsKjQoeA your_email@example.com" - DefaultUser = "cloud" - DefaultPassword = "cloud" + DefaultUser = "cloud" + DefaultPassword = "cloud" ) diff --git a/test/e2e/internal/object/precreated_cvi.go b/test/e2e/internal/object/precreated_cvi.go index f5471ec756..3707807798 100644 --- a/test/e2e/internal/object/precreated_cvi.go +++ b/test/e2e/internal/object/precreated_cvi.go @@ -41,8 +41,8 @@ func PrecreatedClusterVirtualImages() []*v1alpha2.ClusterVirtualImage { return []*v1alpha2.ClusterVirtualImage{ newPrecreatedHTTPCVI(PrecreatedCVIAlpineUEFI, ImageURLAlpineUEFI), newPrecreatedHTTPCVI(PrecreatedCVIAlpineBIOS, ImageURLAlpineBIOS), - newPrecreatedHTTPCVI(PrecreatedCVIAlpineUEFIPerf, ImagesURLAlpineUEFIPerf), - newPrecreatedHTTPCVI(PrecreatedCVIAlpineBIOSPerf, ImagesURLAlpineBIOSPerf), + newPrecreatedHTTPCVI(PrecreatedCVIAlpineUEFIPerf, ImageURLAlpineUEFIPerf), + newPrecreatedHTTPCVI(PrecreatedCVIAlpineBIOSPerf, ImageURLAlpineBIOSPerf), newPrecreatedHTTPCVI(PrecreatedCVIUbuntu, ImageURLUbuntu), newPrecreatedHTTPCVI(PrecreatedCVIUbuntuISO, ImageURLUbuntuISO), newPrecreatedContainerImageCVI(PrecreatedCVIContainerImage, ImageURLContainerImage), diff --git a/test/e2e/internal/object/vd.go b/test/e2e/internal/object/vd.go index 65eceb6d18..22606643b8 100644 --- a/test/e2e/internal/object/vd.go +++ b/test/e2e/internal/object/vd.go @@ -55,18 +55,6 @@ func NewHTTPVDAlpineBIOS(name, namespace string, opts ...vd.Option) *v1alpha2.Vi return vd.New(baseOpts...) } -func NewHTTPVDAlpineUEFIPerf(name, namespace string, opts ...vd.Option) *v1alpha2.VirtualDisk { - baseOpts := []vd.Option{ - vd.WithName(name), - vd.WithNamespace(namespace), - vd.WithDataSourceHTTP(&v1alpha2.DataSourceHTTP{ - URL: ImagesURLAlpineUEFIPerf, - }), - } - baseOpts = append(baseOpts, opts...) - return vd.New(baseOpts...) -} - func NewVDFromCVI(name, namespace, cviName string, opts ...vd.Option) *v1alpha2.VirtualDisk { baseOpts := []vd.Option{ vd.WithName(name), diff --git a/test/e2e/internal/object/vi.go b/test/e2e/internal/object/vi.go index 3e23d3d153..fd064f4d7a 100644 --- a/test/e2e/internal/object/vi.go +++ b/test/e2e/internal/object/vi.go @@ -34,19 +34,6 @@ func NewGeneratedHTTPVIAlpineBIOS(prefix, namespace string, opts ...vi.Option) * return vi.New(baseOpts...) } -func NewGeneratedHTTPVIAlpineBIOSPerf(prefix, namespace string, opts ...vi.Option) *v1alpha2.VirtualImage { - baseOpts := []vi.Option{ - vi.WithGenerateName(prefix), - vi.WithNamespace(namespace), - vi.WithDataSourceHTTP( - ImagesURLAlpineBIOSPerf, nil, nil, - ), - vi.WithStorage(v1alpha2.StorageContainerRegistry), - } - baseOpts = append(baseOpts, opts...) - return vi.New(baseOpts...) -} - func NewGeneratedContainerImageVI(prefix, namespace string, opts ...vi.Option) *v1alpha2.VirtualImage { baseOpts := []vi.Option{ vi.WithGenerateName(prefix), From 2f8064fe3ca540d86216bd84a26e5229521d212f Mon Sep 17 00:00:00 2001 From: Nikita Korolev Date: Fri, 27 Mar 2026 17:02:01 +0300 Subject: [PATCH 31/34] refactor cloud-init Signed-off-by: Nikita Korolev --- test/e2e/go.mod | 2 + test/e2e/internal/object/cloud_config.go | 80 ++++++++++ test/e2e/internal/object/cloud_config_test.go | 149 ++++++++++++++++++ test/e2e/internal/object/const.go | 141 +++++++---------- 4 files changed, 291 insertions(+), 81 deletions(-) create mode 100644 test/e2e/internal/object/cloud_config.go create mode 100644 test/e2e/internal/object/cloud_config_test.go diff --git a/test/e2e/go.mod b/test/e2e/go.mod index 0ad4e8cf42..e635c446ef 100644 --- a/test/e2e/go.mod +++ b/test/e2e/go.mod @@ -9,6 +9,7 @@ require ( github.com/deckhouse/virtualization/api v0.0.0-20240923080356-bb5809dba578 github.com/onsi/ginkgo/v2 v2.23.3 github.com/onsi/gomega v1.37.0 + github.com/stretchr/testify v1.11.1 gopkg.in/yaml.v3 v3.0.1 k8s.io/api v0.34.2 k8s.io/apimachinery v0.34.2 @@ -57,6 +58,7 @@ require ( github.com/openshift/custom-resource-status v1.1.2 // indirect github.com/peterbourgon/diskv v2.0.1+incompatible // indirect github.com/pkg/errors v0.9.1 // indirect + github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect github.com/spf13/cobra v1.9.1 // indirect github.com/spf13/pflag v1.0.7 // indirect github.com/x448/float16 v0.8.4 // indirect diff --git a/test/e2e/internal/object/cloud_config.go b/test/e2e/internal/object/cloud_config.go new file mode 100644 index 0000000000..480ad8ba0a --- /dev/null +++ b/test/e2e/internal/object/cloud_config.go @@ -0,0 +1,80 @@ +/* +Copyright 2025 Flant JSC + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package object + +import ( + "fmt" + + "k8s.io/utils/ptr" + "sigs.k8s.io/yaml" +) + +// CloudConfig mirrors the cloud-init cloud-config YAML schema. +// Only the keys used by e2e tests are included. +// See https://cloudinit.readthedocs.io/en/latest/reference/modules.html +type CloudConfig struct { + PackageUpdate bool `json:"package_update,omitempty"` + Packages []string `json:"packages,omitempty"` + WriteFiles []WriteFile `json:"write_files,omitempty"` + Users []CloudConfigUser `json:"users,omitempty"` + Runcmd []string `json:"runcmd,omitempty"` + SSHPwauth *bool `json:"ssh_pwauth,omitempty"` +} + +type CloudConfigUser struct { + Name string `json:"name"` + Passwd string `json:"passwd,omitempty"` + Shell string `json:"shell,omitempty"` + Sudo string `json:"sudo,omitempty"` + LockPasswd *bool `json:"lock_passwd,omitempty"` + SSHAuthorizedKeys []string `json:"ssh_authorized_keys,omitempty"` +} + +type WriteFile struct { + Path string `json:"path"` + Permissions string `json:"permissions,omitempty"` + Content string `json:"content,omitempty"` + Append bool `json:"append,omitempty"` +} + +const defaultSSHPublicKey = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIFxcXHmwaGnJ8scJaEN5RzklBPZpVSic4GdaAsKjQoeA your_email@example.com" + +// DefaultCloudUser returns the standard e2e test user (cloud/cloud) with SSH key. +func DefaultCloudUser() CloudConfigUser { + return CloudConfigUser{ + Name: DefaultUser, + Passwd: "$6$rounds=4096$vln/.aPHBOI7BMYR$bBMkqQvuGs5Gyd/1H5DP4m9HjQSy.kgrxpaGEHwkX7KEFV8BS.HZWPitAtZ2Vd8ZqIZRqmlykRCagTgPejt1i.", + Shell: "/bin/bash", + Sudo: "ALL=(ALL) NOPASSWD:ALL", + LockPasswd: ptr.To(false), + SSHAuthorizedKeys: []string{defaultSSHPublicKey}, + } +} + +var basePackages = []string{ + "qemu-guest-agent", "curl", "bash", "sudo", "util-linux", "iperf3", "jq", +} + +// Render serializes the CloudConfig to a valid cloud-init user-data string +// with the required #cloud-config header. +func (c CloudConfig) Render() string { + data, err := yaml.Marshal(c) + if err != nil { + panic(fmt.Sprintf("cloud-config marshal: %v", err)) + } + return "#cloud-config\n" + string(data) +} diff --git a/test/e2e/internal/object/cloud_config_test.go b/test/e2e/internal/object/cloud_config_test.go new file mode 100644 index 0000000000..259173a4b5 --- /dev/null +++ b/test/e2e/internal/object/cloud_config_test.go @@ -0,0 +1,149 @@ +/* +Copyright 2025 Flant JSC + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package object + +import ( + "strings" + "testing" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + "sigs.k8s.io/yaml" +) + +func TestCloudConfigRender(t *testing.T) { + tests := []struct { + name string + rendered string + }{ + {"AlpineCloudInit", AlpineCloudInit}, + {"UbuntuCloudInit", UbuntuCloudInit}, + {"PerfCloudInit", PerfCloudInit}, + } + + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + require.True(t, strings.HasPrefix(tt.rendered, "#cloud-config\n"), + "cloud-init must start with #cloud-config header") + + var parsed map[string]interface{} + err := yaml.Unmarshal([]byte(tt.rendered), &parsed) + require.NoError(t, err, "cloud-init must be valid YAML") + + assert.Equal(t, true, parsed["package_update"]) + + users, ok := parsed["users"].([]interface{}) + require.True(t, ok, "users must be a list") + require.Len(t, users, 1) + + user := users[0].(map[string]interface{}) + assert.Equal(t, DefaultUser, user["name"]) + assert.Equal(t, false, user["lock_passwd"]) + + keys, ok := user["ssh_authorized_keys"].([]interface{}) + require.True(t, ok) + require.Len(t, keys, 1) + + runcmd, ok := parsed["runcmd"].([]interface{}) + require.True(t, ok, "runcmd must be a list") + assert.NotEmpty(t, runcmd) + }) + } +} + +func TestPerfCloudInitHasWriteFiles(t *testing.T) { + var parsed map[string]interface{} + err := yaml.Unmarshal([]byte(PerfCloudInit), &parsed) + require.NoError(t, err) + + writeFiles, ok := parsed["write_files"].([]interface{}) + require.True(t, ok, "PerfCloudInit must have write_files") + require.Len(t, writeFiles, 1) + + wf := writeFiles[0].(map[string]interface{}) + assert.Equal(t, "/usr/scripts/iperf3.sh", wf["path"]) + assert.Equal(t, "0755", wf["permissions"]) + + content, ok := wf["content"].(string) + require.True(t, ok) + assert.Contains(t, content, "#!/bin/bash") + assert.Contains(t, content, "iperf3") +} + +func TestPerfCloudInitGolden(t *testing.T) { + expected := `#cloud-config +package_update: true +packages: +- qemu-guest-agent +- curl +- bash +- sudo +- util-linux +- iperf3 +- jq +- iputils +runcmd: +- /usr/scripts/iperf3.sh +- rc-update add qemu-guest-agent && rc-service qemu-guest-agent start +- rc-update add iperf3 && rc-service iperf3 start +- rc-update add sshd && rc-service sshd start +users: +- lock_passwd: false + name: cloud + passwd: $6$rounds=4096$vln/.aPHBOI7BMYR$bBMkqQvuGs5Gyd/1H5DP4m9HjQSy.kgrxpaGEHwkX7KEFV8BS.HZWPitAtZ2Vd8ZqIZRqmlykRCagTgPejt1i. + shell: /bin/bash + ssh_authorized_keys: + - ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIFxcXHmwaGnJ8scJaEN5RzklBPZpVSic4GdaAsKjQoeA + your_email@example.com + sudo: ALL=(ALL) NOPASSWD:ALL +write_files: +- content: | + #!/bin/bash + cat > /etc/init.d/iperf3 <<-"EOF" + #!/sbin/openrc-run + + name="iperf3" + description="iperf3 server" + command="/usr/bin/iperf3" + command_args="-s" + pidfile="/run/${name}.pid" + supervisor="supervise-daemon" + supervise_daemon_args="--respawn-delay 2 --stdout /var/log/iperf3.log --stderr /var/log/iperf3.log" + + depend() { + need net + } + + start_pre() { + checkpath --directory --owner root:root --mode 0755 /run + touch /var/log/iperf3.log + chmod 644 /var/log/iperf3.log + } + + stop_post() { + logger -t iperf3 "Stopped by $(whoami) at $(date)" + rm -f "$pidfile" + } + EOF + chmod +x /etc/init.d/iperf3 + rc-update add iperf3 default + path: /usr/scripts/iperf3.sh + permissions: "0755" +` + + assert.Equal(t, expected, PerfCloudInit) +} diff --git a/test/e2e/internal/object/const.go b/test/e2e/internal/object/const.go index bbc90dcbca..f8253a6320 100644 --- a/test/e2e/internal/object/const.go +++ b/test/e2e/internal/object/const.go @@ -38,89 +38,37 @@ const ( Mi256 = 256 * 1024 * 1024 DefaultVMClass = "generic" - cloudInitBasePackages = `#cloud-config -package_update: true -packages: - - qemu-guest-agent - - curl - - bash - - sudo - - util-linux - - iperf3 - - jq -` - cloudInitUbuntuPackages = ` - iputils-ping -` - cloudInitAlpinePackages = ` - iputils -` - cloudInitUsers = ` -users: - - name: cloud - # passwd: cloud - passwd: $6$rounds=4096$vln/.aPHBOI7BMYR$bBMkqQvuGs5Gyd/1H5DP4m9HjQSy.kgrxpaGEHwkX7KEFV8BS.HZWPitAtZ2Vd8ZqIZRqmlykRCagTgPejt1i. - shell: /bin/bash - sudo: ALL=(ALL) NOPASSWD:ALL - lock_passwd: false - ssh_authorized_keys: - # testcases - - ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIFxcXHmwaGnJ8scJaEN5RzklBPZpVSic4GdaAsKjQoeA your_email@example.com -` - cloudInitAlpineRuncmd = ` -runcmd: -- "rc-update add qemu-guest-agent && rc-service qemu-guest-agent start" -` - cloudInitUbuntuRuncmd = ` -runcmd: -- "systemctl enable --now qemu-guest-agent" + iperf3Script = `#!/bin/bash +cat > /etc/init.d/iperf3 <<-"EOF" +#!/sbin/openrc-run + +name="iperf3" +description="iperf3 server" +command="/usr/bin/iperf3" +command_args="-s" +pidfile="/run/${name}.pid" +supervisor="supervise-daemon" +supervise_daemon_args="--respawn-delay 2 --stdout /var/log/iperf3.log --stderr /var/log/iperf3.log" + +depend() { + need net +} + +start_pre() { + checkpath --directory --owner root:root --mode 0755 /run + touch /var/log/iperf3.log + chmod 644 /var/log/iperf3.log +} + +stop_post() { + logger -t iperf3 "Stopped by $(whoami) at $(date)" + rm -f "$pidfile" +} +EOF +chmod +x /etc/init.d/iperf3 +rc-update add iperf3 default ` - AlpineCloudInit = cloudInitBasePackages + cloudInitAlpinePackages + cloudInitUsers + cloudInitAlpineRuncmd - UbuntuCloudInit = cloudInitBasePackages + cloudInitUbuntuPackages + cloudInitUsers + cloudInitUbuntuRuncmd - - cloudInitPerfWriteFiles = ` -write_files: -- path: /usr/scripts/iperf3.sh - permissions: '0755' - content: | - #!/bin/bash - cat > /etc/init.d/iperf3 <<-"EOF" - #!/sbin/openrc-run - - name="iperf3" - description="iperf3 server" - command="/usr/bin/iperf3" - command_args="-s" - pidfile="/run/${name}.pid" - supervisor="supervise-daemon" - supervise_daemon_args="--respawn-delay 2 --stdout /var/log/iperf3.log --stderr /var/log/iperf3.log" - - depend() { - need net - } - - start_pre() { - checkpath --directory --owner root:root --mode 0755 /run - touch /var/log/iperf3.log - chmod 644 /var/log/iperf3.log - } - - stop_post() { - logger -t iperf3 "Stopped by $(whoami) at $(date)" - rm -f "$pidfile" - } - EOF - chmod +x /etc/init.d/iperf3 - rc-update add iperf3 default -` - cloudInitPerfRuncmd = ` -runcmd: -- "/usr/scripts/iperf3.sh" -- "rc-update add qemu-guest-agent && rc-service qemu-guest-agent start" -- "rc-update add iperf3 && rc-service iperf3 start" -- "rc-update add sshd && rc-service sshd start" -` - - PerfCloudInit = cloudInitBasePackages + cloudInitAlpinePackages + cloudInitPerfWriteFiles + cloudInitUsers + cloudInitPerfRuncmd DefaultSSHPrivateKey = `-----BEGIN OPENSSH PRIVATE KEY----- b3BlbnNzaC1rZXktdjEAAAAABG5vbmUAAAAEbm9uZQAAAAAAAAABAAAAMwAAAAtzc2gtZW QyNTUxOQAAACBcXFx5sGhpyfLHCWhDeUc5JQT2aVUonOBnWgLCo0KHgAAAAKDCANDUwgDQ @@ -133,3 +81,34 @@ BPZpVSic4GdaAsKjQoeAAAAAFnlvdXJfZW1haWxAZXhhbXBsZS5jb20BAgMEBQYH DefaultUser = "cloud" DefaultPassword = "cloud" ) + +var AlpineCloudInit = CloudConfig{ + PackageUpdate: true, + Packages: append(basePackages, "iputils"), + Users: []CloudConfigUser{DefaultCloudUser()}, + Runcmd: []string{"rc-update add qemu-guest-agent && rc-service qemu-guest-agent start"}, +}.Render() + +var UbuntuCloudInit = CloudConfig{ + PackageUpdate: true, + Packages: append(basePackages, "iputils-ping"), + Users: []CloudConfigUser{DefaultCloudUser()}, + Runcmd: []string{"systemctl enable --now qemu-guest-agent"}, +}.Render() + +var PerfCloudInit = CloudConfig{ + PackageUpdate: true, + Packages: append(basePackages, "iputils"), + WriteFiles: []WriteFile{{ + Path: "/usr/scripts/iperf3.sh", + Permissions: "0755", + Content: iperf3Script, + }}, + Users: []CloudConfigUser{DefaultCloudUser()}, + Runcmd: []string{ + "/usr/scripts/iperf3.sh", + "rc-update add qemu-guest-agent && rc-service qemu-guest-agent start", + "rc-update add iperf3 && rc-service iperf3 start", + "rc-update add sshd && rc-service sshd start", + }, +}.Render() From b8f58881418a124595fd13cb158e94cf610a9841 Mon Sep 17 00:00:00 2001 From: Nikita Korolev Date: Fri, 27 Mar 2026 18:23:59 +0300 Subject: [PATCH 32/34] fix golint Signed-off-by: Nikita Korolev --- test/e2e/internal/object/vi.go | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/test/e2e/internal/object/vi.go b/test/e2e/internal/object/vi.go index fd064f4d7a..08ef4ead45 100644 --- a/test/e2e/internal/object/vi.go +++ b/test/e2e/internal/object/vi.go @@ -34,6 +34,19 @@ func NewGeneratedHTTPVIAlpineBIOS(prefix, namespace string, opts ...vi.Option) * return vi.New(baseOpts...) } +func NewGeneratedHTTPVIAlpineBIOSPerf(prefix, namespace string, opts ...vi.Option) *v1alpha2.VirtualImage { + baseOpts := []vi.Option{ + vi.WithGenerateName(prefix), + vi.WithNamespace(namespace), + vi.WithDataSourceHTTP( + ImageURLAlpineBIOSPerf, nil, nil, + ), + vi.WithStorage(v1alpha2.StorageContainerRegistry), + } + baseOpts = append(baseOpts, opts...) + return vi.New(baseOpts...) +} + func NewGeneratedContainerImageVI(prefix, namespace string, opts ...vi.Option) *v1alpha2.VirtualImage { baseOpts := []vi.Option{ vi.WithGenerateName(prefix), From 7c8040f3aeb6c0dd3f4a1cb3ebf2e9594b79fd9b Mon Sep 17 00:00:00 2001 From: Nikita Korolev Date: Fri, 27 Mar 2026 18:42:31 +0300 Subject: [PATCH 33/34] fix lint 1 Signed-off-by: Nikita Korolev --- test/e2e/legacy/image_hotplug.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/e2e/legacy/image_hotplug.go b/test/e2e/legacy/image_hotplug.go index 6165e2ae26..364e5f93a6 100644 --- a/test/e2e/legacy/image_hotplug.go +++ b/test/e2e/legacy/image_hotplug.go @@ -30,9 +30,9 @@ import ( "github.com/deckhouse/virtualization/test/e2e/internal/config" "github.com/deckhouse/virtualization/test/e2e/internal/d8" "github.com/deckhouse/virtualization/test/e2e/internal/framework" - "github.com/deckhouse/virtualization/test/e2e/internal/object" kc "github.com/deckhouse/virtualization/test/e2e/internal/kubectl" "github.com/deckhouse/virtualization/test/e2e/internal/label" + "github.com/deckhouse/virtualization/test/e2e/internal/object" ) var _ = Describe("ImageHotplug", Ordered, label.Legacy(), func() { From 27b27d839804ff3aadce9c968d1af551194c55d8 Mon Sep 17 00:00:00 2001 From: Nikita Korolev Date: Fri, 27 Mar 2026 19:10:52 +0300 Subject: [PATCH 34/34] add nolint fo util.UntilObjectPhase in manager Signed-off-by: Nikita Korolev --- test/e2e/internal/precreatedcvi/manager.go | 1 + 1 file changed, 1 insertion(+) diff --git a/test/e2e/internal/precreatedcvi/manager.go b/test/e2e/internal/precreatedcvi/manager.go index c222467df6..a4880711f8 100644 --- a/test/e2e/internal/precreatedcvi/manager.go +++ b/test/e2e/internal/precreatedcvi/manager.go @@ -75,6 +75,7 @@ func (m *PrecreatedCVIManager) Bootstrap(ctx context.Context) { } By(fmt.Sprintf("Wait until all %d precreated CVIs are ready", len(m.cvis))) + //nolint:contextcheck // UntilObjectPhase uses Eventually.WithTimeout for cancellation, not context cancel. util.UntilObjectPhase(string(v1alpha2.ImageReady), framework.LongTimeout, m.cvisAsObjects()...) By(fmt.Sprintf("All %d precreated CVIs are ready", len(m.cvis))) }