From d385815413b69e408a1831708ec70d7670449326 Mon Sep 17 00:00:00 2001 From: Daniil Antoshin Date: Mon, 14 Apr 2025 19:12:19 +0200 Subject: [PATCH] chore(test): add disks tests Signed-off-by: Daniil Antoshin --- tests/e2e/config/config.go | 28 +++ tests/e2e/disks_test.go | 169 +++++++++++++ .../testdata/disks-creation/cvi/cvi_http.yaml | 9 + .../disks-creation/cvi/kustomization.yaml | 9 + .../disks-creation/kustomization.yaml | 17 ++ tests/e2e/testdata/disks-creation/ns.yaml | 4 + .../testdata/disks-creation/transformer.yaml | 51 ++++ .../disks-creation/vd/kustomization.yaml | 4 + .../disks-creation/vd/vd-alpine-http.yaml | 12 + .../testdata/disks-creation/vd/vd-http.yaml | 16 ++ .../vdsnapshot/kustomization.yaml | 4 + .../disks-creation/vdsnapshot/vdsnapshot.yaml | 7 + .../disks-creation/vi/kustomization.yaml | 10 + .../testdata/disks-creation/vi/vi_http.yaml | 23 ++ tests/e2e/tests_suite_test.go | 5 +- tests/e2e/todo_req_refactor_disks_test | 224 ------------------ 16 files changed, 366 insertions(+), 226 deletions(-) create mode 100644 tests/e2e/disks_test.go create mode 100644 tests/e2e/testdata/disks-creation/cvi/cvi_http.yaml create mode 100644 tests/e2e/testdata/disks-creation/cvi/kustomization.yaml create mode 100644 tests/e2e/testdata/disks-creation/kustomization.yaml create mode 100644 tests/e2e/testdata/disks-creation/ns.yaml create mode 100644 tests/e2e/testdata/disks-creation/transformer.yaml create mode 100644 tests/e2e/testdata/disks-creation/vd/kustomization.yaml create mode 100644 tests/e2e/testdata/disks-creation/vd/vd-alpine-http.yaml create mode 100644 tests/e2e/testdata/disks-creation/vd/vd-http.yaml create mode 100644 tests/e2e/testdata/disks-creation/vdsnapshot/kustomization.yaml create mode 100644 tests/e2e/testdata/disks-creation/vdsnapshot/vdsnapshot.yaml create mode 100644 tests/e2e/testdata/disks-creation/vi/kustomization.yaml create mode 100644 tests/e2e/testdata/disks-creation/vi/vi_http.yaml delete mode 100644 tests/e2e/todo_req_refactor_disks_test diff --git a/tests/e2e/config/config.go b/tests/e2e/config/config.go index f03b0ae2cd..8aa7813639 100644 --- a/tests/e2e/config/config.go +++ b/tests/e2e/config/config.go @@ -115,6 +115,33 @@ type Kustomize struct { Namespace string `yaml:"namespace"` NamePrefix string `yaml:"namePrefix"` Resources []string `yaml:"resources"` + Patches []Patch `json:"patches,omitempty" yaml:"patches,omitempty"` +} + +type Patch struct { + Path string `json:"path,omitempty" yaml:"path,omitempty"` + Patch string `json:"patch,omitempty" yaml:"patch,omitempty"` + Target *Selector `json:"target,omitempty" yaml:"target,omitempty"` + Options map[string]bool `json:"options,omitempty" yaml:"options,omitempty"` +} + +type Selector struct { + ResId `json:",inline,omitempty" yaml:",inline,omitempty"` + AnnotationSelector string `json:"annotationSelector,omitempty" yaml:"annotationSelector,omitempty"` + LabelSelector string `json:"labelSelector,omitempty" yaml:"labelSelector,omitempty"` +} + +type ResId struct { + Gvk `json:",inline,omitempty" yaml:",inline,omitempty"` + Name string `json:"name,omitempty" yaml:"name,omitempty"` + Namespace string `json:"namespace,omitempty" yaml:"namespace,omitempty"` +} + +type Gvk struct { + Group string `json:"group,omitempty" yaml:"group,omitempty"` + Version string `json:"version,omitempty" yaml:"version,omitempty"` + Kind string `json:"kind,omitempty" yaml:"kind,omitempty"` + isClusterScoped bool } type KustomizeLabel struct { @@ -141,6 +168,7 @@ type TestData struct { ComplexTest string `yaml:"complexTest"` Connectivity string `yaml:"connectivity"` DiskResizing string `yaml:"diskResizing"` + DisksCreation string `yaml:"disksCreation"` SizingPolicy string `yaml:"sizingPolicy"` ImporterNetworkPolicy string `yaml:"importerNetworkPolicy"` ImageHotplug string `yaml:"imageHotplug"` diff --git a/tests/e2e/disks_test.go b/tests/e2e/disks_test.go new file mode 100644 index 0000000000..67b6e89d3e --- /dev/null +++ b/tests/e2e/disks_test.go @@ -0,0 +1,169 @@ +/* +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 e2e + +import ( + "fmt" + + . "github.com/onsi/ginkgo/v2" + . "github.com/onsi/gomega" + storagev1 "k8s.io/api/storage/v1" + + sdsrepvolv1 "github.com/deckhouse/sds-replicated-volume/api/v1alpha1" + virtv2 "github.com/deckhouse/virtualization/api/core/v1alpha2" + "github.com/deckhouse/virtualization/tests/e2e/config" + "github.com/deckhouse/virtualization/tests/e2e/ginkgoutil" + . "github.com/deckhouse/virtualization/tests/e2e/helper" + kc "github.com/deckhouse/virtualization/tests/e2e/kubectl" +) + +var _ = Describe("Virtual disks creation", ginkgoutil.CommonE2ETestDecorators(), func() { + var ( + immediateStorageClassName string // require for unattached virtual disk snapshots + testCaseLabel = map[string]string{"testcase": "disks-creation"} + ) + + BeforeEach(func() { + if config.IsReusable() { + Skip("Test not available in REUSABLE mode: not supported yet.") + } + }) + + AfterEach(func() { + if CurrentSpecReport().Failed() { + SaveTestResources(testCaseLabel, CurrentSpecReport().LeafNodeText) + } + }) + + Context("Preparing the environment", func() { + It("sets the namespace", func() { + kustomization := fmt.Sprintf("%s/%s", conf.TestData.DisksCreation, "kustomization.yaml") + ns, err := kustomize.GetNamespace(kustomization) + Expect(err).NotTo(HaveOccurred(), "%w", err) + conf.SetNamespace(ns) + }) + + It("prepares `Immediate` storage class and virtual disk that use it", func() { + sc, err := GetDefaultStorageClass() + Expect(err).NotTo(HaveOccurred(), "cannot get default storage class\nstderr: %s", err) + + defaultVolumeSnapshotClassName, err := GetVolumeSnapshotClassName(sc) + Expect(err).NotTo(HaveOccurred(), "cannot define default `VolumeSnapshotClass`\nstderr: %s", err) + + if sc.Provisioner == LinstorProviderName { + storagePoolName := sc.Parameters["replicated.csi.storage.deckhouse.io/storagePool"] + storagePoolObj := sdsrepvolv1.ReplicatedStoragePool{} + err := GetObject(kc.ResourceReplicatedStoragePool, storagePoolName, &storagePoolObj, kc.GetOptions{}) + Expect(err).NotTo(HaveOccurred(), "cannot get `storagePoolObj`: %s\nstderr: %s", storagePoolName, err) + Expect(storagePoolObj.Spec.Type).To(Equal(LVMThinName), "type of replicated storage pool should be `LVMThin`") + } + + if *sc.VolumeBindingMode != storagev1.VolumeBindingImmediate { + immediateStorageClassName, err = CreateImmediateStorageClass(sc.Provisioner, testCaseLabel) + Expect(err).NotTo(HaveOccurred(), "%s", err) + + virtualDisk := virtv2.VirtualDisk{} + vdFilePath := fmt.Sprintf("%s/vd/vd-alpine-http.yaml", conf.TestData.DisksCreation) + err = UnmarshalResource(vdFilePath, &virtualDisk) + Expect(err).NotTo(HaveOccurred(), "cannot get object from file: %s\nstderr: %s", vdFilePath, err) + + virtualDisk.Spec.PersistentVolumeClaim.StorageClass = &immediateStorageClassName + err = WriteYamlObject(vdFilePath, &virtualDisk) + Expect(err).NotTo(HaveOccurred(), "cannot update virtual disk with custom storage class: %s\nstderr: %s", vdFilePath, err) + } else { + immediateStorageClassName = sc.Name + } + + virtualDiskSnapshot := virtv2.VirtualDiskSnapshot{} + vdSnapshotFilePath := fmt.Sprintf("%s/vdsnapshot/vdsnapshot.yaml", conf.TestData.DisksCreation) + err = UnmarshalResource(vdSnapshotFilePath, &virtualDiskSnapshot) + Expect(err).NotTo(HaveOccurred(), "cannot get object from file: %s\nstderr: %s", vdSnapshotFilePath, err) + + virtualDiskSnapshot.Spec.VolumeSnapshotClassName = defaultVolumeSnapshotClassName + err = WriteYamlObject(vdSnapshotFilePath, &virtualDiskSnapshot) + Expect(err).NotTo(HaveOccurred(), "cannot update virtual disk with custom storage class: %s\nstderr: %s", vdSnapshotFilePath, err) + }) + }) + + Context("When resources are applied", func() { + It("result should be succeeded", func() { + res := kubectl.Apply(kc.ApplyOptions{ + Filename: []string{conf.TestData.DisksCreation}, + 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", virtv2.DiskReady)) + WaitPhaseByLabel(kc.ResourceVD, string(virtv2.DiskReady), kc.WaitOptions{ + Labels: testCaseLabel, + Namespace: conf.Namespace, + Timeout: MaxWaitTimeout, + }) + }) + + It("checks VDSnapshot phase", func() { + By(fmt.Sprintf("VDSnapshot should be in %s phase", virtv2.VirtualDiskSnapshotPhaseReady)) + WaitPhaseByLabel(kc.ResourceVDSnapshot, string(virtv2.VirtualDiskSnapshotPhaseReady), kc.WaitOptions{ + Labels: testCaseLabel, + Namespace: conf.Namespace, + Timeout: MaxWaitTimeout, + }) + }) + }) + + Context("When virtual images are applied", func() { + It("checks VIs phases", func() { + By(fmt.Sprintf("VIs should be in %s phases", virtv2.ImageReady)) + WaitPhaseByLabel(kc.ResourceVI, string(virtv2.ImageReady), kc.WaitOptions{ + Labels: testCaseLabel, + Namespace: conf.Namespace, + Timeout: MaxWaitTimeout, + }) + }) + + It("checks CVIs phases", func() { + By(fmt.Sprintf("CVIs should be in %s phases", virtv2.ImageReady)) + WaitPhaseByLabel(kc.ResourceCVI, string(virtv2.ImageReady), kc.WaitOptions{ + Labels: testCaseLabel, + Namespace: conf.Namespace, + Timeout: MaxWaitTimeout, + }) + }) + }) + + Context("When test is completed", func() { + It("deletes test case resources", func() { + DeleteTestCaseResources(ResourcesToDelete{ + KustomizationDir: conf.TestData.DisksCreation, + AdditionalResources: []AdditionalResource{ + { + Resource: kc.ResourceReplicatedStorageClass, + Labels: testCaseLabel, + }, + { + Resource: kc.ResourceStorageClass, + Labels: testCaseLabel, + }, + }, + }) + }) + }) +}) diff --git a/tests/e2e/testdata/disks-creation/cvi/cvi_http.yaml b/tests/e2e/testdata/disks-creation/cvi/cvi_http.yaml new file mode 100644 index 0000000000..c4c2e653e6 --- /dev/null +++ b/tests/e2e/testdata/disks-creation/cvi/cvi_http.yaml @@ -0,0 +1,9 @@ +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/tests/e2e/testdata/disks-creation/cvi/kustomization.yaml b/tests/e2e/testdata/disks-creation/cvi/kustomization.yaml new file mode 100644 index 0000000000..0f1a314cbe --- /dev/null +++ b/tests/e2e/testdata/disks-creation/cvi/kustomization.yaml @@ -0,0 +1,9 @@ +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/tests/e2e/testdata/disks-creation/kustomization.yaml b/tests/e2e/testdata/disks-creation/kustomization.yaml new file mode 100644 index 0000000000..9296072cf4 --- /dev/null +++ b/tests/e2e/testdata/disks-creation/kustomization.yaml @@ -0,0 +1,17 @@ +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: disks-creation diff --git a/tests/e2e/testdata/disks-creation/ns.yaml b/tests/e2e/testdata/disks-creation/ns.yaml new file mode 100644 index 0000000000..5efde875b6 --- /dev/null +++ b/tests/e2e/testdata/disks-creation/ns.yaml @@ -0,0 +1,4 @@ +apiVersion: v1 +kind: Namespace +metadata: + name: default diff --git a/tests/e2e/testdata/disks-creation/transformer.yaml b/tests/e2e/testdata/disks-creation/transformer.yaml new file mode 100644 index 0000000000..073ebcb6d9 --- /dev/null +++ b/tests/e2e/testdata/disks-creation/transformer.yaml @@ -0,0 +1,51 @@ +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/tests/e2e/testdata/disks-creation/vd/kustomization.yaml b/tests/e2e/testdata/disks-creation/vd/kustomization.yaml new file mode 100644 index 0000000000..00754911b6 --- /dev/null +++ b/tests/e2e/testdata/disks-creation/vd/kustomization.yaml @@ -0,0 +1,4 @@ +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization +resources: + - vd-alpine-http.yaml diff --git a/tests/e2e/testdata/disks-creation/vd/vd-alpine-http.yaml b/tests/e2e/testdata/disks-creation/vd/vd-alpine-http.yaml new file mode 100644 index 0000000000..3445633a6a --- /dev/null +++ b/tests/e2e/testdata/disks-creation/vd/vd-alpine-http.yaml @@ -0,0 +1,12 @@ +--- +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: + size: 370Mi diff --git a/tests/e2e/testdata/disks-creation/vd/vd-http.yaml b/tests/e2e/testdata/disks-creation/vd/vd-http.yaml new file mode 100644 index 0000000000..dedeb65fc9 --- /dev/null +++ b/tests/e2e/testdata/disks-creation/vd/vd-http.yaml @@ -0,0 +1,16 @@ +--- +apiVersion: virtualization.deckhouse.io/v1alpha2 +kind: VirtualDisk +metadata: + name: vd-http +spec: + dataSource: + type: HTTP +--- +apiVersion: virtualization.deckhouse.io/v1alpha2 +kind: VirtualDisk +metadata: + name: vd-pvc-http +spec: + dataSource: + type: HTTP diff --git a/tests/e2e/testdata/disks-creation/vdsnapshot/kustomization.yaml b/tests/e2e/testdata/disks-creation/vdsnapshot/kustomization.yaml new file mode 100644 index 0000000000..ebce4baedf --- /dev/null +++ b/tests/e2e/testdata/disks-creation/vdsnapshot/kustomization.yaml @@ -0,0 +1,4 @@ +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization +resources: + - vdsnapshot.yaml diff --git a/tests/e2e/testdata/disks-creation/vdsnapshot/vdsnapshot.yaml b/tests/e2e/testdata/disks-creation/vdsnapshot/vdsnapshot.yaml new file mode 100644 index 0000000000..115ea2c729 --- /dev/null +++ b/tests/e2e/testdata/disks-creation/vdsnapshot/vdsnapshot.yaml @@ -0,0 +1,7 @@ +apiVersion: virtualization.deckhouse.io/v1alpha2 +kind: VirtualDiskSnapshot +metadata: + name: vdsnapshot +spec: + requiredConsistency: true + virtualDiskName: vd-alpine-http diff --git a/tests/e2e/testdata/disks-creation/vi/kustomization.yaml b/tests/e2e/testdata/disks-creation/vi/kustomization.yaml new file mode 100644 index 0000000000..6ec4dd412a --- /dev/null +++ b/tests/e2e/testdata/disks-creation/vi/kustomization.yaml @@ -0,0 +1,10 @@ +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/tests/e2e/testdata/disks-creation/vi/vi_http.yaml b/tests/e2e/testdata/disks-creation/vi/vi_http.yaml new file mode 100644 index 0000000000..dbfe7900f4 --- /dev/null +++ b/tests/e2e/testdata/disks-creation/vi/vi_http.yaml @@ -0,0 +1,23 @@ +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 + dataSource: + type: "HTTP" + http: + url: https://89d64382-20df-4581-8cc7-80df331f67fa.selstorage.ru/alpine/alpine-virt-3.21.0-x86.iso diff --git a/tests/e2e/tests_suite_test.go b/tests/e2e/tests_suite_test.go index 77da3c9e50..607675ffb6 100644 --- a/tests/e2e/tests_suite_test.go +++ b/tests/e2e/tests_suite_test.go @@ -111,6 +111,7 @@ func init() { fmt.Sprintf("%s/%s", conf.TestData.ComplexTest, "kustomization.yaml"), fmt.Sprintf("%s/%s", conf.TestData.Connectivity, "kustomization.yaml"), fmt.Sprintf("%s/%s", conf.TestData.DiskResizing, "kustomization.yaml"), + fmt.Sprintf("%s/%s", conf.TestData.DisksCreation, "kustomization.yaml"), fmt.Sprintf("%s/%s", conf.TestData.ImageHotplug, "kustomization.yaml"), fmt.Sprintf("%s/%s", conf.TestData.SizingPolicy, "kustomization.yaml"), fmt.Sprintf("%s/%s", conf.TestData.ImporterNetworkPolicy, "kustomization.yaml"), @@ -211,12 +212,12 @@ func Cleanup() []error { continue } } - + for _, r := range conf.CleanupResources { res = kubectl.Delete(kc.DeleteOptions{ IgnoreNotFound: true, Labels: map[string]string{"id": namePrefix}, - Resource: kc.Resource(r), + Resource: kc.Resource(r), }) if res.Error() != nil { cleanupErrs = append( diff --git a/tests/e2e/todo_req_refactor_disks_test b/tests/e2e/todo_req_refactor_disks_test deleted file mode 100644 index 56b2521723..0000000000 --- a/tests/e2e/todo_req_refactor_disks_test +++ /dev/null @@ -1,224 +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 e2e - -import ( - "fmt" - "path" - - . "github.com/onsi/ginkgo/v2" - . "github.com/onsi/gomega" - - "github.com/deckhouse/virtualization/tests/e2e/ginkgoutil" - kc "github.com/deckhouse/virtualization/tests/e2e/kubectl" -) - -const ( - UploadHelpPod = "upload-helper" -) - -func cviPath(file string) string { - return path.Join(conf.Disks.CviTestDataDir, file) -} - -func viPath(file string) string { - return path.Join(conf.Disks.ViTestDataDir, file) -} - -func vdPath(file string) string { - return path.Join(conf.Disks.VdTestDataDir, file) -} - -var _ = Describe("Disks", ginkgoutil.CommonE2ETestDecorators(), func() { - CheckProgress := func(filepath string) { - GinkgoHelper() - out := "jsonpath={.status.progress}" - ItCheckStatusFromFile(filepath, out, "100%") - } - ItUpload := func(filepath string) { - GinkgoHelper() - ItApplyWaitGet(filepath, ApplyWaitGetOptions{ - Phase: PhaseWaitForUserUpload, - }) - It("Run pod upload helper", func() { - res := kubectl.Get(filepath, kc.GetOptions{ - Output: "jsonpath={.status.uploadCommand}", - }) - - Expect(res.Error()).NotTo(HaveOccurred(), "get failed upload.\n%s", res.StdErr()) - subCMD := fmt.Sprintf("run -n %s --restart=Never -i --tty %s --image=%s -- %s", conf.Namespace, UploadHelpPod, conf.Disks.UploadHelperImage, res.StdOut()+" -k") - - res = kubectl.RawCommand(subCMD, LongWaitDuration) - Expect(res.Error()).NotTo(HaveOccurred(), "create pod upload helper failed.\n%s", res.StdErr()) - For := "jsonpath={.status.phase}=" + PhaseSucceeded - WaitResource(kc.ResourcePod, UploadHelpPod, For, LongWaitDuration) - CheckField(kc.ResourcePod, UploadHelpPod, "jsonpath={.status.phase}", PhaseSucceeded) - }) - ItWaitFromFile(filepath, PhaseReady, ShortWaitDuration) - ItChekStatusPhaseFromFile(filepath, PhaseReady) - } - - Context("CVI", func() { - AfterAll(func() { - By("Removing resources for cvi tests") - kubectl.Delete(kc.DeleteOptions{ - Filename: []string{conf.Disks.CviTestDataDir}, - FilenameOption: kc.Filename, - }) - }) - When("http source", func() { - filepath := cviPath("/cvi_http.yaml") - ItApplyWaitGet(filepath, ApplyWaitGetOptions{}) - CheckProgress(filepath) - }) - When("containerimage source", func() { - filepath := cviPath("/cvi_containerimage.yaml") - ItApplyWaitGet(filepath, ApplyWaitGetOptions{}) - CheckProgress(filepath) - }) - When("vi source", func() { - filepath := cviPath("/cvi_vi.yaml") - ItApplyWaitGet(filepath, ApplyWaitGetOptions{ - WaitTimeout: LongWaitDuration, - }) - CheckProgress(filepath) - }) - When("cvi source", func() { - filepath := cviPath("/cvi_cvi.yaml") - ItApplyWaitGet(filepath, ApplyWaitGetOptions{ - WaitTimeout: LongWaitDuration, - }) - CheckProgress(filepath) - }) - When("upload", func() { - AfterAll(func() { - By("Removing support resources for cvi upload test") - kubectl.Delete(kc.DeleteOptions{ - Filename: []string{UploadHelpPod}, - Namespace: conf.Namespace, - Resource: kc.ResourcePod, - }) - }) - filepath := cviPath("/cvi_upload.yaml") - ItUpload(filepath) - CheckProgress(filepath) - }) - }) - Context("VI", func() { - AfterAll(func() { - By("Removing resources for vi tests") - kubectl.Delete(kc.DeleteOptions{ - Filename: []string{conf.Disks.ViTestDataDir}, - FilenameOption: kc.Filename, - }) - }) - When("http source", func() { - filepath := viPath("/vi_http.yaml") - ItApplyWaitGet(filepath, ApplyWaitGetOptions{}) - CheckProgress(filepath) - }) - When("containerimage source", func() { - filepath := viPath("/vi_containerimage.yaml") - ItApplyWaitGet(filepath, ApplyWaitGetOptions{}) - CheckProgress(filepath) - }) - When("vi source", func() { - filepath := viPath("/vi_vi.yaml") - ItApplyWaitGet(filepath, ApplyWaitGetOptions{ - WaitTimeout: LongWaitDuration, - }) - CheckProgress(filepath) - }) - When("cvi source", func() { - filepath := viPath("/vi_cvi.yaml") - ItApplyWaitGet(filepath, ApplyWaitGetOptions{ - WaitTimeout: LongWaitDuration, - }) - CheckProgress(filepath) - }) - When("upload", func() { - AfterAll(func() { - By("Removing support resources for vi upload test") - kubectl.Delete(kc.DeleteOptions{ - Filename: []string{UploadHelpPod}, - Namespace: conf.Namespace, - Resource: kc.ResourcePod, - }) - }) - filepath := viPath("/vi_upload.yaml") - ItUpload(filepath) - CheckProgress(filepath) - }) - }) - Context("VD", func() { - AfterAll(func() { - By("Removing resources for vd tests") - kubectl.Delete(kc.DeleteOptions{ - Filename: []string{conf.Disks.VdTestDataDir}, - FilenameOption: kc.Filename, - }) - }) - When("http source", func() { - filepath := vdPath("/vd_http.yaml") - ItApplyWaitGet(filepath, ApplyWaitGetOptions{ - WaitTimeout: LongWaitDuration, - }) - CheckProgress(filepath) - }) - When("containerimage source", func() { - filepath := vdPath("/vd_containerimage.yaml") - ItApplyWaitGet(filepath, ApplyWaitGetOptions{ - WaitTimeout: LongWaitDuration, - }) - CheckProgress(filepath) - }) - When("vi source", func() { - filepath := vdPath("/vd_vi.yaml") - ItApplyWaitGet(filepath, ApplyWaitGetOptions{ - WaitTimeout: LongWaitDuration, - }) - CheckProgress(filepath) - }) - When("cvi source", func() { - filepath := vdPath("/vd_cvi.yaml") - ItApplyWaitGet(filepath, ApplyWaitGetOptions{ - WaitTimeout: LongWaitDuration, - }) - CheckProgress(filepath) - }) - When("blank", func() { - filepath := vdPath("/vd_blank.yaml") - ItApplyWaitGet(filepath, ApplyWaitGetOptions{ - WaitTimeout: LongWaitDuration, - }) - CheckProgress(filepath) - }) - When("upload", func() { - AfterAll(func() { - By("Removing support resources for vd upload test") - kubectl.Delete(kc.DeleteOptions{ - Filename: []string{UploadHelpPod}, - Namespace: conf.Namespace, - Resource: kc.ResourcePod, - }) - }) - filepath := vdPath("/vd_upload.yaml") - ItUpload(filepath) - CheckProgress(filepath) - }) - }) -})