diff --git a/images/virtualization-artifact/pkg/builder/vdsnapshot/option.go b/images/virtualization-artifact/pkg/builder/vdsnapshot/option.go new file mode 100644 index 0000000000..6a11b4e923 --- /dev/null +++ b/images/virtualization-artifact/pkg/builder/vdsnapshot/option.go @@ -0,0 +1,53 @@ +/* +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 vdsnapshot + +import ( + "github.com/deckhouse/virtualization-controller/pkg/builder/meta" + "github.com/deckhouse/virtualization/api/core/v1alpha2" +) + +type Option func(vdsnapshot *v1alpha2.VirtualDiskSnapshot) + +var ( + WithName = meta.WithName[*v1alpha2.VirtualDiskSnapshot] + WithNamespace = meta.WithNamespace[*v1alpha2.VirtualDiskSnapshot] + WithGenerateName = meta.WithGenerateName[*v1alpha2.VirtualDiskSnapshot] + WithLabel = meta.WithLabel[*v1alpha2.VirtualDiskSnapshot] + WithLabels = meta.WithLabels[*v1alpha2.VirtualDiskSnapshot] + WithAnnotation = meta.WithAnnotation[*v1alpha2.VirtualDiskSnapshot] + WithAnnotations = meta.WithAnnotations[*v1alpha2.VirtualDiskSnapshot] + WithFinalizer = meta.WithFinalizer[*v1alpha2.VirtualDiskSnapshot] +) + +func WithVirtualDiskName(virtualDiskName string) Option { + return func(vdsnapshot *v1alpha2.VirtualDiskSnapshot) { + vdsnapshot.Spec.VirtualDiskName = virtualDiskName + } +} + +func WithVirtualDisk(vd *v1alpha2.VirtualDisk) Option { + return func(vdsnapshot *v1alpha2.VirtualDiskSnapshot) { + vdsnapshot.Spec.VirtualDiskName = vd.Name + } +} + +func WithRequiredConsistency(requiredConsistency bool) Option { + return func(vdsnapshot *v1alpha2.VirtualDiskSnapshot) { + vdsnapshot.Spec.RequiredConsistency = requiredConsistency + } +} diff --git a/images/virtualization-artifact/pkg/builder/vdsnapshot/vdsnapshot.go b/images/virtualization-artifact/pkg/builder/vdsnapshot/vdsnapshot.go new file mode 100644 index 0000000000..8542ea6726 --- /dev/null +++ b/images/virtualization-artifact/pkg/builder/vdsnapshot/vdsnapshot.go @@ -0,0 +1,51 @@ +/* +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 vdsnapshot + +import ( + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + + "github.com/deckhouse/virtualization/api/core/v1alpha2" +) + +func New(options ...Option) *v1alpha2.VirtualDiskSnapshot { + vdsnapshot := NewEmpty("", "") + ApplyOptions(vdsnapshot, options...) + return vdsnapshot +} + +func ApplyOptions(vdsnapshot *v1alpha2.VirtualDiskSnapshot, opts ...Option) { + if vdsnapshot == nil { + return + } + for _, opt := range opts { + opt(vdsnapshot) + } +} + +func NewEmpty(name, namespace string) *v1alpha2.VirtualDiskSnapshot { + return &v1alpha2.VirtualDiskSnapshot{ + TypeMeta: metav1.TypeMeta{ + APIVersion: v1alpha2.SchemeGroupVersion.String(), + Kind: v1alpha2.VirtualDiskSnapshotKind, + }, + ObjectMeta: metav1.ObjectMeta{ + Name: name, + Namespace: namespace, + }, + } +} diff --git a/images/virtualization-artifact/pkg/builder/vi/option.go b/images/virtualization-artifact/pkg/builder/vi/option.go index 940e3988a6..2059890041 100644 --- a/images/virtualization-artifact/pkg/builder/vi/option.go +++ b/images/virtualization-artifact/pkg/builder/vi/option.go @@ -71,7 +71,7 @@ func WithDataSourceContainerImage(image string, imagePullSecret v1alpha2.ImagePu } } -func WithDataSourceObjectRef(kind v1alpha2.VirtualImageObjectRefKind, name, namespace string) Option { +func WithDataSourceObjectRef(kind v1alpha2.VirtualImageObjectRefKind, name string) Option { return func(vi *v1alpha2.VirtualImage) { vi.Spec.DataSource = v1alpha2.VirtualImageDataSource{ Type: v1alpha2.DataSourceTypeObjectRef, diff --git a/test/e2e/blockdevice/creation.go b/test/e2e/blockdevice/creation.go new file mode 100644 index 0000000000..4bb1f260cd --- /dev/null +++ b/test/e2e/blockdevice/creation.go @@ -0,0 +1,265 @@ +/* +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 blockdevice + +import ( + "context" + "fmt" + + . "github.com/onsi/ginkgo/v2" + . "github.com/onsi/gomega" + "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" + vdsnapshotbuilder "github.com/deckhouse/virtualization-controller/pkg/builder/vdsnapshot" + 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" + "github.com/deckhouse/virtualization/test/e2e/internal/object" + "github.com/deckhouse/virtualization/test/e2e/internal/util" +) + +var _ = Describe("VirtualImageCreation", func() { + f := framework.NewFramework("vi-creation") + + BeforeEach(func() { + f.Before() + DeferCleanup(f.After) + }) + + It("verifies the images are created successfully", func() { + const cviPrefix = "v12-e2e" + var ( + vd *v1alpha2.VirtualDisk + vdSnapshot *v1alpha2.VirtualDiskSnapshot + vis []*v1alpha2.VirtualImage + cvis []*v1alpha2.ClusterVirtualImage + + baseCvis []*v1alpha2.ClusterVirtualImage + baseVis []*v1alpha2.VirtualImage + ) + + By("Creating VirtualDisk", func() { + vd = vdbuilder.New( + vdbuilder.WithGenerateName("vd-"), + vdbuilder.WithNamespace(f.Namespace().Name), + vdbuilder.WithDataSourceHTTP( + &v1alpha2.DataSourceHTTP{ + URL: object.ImageURLAlpineUEFIPerf, + }, + ), + ) + err := f.CreateWithDeferredDeletion(context.Background(), vd) + Expect(err).NotTo(HaveOccurred()) + vm := object.NewMinimalVM("vm-", f.Namespace().Name, vmbuilder.WithBlockDeviceRefs(v1alpha2.BlockDeviceSpecRef{ + Kind: v1alpha2.VirtualDiskKind, + Name: vd.Name, + })) + err = f.CreateWithDeferredDeletion(context.Background(), vm) + Expect(err).NotTo(HaveOccurred()) + util.UntilObjectPhase(string(v1alpha2.DiskReady), framework.LongTimeout, vd) + err = f.Delete(context.Background(), vm) + Expect(err).NotTo(HaveOccurred()) + }) + + By("Creating VirtualDiskSnapshot", func() { + vdSnapshot = vdsnapshotbuilder.New( + vdsnapshotbuilder.WithGenerateName("vdsnapshot-"), + vdsnapshotbuilder.WithNamespace(f.Namespace().Name), + vdsnapshotbuilder.WithVirtualDiskName(vd.Name), + vdsnapshotbuilder.WithRequiredConsistency(true), + ) + err := f.CreateWithDeferredDeletion(context.Background(), vdSnapshot) + Expect(err).NotTo(HaveOccurred()) + util.UntilObjectPhase(string(v1alpha2.VirtualDiskSnapshotPhaseReady), framework.ShortTimeout, vdSnapshot) + }) + + By("Generating base cvis", func() { + baseCvis = append(baseCvis, object.NewGenerateContainerImageCVI(fmt.Sprintf("%s-cvi-ci-", cviPrefix))) + baseCvis = append(baseCvis, cvibuilder.New( + cvibuilder.WithGenerateName(fmt.Sprintf("%s-cvi-http-", cviPrefix)), + cvibuilder.WithDataSourceHTTP( + object.ImageURLAlpineUEFIPerf, + nil, + nil, + ), + )) + baseCvis = append(baseCvis, cvibuilder.New( + cvibuilder.WithGenerateName(fmt.Sprintf("%s-cvi-from-vd-", cviPrefix)), + cvibuilder.WithDataSourceObjectRef(v1alpha2.ClusterVirtualImageObjectRefKindVirtualDisk, vd.Name, f.Namespace().Name), + )) + baseCvis = append(baseCvis, cvibuilder.New( + cvibuilder.WithGenerateName(fmt.Sprintf("%s-cvi-from-vds-", cviPrefix)), + cvibuilder.WithDataSourceObjectRef(v1alpha2.ClusterVirtualImageObjectRefKindVirtualDiskSnapshot, vdSnapshot.Name, f.Namespace().Name), + )) + }) + + By("Generating base vis on dvcr", func() { + baseVis = append(baseVis, object.NewGeneratedContainerImageVI("vi-ci-", f.Namespace().Name)) + baseVis = append(baseVis, vibuilder.New( + vibuilder.WithGenerateName("vi-http-"), + vibuilder.WithNamespace(f.Namespace().Name), + vibuilder.WithStorage(v1alpha2.StorageContainerRegistry), + vibuilder.WithDataSourceHTTP( + object.ImageURLAlpineUEFIPerf, + nil, + nil, + ), + )) + baseVis = append(baseVis, vibuilder.New( + vibuilder.WithGenerateName("vi-from-vd-"), + vibuilder.WithNamespace(f.Namespace().Name), + vibuilder.WithStorage(v1alpha2.StorageContainerRegistry), + vibuilder.WithDataSourceObjectRef(v1alpha2.VirtualImageObjectRefKindVirtualDisk, vd.Name), + )) + baseVis = append(baseVis, vibuilder.New( + vibuilder.WithGenerateName("vi-from-vds-"), + vibuilder.WithNamespace(f.Namespace().Name), + vibuilder.WithStorage(v1alpha2.StorageContainerRegistry), + vibuilder.WithDataSourceObjectRef(v1alpha2.VirtualImageObjectRefKindVirtualDiskSnapshot, vdSnapshot.Name), + )) + }) + + By("Generating base vis on pvc", func() { + baseVis = append(baseVis, object.NewGeneratedContainerImageVI("vi-pvc-ci-", f.Namespace().Name, vibuilder.WithStorage(v1alpha2.StoragePersistentVolumeClaim))) + baseVis = append(baseVis, vibuilder.New( + vibuilder.WithGenerateName("vi-http-"), + vibuilder.WithNamespace(f.Namespace().Name), + vibuilder.WithStorage(v1alpha2.StoragePersistentVolumeClaim), + vibuilder.WithDataSourceHTTP( + object.ImageURLAlpineUEFIPerf, + nil, + nil, + ), + )) + baseVis = append(baseVis, vibuilder.New( + vibuilder.WithGenerateName("vi-pvc-from-vd-"), + vibuilder.WithStorage(v1alpha2.StoragePersistentVolumeClaim), + vibuilder.WithNamespace(f.Namespace().Name), + vibuilder.WithDataSourceObjectRef(v1alpha2.VirtualImageObjectRefKindVirtualDisk, vd.Name), + )) + baseVis = append(baseVis, vibuilder.New( + vibuilder.WithGenerateName("vi-pvc-from-vds-"), + vibuilder.WithStorage(v1alpha2.StoragePersistentVolumeClaim), + vibuilder.WithNamespace(f.Namespace().Name), + vibuilder.WithDataSourceObjectRef(v1alpha2.VirtualImageObjectRefKindVirtualDiskSnapshot, vdSnapshot.Name), + )) + }) + + By("Creating base images", func() { + for _, cvi := range baseCvis { + err := f.CreateWithDeferredDeletion(context.Background(), cvi) + Expect(err).NotTo(HaveOccurred()) + } + for _, vi := range baseVis { + err := f.CreateWithDeferredDeletion(context.Background(), vi) + Expect(err).NotTo(HaveOccurred()) + } + }) + + By("Generating cvis from base cvis", func() { + for _, baseCvi := range baseCvis { + cvis = append(cvis, cvibuilder.New( + cvibuilder.WithName(fmt.Sprintf("%s-cvi-from-%s", cviPrefix, baseCvi.Name)), + cvibuilder.WithDataSourceObjectRef(v1alpha2.ClusterVirtualImageObjectRefKindClusterVirtualImage, baseCvi.Name, ""), + )) + } + }) + + By("Generating cvis from base vis", func() { + for _, baseVi := range baseVis { + cvis = append(cvis, cvibuilder.New( + cvibuilder.WithName(fmt.Sprintf("%s-cvi-from-%s", cviPrefix, baseVi.Name)), + cvibuilder.WithDataSourceObjectRef(v1alpha2.ClusterVirtualImageObjectRefKindVirtualImage, baseVi.Name, baseVi.Namespace), + )) + } + }) + + By("Generating dvcr vis from base cvis", func() { + for _, baseCvi := range baseCvis { + vis = append(vis, vibuilder.New( + vibuilder.WithName(fmt.Sprintf("vi-from-%s", baseCvi.Name)), + vibuilder.WithNamespace(f.Namespace().Name), + vibuilder.WithDataSourceObjectRef(v1alpha2.VirtualImageObjectRefKindClusterVirtualImage, baseCvi.Name), + vibuilder.WithStorage(v1alpha2.StorageContainerRegistry), + )) + } + }) + + By("Generating dvcr vis from base vis", func() { + for _, baseVi := range baseVis { + vis = append(vis, vibuilder.New( + vibuilder.WithName(fmt.Sprintf("vi-from-%s", baseVi.Name)), + vibuilder.WithNamespace(f.Namespace().Name), + vibuilder.WithStorage(v1alpha2.StorageContainerRegistry), + vibuilder.WithDataSourceObjectRef(v1alpha2.VirtualImageObjectRefKindVirtualImage, baseVi.Name), + )) + } + }) + + By("Generating pvc vis from base cvis", func() { + for _, baseCvi := range baseCvis { + vis = append(vis, vibuilder.New( + vibuilder.WithName(fmt.Sprintf("vi-pvc-from-%s", baseCvi.Name)), + vibuilder.WithNamespace(f.Namespace().Name), + vibuilder.WithDataSourceObjectRef(v1alpha2.VirtualImageObjectRefKindClusterVirtualImage, baseCvi.Name), + vibuilder.WithStorage(v1alpha2.StoragePersistentVolumeClaim), + )) + } + }) + + By("Generating pvc vis from base vis", func() { + for _, baseVi := range baseVis { + vis = append(vis, vibuilder.New( + vibuilder.WithName(fmt.Sprintf("vi-pvc-from-%s", baseVi.Name)), + vibuilder.WithNamespace(f.Namespace().Name), + vibuilder.WithStorage(v1alpha2.StoragePersistentVolumeClaim), + vibuilder.WithDataSourceObjectRef(v1alpha2.VirtualImageObjectRefKindVirtualImage, baseVi.Name), + )) + } + }) + + By("Creating images", func() { + for _, vi := range vis { + err := f.CreateWithDeferredDeletion(context.Background(), vi) + Expect(err).NotTo(HaveOccurred()) + } + + for _, cvi := range cvis { + err := f.CreateWithDeferredDeletion(context.Background(), cvi) + Expect(err).NotTo(HaveOccurred()) + } + }) + + By("Verifying that images are ready", func() { + // Should check base images too + vis = append(baseVis, vis...) + cvis = append(baseCvis, cvis...) + + var objects []client.Object + for _, vi := range vis { + objects = append(objects, vi) + } + for _, cvi := range cvis { + objects = append(objects, cvi) + } + util.UntilObjectPhase(string(v1alpha2.ImageReady), framework.LongTimeout, objects...) + }) + }) +}) diff --git a/test/e2e/default_config.yaml b/test/e2e/default_config.yaml index 7590ef67a8..43004ed5bc 100644 --- a/test/e2e/default_config.yaml +++ b/test/e2e/default_config.yaml @@ -16,7 +16,6 @@ testData: diskResizing: "/tmp/testdata/disk-resizing" imageHotplug: "/tmp/testdata/image-hotplug" sizingPolicy: "/tmp/testdata/sizing-policy" - imagesCreation: "/tmp/testdata/images-creation" importerNetworkPolicy: "/tmp/testdata/importer-network-policy" vmConfiguration: "/tmp/testdata/vm-configuration" vmLabelAnnotation: "/tmp/testdata/vm-label-annotation" diff --git a/test/e2e/e2e_test.go b/test/e2e/e2e_test.go index 72cc2a3dd0..9176edfd27 100644 --- a/test/e2e/e2e_test.go +++ b/test/e2e/e2e_test.go @@ -22,6 +22,7 @@ import ( . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" + _ "github.com/deckhouse/virtualization/test/e2e/blockdevice" "github.com/deckhouse/virtualization/test/e2e/controller" "github.com/deckhouse/virtualization/test/e2e/legacy" _ "github.com/deckhouse/virtualization/test/e2e/vm" diff --git a/test/e2e/internal/config/config.go b/test/e2e/internal/config/config.go index 23d7fa9727..208520ecde 100644 --- a/test/e2e/internal/config/config.go +++ b/test/e2e/internal/config/config.go @@ -87,7 +87,6 @@ type TestData struct { SizingPolicy string `yaml:"sizingPolicy"` ImporterNetworkPolicy string `yaml:"importerNetworkPolicy"` ImageHotplug string `yaml:"imageHotplug"` - ImagesCreation string `yaml:"imagesCreation"` VMConfiguration string `yaml:"vmConfiguration"` VMLabelAnnotation string `yaml:"vmLabelAnnotation"` VMMigration string `yaml:"vmMigration"` diff --git a/test/e2e/internal/object/const.go b/test/e2e/internal/object/const.go index 6c0aa6671e..4e537eaad2 100644 --- a/test/e2e/internal/object/const.go +++ b/test/e2e/internal/object/const.go @@ -20,6 +20,7 @@ const ( ImageURLAlpineUEFIPerf = "https://89d64382-20df-4581-8cc7-80df331f67fa.selstorage.ru/alpine/alpine-3-21-uefi-perf.qcow2" ImageURLUbuntu = "https://89d64382-20df-4581-8cc7-80df331f67fa.selstorage.ru/ubuntu/ubuntu-24.04-minimal-cloudimg-amd64.qcow2" ImageURLAlpineBIOS = "https://89d64382-20df-4581-8cc7-80df331f67fa.selstorage.ru/alpine/alpine-3-21-bios-base.qcow2" + ImageURLContainerImage = "cr.yandex/crpvs5j3nh1mi2tpithr/e2e/alpine/alpine-image:latest" Mi256 = 256 * 1024 * 1024 DefaultVMClass = "generic" DefaultCloudInit = `#cloud-config diff --git a/test/e2e/internal/object/cvi.go b/test/e2e/internal/object/cvi.go index e3f80735ed..d6b136c8a8 100644 --- a/test/e2e/internal/object/cvi.go +++ b/test/e2e/internal/object/cvi.go @@ -21,24 +21,46 @@ import ( "github.com/deckhouse/virtualization/api/core/v1alpha2" ) -func NewHTTPCVIUbuntu(name string) *v1alpha2.ClusterVirtualImage { - return cvi.New( +func NewHTTPCVIUbuntu(name string, opts ...cvi.Option) *v1alpha2.ClusterVirtualImage { + baseOpts := []cvi.Option{ cvi.WithName(name), cvi.WithDataSourceHTTP( ImageURLUbuntu, nil, nil, ), - ) + } + baseOpts = append(baseOpts, opts...) + return cvi.New(baseOpts...) } -func NewGenerateHTTPCVIUbuntu(prefix string) *v1alpha2.ClusterVirtualImage { - return cvi.New( +func NewGenerateHTTPCVIUbuntu(prefix string, opts ...cvi.Option) *v1alpha2.ClusterVirtualImage { + baseOpts := []cvi.Option{ cvi.WithGenerateName(prefix), cvi.WithDataSourceHTTP( ImageURLUbuntu, nil, nil, ), - ) + } + baseOpts = append(baseOpts, opts...) + return cvi.New(baseOpts...) +} + +func NewContainerImageCVI(name string, opts ...cvi.Option) *v1alpha2.ClusterVirtualImage { + baseOpts := []cvi.Option{ + cvi.WithName(name), + cvi.WithDataSourceContainerImage(ImageURLContainerImage, v1alpha2.ImagePullSecret{}, nil), + } + baseOpts = append(baseOpts, opts...) + return cvi.New(baseOpts...) +} + +func NewGenerateContainerImageCVI(prefix string, opts ...cvi.Option) *v1alpha2.ClusterVirtualImage { + baseOpts := []cvi.Option{ + cvi.WithGenerateName(prefix), + cvi.WithDataSourceContainerImage(ImageURLContainerImage, v1alpha2.ImagePullSecret{}, nil), + } + baseOpts = append(baseOpts, opts...) + return cvi.New(baseOpts...) } diff --git a/test/e2e/internal/object/vi.go b/test/e2e/internal/object/vi.go index 144efca041..ea85ed7274 100644 --- a/test/e2e/internal/object/vi.go +++ b/test/e2e/internal/object/vi.go @@ -21,25 +21,53 @@ import ( "github.com/deckhouse/virtualization/api/core/v1alpha2" ) -func NewHTTPVIUbuntu(name string) *v1alpha2.VirtualImage { - return vi.New( +func NewHTTPVIUbuntu(name string, opts ...vi.Option) *v1alpha2.VirtualImage { + baseOpts := []vi.Option{ vi.WithName(name), + vi.WithStorage(v1alpha2.StorageContainerRegistry), vi.WithDataSourceHTTP( ImageURLUbuntu, nil, nil, ), - ) + } + baseOpts = append(baseOpts, opts...) + return vi.New(baseOpts...) } -func NewGeneratedHTTPVIUbuntu(prefix string) *v1alpha2.VirtualImage { - return vi.New( +func NewGeneratedHTTPVIUbuntu(prefix, namespace string, opts ...vi.Option) *v1alpha2.VirtualImage { + baseOpts := []vi.Option{ vi.WithGenerateName(prefix), + vi.WithNamespace(namespace), vi.WithDataSourceHTTP( ImageURLUbuntu, nil, nil, ), vi.WithStorage(v1alpha2.StorageContainerRegistry), - ) + } + baseOpts = append(baseOpts, opts...) + return vi.New(baseOpts...) +} + +func NewContainerImageVI(name, namespace string, opts ...vi.Option) *v1alpha2.VirtualImage { + baseOpts := []vi.Option{ + vi.WithName(name), + vi.WithNamespace(namespace), + vi.WithStorage(v1alpha2.StorageContainerRegistry), + vi.WithDataSourceContainerImage(ImageURLContainerImage, v1alpha2.ImagePullSecretName{}, nil), + } + baseOpts = append(baseOpts, opts...) + return vi.New(baseOpts...) +} + +func NewGeneratedContainerImageVI(prefix, namespace string, opts ...vi.Option) *v1alpha2.VirtualImage { + baseOpts := []vi.Option{ + vi.WithGenerateName(prefix), + vi.WithNamespace(namespace), + vi.WithStorage(v1alpha2.StorageContainerRegistry), + vi.WithDataSourceContainerImage(ImageURLContainerImage, v1alpha2.ImagePullSecretName{}, nil), + } + baseOpts = append(baseOpts, opts...) + return vi.New(baseOpts...) } diff --git a/test/e2e/internal/util/until.go b/test/e2e/internal/util/until.go new file mode 100644 index 0000000000..c731c78992 --- /dev/null +++ b/test/e2e/internal/util/until.go @@ -0,0 +1,122 @@ +/* +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 util + +import ( + "context" + "strings" + "time" + + . "github.com/onsi/ginkgo/v2" + . "github.com/onsi/gomega" + "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" + "k8s.io/apimachinery/pkg/runtime" + "k8s.io/apimachinery/pkg/runtime/schema" + "sigs.k8s.io/controller-runtime/pkg/client" + + "github.com/deckhouse/virtualization/test/e2e/internal/framework" +) + +// UntilObjectPhase waits for an object to reach the specified phase. +// It accepts a runtime.Object (which serves as a template with name and namespace), +// expected phase string, and timeout duration. +// The GVK is automatically extracted from the object via the client's scheme. +func UntilObjectPhase(expectedPhase string, timeout time.Duration, objs ...client.Object) { + GinkgoHelper() + untilObjectField("status.phase", expectedPhase, timeout, objs...) +} + +// UntilObjectState waits for an object to reach the specified state. +// It accepts a runtime.Object (which serves as a template with name and namespace), +// expected state string, and timeout duration. +// The GVK is automatically extracted from the object via the client's scheme. +func UntilObjectState(expectedState string, timeout time.Duration, objs ...client.Object) { + GinkgoHelper() + untilObjectField("status.state", expectedState, timeout, objs...) +} + +// extractField extracts a string value from an unstructured object at the provided fieldPath (dot-separated, e.g. "status.phase" or "metadata.name"). +func extractField(obj client.Object, fieldPath string) string { + u, ok := obj.(*unstructured.Unstructured) + if !ok { + return "Unknown" + } + path := strings.Split(fieldPath, ".") + value, found, err := unstructured.NestedString(u.Object, path...) + if err != nil || !found { + return "Unknown" + } + return value +} + +// untilObjectField waits for an object field to reach the specified value. +// It accepts a runtime.Object (which serves as a template with name and namespace), +// fieldPath (dot-separated path to the field, e.g. "status.phase" or "metadata.name"), +// expected value string, field name for error messages, and timeout duration. +// The GVK is automatically extracted from the object via the client's scheme. +func untilObjectField(fieldPath, expectedValue string, timeout time.Duration, objs ...client.Object) { + Eventually(func(g Gomega) { + for _, obj := range objs { + key := client.ObjectKeyFromObject(obj) + name := obj.GetName() + namespace := obj.GetNamespace() + divider := "" + if namespace != "" { + divider = "/" + } + + // Create a new unstructured object for each Get call + u := getTemplateUnstructured(obj).DeepCopy() + err := framework.GetClients().GenericClient().Get(context.Background(), key, u) + if err != nil { + g.Expect(err).NotTo(HaveOccurred(), "failed to get object %s%s%s", namespace, divider, name) + } + + value := extractField(u, fieldPath) + g.Expect(value).To(Equal(expectedValue), "object %s%s%s %s is %s, expected %s", namespace, divider, name, fieldPath, value, expectedValue) + } + }).WithTimeout(timeout).WithPolling(time.Second).Should(Succeed()) +} + +func getTemplateUnstructured(obj client.Object) *unstructured.Unstructured { + // Convert the template object to unstructured once + var templateUnstructured *unstructured.Unstructured + var gvk schema.GroupVersionKind + + // Handle two possible input formats: + // 1. If the object is already unstructured, use it directly with its GVK + // 2. If it's a typed struct (e.g., VirtualMachine), convert it to unstructured + // and extract GVK from the client's scheme registry + if unstructuredObj, ok := obj.(*unstructured.Unstructured); ok { + // Object is already unstructured - just copy it and extract GVK + templateUnstructured = unstructuredObj.DeepCopy() + } else { + // Object is a typed struct - convert to unstructured format + objMap, err := runtime.DefaultUnstructuredConverter.ToUnstructured(obj) + Expect(err).NotTo(HaveOccurred(), "failed to convert object to unstructured") + templateUnstructured = &unstructured.Unstructured{Object: objMap} + + // Get GVK from the scheme (which knows about registered types) + client := framework.GetClients().GenericClient() + gvks, _, err := client.Scheme().ObjectKinds(obj) + Expect(err).NotTo(HaveOccurred(), "failed to get GVK from object") + Expect(len(gvks)).To(BeNumerically(">", 0), "no GVK found for object") + gvk = gvks[0] + templateUnstructured.SetGroupVersionKind(gvk) + } + return templateUnstructured +} diff --git a/test/e2e/legacy/images_creation.go b/test/e2e/legacy/images_creation.go deleted file mode 100644 index 85ae80dc99..0000000000 --- a/test/e2e/legacy/images_creation.go +++ /dev/null @@ -1,126 +0,0 @@ -/* -Copyright 2024 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 legacy - -import ( - "fmt" - - . "github.com/onsi/ginkgo/v2" - . "github.com/onsi/gomega" - - "github.com/deckhouse/virtualization/api/core/v1alpha2" - "github.com/deckhouse/virtualization/test/e2e/internal/config" - kc "github.com/deckhouse/virtualization/test/e2e/internal/kubectl" - "github.com/deckhouse/virtualization/test/e2e/internal/util" -) - -var _ = Describe("VirtualImageCreation", Ordered, func() { - var ( - testCaseLabel = map[string]string{"testcase": "images-creation"} - ns string - ) - - BeforeAll(func() { - kustomization := fmt.Sprintf("%s/%s", conf.TestData.ImagesCreation, "kustomization.yaml") - var err error - ns, err = kustomize.GetNamespace(kustomization) - Expect(err).NotTo(HaveOccurred(), "%w", err) - - CreateNamespace(ns) - - Expect(conf.StorageClass.ImmediateStorageClass).NotTo(BeNil(), "immediate storage class cannot be nil; please set up the immediate storage class in the cluster") - - virtualDisk := v1alpha2.VirtualDisk{} - vdFilePath := fmt.Sprintf("%s/vd/vd-alpine-http.yaml", conf.TestData.ImagesCreation) - err = util.UnmarshalResource(vdFilePath, &virtualDisk) - Expect(err).NotTo(HaveOccurred(), "cannot get object from file: %s\nstderr: %s", vdFilePath, err) - - virtualDisk.Spec.PersistentVolumeClaim.StorageClass = &conf.StorageClass.ImmediateStorageClass.Name - err = util.WriteYamlObject(vdFilePath, &virtualDisk) - Expect(err).NotTo(HaveOccurred(), "cannot update virtual disk with custom storage class: %s\nstderr: %s", vdFilePath, err) - - virtualDiskSnapshot := v1alpha2.VirtualDiskSnapshot{} - vdSnapshotFilePath := fmt.Sprintf("%s/vdsnapshot/vdsnapshot.yaml", conf.TestData.ImagesCreation) - err = util.UnmarshalResource(vdSnapshotFilePath, &virtualDiskSnapshot) - Expect(err).NotTo(HaveOccurred(), "cannot get object from file: %s\nstderr: %s", vdSnapshotFilePath, err) - - err = util.WriteYamlObject(vdSnapshotFilePath, &virtualDiskSnapshot) - Expect(err).NotTo(HaveOccurred(), "cannot update virtual disk with custom storage class: %s\nstderr: %s", vdSnapshotFilePath, err) - }) - - AfterAll(func() { - if config.IsCleanUpNeeded() { - DeleteTestCaseResources(ns, ResourcesToDelete{KustomizationDir: conf.TestData.ImagesCreation}) - } - }) - - AfterEach(func() { - if CurrentSpecReport().Failed() { - SaveTestCaseDump(testCaseLabel, CurrentSpecReport().LeafNodeText, ns) - } - }) - - Context("When resources are applied", func() { - It("result should be succeeded", func() { - res := kubectl.Apply(kc.ApplyOptions{ - Filename: []string{conf.TestData.ImagesCreation}, - FilenameOption: kc.Kustomize, - }) - Expect(res.Error()).NotTo(HaveOccurred(), res.StdErr()) - }) - }) - - Context("When base virtual resources are ready", func() { - It("checks VD phase", func() { - By(fmt.Sprintf("VD should be in %s phase", v1alpha2.DiskReady)) - WaitPhaseByLabel(kc.ResourceVD, string(v1alpha2.DiskReady), kc.WaitOptions{ - Labels: testCaseLabel, - Namespace: ns, - Timeout: MaxWaitTimeout, - }) - }) - - It("checks VDSnapshot phase", func() { - By(fmt.Sprintf("VDSnapshot should be in %s phase", v1alpha2.VirtualDiskSnapshotPhaseReady)) - WaitPhaseByLabel(kc.ResourceVDSnapshot, string(v1alpha2.VirtualDiskSnapshotPhaseReady), kc.WaitOptions{ - Labels: testCaseLabel, - Namespace: ns, - Timeout: MaxWaitTimeout, - }) - }) - }) - - Context("When virtual images are applied", func() { - It("checks VIs phases", func() { - By(fmt.Sprintf("VIs should be in %s phases", v1alpha2.ImageReady)) - WaitPhaseByLabel(kc.ResourceVI, string(v1alpha2.ImageReady), kc.WaitOptions{ - Labels: testCaseLabel, - Namespace: ns, - Timeout: MaxWaitTimeout, - }) - }) - - It("checks CVIs phases", func() { - By(fmt.Sprintf("CVIs should be in %s phases", v1alpha2.ImageReady)) - WaitPhaseByLabel(kc.ResourceCVI, string(v1alpha2.ImageReady), kc.WaitOptions{ - Labels: testCaseLabel, - Namespace: ns, - Timeout: MaxWaitTimeout, - }) - }) - }) -}) diff --git a/test/e2e/legacy/testdata/images-creation/cvi/cvi_containerimage.yaml b/test/e2e/legacy/testdata/images-creation/cvi/cvi_containerimage.yaml deleted file mode 100644 index e585753d69..0000000000 --- a/test/e2e/legacy/testdata/images-creation/cvi/cvi_containerimage.yaml +++ /dev/null @@ -1,9 +0,0 @@ -apiVersion: virtualization.deckhouse.io/v1alpha2 -kind: ClusterVirtualImage -metadata: - name: cvi-containerimage -spec: - dataSource: - type: ContainerImage - containerImage: - image: "cr.yandex/crpvs5j3nh1mi2tpithr/e2e/alpine/alpine-image:latest" diff --git a/test/e2e/legacy/testdata/images-creation/cvi/cvi_http.yaml b/test/e2e/legacy/testdata/images-creation/cvi/cvi_http.yaml deleted file mode 100644 index c4c2e653e6..0000000000 --- a/test/e2e/legacy/testdata/images-creation/cvi/cvi_http.yaml +++ /dev/null @@ -1,9 +0,0 @@ -apiVersion: virtualization.deckhouse.io/v1alpha2 -kind: ClusterVirtualImage -metadata: - name: cvi-http -spec: - dataSource: - type: "HTTP" - http: - url: https://89d64382-20df-4581-8cc7-80df331f67fa.selstorage.ru/alpine/alpine-virt-3.21.0-x86.iso diff --git a/test/e2e/legacy/testdata/images-creation/cvi/cvi_objectref_cvi.yaml b/test/e2e/legacy/testdata/images-creation/cvi/cvi_objectref_cvi.yaml deleted file mode 100644 index 9163c12e6b..0000000000 --- a/test/e2e/legacy/testdata/images-creation/cvi/cvi_objectref_cvi.yaml +++ /dev/null @@ -1,10 +0,0 @@ -apiVersion: virtualization.deckhouse.io/v1alpha2 -kind: ClusterVirtualImage -metadata: - name: cvi-oref-cvi -spec: - dataSource: - type: "ObjectRef" - objectRef: - kind: "ClusterVirtualImage" - name: cvi-http diff --git a/test/e2e/legacy/testdata/images-creation/cvi/cvi_objectref_vd.yaml b/test/e2e/legacy/testdata/images-creation/cvi/cvi_objectref_vd.yaml deleted file mode 100644 index 64de1cf11d..0000000000 --- a/test/e2e/legacy/testdata/images-creation/cvi/cvi_objectref_vd.yaml +++ /dev/null @@ -1,11 +0,0 @@ -apiVersion: virtualization.deckhouse.io/v1alpha2 -kind: ClusterVirtualImage -metadata: - name: cvi-oref-vd -spec: - dataSource: - type: "ObjectRef" - objectRef: - kind: "VirtualDisk" - name: vd-alpine-http - namespace: test-d8-virtualization diff --git a/test/e2e/legacy/testdata/images-creation/cvi/cvi_objectref_vdsnapshot.yaml b/test/e2e/legacy/testdata/images-creation/cvi/cvi_objectref_vdsnapshot.yaml deleted file mode 100644 index 9e6fbea226..0000000000 --- a/test/e2e/legacy/testdata/images-creation/cvi/cvi_objectref_vdsnapshot.yaml +++ /dev/null @@ -1,11 +0,0 @@ -apiVersion: virtualization.deckhouse.io/v1alpha2 -kind: ClusterVirtualImage -metadata: - name: cvi-oref-vdsnapshot -spec: - dataSource: - type: "ObjectRef" - objectRef: - kind: "VirtualDiskSnapshot" - name: vdsnapshot - namespace: test-d8-virtualization diff --git a/test/e2e/legacy/testdata/images-creation/cvi/cvi_objectref_vi.yaml b/test/e2e/legacy/testdata/images-creation/cvi/cvi_objectref_vi.yaml deleted file mode 100644 index 447bce0197..0000000000 --- a/test/e2e/legacy/testdata/images-creation/cvi/cvi_objectref_vi.yaml +++ /dev/null @@ -1,122 +0,0 @@ -# DVCR -apiVersion: virtualization.deckhouse.io/v1alpha2 -kind: ClusterVirtualImage -metadata: - name: cvi-oref-vi-http -spec: - dataSource: - type: "ObjectRef" - objectRef: - kind: "VirtualImage" - name: vi-http - namespace: test-d8-virtualization ---- -apiVersion: virtualization.deckhouse.io/v1alpha2 -kind: ClusterVirtualImage -metadata: - name: cvi-oref-vi-conimg -spec: - dataSource: - type: "ObjectRef" - objectRef: - kind: "VirtualImage" - name: vi-containerimage - namespace: test-d8-virtualization ---- -apiVersion: virtualization.deckhouse.io/v1alpha2 -kind: ClusterVirtualImage -metadata: - name: cvi-oref-vi-oref-cvi -spec: - dataSource: - type: "ObjectRef" - objectRef: - kind: "VirtualImage" - name: vi-oref-cvi - namespace: test-d8-virtualization ---- -apiVersion: virtualization.deckhouse.io/v1alpha2 -kind: ClusterVirtualImage -metadata: - name: cvi-oref-vi-oref-vd -spec: - dataSource: - type: "ObjectRef" - objectRef: - kind: "VirtualImage" - name: vi-oref-vd - namespace: test-d8-virtualization ---- -apiVersion: virtualization.deckhouse.io/v1alpha2 -kind: ClusterVirtualImage -metadata: - name: cvi-oref-vi-oref-vdsnp -spec: - dataSource: - type: "ObjectRef" - objectRef: - kind: "VirtualImage" - name: vi-oref-vdsnapshot - namespace: test-d8-virtualization - -# PVC SOURCE ---- -apiVersion: virtualization.deckhouse.io/v1alpha2 -kind: ClusterVirtualImage -metadata: - name: cvi-oref-vi-http-pvc -spec: - dataSource: - type: "ObjectRef" - objectRef: - kind: "VirtualImage" - name: vi-pvc-http - namespace: test-d8-virtualization ---- -apiVersion: virtualization.deckhouse.io/v1alpha2 -kind: ClusterVirtualImage -metadata: - name: cvi-oref-vi-conimg-pvc -spec: - dataSource: - type: "ObjectRef" - objectRef: - kind: "VirtualImage" - name: vi-pvc-containerimage - namespace: test-d8-virtualization ---- -apiVersion: virtualization.deckhouse.io/v1alpha2 -kind: ClusterVirtualImage -metadata: - name: cvi-ref-vi-ref-cvi-pvc -spec: - dataSource: - type: "ObjectRef" - objectRef: - kind: "VirtualImage" - name: vi-pvc-oref-cvi - namespace: test-d8-virtualization ---- -apiVersion: virtualization.deckhouse.io/v1alpha2 -kind: ClusterVirtualImage -metadata: - name: cvi-ref-vi-ref-vd-pvc -spec: - dataSource: - type: "ObjectRef" - objectRef: - kind: "VirtualImage" - name: vi-pvc-oref-vd - namespace: test-d8-virtualization ---- -apiVersion: virtualization.deckhouse.io/v1alpha2 -kind: ClusterVirtualImage -metadata: - name: cvi-rf-vi-rf-vdsnp-pvc -spec: - dataSource: - type: "ObjectRef" - objectRef: - kind: "VirtualImage" - name: vi-pvc-oref-vdsnapshot - namespace: test-d8-virtualization diff --git a/test/e2e/legacy/testdata/images-creation/cvi/kustomization.yaml b/test/e2e/legacy/testdata/images-creation/cvi/kustomization.yaml deleted file mode 100644 index 0f1a314cbe..0000000000 --- a/test/e2e/legacy/testdata/images-creation/cvi/kustomization.yaml +++ /dev/null @@ -1,9 +0,0 @@ -apiVersion: kustomize.config.k8s.io/v1beta1 -kind: Kustomization -resources: - - ./cvi_http.yaml - - ./cvi_containerimage.yaml - - ./cvi_objectref_cvi.yaml - - ./cvi_objectref_vi.yaml - - ./cvi_objectref_vd.yaml - - ./cvi_objectref_vdsnapshot.yaml diff --git a/test/e2e/legacy/testdata/images-creation/kustomization.yaml b/test/e2e/legacy/testdata/images-creation/kustomization.yaml deleted file mode 100644 index 3dc033f5e8..0000000000 --- a/test/e2e/legacy/testdata/images-creation/kustomization.yaml +++ /dev/null @@ -1,17 +0,0 @@ -apiVersion: kustomize.config.k8s.io/v1beta1 -kind: Kustomization -namespace: testcases -namePrefix: pr-number-or-commit-hash- -resources: - - ns.yaml - - vd - - vdsnapshot - - vi - - cvi -configurations: - - transformer.yaml -labels: - - includeSelectors: true - pairs: - id: pr-number-or-commit-hash - testcase: images-creation diff --git a/test/e2e/legacy/testdata/images-creation/ns.yaml b/test/e2e/legacy/testdata/images-creation/ns.yaml deleted file mode 100644 index 5efde875b6..0000000000 --- a/test/e2e/legacy/testdata/images-creation/ns.yaml +++ /dev/null @@ -1,4 +0,0 @@ -apiVersion: v1 -kind: Namespace -metadata: - name: default diff --git a/test/e2e/legacy/testdata/images-creation/transformer.yaml b/test/e2e/legacy/testdata/images-creation/transformer.yaml deleted file mode 100644 index 073ebcb6d9..0000000000 --- a/test/e2e/legacy/testdata/images-creation/transformer.yaml +++ /dev/null @@ -1,51 +0,0 @@ -namespace: - - kind: ClusterVirtualImage - path: spec/dataSource/objectRef/namespace -nameReference: - - kind: VirtualImage - version: v1alpha2 # optional - fieldSpecs: - - path: spec/dataSource/objectRef/name - kind: ClusterVirtualImage - - path: spec/dataSource/objectRef/name - kind: VirtualImage - - path: spec/dataSource/objectRef/name - kind: VirtualDisk - - path: spec/blockDeviceRefs/name - kind: VirtualMachine - - kind: ClusterVirtualImage - version: v1alpha2 # optional - fieldSpecs: - - path: spec/dataSource/objectRef/name - kind: ClusterVirtualImage - - path: spec/dataSource/objectRef/name - kind: VirtualImage - - path: spec/dataSource/objectRef/name - kind: VirtualDisk - - path: spec/blockDeviceRefs/name - kind: VirtualMachine - - kind: VirtualDisk - version: v1alpha2 # optional - fieldSpecs: - - path: spec/blockDeviceRefs/name - kind: VirtualMachine - - path: spec/blockDeviceRef/name - kind: VirtualMachineBlockDeviceAttachment - - path: spec/virtualDiskName - kind: VirtualDiskSnapshot - - path: spec/dataSource/objectRef/name - kind: VirtualImage - - path: spec/dataSource/objectRef/name - kind: ClusterVirtualImage - - kind: VirtualMachine - version: v1alpha2 - fieldSpecs: - - path: spec/virtualMachineName - kind: VirtualMachineBlockDeviceAttachment - - kind: VirtualDiskSnapshot - version: v1alpha2 - fieldSpecs: - - path: spec/dataSource/objectRef/name - kind: VirtualImage - - path: spec/dataSource/objectRef/name - kind: ClusterVirtualImage diff --git a/test/e2e/legacy/testdata/images-creation/vd/kustomization.yaml b/test/e2e/legacy/testdata/images-creation/vd/kustomization.yaml deleted file mode 100644 index 00754911b6..0000000000 --- a/test/e2e/legacy/testdata/images-creation/vd/kustomization.yaml +++ /dev/null @@ -1,4 +0,0 @@ -apiVersion: kustomize.config.k8s.io/v1beta1 -kind: Kustomization -resources: - - vd-alpine-http.yaml diff --git a/test/e2e/legacy/testdata/images-creation/vd/vd-alpine-http.yaml b/test/e2e/legacy/testdata/images-creation/vd/vd-alpine-http.yaml deleted file mode 100644 index 69deac61b0..0000000000 --- a/test/e2e/legacy/testdata/images-creation/vd/vd-alpine-http.yaml +++ /dev/null @@ -1,13 +0,0 @@ ---- -apiVersion: virtualization.deckhouse.io/v1alpha2 -kind: VirtualDisk -metadata: - name: vd-alpine-http -spec: - dataSource: - type: HTTP - http: - url: https://89d64382-20df-4581-8cc7-80df331f67fa.selstorage.ru/alpine/alpine-3-21-uefi-perf.qcow2 - persistentVolumeClaim: - storageClassName: "{{ .STORAGE_CLASS_NAME }}" - size: 370Mi diff --git a/test/e2e/legacy/testdata/images-creation/vdsnapshot/kustomization.yaml b/test/e2e/legacy/testdata/images-creation/vdsnapshot/kustomization.yaml deleted file mode 100644 index ebce4baedf..0000000000 --- a/test/e2e/legacy/testdata/images-creation/vdsnapshot/kustomization.yaml +++ /dev/null @@ -1,4 +0,0 @@ -apiVersion: kustomize.config.k8s.io/v1beta1 -kind: Kustomization -resources: - - vdsnapshot.yaml diff --git a/test/e2e/legacy/testdata/images-creation/vdsnapshot/vdsnapshot.yaml b/test/e2e/legacy/testdata/images-creation/vdsnapshot/vdsnapshot.yaml deleted file mode 100644 index 115ea2c729..0000000000 --- a/test/e2e/legacy/testdata/images-creation/vdsnapshot/vdsnapshot.yaml +++ /dev/null @@ -1,7 +0,0 @@ -apiVersion: virtualization.deckhouse.io/v1alpha2 -kind: VirtualDiskSnapshot -metadata: - name: vdsnapshot -spec: - requiredConsistency: true - virtualDiskName: vd-alpine-http diff --git a/test/e2e/legacy/testdata/images-creation/vi/kustomization.yaml b/test/e2e/legacy/testdata/images-creation/vi/kustomization.yaml deleted file mode 100644 index 6ec4dd412a..0000000000 --- a/test/e2e/legacy/testdata/images-creation/vi/kustomization.yaml +++ /dev/null @@ -1,10 +0,0 @@ -apiVersion: kustomize.config.k8s.io/v1beta1 -kind: Kustomization -resources: - - ./vi_http.yaml - - ./vi_containerimage.yaml - - ./vi_objectref_cvi.yaml - - ./vi_objectref_vi.yaml - - ./vi_pvc_objectref_vi.yaml - - ./vi_objectref_vd.yaml - - ./vi_objectref_vdsnapshot.yaml diff --git a/test/e2e/legacy/testdata/images-creation/vi/vi_containerimage.yaml b/test/e2e/legacy/testdata/images-creation/vi/vi_containerimage.yaml deleted file mode 100644 index 3925003ea2..0000000000 --- a/test/e2e/legacy/testdata/images-creation/vi/vi_containerimage.yaml +++ /dev/null @@ -1,29 +0,0 @@ -apiVersion: virtualization.deckhouse.io/v1alpha2 -kind: VirtualImage -metadata: - name: vi-containerimage - namespace: test-d8-virtualization - annotations: - virt.deckhouse.io/storage.pod.retainAfterCompletion: "true" -spec: - storage: ContainerRegistry - dataSource: - type: ContainerImage - containerImage: - image: "cr.yandex/crpvs5j3nh1mi2tpithr/e2e/alpine/alpine-image:latest" ---- -apiVersion: virtualization.deckhouse.io/v1alpha2 -kind: VirtualImage -metadata: - name: vi-pvc-containerimage - namespace: test-d8-virtualization - annotations: - virt.deckhouse.io/storage.pod.retainAfterCompletion: "true" -spec: - storage: PersistentVolumeClaim - persistentVolumeClaim: - storageClassName: "{{ .STORAGE_CLASS_NAME }}" - dataSource: - type: ContainerImage - containerImage: - image: "cr.yandex/crpvs5j3nh1mi2tpithr/e2e/alpine/alpine-image:latest" diff --git a/test/e2e/legacy/testdata/images-creation/vi/vi_http.yaml b/test/e2e/legacy/testdata/images-creation/vi/vi_http.yaml deleted file mode 100644 index 1827a318ef..0000000000 --- a/test/e2e/legacy/testdata/images-creation/vi/vi_http.yaml +++ /dev/null @@ -1,25 +0,0 @@ -apiVersion: virtualization.deckhouse.io/v1alpha2 -kind: VirtualImage -metadata: - name: vi-http - namespace: test-d8-virtualization -spec: - storage: ContainerRegistry - dataSource: - type: "HTTP" - http: - url: https://89d64382-20df-4581-8cc7-80df331f67fa.selstorage.ru/alpine/alpine-virt-3.21.0-x86.iso ---- -apiVersion: virtualization.deckhouse.io/v1alpha2 -kind: VirtualImage -metadata: - name: vi-pvc-http - namespace: test-d8-virtualization -spec: - storage: PersistentVolumeClaim - persistentVolumeClaim: - storageClassName: "{{ .STORAGE_CLASS_NAME }}" - dataSource: - type: "HTTP" - http: - url: https://89d64382-20df-4581-8cc7-80df331f67fa.selstorage.ru/alpine/alpine-virt-3.21.0-x86.iso diff --git a/test/e2e/legacy/testdata/images-creation/vi/vi_objectref_cvi.yaml b/test/e2e/legacy/testdata/images-creation/vi/vi_objectref_cvi.yaml deleted file mode 100644 index c86c21f167..0000000000 --- a/test/e2e/legacy/testdata/images-creation/vi/vi_objectref_cvi.yaml +++ /dev/null @@ -1,27 +0,0 @@ -apiVersion: virtualization.deckhouse.io/v1alpha2 -kind: VirtualImage -metadata: - name: vi-oref-cvi - namespace: test-d8-virtualization -spec: - storage: ContainerRegistry - dataSource: - type: "ObjectRef" - objectRef: - kind: "ClusterVirtualImage" - name: cvi-http ---- -apiVersion: virtualization.deckhouse.io/v1alpha2 -kind: VirtualImage -metadata: - name: vi-pvc-oref-cvi - namespace: test-d8-virtualization -spec: - storage: PersistentVolumeClaim - persistentVolumeClaim: - storageClassName: "{{ .STORAGE_CLASS_NAME }}" - dataSource: - type: "ObjectRef" - objectRef: - kind: "ClusterVirtualImage" - name: cvi-http diff --git a/test/e2e/legacy/testdata/images-creation/vi/vi_objectref_vd.yaml b/test/e2e/legacy/testdata/images-creation/vi/vi_objectref_vd.yaml deleted file mode 100644 index 757d955386..0000000000 --- a/test/e2e/legacy/testdata/images-creation/vi/vi_objectref_vd.yaml +++ /dev/null @@ -1,27 +0,0 @@ -apiVersion: virtualization.deckhouse.io/v1alpha2 -kind: VirtualImage -metadata: - name: vi-oref-vd - namespace: test-d8-virtualization -spec: - storage: ContainerRegistry - dataSource: - type: "ObjectRef" - objectRef: - kind: "VirtualDisk" - name: vd-alpine-http ---- -apiVersion: virtualization.deckhouse.io/v1alpha2 -kind: VirtualImage -metadata: - name: vi-pvc-oref-vd - namespace: test-d8-virtualization -spec: - storage: PersistentVolumeClaim - persistentVolumeClaim: - storageClassName: "{{ .STORAGE_CLASS_NAME }}" - dataSource: - type: "ObjectRef" - objectRef: - kind: "VirtualDisk" - name: vd-alpine-http diff --git a/test/e2e/legacy/testdata/images-creation/vi/vi_objectref_vdsnapshot.yaml b/test/e2e/legacy/testdata/images-creation/vi/vi_objectref_vdsnapshot.yaml deleted file mode 100644 index f34ab55c78..0000000000 --- a/test/e2e/legacy/testdata/images-creation/vi/vi_objectref_vdsnapshot.yaml +++ /dev/null @@ -1,27 +0,0 @@ -apiVersion: virtualization.deckhouse.io/v1alpha2 -kind: VirtualImage -metadata: - name: vi-oref-vdsnapshot - namespace: test-d8-virtualization -spec: - storage: ContainerRegistry - dataSource: - type: "ObjectRef" - objectRef: - kind: "VirtualDiskSnapshot" - name: vdsnapshot ---- -apiVersion: virtualization.deckhouse.io/v1alpha2 -kind: VirtualImage -metadata: - name: vi-pvc-oref-vdsnapshot - namespace: test-d8-virtualization -spec: - storage: PersistentVolumeClaim - persistentVolumeClaim: - storageClassName: "{{ .STORAGE_CLASS_NAME }}" - dataSource: - type: "ObjectRef" - objectRef: - kind: "VirtualDiskSnapshot" - name: vdsnapshot diff --git a/test/e2e/legacy/testdata/images-creation/vi/vi_objectref_vi.yaml b/test/e2e/legacy/testdata/images-creation/vi/vi_objectref_vi.yaml deleted file mode 100644 index b11ab35844..0000000000 --- a/test/e2e/legacy/testdata/images-creation/vi/vi_objectref_vi.yaml +++ /dev/null @@ -1,132 +0,0 @@ -# DVCR -apiVersion: virtualization.deckhouse.io/v1alpha2 -kind: VirtualImage -metadata: - name: vi-oref-vi-http - namespace: test-d8-virtualization -spec: - storage: ContainerRegistry - dataSource: - type: "ObjectRef" - objectRef: - kind: "VirtualImage" - name: vi-http ---- -apiVersion: virtualization.deckhouse.io/v1alpha2 -kind: VirtualImage -metadata: - name: vi-oref-vi-conimg - namespace: test-d8-virtualization -spec: - storage: ContainerRegistry - dataSource: - type: "ObjectRef" - objectRef: - kind: "VirtualImage" - name: vi-containerimage ---- -apiVersion: virtualization.deckhouse.io/v1alpha2 -kind: VirtualImage -metadata: - name: vi-oref-vi-oref-cvi - namespace: test-d8-virtualization -spec: - storage: ContainerRegistry - dataSource: - type: "ObjectRef" - objectRef: - kind: "VirtualImage" - name: vi-oref-cvi ---- -apiVersion: virtualization.deckhouse.io/v1alpha2 -kind: VirtualImage -metadata: - name: vi-oref-vi-oref-vd - namespace: test-d8-virtualization -spec: - storage: ContainerRegistry - dataSource: - type: "ObjectRef" - objectRef: - kind: "VirtualImage" - name: vi-oref-vd ---- -apiVersion: virtualization.deckhouse.io/v1alpha2 -kind: VirtualImage -metadata: - name: vi-oref-vi-oref-vdsnp - namespace: test-d8-virtualization -spec: - storage: ContainerRegistry - dataSource: - type: "ObjectRef" - objectRef: - kind: "VirtualImage" - name: vi-oref-vdsnapshot - -# PVC SOURCE ---- -apiVersion: virtualization.deckhouse.io/v1alpha2 -kind: VirtualImage -metadata: - name: vi-oref-vi-http-pvc - namespace: test-d8-virtualization -spec: - storage: ContainerRegistry - dataSource: - type: "ObjectRef" - objectRef: - kind: "VirtualImage" - name: vi-pvc-http ---- -apiVersion: virtualization.deckhouse.io/v1alpha2 -kind: VirtualImage -metadata: - name: vi-oref-vi-con-img-pvc - namespace: test-d8-virtualization -spec: - storage: ContainerRegistry - dataSource: - type: "ObjectRef" - objectRef: - kind: "VirtualImage" - name: vi-pvc-containerimage ---- -apiVersion: virtualization.deckhouse.io/v1alpha2 -kind: VirtualImage -metadata: - name: vi-oref-vi-oref-cvi-pvc - namespace: test-d8-virtualization -spec: - storage: ContainerRegistry - dataSource: - type: "ObjectRef" - objectRef: - kind: "VirtualImage" - name: vi-pvc-oref-cvi ---- -apiVersion: virtualization.deckhouse.io/v1alpha2 -kind: VirtualImage -metadata: - name: vi-oref-vi-oref-vd-pvc - namespace: test-d8-virtualization -spec: - storage: ContainerRegistry - dataSource: - type: "ObjectRef" - objectRef: - kind: "VirtualImage" - name: vi-pvc-oref-vd ---- -apiVersion: virtualization.deckhouse.io/v1alpha2 -kind: VirtualImage -metadata: - name: vi-ref-vi-ref-vdsnp-pvc - namespace: test-d8-virtualization -spec: - storage: ContainerRegistry - dataSource: - type: "ObjectRef" - objectRef: - kind: "VirtualImage" - name: vi-pvc-oref-vdsnapshot diff --git a/test/e2e/legacy/testdata/images-creation/vi/vi_pvc_objectref_vi.yaml b/test/e2e/legacy/testdata/images-creation/vi/vi_pvc_objectref_vi.yaml deleted file mode 100644 index 817b65c2dd..0000000000 --- a/test/e2e/legacy/testdata/images-creation/vi/vi_pvc_objectref_vi.yaml +++ /dev/null @@ -1,137 +0,0 @@ -### DVCR -apiVersion: virtualization.deckhouse.io/v1alpha2 -kind: VirtualImage -metadata: - name: vi-pvc-oref-vi-http - namespace: test-d8-virtualization -spec: - storage: PersistentVolumeClaim - persistentVolumeClaim: - storageClassName: "{{ .STORAGE_CLASS_NAME }}" - dataSource: - type: "ObjectRef" - objectRef: - kind: "VirtualImage" - name: vi-http ---- -apiVersion: virtualization.deckhouse.io/v1alpha2 -kind: VirtualImage -metadata: - name: vi-pvc-oref-vi-con-img - namespace: test-d8-virtualization -spec: - storage: PersistentVolumeClaim - persistentVolumeClaim: - storageClassName: "{{ .STORAGE_CLASS_NAME }}" - dataSource: - type: "ObjectRef" - objectRef: - kind: "VirtualImage" - name: vi-containerimage ---- -apiVersion: virtualization.deckhouse.io/v1alpha2 -kind: VirtualImage -metadata: - name: vi-pvc-oref-vi-oref-cvi - namespace: test-d8-virtualization -spec: - storage: PersistentVolumeClaim - persistentVolumeClaim: - storageClassName: "{{ .STORAGE_CLASS_NAME }}" - dataSource: - type: "ObjectRef" - objectRef: - kind: "VirtualImage" - name: vi-oref-cvi ---- -apiVersion: virtualization.deckhouse.io/v1alpha2 -kind: VirtualImage -metadata: - name: vi-pvc-oref-vi-oref-vd - namespace: test-d8-virtualization -spec: - storage: PersistentVolumeClaim - persistentVolumeClaim: - storageClassName: "{{ .STORAGE_CLASS_NAME }}" - dataSource: - type: "ObjectRef" - objectRef: - kind: "VirtualImage" - name: vi-oref-vd ---- -apiVersion: virtualization.deckhouse.io/v1alpha2 -kind: VirtualImage -metadata: - name: vi-pvc-ref-vi-ref-vdsnp - namespace: test-d8-virtualization -spec: - storage: PersistentVolumeClaim - persistentVolumeClaim: - storageClassName: "{{ .STORAGE_CLASS_NAME }}" - dataSource: - type: "ObjectRef" - objectRef: - kind: "VirtualImage" - name: vi-oref-vdsnapshot - -### PVC ---- -apiVersion: virtualization.deckhouse.io/v1alpha2 -kind: VirtualImage -metadata: - name: vi-pvc-oref-vi-http-pvc - namespace: test-d8-virtualization -spec: - storage: PersistentVolumeClaim - persistentVolumeClaim: - storageClassName: "{{ .STORAGE_CLASS_NAME }}" - dataSource: - type: "ObjectRef" - objectRef: - kind: "VirtualImage" - name: vi-pvc-http ---- -apiVersion: virtualization.deckhouse.io/v1alpha2 -kind: VirtualImage -metadata: - name: vi-pvc-rf-vi-conimg-pvc - namespace: test-d8-virtualization -spec: - storage: PersistentVolumeClaim - persistentVolumeClaim: - storageClassName: "{{ .STORAGE_CLASS_NAME }}" - dataSource: - type: "ObjectRef" - objectRef: - kind: "VirtualImage" - name: vi-pvc-containerimage ---- -apiVersion: virtualization.deckhouse.io/v1alpha2 -kind: VirtualImage -metadata: - name: vi-pvc-rf-vi-rf-vd-pvc - namespace: test-d8-virtualization -spec: - storage: PersistentVolumeClaim - persistentVolumeClaim: - storageClassName: "{{ .STORAGE_CLASS_NAME }}" - dataSource: - type: "ObjectRef" - objectRef: - kind: "VirtualImage" - name: vi-pvc-oref-vd ---- -apiVersion: virtualization.deckhouse.io/v1alpha2 -kind: VirtualImage -metadata: - name: vi-pvc-rf-vi-rf-vds-pvc - namespace: test-d8-virtualization -spec: - storage: PersistentVolumeClaim - persistentVolumeClaim: - storageClassName: "{{ .STORAGE_CLASS_NAME }}" - dataSource: - type: "ObjectRef" - objectRef: - kind: "VirtualImage" - name: vi-pvc-oref-vdsnapshot diff --git a/test/e2e/vm/volume_migration_local_disks.go b/test/e2e/vm/volume_migration_local_disks.go index c45a84af63..03bfdaa461 100644 --- a/test/e2e/vm/volume_migration_local_disks.go +++ b/test/e2e/vm/volume_migration_local_disks.go @@ -63,7 +63,7 @@ var _ = Describe("LocalVirtualDiskMigration", Ordered, ContinueOnFailure, func() DeferCleanup(f.After) - newVI := object.NewGeneratedHTTPVIUbuntu("volume-migration-local-disks-") + newVI := object.NewGeneratedHTTPVIUbuntu("volume-migration-local-disks-", f.Namespace().Name) 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 5912aac496..6638dcceeb 100644 --- a/test/e2e/vm/volume_migration_storage_class_changed.go +++ b/test/e2e/vm/volume_migration_storage_class_changed.go @@ -75,7 +75,7 @@ var _ = Describe("StorageClassMigration", Ordered, ContinueOnFailure, func() { DeferCleanup(f.After) - newVI := object.NewGeneratedHTTPVIUbuntu("volume-migration-storage-class-changed-") + newVI := object.NewGeneratedHTTPVIUbuntu("volume-migration-storage-class-changed-", f.Namespace().Name) newVI, err = f.VirtClient().VirtualImages(f.Namespace().Name).Create(context.Background(), newVI, metav1.CreateOptions{}) Expect(err).NotTo(HaveOccurred()) f.DeferDelete(newVI)