diff --git a/.dmtlint.yaml b/.dmtlint.yaml index 9ec052bb20..5b858bcbf1 100644 --- a/.dmtlint.yaml +++ b/.dmtlint.yaml @@ -52,7 +52,6 @@ linters-settings: directories: - tools/addlicense/testdata - test/performance/ssh - - test/e2e/legacy/testdata/sshkeys - images/dvcr-artifact/staging container: exclude-rules: diff --git a/.github/workflows/e2e-reusable-pipeline.yml b/.github/workflows/e2e-reusable-pipeline.yml index 9a452bb0b0..a6ac96e71e 100644 --- a/.github/workflows/e2e-reusable-pipeline.yml +++ b/.github/workflows/e2e-reusable-pipeline.yml @@ -1376,8 +1376,6 @@ jobs: e2e_output_file="e2e_output_${CSI}_${DATE}.log" FOCUS="${{ inputs.e2e_focus_tests }}" - cp -a legacy/testdata /tmp/testdata - echo "[INFO] Kubernetes server version: ${SERVER_K8S_VERSION}" echo "[INFO] USB E2E supported: ${USB_SUPPORTED}" if [ -n "${LABELS:-}" ]; then diff --git a/.gitleaks.toml b/.gitleaks.toml index 0fad91b9f5..5ca52f5a08 100644 --- a/.gitleaks.toml +++ b/.gitleaks.toml @@ -24,15 +24,12 @@ commits = [ "7779a9548280e3d28cd44555efe6d0e18a106b09", # images/virtualization-artifact/config/vm_sysprep.yaml - example config "552a06eb1d2f50ca2d765d42c5ab4d701c92a555", - # legacy entry - "d964aca8c51cc3f2dcd0d72b6016fa6ad94c1ce4", ] paths = [ # test files and data '''^images/dvcr-artifact/pkg/uploader/testdata/auth.json$''', '''^images/hooks/pkg/hooks/generate-secret-for-dvcr/hook_test.go$''', '''^images/hooks/cmd/generate-secret-for-dvcr/main_test\.go$''', - '''^test/e2e/legacy/testdata/sshkeys/id_ed$''', '''^test/e2e/internal/object/const.go$''', '''^tests/e2e/object/const\.go$''', '''^tests/e2e/testdata/connectivity/sshkeys/id_ed$''', diff --git a/test/e2e/README.md b/test/e2e/README.md index 5260edfda2..7c77029e78 100644 --- a/test/e2e/README.md +++ b/test/e2e/README.md @@ -92,7 +92,7 @@ task runp - Use the FOCUS environment variable to run a specific test. - Set `POST_CLEANUP=never` to disable cleanup after tests (takes precedence over `postCleanupMode` in config). - Set LABELS to run tests with specific label(https://onsi.github.io/ginkgo/#spec-labels). -- Manage timeouts for new e2e tests (not for legacy tests) using env variables `E2E_SHORT_TIMEOUT`, `E2E_MIDDLE_TIMEOUT`, `E2E_LONG_TIMEOUT` and `E2E_MAX_TIMEOUT`. +- Manage timeouts for e2e tests using env variables `E2E_SHORT_TIMEOUT`, `E2E_MIDDLE_TIMEOUT`, `E2E_LONG_TIMEOUT` and `E2E_MAX_TIMEOUT`. For example, to run only one test and leave all created resources in the cluster, use the following command: ```bash diff --git a/test/e2e/Taskfile.yaml b/test/e2e/Taskfile.yaml index ba503e6e96..25fedf7790 100644 --- a/test/e2e/Taskfile.yaml +++ b/test/e2e/Taskfile.yaml @@ -6,16 +6,6 @@ vars: VERSION: "v1.0.0" tasks: - copy: - cmds: - - | - if [ "{{OS}}" == "darwin" ]; then - rm -rf /tmp/testdata - else - rm --force --recursive /tmp/testdata - fi - cp -a legacy/testdata /tmp/testdata - kubectl: cmds: - | @@ -37,7 +27,6 @@ tasks: env: FOCUS: "VirtualMachineAdditionalNetworkInterfaces" deps: - - copy - kubectl - d8 - precheck:prepare @@ -55,7 +44,6 @@ tasks: run: desc: "Run e2e tests" deps: - - copy - kubectl - d8 - precheck:prepare @@ -87,7 +75,6 @@ tasks: runp: desc: "Run e2e tests in parallel mode" deps: - - copy - kubectl - d8 cmds: diff --git a/test/e2e/default_config.yaml b/test/e2e/default_config.yaml index ba96dcd37d..1474cb39ec 100644 --- a/test/e2e/default_config.yaml +++ b/test/e2e/default_config.yaml @@ -17,13 +17,6 @@ clusterTransport: helperImages: curlImage: "curlimages/curl" -testData: - imageHotplug: "/tmp/testdata/image-hotplug" - sizingPolicy: "/tmp/testdata/sizing-policy" - vmConfiguration: "/tmp/testdata/vm-configuration" - vmMigration: "/tmp/testdata/vm-migration" - sshKey: "/tmp/testdata/sshkeys/id_ed" - sshUser: "cloud" logFilter: - "pattern to exclude" - "validation failed for data source objectref" # Err. diff --git a/test/e2e/e2e_test.go b/test/e2e/e2e_test.go index be3911b5bd..a6bd06ff67 100644 --- a/test/e2e/e2e_test.go +++ b/test/e2e/e2e_test.go @@ -29,7 +29,6 @@ import ( "github.com/deckhouse/virtualization/test/e2e/controller" "github.com/deckhouse/virtualization/test/e2e/internal/framework" "github.com/deckhouse/virtualization/test/e2e/internal/precheck" - "github.com/deckhouse/virtualization/test/e2e/legacy" _ "github.com/deckhouse/virtualization/test/e2e/snapshot" _ "github.com/deckhouse/virtualization/test/e2e/vm" _ "github.com/deckhouse/virtualization/test/e2e/vmop" @@ -45,7 +44,6 @@ var _ = SynchronizedBeforeSuite(func() { // Initialize test resources BEFORE running prechecks // This ensures resources are available even if prechecks fail controller.NewBeforeProcess1Body() - legacy.NewBeforeProcess1Body() // Validate precheck labels from JSON report (created by dry-run during prepare) if err := precheck.ValidateFromJSONFile(precheck.LabelsFile); err != nil { @@ -62,6 +60,5 @@ var _ = SynchronizedAfterSuite(func() { // Cleanup precreated CVIs if PRECREATED_CVI_CLEANUP=yes precheck.CleanupPrecreatedCVIs(context.Background(), framework.NewFramework("")) }, func() { - legacy.NewAfterAllProcessBody() controller.NewAfterAllProcessBody() }) diff --git a/test/e2e/internal/config/config.go b/test/e2e/internal/config/config.go index 07c168d637..71fd05f5c6 100644 --- a/test/e2e/internal/config/config.go +++ b/test/e2e/internal/config/config.go @@ -17,13 +17,10 @@ limitations under the License. package config import ( - "errors" "fmt" "os" "path/filepath" - "reflect" "regexp" - "slices" "strconv" "github.com/onsi/ginkgo/v2" @@ -73,7 +70,6 @@ type Config struct { ClusterTransport ClusterTransport `yaml:"clusterTransport"` HelperImages HelperImages `yaml:"helperImages"` NamespaceSuffix string `yaml:"namespaceSuffix"` - TestData TestData `yaml:"testData"` LogFilter []string `yaml:"logFilter"` CleanupResources []string `yaml:"cleanupResources"` RegexpLogFilter []regexp.Regexp `yaml:"regexpLogFilter"` @@ -110,13 +106,6 @@ const ( PostCleanupNoOnFailure PostCleanupMode = "no-on-failure" ) -type TestData struct { - ImageHotplug string `yaml:"imageHotplug"` - VMMigration string `yaml:"vmMigration"` - Sshkey string `yaml:"sshKey"` - SSHUser string `yaml:"sshUser"` -} - type StorageClass struct { DefaultStorageClass *storagev1.StorageClass ImmediateStorageClass *storagev1.StorageClass @@ -189,26 +178,6 @@ func (c *Config) setEnvs() error { return nil } -func (c *Config) GetTestCases() ([]string, error) { - testDataValue := reflect.ValueOf(c.TestData) - testDataType := reflect.TypeOf(c.TestData) - excludedData := []string{"Sshkey", "SSHUser"} - testCases := make([]string, 0, testDataType.NumField()-len(excludedData)) - - if testDataType.Kind() == reflect.Struct { - for i := 0; i < testDataType.NumField(); i++ { - field := testDataType.Field(i) - value := testDataValue.Field(i) - if !slices.Contains(excludedData, field.Name) { - testCases = append(testCases, fmt.Sprintf("%v", value.Interface())) - } - } - return testCases, nil - } else { - return nil, errors.New("`config.TestData` it is not a structure") - } -} - func (k *Kustomize) SetParams(filePath, namespace, namePrefix string) error { var kustomizeFile Kustomize diff --git a/test/e2e/internal/framework/config.go b/test/e2e/internal/framework/config.go index fa00c5ce50..09397aba3a 100644 --- a/test/e2e/internal/framework/config.go +++ b/test/e2e/internal/framework/config.go @@ -46,8 +46,7 @@ func GetConfig() *config.Config { } // SetConfig sets the config. -// this needs because we have some legacy, config mutating in the main test suite -// should be refactored in the future +// TODO: avoid mutable shared config in the main test suite. func SetConfig(c *config.Config) { conf = c } diff --git a/test/e2e/internal/framework/git.go b/test/e2e/internal/framework/git.go index 059b04871e..d16cfdbbf3 100644 --- a/test/e2e/internal/framework/git.go +++ b/test/e2e/internal/framework/git.go @@ -16,50 +16,8 @@ limitations under the License. package framework -import ( - "errors" - "fmt" - "os" - - storagev1 "k8s.io/api/storage/v1" -) - const ( Ceph = "rbd.csi.ceph.com" SDSReplicatedVolume = "replicated.csi.storage.deckhouse.io" NFS = "nfs.csi.k8s.io" ) - -// Deprecated: do not use for new e2e tests (only for legacy ones). -func (f *Framework) GetNamePrefix(storageClass *storagev1.StorageClass) (string, error) { - if prNumber, ok := os.LookupEnv("MODULES_MODULE_TAG"); ok && prNumber != "" { - return prNumber, nil - } - - res := f.git.GetHeadHash() - if !res.WasSuccess() { - return "", errors.New(res.StdErr()) - } - - commitHash := res.StdOut() - commitHash = commitHash[:5] - namePrefix := fmt.Sprintf("v12n-%s", commitHash) - - var scPrefix string - if storageClass != nil { - switch storageClass.Provisioner { - case Ceph: - scPrefix = "ceph" - case SDSReplicatedVolume: - scPrefix = "sds-rep-vol" - case NFS: - scPrefix = "nfs" - default: - scPrefix = "unknown-csi" - } - - namePrefix = fmt.Sprintf("%s-%s", namePrefix, scPrefix) - } - - return namePrefix, nil -} diff --git a/test/e2e/internal/object/precreated_cvi.go b/test/e2e/internal/object/precreated_cvi.go index 0820a9b218..96f7a80cd7 100644 --- a/test/e2e/internal/object/precreated_cvi.go +++ b/test/e2e/internal/object/precreated_cvi.go @@ -32,7 +32,6 @@ const ( PrecreatedCVIUbuntu = "v12n-e2e-ubuntu" PrecreatedCVIUbuntuISO = "v12n-e2e-ubuntu-iso" PrecreatedCVIContainerImage = "v12n-e2e-container-image" - PrecreatedCVILegacyRegistry = "v12n-e2e-legacy-registry" PrecreatedCVICirros = "v12n-e2e-cirros" PrecreatedCVIDebian = "v12n-e2e-debian" PrecreatedCVITestDataQCOW = "v12n-e2e-testdata-qcow" @@ -48,8 +47,7 @@ const ( 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" + ImageURLContainerImage = "cr.yandex/crpvs5j3nh1mi2tpithr/e2e/alpine/alpine-image:latest" // Test data (not bootable) ImageTestDataQCOW = imageBaseURL + "/test/test.qcow2" @@ -66,7 +64,6 @@ func PrecreatedClusterVirtualImages() []*v1alpha2.ClusterVirtualImage { newPrecreatedHTTPCVI(PrecreatedCVIUbuntu, ImageURLUbuntu), newPrecreatedHTTPCVI(PrecreatedCVIUbuntuISO, ImageURLUbuntuISO), newPrecreatedContainerImageCVI(PrecreatedCVIContainerImage, ImageURLContainerImage), - newPrecreatedContainerImageCVI(PrecreatedCVILegacyRegistry, ImageURLLegacyContainerImage), newPrecreatedHTTPCVI(PrecreatedCVICirros, ImageURLCirros), newPrecreatedHTTPCVI(PrecreatedCVIDebian, ImageURLDebian), newPrecreatedHTTPCVI(PrecreatedCVITestDataQCOW, ImageTestDataQCOW), diff --git a/test/e2e/internal/util/project.go b/test/e2e/internal/util/project.go deleted file mode 100644 index 89165a6159..0000000000 --- a/test/e2e/internal/util/project.go +++ /dev/null @@ -1,55 +0,0 @@ -/* -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 ( - "fmt" - - . "github.com/onsi/gomega" - storagev1 "k8s.io/api/storage/v1" - - dv1alpha2 "github.com/deckhouse/virtualization/test/e2e/internal/api/deckhouse/v1alpha2" - "github.com/deckhouse/virtualization/test/e2e/internal/config" - "github.com/deckhouse/virtualization/test/e2e/internal/framework" -) - -// Deprecated: Should be deleted. -func PrepareProject(testData string, storageClass *storagev1.StorageClass) { - kustomize := &config.Kustomize{} - - kustomization := fmt.Sprintf("%s/%s", testData, "kustomization.yaml") - ns, err := kustomize.GetNamespace(kustomization) - Expect(err).NotTo(HaveOccurred(), err) - project := dv1alpha2.Project{} - projectFilePath := fmt.Sprintf("%s/project/project.yaml", testData) - - err = UnmarshalResource(projectFilePath, &project) - Expect(err).NotTo(HaveOccurred(), "cannot get project from file: %s\nstderr: %s", projectFilePath, err) - - namePrefix, err := framework.NewFramework("").GetNamePrefix(storageClass) - Expect(err).NotTo(HaveOccurred(), "cannot get name prefix\nstderr: %s", err) - - project.Name = ns - - if project.Labels == nil { - project.SetLabels(make(map[string]string)) - } - project.Labels["id"] = namePrefix - - err = WriteYamlObject(projectFilePath, &project) - Expect(err).NotTo(HaveOccurred(), "cannot update project with id and labels: %s\nstderr: %s", projectFilePath, err) -} diff --git a/test/e2e/legacy/image_hotplug.go b/test/e2e/legacy/image_hotplug.go deleted file mode 100644 index ce3a5d2494..0000000000 --- a/test/e2e/legacy/image_hotplug.go +++ /dev/null @@ -1,441 +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 ( - "encoding/json" - "errors" - "fmt" - "strings" - - . "github.com/onsi/ginkgo/v2" - . "github.com/onsi/gomega" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - virtv1 "kubevirt.io/api/core/v1" - - "github.com/deckhouse/virtualization/api/core/v1alpha2" - "github.com/deckhouse/virtualization/test/e2e/internal/config" - "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/object" - "github.com/deckhouse/virtualization/test/e2e/internal/precheck" - "github.com/deckhouse/virtualization/test/e2e/internal/util" -) - -const ( - DiskIDPrefix = "scsi-0QEMU_QEMU_HARDDISK" - CdRomIDPrefix = "scsi-0QEMU_QEMU_CD-ROM_drive-ua" - unacceptableCount = -1000 -) - -var APIVersion = v1alpha2.SchemeGroupVersion.String() - -var _ = Describe("ImageHotplug", Ordered, label.Legacy(), Label(precheck.NoPrecheck), func() { - const ( - viCount = 2 - cviCount = 2 - vmCount = 1 - imgCount = viCount + cviCount - ) - - var ( - vmObj v1alpha2.VirtualMachine - disksBefore Disks - disksAfter Disks - testCaseLabel = map[string]string{"testcase": "image-hotplug"} - ns string - ) - - BeforeAll(func() { - if conf.StorageClass.TemplateStorageClass != nil && conf.StorageClass.TemplateStorageClass.Provisioner == config.NFS { - Skip("VirtualImages on PVC only work with block storage classes, skipping NFS") - } - - kustomization := fmt.Sprintf("%s/%s", conf.TestData.ImageHotplug, "kustomization.yaml") - var err error - ns, err = kustomize.GetNamespace(kustomization) - Expect(err).NotTo(HaveOccurred(), "%w", err) - - CreateNamespace(ns) - }) - - AfterEach(func() { - if CurrentSpecReport().Failed() { - SaveTestCaseDump(testCaseLabel, CurrentSpecReport().LeafNodeText, ns) - } - }) - - AfterAll(func() { - if conf.IsCleanupNeeded() { - DeleteTestCaseResources(ns, ResourcesToDelete{ - KustomizationDir: conf.TestData.ImageHotplug, - }) - } - }) - - Context("When the virtualization resources are applied", func() { - It("result should be succeeded", func() { - res := kubectl.Apply(kc.ApplyOptions{ - Filename: []string{conf.TestData.ImageHotplug}, - FilenameOption: kc.Kustomize, - }) - Expect(res.Error()).NotTo(HaveOccurred(), res.StdErr()) - }) - - 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("`VirtualDisk` should be in the %q phase", v1alpha2.DiskReady), func() { - WaitPhaseByLabel(kc.ResourceVD, PhaseReady, kc.WaitOptions{ - Labels: testCaseLabel, - Namespace: ns, - Timeout: MaxWaitTimeout, - }) - }) - By("`VirtualMachine` agent should be ready", func() { - WaitVMAgentReady(kc.WaitOptions{ - Labels: testCaseLabel, - Namespace: ns, - Timeout: MaxWaitTimeout, - }) - }) - }) - }) - - Context("When the resources are ready to use", func() { - imageBlockDevices := make([]Image, 0, imgCount) - - It("retrieves the test objects", func() { - By("`VirtualMachine`", func() { - vmObjs := &v1alpha2.VirtualMachineList{} - err := GetObjects(v1alpha2.VirtualMachineResource, vmObjs, kc.GetOptions{ - Labels: testCaseLabel, - Namespace: ns, - }) - Expect(err).NotTo(HaveOccurred(), "failed to get `VirtualMachines`: %s", err) - Expect(len(vmObjs.Items)).To(Equal(vmCount), "there is only %d `VirtualMachine` in this test case", vmCount) - vmObj = vmObjs.Items[0] - }) - By("`VirtualImages`", func() { - viObjs := &v1alpha2.VirtualImageList{} - err := GetObjects(v1alpha2.VirtualImageResource, viObjs, kc.GetOptions{ - Labels: testCaseLabel, - Namespace: ns, - }) - Expect(err).NotTo(HaveOccurred(), "failed to get `VirtualImages`: %s", err) - - for _, viObj := range viObjs.Items { - imageBlockDevices = append(imageBlockDevices, Image{ - Kind: viObj.Kind, - Name: viObj.Name, - }) - } - }) - By("`ClusterVirtualImages`", func() { - // 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) - - imageBlockDevices = append(imageBlockDevices, Image{ - Kind: cviObj.Kind, - Name: cviObj.Name, - }) - } - }) - }) - - It("retrieves the disk count before the images attachment", func() { - Eventually(func() error { - return GetDisksMetadata(ns, vmObj.Name, &disksBefore) - }).WithTimeout(Timeout).WithPolling(Interval).ShouldNot(HaveOccurred(), "virtualMachine: %s", vmObj.Name) - }) - - It("attaches the images into the `VirtualMachine`", func() { - for _, bd := range imageBlockDevices { - By(bd.Name, func() { - AttachBlockDevice(ns, vmObj.Name, bd.Name, v1alpha2.VMBDAObjectRefKind(bd.Kind), testCaseLabel, conf.TestData.ImageHotplug) - }) - } - }) - - It("checks the `VirtualMachine` and the `VirtualMachineBlockDeviceAttachments` phases", func() { - By(fmt.Sprintf("`VirtualMachineBlockDeviceAttachments` should be in the %q phase", v1alpha2.BlockDeviceAttachmentPhaseAttached), func() { - WaitPhaseByLabel(kc.ResourceVMBDA, PhaseAttached, kc.WaitOptions{ - Labels: testCaseLabel, - Namespace: ns, - Timeout: MaxWaitTimeout, - }) - }) - By("`VirtualMachine` should be ready", func() { - WaitVMAgentReady(kc.WaitOptions{ - Labels: testCaseLabel, - Namespace: ns, - Timeout: MaxWaitTimeout, - }) - }) - By("`BlockDevices` should be attached", func() { - WaitBlockDeviceRefsAttached(ns, vmObj.Name) - }) - }) - - It("compares the disk count before and after attachment", func() { - diskCountBefore := len(disksBefore.BlockDevices) - Eventually(func() (int, error) { - err := GetDisksMetadata(ns, vmObj.Name, &disksAfter) - if err != nil { - return unacceptableCount, err - } - diskCountAfter := len(disksAfter.BlockDevices) - return diskCountAfter, nil - }).WithTimeout(Timeout).WithPolling(Interval).Should(Equal(diskCountBefore+imgCount), "comparing error: 'after' must be equal 'before + %d'", imgCount) - }) - - It("checks that the `ISO` image is attached as `CD-ROM`", func() { - var ( - isoBlockDeviceName string - isolockDeviceCount int - ) - intVirtVmi := &virtv1.VirtualMachineInstance{} - err := GetObject(kc.ResourceKubevirtVMI, vmObj.Name, intVirtVmi, kc.GetOptions{ - Namespace: ns, - }) - Expect(err).NotTo(HaveOccurred(), "failed to get `InternalVirtualMachineInstance`: %s", err) - for _, disk := range intVirtVmi.Spec.Domain.Devices.Disks { - if disk.CDRom != nil { - isoBlockDeviceName = disk.Name - isolockDeviceCount += 1 - } - } - Expect(isolockDeviceCount).To(Equal(1), "there is only one `ISO` block device in this case") - isCdRom, err := IsBlockDeviceCdRom(ns, vmObj.Name, isoBlockDeviceName) - Expect(err).NotTo(HaveOccurred(), "failed to get `BlockDeviceType` of %q: %s", isoBlockDeviceName, err) - Expect(isCdRom).Should(BeTrue(), "wrong type of the block device: %s", isoBlockDeviceName) - }) - - It("check that the images are attached as the `ReadOnly` devices", func() { - imgs := make(map[string]string, imgCount) - intVirtVmi := &virtv1.VirtualMachineInstance{} - err := GetObject(kc.ResourceKubevirtVMI, vmObj.Name, intVirtVmi, kc.GetOptions{ - Namespace: ns, - }) - Expect(err).NotTo(HaveOccurred(), "failed to get `InternalVirtulMachineInstance`: %s", err) - for _, disk := range intVirtVmi.Spec.Domain.Devices.Disks { - switch { - case strings.HasSuffix(disk.Name, "iso"): - imgs[disk.Name] = fmt.Sprintf("%s-%s", CdRomIDPrefix, disk.Name) - case strings.HasPrefix(disk.Name, "cvi-") || strings.HasPrefix(disk.Name, "vi-"): - imgs[disk.Name] = fmt.Sprintf("%s_%s", DiskIDPrefix, disk.Serial) - } - } - - Expect(len(imgs)).To(Equal(imgCount), "there are only %d `blockDevices` in this case", imgCount) - for img, diskID := range imgs { - err := MountBlockDevice(ns, vmObj.Name, diskID) - Expect(err).NotTo(HaveOccurred(), "failed to mount %q into the `VirtualMachine`: %s", img, err) - isReadOnly, err := IsBlockDeviceReadOnly(ns, vmObj.Name, diskID) - Expect(err).NotTo(HaveOccurred(), "failed to check the `ReadOnly` status: %s", img) - Expect(isReadOnly).Should(BeTrue(), "the mounted disk should be `ReadOnly`") - } - }) - - It("detaches the images", func() { - res := kubectl.Delete(kc.DeleteOptions{ - FilenameOption: kc.Filename, - Filename: []string{fmt.Sprintf("%s/vmbda", conf.TestData.ImageHotplug)}, - Namespace: ns, - Labels: testCaseLabel, - }) - Expect(res.Error()).NotTo(HaveOccurred(), "failed to delete `VirtualMachineBlockDeviceAttachments`: %s", res.StdErr()) - }) - - It("compares the disk count after detachment", func() { - diskCountBefore := len(disksBefore.BlockDevices) - Expect(diskCountBefore).NotTo(BeZero(), "the disk count `before` should not be zero") - Eventually(func() (int, error) { - err := GetDisksMetadata(ns, vmObj.Name, &disksAfter) - if err != nil { - return unacceptableCount, err - } - diskCountAfter := len(disksAfter.BlockDevices) - return diskCountAfter, nil - }).WithTimeout(Timeout).WithPolling(Interval).Should(Equal(diskCountBefore), "comparing error: 'after' must be equal 'before'") - }) - }) -}) - -type Image struct { - Kind string - Name string -} - -func IsBlockDeviceCdRom(vmNamespace, vmName, blockDeviceName string) (bool, error) { - var blockDevices *BlockDevices - bdIDPath := fmt.Sprintf("/dev/disk/by-id/%s-%s", CdRomIDPrefix, blockDeviceName) - cmd := fmt.Sprintf("lsblk --json --nodeps --output name,type %s", bdIDPath) - res := framework.GetClients().D8Virtualization().SSHCommand(vmName, cmd, d8.SSHOptions{ - Namespace: vmNamespace, - Username: conf.TestData.SSHUser, - IdentityFile: conf.TestData.Sshkey, - }) - if res.Error() != nil { - return false, errors.New(res.StdErr()) - } - err := json.Unmarshal(res.StdOutBytes(), &blockDevices) - if err != nil { - return false, err - } - if len(blockDevices.BlockDevices) != 1 { - return false, fmt.Errorf("`blockDevices` length should be 1") - } - blockDevice := &blockDevices.BlockDevices[0] - return blockDevice.Type == "rom", nil -} - -func MountBlockDevice(vmNamespace, vmName, blockDeviceID string) error { - bdIDPath := fmt.Sprintf("/dev/disk/by-id/%s", blockDeviceID) - cmd := fmt.Sprintf("sudo mount --read-only %s /mnt", bdIDPath) - res := framework.GetClients().D8Virtualization().SSHCommand(vmName, cmd, d8.SSHOptions{ - Namespace: vmNamespace, - Username: conf.TestData.SSHUser, - IdentityFile: conf.TestData.Sshkey, - }) - if res.Error() != nil { - return errors.New(res.StdErr()) - } - return nil -} - -func IsBlockDeviceReadOnly(vmNamespace, vmName, blockDeviceID string) (bool, error) { - bdIDPath := fmt.Sprintf("/dev/disk/by-id/%s", blockDeviceID) - cmd := fmt.Sprintf("findmnt --noheadings --output options %s", bdIDPath) - res := framework.GetClients().D8Virtualization().SSHCommand(vmName, cmd, d8.SSHOptions{ - Namespace: vmNamespace, - Username: conf.TestData.SSHUser, - IdentityFile: conf.TestData.Sshkey, - }) - if res.Error() != nil { - return false, errors.New(res.StdErr()) - } - options := strings.Split(res.StdOut(), ",") - if len(options) == 0 { - return false, fmt.Errorf("list of options is empty: %s", options) - } - roOpt := options[0] - return roOpt == "ro", nil -} - -// lsblk JSON output -type Disks struct { - BlockDevices []BlockDevice `json:"blockdevices"` -} - -type BlockDevices struct { - BlockDevices []BlockDevice `json:"blockdevices"` -} - -type BlockDevice struct { - Name string `json:"name"` - Size string `json:"size"` - Type string `json:"type"` -} - -func AttachBlockDevice(vmNamespace, vmName, blockDeviceName string, blockDeviceType v1alpha2.VMBDAObjectRefKind, labels map[string]string, testDataPath string) { - vmbdaFilePath := fmt.Sprintf("%s/vmbda/%s.yaml", testDataPath, blockDeviceName) - err := CreateVMBDAManifest(vmbdaFilePath, vmName, blockDeviceName, blockDeviceType, labels) - Expect(err).NotTo(HaveOccurred(), "%v", err) - - res := kubectl.Apply(kc.ApplyOptions{ - Filename: []string{vmbdaFilePath}, - FilenameOption: kc.Filename, - Namespace: vmNamespace, - }) - Expect(res.Error()).NotTo(HaveOccurred(), res.StdErr()) -} - -func CreateVMBDAManifest(filePath, vmName, blockDeviceName string, blockDeviceType v1alpha2.VMBDAObjectRefKind, labels map[string]string) error { - vmbda := &v1alpha2.VirtualMachineBlockDeviceAttachment{ - TypeMeta: metav1.TypeMeta{ - APIVersion: APIVersion, - Kind: v1alpha2.VirtualMachineBlockDeviceAttachmentKind, - }, - ObjectMeta: metav1.ObjectMeta{ - Name: blockDeviceName, - Labels: labels, - }, - Spec: v1alpha2.VirtualMachineBlockDeviceAttachmentSpec{ - VirtualMachineName: vmName, - BlockDeviceRef: v1alpha2.VMBDAObjectRef{ - Kind: blockDeviceType, - Name: blockDeviceName, - }, - }, - } - - err := util.WriteYamlObject(filePath, vmbda) - if err != nil { - return err - } - - return nil -} - -func GetDisksMetadata(vmNamespace, vmName string, disks *Disks) error { - GinkgoHelper() - cmd := "lsblk --nodeps --json" - res := framework.GetClients().D8Virtualization().SSHCommand(vmName, cmd, d8.SSHOptions{ - Namespace: vmNamespace, - Username: conf.TestData.SSHUser, - IdentityFile: conf.TestData.Sshkey, - }) - if res.Error() != nil { - return fmt.Errorf("cmd: %s\nstderr: %s", res.GetCmd(), res.StdErr()) - } - err := json.Unmarshal(res.StdOutBytes(), disks) - if err != nil { - return fmt.Errorf("failed when getting disk count\nvirtualMachine: %s/%s\nstderr: %s", vmNamespace, vmName, res.StdErr()) - } - return nil -} - -func WaitBlockDeviceRefsAttached(namespace string, vms ...string) { - GinkgoHelper() - Eventually(func() error { - for _, vmName := range vms { - vm := v1alpha2.VirtualMachine{} - err := GetObject(v1alpha2.VirtualMachineResource, vmName, &vm, kc.GetOptions{Namespace: namespace}) - if err != nil { - return fmt.Errorf("virtualMachine: %s\nstderr: %w", vmName, err) - } - for _, bd := range vm.Status.BlockDeviceRefs { - if !bd.Attached { - return fmt.Errorf("virtualMachine: %s\nblockDeviceRefs: %#v", vmName, bd) - } - } - } - return nil - }).WithTimeout(Timeout).WithPolling(Interval).Should(Succeed()) -} diff --git a/test/e2e/legacy/legacy.go b/test/e2e/legacy/legacy.go deleted file mode 100644 index 0472c21ace..0000000000 --- a/test/e2e/legacy/legacy.go +++ /dev/null @@ -1,262 +0,0 @@ -/* -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 legacy - -import ( - "context" - "errors" - "fmt" - "reflect" - "sync" - "time" - - . "github.com/onsi/ginkgo/v2" - . "github.com/onsi/gomega" - storagev1 "k8s.io/api/storage/v1" - k8serrors "k8s.io/apimachinery/pkg/api/errors" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - crclient "sigs.k8s.io/controller-runtime/pkg/client" - - dv1alpha2 "github.com/deckhouse/virtualization/test/e2e/internal/api/deckhouse/v1alpha2" - "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" -) - -const ( - Interval = 5 * time.Second - ShortTimeout = 30 * time.Second - Timeout = 90 * time.Second - ShortWaitDuration = 60 * time.Second - LongWaitDuration = 300 * time.Second - MaxWaitTimeout = 1000 * time.Second - PhaseAttached = "Attached" - PhaseReady = "Ready" - PhasePending = "Pending" - PhaseRunning = "Running" - storageClassName = "STORAGE_CLASS_NAME" - testDataDir = "/tmp/testdata" -) - -var ( - conf *config.Config - kustomize *config.Kustomize - kubectl kc.Kubectl - namePrefix string -) - -// Init configures the legacy package. -// This should be called before using legacy test functions. -func Init() error { - return configure() -} - -func configure() (err error) { - conf = framework.GetConfig() - defer framework.SetConfig(conf) - - clients := framework.GetClients() - kubectl = clients.Kubectl() - - var scList storagev1.StorageClassList - if err := clients.GenericClient().List(context.Background(), &scList); err != nil { - return fmt.Errorf("failed to list StorageClasses: %w", err) - } - - conf.StorageClass.DefaultStorageClass = config.FindDefaultStorageClass(&scList) - if conf.StorageClass.DefaultStorageClass == nil { - return fmt.Errorf("default StorageClass not found in the cluster") - } - - conf.StorageClass.ImmediateStorageClass = config.FindImmediateStorageClass(conf.StorageClass.DefaultStorageClass, &scList) - - scFromEnv, err := GetStorageClassFromEnv(storageClassName) - if err != nil { - return err - } - - if scFromEnv != nil { - conf.StorageClass.TemplateStorageClass = scFromEnv - } else { - conf.StorageClass.TemplateStorageClass = conf.StorageClass.DefaultStorageClass - } - - if err = SetStorageClass(testDataDir, map[string]string{storageClassName: conf.StorageClass.TemplateStorageClass.Name}); err != nil { - return err - } - - //nolint:staticcheck // It can be used in legacy tests. - namePrefix, err = framework.NewFramework("").GetNamePrefix(conf.StorageClass.TemplateStorageClass) - if err != nil { - return err - } - - if err = ChmodFile(conf.TestData.Sshkey, 0o600); err != nil { - return err - } - - return nil -} - -func NewBeforeProcess1Body() { - if err := Init(); err != nil { - panic(fmt.Errorf("failed to init legacy: %w", err)) - } - - var kustomizationFiles []string - v := reflect.ValueOf(conf.TestData) - t := reflect.TypeOf(conf.TestData) - - if v.Kind() == reflect.Struct { - for i := range v.NumField() { - field := v.Field(i) - fieldType := t.Field(i) - - // Ignore - if fieldType.Name == "Sshkey" || fieldType.Name == "SSHUser" { - continue - } - - if field.Kind() == reflect.String { - path := fmt.Sprintf("%s/%s", field.String(), "kustomization.yaml") - kustomizationFiles = append(kustomizationFiles, path) - } - } - } - - ns := fmt.Sprintf("%s-%s", namePrefix, conf.NamespaceSuffix) - for _, filePath := range kustomizationFiles { - err := kustomize.SetParams(filePath, ns, namePrefix) - if err != nil { - Expect(err).NotTo(HaveOccurred()) - } - } - - Expect(Cleanup()).To(Succeed()) -} - -func NewAfterAllProcessBody() { - if conf.IsCleanupNeeded() { - Expect(Cleanup()).To(Succeed()) - } -} - -func Cleanup() error { - err := deleteProjects() - if err != nil { - return err - } - - var wg sync.WaitGroup - errChan := make(chan error, 2) - - wg.Add(1) - go func() { - defer GinkgoRecover() - defer wg.Done() - if err := deleteNamespaces(); err != nil { - errChan <- err - } - }() - - wg.Add(1) - go func() { - defer GinkgoRecover() - defer wg.Done() - if err := deleteResources(); err != nil { - errChan <- err - } - }() - - go func() { - defer GinkgoRecover() - wg.Wait() - close(errChan) - }() - - for err := range errChan { - if err != nil { - return err - } - } - - return nil -} - -func deleteProjects() error { - genericClient := framework.GetClients().GenericClient() - - projects := &dv1alpha2.ProjectList{} - err := genericClient.List(context.Background(), projects, crclient.MatchingLabels{"id": namePrefix}) - if err != nil { - return err - } - - var errs error - for _, project := range projects.Items { - err = genericClient.Delete(context.Background(), &project) - if err != nil && !k8serrors.IsNotFound(err) { - errs = errors.Join(errs, err) - } - } - - return errs -} - -func deleteNamespaces() error { - testCases, err := conf.GetTestCases() - if err != nil { - return err - } - - kubeClient := framework.GetClients().KubeClient() - - var cleanupErr error - - for _, tc := range testCases { - kustomizeFilePath := fmt.Sprintf("%s/kustomization.yaml", tc) - namespace, err := kustomize.GetNamespace(kustomizeFilePath) - if err != nil { - cleanupErr = errors.Join(cleanupErr, err) - continue - } - - err = kubeClient.CoreV1().Namespaces().Delete(context.Background(), namespace, metav1.DeleteOptions{}) - if err != nil && !k8serrors.IsNotFound(err) { - cleanupErr = errors.Join(cleanupErr, err) - continue - } - } - - return cleanupErr -} - -func deleteResources() error { - var cleanupErr error - for _, r := range conf.CleanupResources { - res := kubectl.Delete(kc.DeleteOptions{ - IgnoreNotFound: true, - Labels: map[string]string{"id": namePrefix}, - Resource: kc.Resource(r), - }) - if res.Error() != nil { - cleanupErr = errors.Join(cleanupErr, fmt.Errorf("cmd: %s\nstderr: %s", res.GetCmd(), res.StdErr())) - } - } - - return cleanupErr -} diff --git a/test/e2e/legacy/testdata/image-hotplug/base/cfg/cloudinit.yaml b/test/e2e/legacy/testdata/image-hotplug/base/cfg/cloudinit.yaml deleted file mode 100644 index b2372f3279..0000000000 --- a/test/e2e/legacy/testdata/image-hotplug/base/cfg/cloudinit.yaml +++ /dev/null @@ -1,11 +0,0 @@ -#cloud-config -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 diff --git a/test/e2e/legacy/testdata/image-hotplug/base/kustomization.yaml b/test/e2e/legacy/testdata/image-hotplug/base/kustomization.yaml deleted file mode 100644 index d820a3f566..0000000000 --- a/test/e2e/legacy/testdata/image-hotplug/base/kustomization.yaml +++ /dev/null @@ -1,14 +0,0 @@ -apiVersion: kustomize.config.k8s.io/v1beta1 -kind: Kustomization -resources: - - ./vm.yaml - - ./vd-root.yaml -configurations: - - transformer.yaml -generatorOptions: - disableNameSuffixHash: true -secretGenerator: - - files: - - userData=cfg/cloudinit.yaml - name: cloud-init - type: provisioning.virtualization.deckhouse.io/cloud-init diff --git a/test/e2e/legacy/testdata/image-hotplug/base/transformer.yaml b/test/e2e/legacy/testdata/image-hotplug/base/transformer.yaml deleted file mode 100644 index 1dc146a3af..0000000000 --- a/test/e2e/legacy/testdata/image-hotplug/base/transformer.yaml +++ /dev/null @@ -1,54 +0,0 @@ -# https://github.com/kubernetes-sigs/kustomize/blob/master/examples/transformerconfigs/README.md#transformer-configurations - -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 - - kind: Secret - fieldSpecs: - - path: spec/provisioning/userDataRef/name - kind: VirtualMachine - - kind: VirtualMachineIPAddress - version: v1alpha2 - fieldSpecs: - - path: spec/virtualMachineIPAddressName - kind: VirtualMachine - - kind: VirtualMachine - version: v1alpha2 - fieldSpecs: - - path: spec/virtualMachineName - kind: VirtualMachineBlockDeviceAttachment - - kind: VirtualMachineClass - version: v1alpha3 - fieldSpecs: - - path: spec/virtualMachineClassName - kind: VirtualMachine diff --git a/test/e2e/legacy/testdata/image-hotplug/base/vd-root.yaml b/test/e2e/legacy/testdata/image-hotplug/base/vd-root.yaml deleted file mode 100644 index 0f98ff3633..0000000000 --- a/test/e2e/legacy/testdata/image-hotplug/base/vd-root.yaml +++ /dev/null @@ -1,13 +0,0 @@ -apiVersion: virtualization.deckhouse.io/v1alpha2 -kind: VirtualDisk -metadata: - name: vd-root -spec: - persistentVolumeClaim: - storageClassName: "{{ .STORAGE_CLASS_NAME }}" - size: 512Mi - dataSource: - type: ObjectRef - objectRef: - kind: VirtualImage - name: vi-alpine-http diff --git a/test/e2e/legacy/testdata/image-hotplug/base/vm.yaml b/test/e2e/legacy/testdata/image-hotplug/base/vm.yaml deleted file mode 100644 index 04d8ff038b..0000000000 --- a/test/e2e/legacy/testdata/image-hotplug/base/vm.yaml +++ /dev/null @@ -1,22 +0,0 @@ -apiVersion: virtualization.deckhouse.io/v1alpha2 -kind: VirtualMachine -metadata: - name: vm -spec: - bootloader: BIOS - virtualMachineClassName: generic - cpu: - cores: 1 - coreFraction: 50% - memory: - size: 256Mi - disruptions: - restartApprovalMode: Manual - provisioning: - type: UserDataRef - userDataRef: - kind: Secret - name: cloud-init - blockDeviceRefs: - - kind: VirtualDisk - name: vd-root diff --git a/test/e2e/legacy/testdata/image-hotplug/kustomization.yaml b/test/e2e/legacy/testdata/image-hotplug/kustomization.yaml deleted file mode 100644 index a642cb0684..0000000000 --- a/test/e2e/legacy/testdata/image-hotplug/kustomization.yaml +++ /dev/null @@ -1,15 +0,0 @@ -apiVersion: kustomize.config.k8s.io/v1beta1 -kind: Kustomization -namespace: testcases -namePrefix: pr-number-or-commit-hash- -resources: - - ns.yaml - - vi - - overlays/image-hotplug -configurations: - - transformer.yaml -labels: - - includeSelectors: true - pairs: - id: pr-number-or-commit-hash - testcase: image-hotplug diff --git a/test/e2e/legacy/testdata/image-hotplug/ns.yaml b/test/e2e/legacy/testdata/image-hotplug/ns.yaml deleted file mode 100644 index 5efde875b6..0000000000 --- a/test/e2e/legacy/testdata/image-hotplug/ns.yaml +++ /dev/null @@ -1,4 +0,0 @@ -apiVersion: v1 -kind: Namespace -metadata: - name: default diff --git a/test/e2e/legacy/testdata/image-hotplug/overlays/image-hotplug/kustomization.yaml b/test/e2e/legacy/testdata/image-hotplug/overlays/image-hotplug/kustomization.yaml deleted file mode 100644 index 449b726e0b..0000000000 --- a/test/e2e/legacy/testdata/image-hotplug/overlays/image-hotplug/kustomization.yaml +++ /dev/null @@ -1,20 +0,0 @@ -apiVersion: kustomize.config.k8s.io/v1beta1 -kind: Kustomization -nameSuffix: -image-hotplug -resources: - - ../../base -patches: - - patch: |- - - op: replace - path: /spec/runPolicy - value: AlwaysOn - target: - kind: VirtualMachine - name: vm - - patch: |- - - op: replace - path: /spec/disruptions/restartApprovalMode - value: Automatic - target: - kind: VirtualMachine - name: vm diff --git a/test/e2e/legacy/testdata/image-hotplug/transformer.yaml b/test/e2e/legacy/testdata/image-hotplug/transformer.yaml deleted file mode 100644 index ec70d37fcd..0000000000 --- a/test/e2e/legacy/testdata/image-hotplug/transformer.yaml +++ /dev/null @@ -1,52 +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 - - kind: Secret - fieldSpecs: - - path: spec/provisioning/userDataRef/name - kind: VirtualMachine - - kind: VirtualMachineIPAddress - version: v1alpha2 - fieldSpecs: - - path: spec/virtualMachineIPAddressName - kind: VirtualMachine - - kind: VirtualMachine - version: v1alpha2 - fieldSpecs: - - path: spec/virtualMachineName - kind: VirtualMachineBlockDeviceAttachment - - kind: VirtualMachineClass - version: v1alpha3 - fieldSpecs: - - path: spec/virtualMachineClassName - kind: VirtualMachine diff --git a/test/e2e/legacy/testdata/image-hotplug/vi/kustomization.yaml b/test/e2e/legacy/testdata/image-hotplug/vi/kustomization.yaml deleted file mode 100644 index 4f93175290..0000000000 --- a/test/e2e/legacy/testdata/image-hotplug/vi/kustomization.yaml +++ /dev/null @@ -1,5 +0,0 @@ -apiVersion: kustomize.config.k8s.io/v1beta1 -kind: Kustomization -resources: - - vi-alpine-http.yaml - - vi-pvc-alpine-http.yaml diff --git a/test/e2e/legacy/testdata/image-hotplug/vi/vi-alpine-http.yaml b/test/e2e/legacy/testdata/image-hotplug/vi/vi-alpine-http.yaml deleted file mode 100644 index c8b09cd34d..0000000000 --- a/test/e2e/legacy/testdata/image-hotplug/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-bios-perf.qcow2 diff --git a/test/e2e/legacy/testdata/image-hotplug/vi/vi-pvc-alpine-http.yaml b/test/e2e/legacy/testdata/image-hotplug/vi/vi-pvc-alpine-http.yaml deleted file mode 100644 index 229c978df9..0000000000 --- a/test/e2e/legacy/testdata/image-hotplug/vi/vi-pvc-alpine-http.yaml +++ /dev/null @@ -1,13 +0,0 @@ ---- -apiVersion: virtualization.deckhouse.io/v1alpha2 -kind: VirtualImage -metadata: - name: vi-pvc-alpine-http -spec: - storage: PersistentVolumeClaim - persistentVolumeClaim: - storageClassName: "{{ .STORAGE_CLASS_NAME }}" - 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/vmbda/.keep b/test/e2e/legacy/testdata/image-hotplug/vmbda/.keep deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/test/e2e/legacy/testdata/sshkeys/id_ed b/test/e2e/legacy/testdata/sshkeys/id_ed deleted file mode 100644 index ad9652cae0..0000000000 --- a/test/e2e/legacy/testdata/sshkeys/id_ed +++ /dev/null @@ -1,7 +0,0 @@ ------BEGIN OPENSSH PRIVATE KEY----- -b3BlbnNzaC1rZXktdjEAAAAABG5vbmUAAAAEbm9uZQAAAAAAAAABAAAAMwAAAAtzc2gtZW -QyNTUxOQAAACBcXFx5sGhpyfLHCWhDeUc5JQT2aVUonOBnWgLCo0KHgAAAAKDCANDUwgDQ -1AAAAAtzc2gtZWQyNTUxOQAAACBcXFx5sGhpyfLHCWhDeUc5JQT2aVUonOBnWgLCo0KHgA -AAAED/iI2D9QTc70eISkYFC/TrXG3JpHYLu5FqQhGCTxveElxcXHmwaGnJ8scJaEN5Rzkl -BPZpVSic4GdaAsKjQoeAAAAAFnlvdXJfZW1haWxAZXhhbXBsZS5jb20BAgMEBQYH ------END OPENSSH PRIVATE KEY----- diff --git a/test/e2e/legacy/testdata/sshkeys/id_ed.pub b/test/e2e/legacy/testdata/sshkeys/id_ed.pub deleted file mode 100644 index 737703c561..0000000000 --- a/test/e2e/legacy/testdata/sshkeys/id_ed.pub +++ /dev/null @@ -1 +0,0 @@ -ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIFxcXHmwaGnJ8scJaEN5RzklBPZpVSic4GdaAsKjQoeA your_email@example.com diff --git a/test/e2e/legacy/testdata/templates/kustomization.yaml b/test/e2e/legacy/testdata/templates/kustomization.yaml deleted file mode 100644 index 25ef538eed..0000000000 --- a/test/e2e/legacy/testdata/templates/kustomization.yaml +++ /dev/null @@ -1,12 +0,0 @@ -apiVersion: kustomize.config.k8s.io/v1beta1 -kind: Kustomization -namespace: testcases -namePrefix: pr-number-or-commit-hash- -resources: - - ns.yaml -configurations: - - transformer.yaml -labels: - - includeSelectors: true - pairs: - id: pr-number-or-commit-hash diff --git a/test/e2e/legacy/testdata/templates/ns.yaml b/test/e2e/legacy/testdata/templates/ns.yaml deleted file mode 100644 index 5efde875b6..0000000000 --- a/test/e2e/legacy/testdata/templates/ns.yaml +++ /dev/null @@ -1,4 +0,0 @@ -apiVersion: v1 -kind: Namespace -metadata: - name: default diff --git a/test/e2e/legacy/testdata/templates/transformer.yaml b/test/e2e/legacy/testdata/templates/transformer.yaml deleted file mode 100644 index ec70d37fcd..0000000000 --- a/test/e2e/legacy/testdata/templates/transformer.yaml +++ /dev/null @@ -1,52 +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 - - kind: Secret - fieldSpecs: - - path: spec/provisioning/userDataRef/name - kind: VirtualMachine - - kind: VirtualMachineIPAddress - version: v1alpha2 - fieldSpecs: - - path: spec/virtualMachineIPAddressName - kind: VirtualMachine - - kind: VirtualMachine - version: v1alpha2 - fieldSpecs: - - path: spec/virtualMachineName - kind: VirtualMachineBlockDeviceAttachment - - kind: VirtualMachineClass - version: v1alpha3 - fieldSpecs: - - path: spec/virtualMachineClassName - kind: VirtualMachine diff --git a/test/e2e/legacy/testdata/vd-snapshots/snapshots/.keep b/test/e2e/legacy/testdata/vd-snapshots/snapshots/.keep deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/test/e2e/legacy/testdata/vm-evacuation/migrations/.keep b/test/e2e/legacy/testdata/vm-evacuation/migrations/.keep deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/test/e2e/legacy/testdata/vm-migration-cancel/migrations/.keep b/test/e2e/legacy/testdata/vm-migration-cancel/migrations/.keep deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/test/e2e/legacy/testdata/vm-migration/kustomization.yaml b/test/e2e/legacy/testdata/vm-migration/kustomization.yaml deleted file mode 100644 index 0ef3f36322..0000000000 --- a/test/e2e/legacy/testdata/vm-migration/kustomization.yaml +++ /dev/null @@ -1,15 +0,0 @@ -apiVersion: kustomize.config.k8s.io/v1beta1 -kind: Kustomization -namespace: testcases -namePrefix: pr-number-or-commit-hash- -resources: - - vi - - vm - - ns.yaml -configurations: - - transformer.yaml -labels: - - includeSelectors: true - pairs: - id: pr-number-or-commit-hash - testcase: vm-migration diff --git a/test/e2e/legacy/testdata/vm-migration/migrations/.keep b/test/e2e/legacy/testdata/vm-migration/migrations/.keep deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/test/e2e/legacy/testdata/vm-migration/ns.yaml b/test/e2e/legacy/testdata/vm-migration/ns.yaml deleted file mode 100644 index 5efde875b6..0000000000 --- a/test/e2e/legacy/testdata/vm-migration/ns.yaml +++ /dev/null @@ -1,4 +0,0 @@ -apiVersion: v1 -kind: Namespace -metadata: - name: default diff --git a/test/e2e/legacy/testdata/vm-migration/transformer.yaml b/test/e2e/legacy/testdata/vm-migration/transformer.yaml deleted file mode 100644 index ec70d37fcd..0000000000 --- a/test/e2e/legacy/testdata/vm-migration/transformer.yaml +++ /dev/null @@ -1,52 +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 - - kind: Secret - fieldSpecs: - - path: spec/provisioning/userDataRef/name - kind: VirtualMachine - - kind: VirtualMachineIPAddress - version: v1alpha2 - fieldSpecs: - - path: spec/virtualMachineIPAddressName - kind: VirtualMachine - - kind: VirtualMachine - version: v1alpha2 - fieldSpecs: - - path: spec/virtualMachineName - kind: VirtualMachineBlockDeviceAttachment - - kind: VirtualMachineClass - version: v1alpha3 - fieldSpecs: - - path: spec/virtualMachineClassName - kind: VirtualMachine diff --git a/test/e2e/legacy/testdata/vm-migration/vi/kustomization.yaml b/test/e2e/legacy/testdata/vm-migration/vi/kustomization.yaml deleted file mode 100644 index f9c61289fc..0000000000 --- a/test/e2e/legacy/testdata/vm-migration/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/vi/vi-alpine-http-bios.yaml b/test/e2e/legacy/testdata/vm-migration/vi/vi-alpine-http-bios.yaml deleted file mode 100644 index 681822ea6c..0000000000 --- a/test/e2e/legacy/testdata/vm-migration/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/vi/vi-alpine-http-uefi.yaml b/test/e2e/legacy/testdata/vm-migration/vi/vi-alpine-http-uefi.yaml deleted file mode 100644 index c210fb37a5..0000000000 --- a/test/e2e/legacy/testdata/vm-migration/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/vm/base/cfg/cloudinit.yaml b/test/e2e/legacy/testdata/vm-migration/vm/base/cfg/cloudinit.yaml deleted file mode 100644 index dde99db581..0000000000 --- a/test/e2e/legacy/testdata/vm-migration/vm/base/cfg/cloudinit.yaml +++ /dev/null @@ -1,24 +0,0 @@ -#cloud-config -package_update: true -packages: - - qemu-guest-agent - - curl - - bash - - sudo - - iputils - - iperf3 -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 -final_message: "\U0001F525\U0001F525\U0001F525 The system is finally up, after ${updame} \U0001F525\U0001F525\U0001F525" -runcmd: - - "echo \"\U0001F7E1 Starting runcmd at $(date +%H:%M:%S)\"" - - "rc-update add qemu-guest-agent && rc-service qemu-guest-agent start" - - "echo \"\U0001F7E1 Finished runcmd at $(date +%H:%M:%S)\"" diff --git a/test/e2e/legacy/testdata/vm-migration/vm/base/kustomization.yaml b/test/e2e/legacy/testdata/vm-migration/vm/base/kustomization.yaml deleted file mode 100644 index 8ff06116f3..0000000000 --- a/test/e2e/legacy/testdata/vm-migration/vm/base/kustomization.yaml +++ /dev/null @@ -1,15 +0,0 @@ -apiVersion: kustomize.config.k8s.io/v1beta1 -kind: Kustomization -resources: - - ./vm.yaml - - ./vd-root.yaml - - ./vd-blank.yaml -configurations: - - transformer.yaml -generatorOptions: - disableNameSuffixHash: true -secretGenerator: - - files: - - userData=cfg/cloudinit.yaml - name: cloud-init - type: provisioning.virtualization.deckhouse.io/cloud-init diff --git a/test/e2e/legacy/testdata/vm-migration/vm/base/transformer.yaml b/test/e2e/legacy/testdata/vm-migration/vm/base/transformer.yaml deleted file mode 100644 index 1dc146a3af..0000000000 --- a/test/e2e/legacy/testdata/vm-migration/vm/base/transformer.yaml +++ /dev/null @@ -1,54 +0,0 @@ -# https://github.com/kubernetes-sigs/kustomize/blob/master/examples/transformerconfigs/README.md#transformer-configurations - -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 - - kind: Secret - fieldSpecs: - - path: spec/provisioning/userDataRef/name - kind: VirtualMachine - - kind: VirtualMachineIPAddress - version: v1alpha2 - fieldSpecs: - - path: spec/virtualMachineIPAddressName - kind: VirtualMachine - - kind: VirtualMachine - version: v1alpha2 - fieldSpecs: - - path: spec/virtualMachineName - kind: VirtualMachineBlockDeviceAttachment - - kind: VirtualMachineClass - version: v1alpha3 - fieldSpecs: - - path: spec/virtualMachineClassName - kind: VirtualMachine diff --git a/test/e2e/legacy/testdata/vm-migration/vm/base/vd-blank.yaml b/test/e2e/legacy/testdata/vm-migration/vm/base/vd-blank.yaml deleted file mode 100644 index fcc4b94ea8..0000000000 --- a/test/e2e/legacy/testdata/vm-migration/vm/base/vd-blank.yaml +++ /dev/null @@ -1,8 +0,0 @@ -apiVersion: virtualization.deckhouse.io/v1alpha2 -kind: VirtualDisk -metadata: - name: vd-blank -spec: - persistentVolumeClaim: - storageClassName: "{{ .STORAGE_CLASS_NAME }}" - size: 100Mi diff --git a/test/e2e/legacy/testdata/vm-migration/vm/base/vd-root.yaml b/test/e2e/legacy/testdata/vm-migration/vm/base/vd-root.yaml deleted file mode 100644 index c2bf54f1ff..0000000000 --- a/test/e2e/legacy/testdata/vm-migration/vm/base/vd-root.yaml +++ /dev/null @@ -1,13 +0,0 @@ -apiVersion: virtualization.deckhouse.io/v1alpha2 -kind: VirtualDisk -metadata: - name: vd-root -spec: - persistentVolumeClaim: - storageClassName: "{{ .STORAGE_CLASS_NAME }}" - size: 350Mi - dataSource: - type: ObjectRef - objectRef: - kind: VirtualImage - name: vi-alpine-http diff --git a/test/e2e/legacy/testdata/vm-migration/vm/base/vm.yaml b/test/e2e/legacy/testdata/vm-migration/vm/base/vm.yaml deleted file mode 100644 index 880706eacd..0000000000 --- a/test/e2e/legacy/testdata/vm-migration/vm/base/vm.yaml +++ /dev/null @@ -1,24 +0,0 @@ -apiVersion: virtualization.deckhouse.io/v1alpha2 -kind: VirtualMachine -metadata: - name: vm -spec: - bootloader: EFI - virtualMachineClassName: generic - cpu: - cores: 1 - coreFraction: 20% - memory: - size: 256Mi - disruptions: - restartApprovalMode: Manual - provisioning: - type: UserDataRef - userDataRef: - kind: Secret - name: cloud-init - blockDeviceRefs: - - kind: VirtualDisk - name: vd-root - - kind: VirtualDisk - name: vd-blank diff --git a/test/e2e/legacy/testdata/vm-migration/vm/kustomization.yaml b/test/e2e/legacy/testdata/vm-migration/vm/kustomization.yaml deleted file mode 100644 index 7becc7eb6b..0000000000 --- a/test/e2e/legacy/testdata/vm-migration/vm/kustomization.yaml +++ /dev/null @@ -1,6 +0,0 @@ -apiVersion: kustomize.config.k8s.io/v1beta1 -kind: Kustomization -resources: - - overlays/migration-bios - - overlays/migration-uefi -# - overlays/with-cvi # TODO: Remove Skip after fixing the issue. diff --git a/test/e2e/legacy/testdata/vm-migration/vm/overlays/migration-always-forced/kustomization.yaml b/test/e2e/legacy/testdata/vm-migration/vm/overlays/migration-always-forced/kustomization.yaml deleted file mode 100644 index f829843d99..0000000000 --- a/test/e2e/legacy/testdata/vm-migration/vm/overlays/migration-always-forced/kustomization.yaml +++ /dev/null @@ -1,17 +0,0 @@ -apiVersion: kustomize.config.k8s.io/v1beta1 -kind: Kustomization -nameSuffix: -migration-always-forced -resources: - - ../../base -patches: - - path: vd.image.patch.yaml - - patch: |- - - op: replace - path: /spec/bootloader - value: BIOS - - op: replace - path: /spec/liveMigrationPolicy - value: AlwaysForced - target: - kind: VirtualMachine - name: vm diff --git a/test/e2e/legacy/testdata/vm-migration/vm/overlays/migration-always-forced/vd.image.patch.yaml b/test/e2e/legacy/testdata/vm-migration/vm/overlays/migration-always-forced/vd.image.patch.yaml deleted file mode 100644 index 0805403f38..0000000000 --- a/test/e2e/legacy/testdata/vm-migration/vm/overlays/migration-always-forced/vd.image.patch.yaml +++ /dev/null @@ -1,10 +0,0 @@ -apiVersion: virtualization.deckhouse.io/v1alpha2 -kind: VirtualDisk -metadata: - name: vd-root -spec: - dataSource: - type: ObjectRef - objectRef: - kind: VirtualImage - name: vi-alpine-http-bios diff --git a/test/e2e/legacy/testdata/vm-migration/vm/overlays/migration-always-safe/kustomization.yaml b/test/e2e/legacy/testdata/vm-migration/vm/overlays/migration-always-safe/kustomization.yaml deleted file mode 100644 index 29c567ef0e..0000000000 --- a/test/e2e/legacy/testdata/vm-migration/vm/overlays/migration-always-safe/kustomization.yaml +++ /dev/null @@ -1,17 +0,0 @@ -apiVersion: kustomize.config.k8s.io/v1beta1 -kind: Kustomization -nameSuffix: -migration-always-safe -resources: - - ../../base -patches: - - path: vd.image.patch.yaml - - patch: |- - - op: replace - path: /spec/bootloader - value: BIOS - - op: replace - path: /spec/liveMigrationPolicy - value: AlwaysSafe - target: - kind: VirtualMachine - name: vm diff --git a/test/e2e/legacy/testdata/vm-migration/vm/overlays/migration-always-safe/vd.image.patch.yaml b/test/e2e/legacy/testdata/vm-migration/vm/overlays/migration-always-safe/vd.image.patch.yaml deleted file mode 100644 index 0805403f38..0000000000 --- a/test/e2e/legacy/testdata/vm-migration/vm/overlays/migration-always-safe/vd.image.patch.yaml +++ /dev/null @@ -1,10 +0,0 @@ -apiVersion: virtualization.deckhouse.io/v1alpha2 -kind: VirtualDisk -metadata: - name: vd-root -spec: - dataSource: - type: ObjectRef - objectRef: - kind: VirtualImage - name: vi-alpine-http-bios diff --git a/test/e2e/legacy/testdata/vm-migration/vm/overlays/migration-bios/kustomization.yaml b/test/e2e/legacy/testdata/vm-migration/vm/overlays/migration-bios/kustomization.yaml deleted file mode 100644 index bec3478a3a..0000000000 --- a/test/e2e/legacy/testdata/vm-migration/vm/overlays/migration-bios/kustomization.yaml +++ /dev/null @@ -1,14 +0,0 @@ -apiVersion: kustomize.config.k8s.io/v1beta1 -kind: Kustomization -nameSuffix: -migration-bios -resources: - - ../../base -patches: - - path: vd.image.patch.yaml - - patch: |- - - op: replace - path: /spec/bootloader - value: BIOS - target: - kind: VirtualMachine - name: vm diff --git a/test/e2e/legacy/testdata/vm-migration/vm/overlays/migration-bios/vd.image.patch.yaml b/test/e2e/legacy/testdata/vm-migration/vm/overlays/migration-bios/vd.image.patch.yaml deleted file mode 100644 index 0805403f38..0000000000 --- a/test/e2e/legacy/testdata/vm-migration/vm/overlays/migration-bios/vd.image.patch.yaml +++ /dev/null @@ -1,10 +0,0 @@ -apiVersion: virtualization.deckhouse.io/v1alpha2 -kind: VirtualDisk -metadata: - name: vd-root -spec: - dataSource: - type: ObjectRef - objectRef: - kind: VirtualImage - name: vi-alpine-http-bios diff --git a/test/e2e/legacy/testdata/vm-migration/vm/overlays/migration-prefer-forced/kustomization.yaml b/test/e2e/legacy/testdata/vm-migration/vm/overlays/migration-prefer-forced/kustomization.yaml deleted file mode 100644 index adb0b8dca8..0000000000 --- a/test/e2e/legacy/testdata/vm-migration/vm/overlays/migration-prefer-forced/kustomization.yaml +++ /dev/null @@ -1,17 +0,0 @@ -apiVersion: kustomize.config.k8s.io/v1beta1 -kind: Kustomization -nameSuffix: -migration-prefer-forced -resources: - - ../../base -patches: - - path: vd.image.patch.yaml - - patch: |- - - op: replace - path: /spec/bootloader - value: BIOS - - op: replace - path: /spec/liveMigrationPolicy - value: PreferForced - target: - kind: VirtualMachine - name: vm diff --git a/test/e2e/legacy/testdata/vm-migration/vm/overlays/migration-prefer-forced/vd.image.patch.yaml b/test/e2e/legacy/testdata/vm-migration/vm/overlays/migration-prefer-forced/vd.image.patch.yaml deleted file mode 100644 index 0805403f38..0000000000 --- a/test/e2e/legacy/testdata/vm-migration/vm/overlays/migration-prefer-forced/vd.image.patch.yaml +++ /dev/null @@ -1,10 +0,0 @@ -apiVersion: virtualization.deckhouse.io/v1alpha2 -kind: VirtualDisk -metadata: - name: vd-root -spec: - dataSource: - type: ObjectRef - objectRef: - kind: VirtualImage - name: vi-alpine-http-bios diff --git a/test/e2e/legacy/testdata/vm-migration/vm/overlays/migration-prefer-safe/kustomization.yaml b/test/e2e/legacy/testdata/vm-migration/vm/overlays/migration-prefer-safe/kustomization.yaml deleted file mode 100644 index db5cbf5936..0000000000 --- a/test/e2e/legacy/testdata/vm-migration/vm/overlays/migration-prefer-safe/kustomization.yaml +++ /dev/null @@ -1,17 +0,0 @@ -apiVersion: kustomize.config.k8s.io/v1beta1 -kind: Kustomization -nameSuffix: -migration-prefer-safe -resources: - - ../../base -patches: - - path: vd.image.patch.yaml - - patch: |- - - op: replace - path: /spec/bootloader - value: BIOS - - op: replace - path: /spec/liveMigrationPolicy - value: PreferSafe - target: - kind: VirtualMachine - name: vm diff --git a/test/e2e/legacy/testdata/vm-migration/vm/overlays/migration-prefer-safe/vd.image.patch.yaml b/test/e2e/legacy/testdata/vm-migration/vm/overlays/migration-prefer-safe/vd.image.patch.yaml deleted file mode 100644 index 0805403f38..0000000000 --- a/test/e2e/legacy/testdata/vm-migration/vm/overlays/migration-prefer-safe/vd.image.patch.yaml +++ /dev/null @@ -1,10 +0,0 @@ -apiVersion: virtualization.deckhouse.io/v1alpha2 -kind: VirtualDisk -metadata: - name: vd-root -spec: - dataSource: - type: ObjectRef - objectRef: - kind: VirtualImage - name: vi-alpine-http-bios diff --git a/test/e2e/legacy/testdata/vm-migration/vm/overlays/migration-uefi/kustomization.yaml b/test/e2e/legacy/testdata/vm-migration/vm/overlays/migration-uefi/kustomization.yaml deleted file mode 100644 index 2303fd1580..0000000000 --- a/test/e2e/legacy/testdata/vm-migration/vm/overlays/migration-uefi/kustomization.yaml +++ /dev/null @@ -1,8 +0,0 @@ -apiVersion: kustomize.config.k8s.io/v1beta1 -kind: Kustomization -nameSuffix: -migration-uefi -resources: - - ../../base -patches: - - path: vd.image.patch.yaml - - path: vm.bootloader.patch.yaml diff --git a/test/e2e/legacy/testdata/vm-migration/vm/overlays/migration-uefi/vd.image.patch.yaml b/test/e2e/legacy/testdata/vm-migration/vm/overlays/migration-uefi/vd.image.patch.yaml deleted file mode 100644 index fb750b7a46..0000000000 --- a/test/e2e/legacy/testdata/vm-migration/vm/overlays/migration-uefi/vd.image.patch.yaml +++ /dev/null @@ -1,10 +0,0 @@ -apiVersion: virtualization.deckhouse.io/v1alpha2 -kind: VirtualDisk -metadata: - name: vd-root -spec: - dataSource: - type: ObjectRef - objectRef: - kind: VirtualImage - name: vi-alpine-http-uefi diff --git a/test/e2e/legacy/testdata/vm-migration/vm/overlays/migration-uefi/vm.bootloader.patch.yaml b/test/e2e/legacy/testdata/vm-migration/vm/overlays/migration-uefi/vm.bootloader.patch.yaml deleted file mode 100644 index 3ef9892ace..0000000000 --- a/test/e2e/legacy/testdata/vm-migration/vm/overlays/migration-uefi/vm.bootloader.patch.yaml +++ /dev/null @@ -1,6 +0,0 @@ -apiVersion: virtualization.deckhouse.io/v1alpha2 -kind: VirtualMachine -metadata: - name: vm -spec: - bootloader: EFI 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 deleted file mode 100644 index 3b3d2fee7e..0000000000 --- a/test/e2e/legacy/testdata/vm-migration/vm/overlays/with-cvi/kustomization.yaml +++ /dev/null @@ -1,18 +0,0 @@ -apiVersion: kustomize.config.k8s.io/v1beta1 -kind: Kustomization -nameSuffix: -migration-with-cvi -resources: - - ../../base -patches: - - path: vd.image.patch.yaml - - path: vm.bootloader.patch.yaml - - patch: |- - - op: add - path: /spec/blockDeviceRefs/- - value: { - "kind": "ClusterVirtualImage", - "name": "v12n-e2e-cirros" - } - target: - kind: VirtualMachine - name: vm diff --git a/test/e2e/legacy/testdata/vm-migration/vm/overlays/with-cvi/vd.image.patch.yaml b/test/e2e/legacy/testdata/vm-migration/vm/overlays/with-cvi/vd.image.patch.yaml deleted file mode 100644 index fb750b7a46..0000000000 --- a/test/e2e/legacy/testdata/vm-migration/vm/overlays/with-cvi/vd.image.patch.yaml +++ /dev/null @@ -1,10 +0,0 @@ -apiVersion: virtualization.deckhouse.io/v1alpha2 -kind: VirtualDisk -metadata: - name: vd-root -spec: - dataSource: - type: ObjectRef - objectRef: - kind: VirtualImage - name: vi-alpine-http-uefi diff --git a/test/e2e/legacy/testdata/vm-migration/vm/overlays/with-cvi/vm.bootloader.patch.yaml b/test/e2e/legacy/testdata/vm-migration/vm/overlays/with-cvi/vm.bootloader.patch.yaml deleted file mode 100644 index 3ef9892ace..0000000000 --- a/test/e2e/legacy/testdata/vm-migration/vm/overlays/with-cvi/vm.bootloader.patch.yaml +++ /dev/null @@ -1,6 +0,0 @@ -apiVersion: virtualization.deckhouse.io/v1alpha2 -kind: VirtualMachine -metadata: - name: vm -spec: - bootloader: EFI diff --git a/test/e2e/legacy/util.go b/test/e2e/legacy/util.go deleted file mode 100644 index d7d3632339..0000000000 --- a/test/e2e/legacy/util.go +++ /dev/null @@ -1,833 +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 ( - "context" - "encoding/json" - "errors" - "fmt" - "net" - "net/netip" - "os" - "path/filepath" - "strings" - "sync" - "text/template" - "time" - - . "github.com/onsi/ginkgo/v2" - . "github.com/onsi/gomega" - corev1 "k8s.io/api/core/v1" - storagev1 "k8s.io/api/storage/v1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" - "k8s.io/apimachinery/pkg/runtime" - k8snet "k8s.io/utils/net" - "sigs.k8s.io/controller-runtime/pkg/client" - - "github.com/deckhouse/virtualization/api/core/v1alpha2" - "github.com/deckhouse/virtualization/api/core/v1alpha2/vmcondition" - "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/network" -) - -const ( - CurlPod = "curl-helper" - externalHost = "https://flant.ru" - httpStatusOk = "200" -) - -func WaitResource(resource kc.Resource, ns, name, waitFor string, timeout time.Duration) { - GinkgoHelper() - waitOpts := kc.WaitOptions{ - Namespace: ns, - For: waitFor, - Timeout: timeout, - } - res := kubectl.WaitResources(resource, waitOpts, name) - Expect(res.Error()).NotTo(HaveOccurred(), "wait failed %s %s/%s.\n%s", resource, ns, name, res.StdErr()) -} - -func PatchResource(resource kc.Resource, ns, name string, patch []*kc.JSONPatch) { - GinkgoHelper() - res := kubectl.PatchResource(resource, name, kc.PatchOptions{ - Namespace: ns, - JSONPatch: patch, - }) - Expect(res.Error()).NotTo(HaveOccurred(), "patch failed %s %s/%s.\n%s", resource, ns, name, - res.StdErr()) -} - -func MergePatchResource(resource kc.Resource, ns, name, patch string) error { - GinkgoHelper() - res := kubectl.PatchResource(resource, name, kc.PatchOptions{ - Namespace: ns, - MergePatch: patch, - }) - if res.Error() != nil { - return fmt.Errorf("patch failed %s %s/%s.\n%s", resource, ns, name, res.StdErr()) - } - return nil -} - -func CheckField(resource kc.Resource, ns, name, output, compareValue string) { - GinkgoHelper() - res := kubectl.GetResource(resource, name, kc.GetOptions{ - Namespace: ns, - Output: output, - }) - Expect(res.Error()).NotTo(HaveOccurred(), "get failed %s %s/%s.\n%s", resource, ns, name, res.StdErr()) - Expect(res.StdOut()).To(Equal(compareValue)) -} - -func GetObject(resource kc.Resource, name string, object client.Object, opts kc.GetOptions) error { - GinkgoHelper() - cmdOpts := kc.GetOptions{ - Output: "json", - } - if opts.Namespace != "" { - cmdOpts.Namespace = opts.Namespace - } - if opts.Labels != nil { - cmdOpts.Labels = opts.Labels - } - cmd := kubectl.GetResource(resource, name, cmdOpts) - if cmd.Error() != nil { - return errors.New(cmd.StdErr()) - } - err := json.Unmarshal(cmd.StdOutBytes(), object) - if err != nil { - return err - } - return nil -} - -func GetObjects(resource kc.Resource, object client.ObjectList, opts kc.GetOptions) error { - GinkgoHelper() - cmdOpts := kc.GetOptions{ - Output: "json", - } - if opts.Namespace != "" { - cmdOpts.Namespace = opts.Namespace - } - if opts.Labels != nil { - cmdOpts.Labels = opts.Labels - } - if opts.ExcludedLabels != nil { - cmdOpts.ExcludedLabels = opts.ExcludedLabels - } - if opts.IgnoreNotFound { - cmdOpts.IgnoreNotFound = opts.IgnoreNotFound - } - cmd := kubectl.List(resource, cmdOpts) - if cmd.Error() != nil { - return fmt.Errorf("cmd: %s\nstderr: %s", cmd.GetCmd(), cmd.StdErr()) - } - if cmd.StdOut() != "" { - err := json.Unmarshal(cmd.StdOutBytes(), object) - if err != nil { - return err - } - } - return nil -} - -func ChmodFile(pathFile string, permission os.FileMode) error { - stats, err := os.Stat(pathFile) - if err != nil { - return err - } - - if stats.Mode().Perm() != permission { - err = os.Chmod(pathFile, permission) - if err != nil { - return err - } - } - return nil -} - -func WaitVMAgentReady(opts kc.WaitOptions) { - GinkgoHelper() - WaitPhaseByLabel(kc.ResourceVM, PhaseRunning, opts) - WaitConditionIsTrueByLabel(kc.ResourceVM, vmcondition.TypeAgentReady.String(), opts) -} - -func WaitConditionIsTrueByLabel(resource kc.Resource, conditionName string, opts kc.WaitOptions) { - GinkgoHelper() - opts.For = fmt.Sprintf("condition=%s=True", conditionName) - WaitByLabel(resource, opts) -} - -// Useful when require to async await resources filtered by labels. -// -// Static condition `wait --for`: `jsonpath={.status.phase}=phase`. -func WaitPhaseByLabel(resource kc.Resource, phase string, opts kc.WaitOptions) { - GinkgoHelper() - opts.For = fmt.Sprintf("'jsonpath={.status.phase}=%s'", phase) - WaitByLabel(resource, opts) -} - -func WaitByLabel(resource kc.Resource, opts kc.WaitOptions) { - GinkgoHelper() - - res := kubectl.List(resource, kc.GetOptions{ - ExcludedLabels: opts.ExcludedLabels, - Labels: opts.Labels, - Namespace: opts.Namespace, - Output: "jsonpath='{.items[*].metadata.name}'", - }) - Expect(res.Error()).NotTo(HaveOccurred(), res.StdErr()) - - var resources []string - if stdout := res.StdOut(); stdout != "" { - resources = strings.Split(res.StdOut(), " ") - } - WaitResources(resources, resource, opts) -} - -// Useful when require to async await resources with specified names. -// -// Do not use 'labels' or 'excluded labels' in opts; they will be ignored. -// -// Static condition `wait --for`: `jsonpath={.status.phase}=phase`. -func WaitResourcesByPhase(resources []string, resource kc.Resource, phase string, opts kc.WaitOptions) { - GinkgoHelper() - opts.For = fmt.Sprintf("'jsonpath={.status.phase}=%s'", phase) - WaitResources(resources, resource, opts) -} - -func WaitResources(resources []string, resource kc.Resource, opts kc.WaitOptions) { - GinkgoHelper() - - var ( - mu sync.Mutex - wg sync.WaitGroup - ) - - waitErr := make([]string, 0, len(resources)) - waitOpts := kc.WaitOptions{ - For: opts.For, - Namespace: opts.Namespace, - Timeout: opts.Timeout, - } - - for _, name := range resources { - wg.Add(1) - go func() { - defer wg.Done() - res := kubectl.WaitResource(resource, name, waitOpts) - if res.Error() != nil { - mu.Lock() - waitErr = append(waitErr, fmt.Sprintf("cmd: %s\nstderr: %s\nwaited for: %s", res.GetCmd(), res.StdErr(), opts.For)) - mu.Unlock() - } - }() - } - wg.Wait() - Expect(waitErr).To(BeEmpty(), "should observe resources in '%s' state before %s timeout", opts.For, opts.Timeout.String()) -} - -func GetStorageClassFromEnv(envName string) (*storagev1.StorageClass, error) { - sc := &storagev1.StorageClass{} - scName, ok := os.LookupEnv(envName) - if ok { - err := GetObject(kc.ResourceStorageClass, scName, sc, kc.GetOptions{}) - if err != nil { - return nil, err - } - return sc, nil - } - - return nil, nil -} - -func SetStorageClass(tmplRoot string, storageClasse map[string]string) error { - return filepath.Walk(tmplRoot, func(path string, info os.FileInfo, err error) error { - if err != nil { - return fmt.Errorf("failed to set a storage class: %w", err) - } - - if !info.IsDir() { - tmpl, err := template.ParseFiles(path) - if err != nil { - return err - } - - file, err := os.OpenFile(path, os.O_WRONLY|os.O_TRUNC, info.Mode()) - if err != nil { - return err - } - defer file.Close() - - err = tmpl.Execute(file, storageClasse) - if err != nil { - return err - } - } - return nil - }) -} - -func GetWaitForFirstConsumerStorageClass() (*storagev1.StorageClass, error) { - scList := storagev1.StorageClassList{} - err := GetObjects(kc.ResourceStorageClass, &scList, kc.GetOptions{}) - if err != nil { - return nil, err - } - for _, sc := range scList.Items { - if sc.VolumeBindingMode != nil && *sc.VolumeBindingMode == storagev1.VolumeBindingWaitForFirstConsumer { - return &sc, nil - } - } - return nil, nil -} - -func toIPNet(prefix netip.Prefix) *net.IPNet { - return &net.IPNet{ - IP: prefix.Masked().Addr().AsSlice(), - Mask: net.CIDRMask(prefix.Bits(), prefix.Addr().BitLen()), - } -} - -func isFirstLastIP(ip netip.Addr, cidr netip.Prefix) (bool, error) { - ipNet := toIPNet(cidr) - size := int(k8snet.RangeSize(ipNet)) - - first, err := k8snet.GetIndexedIP(ipNet, 0) - if err != nil { - return false, err - } - - if first.Equal(ip.AsSlice()) { - return true, nil - } - - last, err := k8snet.GetIndexedIP(ipNet, size-1) - if err != nil { - return false, err - } - - return last.Equal(ip.AsSlice()), nil -} - -func FindUnassignedIP(subnets []string) (string, error) { - findError := fmt.Errorf("error: cannot find unassigned IP address") - res := kubectl.List(kc.ResourceVMIPLease, kc.GetOptions{Output: "jsonpath='{.items[*].metadata.name}'"}) - if !res.WasSuccess() { - return "", fmt.Errorf("failed to get vmipl: %s", res.StdErr()) - } - ips := strings.Split(res.StdOut(), " ") - reservedIPs := make(map[string]struct{}, len(ips)) - for _, ip := range ips { - reservedIPs[ip] = struct{}{} - } - for _, rawSubnet := range subnets { - prefix, err := netip.ParsePrefix(rawSubnet) - if err != nil { - return "", fmt.Errorf("failed to parse subnet %s: %w", rawSubnet, err) - } - nextAddr := prefix.Addr().Next() - for { - nextAddr = nextAddr.Next() - ip := fmt.Sprintf("ip-%s", strings.ReplaceAll(nextAddr.String(), ".", "-")) - if _, found := reservedIPs[ip]; found { - continue - } - isFirstLast, err := isFirstLastIP(nextAddr, prefix) - if err != nil { - return "", findError - } - if isFirstLast { - continue - } - if prefix.Contains(nextAddr) { - return nextAddr.String(), nil - } - break - } - } - return "", findError -} - -func GetConditionStatus(obj client.Object, conditionType string) (metav1.ConditionStatus, error) { - condition, err := GetCondition(conditionType, obj) - if err != nil { - return "", err - } - - return condition.Status, nil -} - -func GetCondition(conditionType string, obj client.Object) (metav1.Condition, error) { - u, err := runtime.DefaultUnstructuredConverter.ToUnstructured(obj) - if err != nil { - return metav1.Condition{}, err - } - - unstructuredObj := &unstructured.Unstructured{Object: u} - - conditions, found, err := unstructured.NestedSlice(unstructuredObj.Object, "status", "conditions") - if err != nil { - return metav1.Condition{}, err - } - if !found { - return metav1.Condition{}, fmt.Errorf(".status.conditions not found") - } - - for _, c := range conditions { - if conditionMap, isMap := c.(map[string]interface{}); isMap { - if conditionMap["type"] == conditionType { - return metav1.Condition{ - Type: conditionMap["type"].(string), - Status: metav1.ConditionStatus(conditionMap["status"].(string)), - Reason: conditionMap["reason"].(string), - ObservedGeneration: conditionMap["observedGeneration"].(int64), - }, nil - } - } - } - - return metav1.Condition{}, fmt.Errorf("condition %s not found", conditionType) -} - -// Test data templates does not contain this resources, but this resources are created in test case. -type AdditionalResource struct { - Resource kc.Resource - Labels map[string]string -} - -// KustomizationDir - `kubectl delete --kustomize