diff --git a/hack/cluster-deploy.sh b/hack/cluster-deploy.sh index facee6b7a6ec..5e9656048588 100755 --- a/hack/cluster-deploy.sh +++ b/hack/cluster-deploy.sh @@ -35,7 +35,7 @@ function dump_kubevirt() { function _deploy_infra_for_tests() { # Remove cdi manifests for sriov-lane until kubevirt/kubevirt#4120 is fixed if [[ "$KUBEVIRT_PROVIDER" =~ sriov.* ]]; then - rm -f ${MANIFESTS_OUT_DIR}/testing/cdi-* + rm -f ${MANIFESTS_OUT_DIR}/testing/cdi-* ${MANIFESTS_OUT_DIR}/testing/uploadproxy-nodeport.yaml fi # Deploy infra for testing first @@ -66,6 +66,11 @@ EOF sleep 1 done _kubectl patch configmap cdi-insecure-registries -n $cdi_namespace --type merge -p '{"data":{"dev-registry": "registry:5000"}}' + + # Configure uploadproxy override for virtctl imageupload + host_port=$(${KUBEVIRT_PATH}cluster-up/cli.sh ports uploadproxy | xargs) + override="https://127.0.0.1:$host_port" + _kubectl patch cdi ${cdi_namespace} --type merge -p '{"spec": {"config": {"uploadProxyURLOverride": "'"$override"'"}}}' fi } diff --git a/manifests/testing/uploadproxy-nodeport.yaml.in b/manifests/testing/uploadproxy-nodeport.yaml.in new file mode 100644 index 000000000000..6742da4b088c --- /dev/null +++ b/manifests/testing/uploadproxy-nodeport.yaml.in @@ -0,0 +1,15 @@ +apiVersion: v1 +kind: Service +metadata: + name: cdi-uploadproxy-nodeport + namespace: {{.CDINamespace}} + labels: + kubevirt.io: "cdi-uploadproxy-nodeport" +spec: + type: NodePort + selector: + cdi.kubevirt.io: cdi-uploadproxy + ports: + - port: 443 + targetPort: 8443 + nodePort: 31001 diff --git a/tests/storage/imageupload.go b/tests/storage/imageupload.go index 36ad8ff5ed16..b462c88c114b 100644 --- a/tests/storage/imageupload.go +++ b/tests/storage/imageupload.go @@ -17,6 +17,7 @@ import ( "k8s.io/apimachinery/pkg/api/errors" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/util/rand" "kubevirt.io/client-go/kubecli" "kubevirt.io/kubevirt/tests" @@ -68,13 +69,17 @@ var _ = SIGDescribe("[Serial]ImageUpload", func() { close(stopChan) - By("Setting up port forwarding") - portMapping := fmt.Sprintf("%d:%d", localUploadProxyPort, uploadProxyPort) - _, kubectlCmd, err = tests.CreateCommandWithNS(flags.ContainerizedDataImporterNamespace, "kubectl", "port-forward", uploadProxyService, portMapping) + config, err := virtClient.CdiClient().CdiV1beta1().CDIConfigs().Get(context.Background(), "config", metav1.GetOptions{}) Expect(err).ToNot(HaveOccurred()) + if config.Status.UploadProxyURL == nil { + By("Setting up port forwarding") + portMapping := fmt.Sprintf("%d:%d", localUploadProxyPort, uploadProxyPort) + _, kubectlCmd, err = tests.CreateCommandWithNS(flags.ContainerizedDataImporterNamespace, "kubectl", "port-forward", uploadProxyService, portMapping) + Expect(err).ToNot(HaveOccurred()) - err = kubectlCmd.Start() - Expect(err).ToNot(HaveOccurred()) + err = kubectlCmd.Start() + Expect(err).ToNot(HaveOccurred()) + } }) validateDataVolume := func(targetName string, _ string) { @@ -98,6 +103,19 @@ var _ = SIGDescribe("[Serial]ImageUpload", func() { Expect(err).ToNot(HaveOccurred()) return false }, 90*time.Second, 2*time.Second).Should(BeTrue()) + + Eventually(func() bool { + pvList, err := virtClient.CoreV1().PersistentVolumes().List(context.Background(), metav1.ListOptions{}) + Expect(err).ToNot(HaveOccurred()) + for _, pv := range pvList.Items { + if ref := pv.Spec.ClaimRef; ref != nil { + if ref.Name == targetName { + return false + } + } + } + return true + }, 120*time.Second, 2*time.Second).Should(BeTrue()) } deleteDataVolume := func(targetName string) { @@ -144,9 +162,8 @@ var _ = SIGDescribe("[Serial]ImageUpload", func() { "--namespace", util.NamespaceTestDefault, "--image-path", imagePath, "--size", pvcSize, - "--uploadproxy-url", fmt.Sprintf("https://127.0.0.1:%d", localUploadProxyPort), - "--wait-secs", "60", "--storage-class", sc, + "--block-volume", "--insecure") err := virtctlCmd() if err != nil { @@ -170,8 +187,8 @@ var _ = SIGDescribe("[Serial]ImageUpload", func() { Expect(err).ToNot(HaveOccurred()) } }, - Entry("DataVolume", "dv", "alpine-dv", validateDataVolume, deleteDataVolume, true), - Entry("PVC", "pvc", "alpine-pvc", validatePVC, deletePVC, false), + Entry("DataVolume", "dv", "alpine-dv-"+rand.String(12), validateDataVolume, deleteDataVolume, true), + Entry("PVC", "pvc", "alpine-pvc-"+rand.String(12), validatePVC, deletePVC, false), ) })