Skip to content

Commit

Permalink
Remove 4621 from quarantine by switching kubectl port-forward->NodePort
Browse files Browse the repository at this point in the history
Our functional tests are using `kubectl port-forward` to upload the images, which is not very reliable.
Since kubevirt/kubevirtci#653, we have a port that is exposed from host->VM;
We can look it up and set up a NodePort against it instead.

Signed-off-by: Alex Kalenyuk <[email protected]>
  • Loading branch information
akalenyu committed Aug 30, 2021
1 parent 522d336 commit e3c7a40
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 10 deletions.
7 changes: 6 additions & 1 deletion hack/cluster-deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
}

Expand Down
15 changes: 15 additions & 0 deletions manifests/testing/uploadproxy-nodeport.yaml.in
Original file line number Diff line number Diff line change
@@ -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
35 changes: 26 additions & 9 deletions tests/storage/imageupload.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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) {
Expand All @@ -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) {
Expand Down Expand Up @@ -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 {
Expand All @@ -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),
)
})

Expand Down

0 comments on commit e3c7a40

Please sign in to comment.