Skip to content

Commit

Permalink
Enable the use of non-csi HPP in testing lanes
Browse files Browse the repository at this point in the history
This commit modifies several scripts to allow the usage of classic HPP as the default SC in tests.

This allows us to test our non-populator flow with a non-csi provisioner.

Signed-off-by: Alvaro Romero <alromero@redhat.com>
  • Loading branch information
alromeros committed Jun 2, 2023
1 parent e7aa9c0 commit bd9e52c
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 20 deletions.
25 changes: 25 additions & 0 deletions automation/non-csi-hpp.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/bin/bash
#
# This file is part of the KubeVirt project
#
# 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.
#
# Copyright 2023 Red Hat, Inc.
#

set -ex
export TARGET=k8s-1.26-centos9
export KUBEVIRT_STORAGE=hpp
export HPP_CLASSIC=true
export CDI_E2E_SKIP=Destructive
automation/test.sh
13 changes: 12 additions & 1 deletion cluster-sync/ephemeral_provider.sh
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,18 @@ function configure_hpp() {
_kubectl apply -f https://github.com/kubevirt/hostpath-provisioner-operator/releases/download/$HPP_RELEASE/storageclass-wffc-legacy-csi.yaml
echo "Waiting for hostpath provisioner to be available"
_kubectl wait hostpathprovisioners.hostpathprovisioner.kubevirt.io/hostpath-provisioner --for=condition=Available --timeout=480s
_kubectl patch storageclass hostpath-csi -p '{"metadata": {"annotations":{"storageclass.kubernetes.io/is-default-class":"true"}}}'
}

function configure_hpp_classic() {
# Configure hpp and default to classic non-csi hostpath-provisioner
configure_hpp
_kubectl patch storageclass hostpath-provisioner -p '{"metadata": {"annotations":{"storageclass.kubernetes.io/is-default-class":"true"}}}'
}

function configure_hpp_csi() {
# Configure hpp and default to hostpath-csi
configure_hpp
_kubectl patch storageclass hostpath-csi -p '{"metadata": {"annotations":{"storageclass.kubernetes.io/is-default-class":"true"}}}'
}

function configure_nfs() {
Expand Down
6 changes: 5 additions & 1 deletion cluster-sync/kubevirtci/provider.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,11 @@ function configure_storage() {
fi
elif [[ $KUBEVIRT_STORAGE == "hpp" ]] ; then
echo "Installing hostpath provisioner storage"
configure_hpp
if [[ $HPP_CLASSIC == "true" ]] ; then
configure_hpp_classic
else
configure_hpp_csi
fi
elif [[ $KUBEVIRT_STORAGE == "nfs" ]] ; then
echo "Installing NFS CSI dynamic storage"
configure_nfs_csi
Expand Down
21 changes: 8 additions & 13 deletions tests/datavolume_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1750,17 +1750,12 @@ var _ = Describe("[vendor:cnv-qe@redhat.com][level:component]DataVolume tests",

updateStorageProfileSpec := func(client client.Client, name string, spec cdiv1.StorageProfileSpec) {
storageProfile := &cdiv1.StorageProfile{}
err := client.Get(context.TODO(), types.NamespacedName{Name: name}, storageProfile)
Expect(err).ToNot(HaveOccurred())
// TODO: Adding a second Get here fixes a "the object has been modified; please apply
// your changes to the latest version and try again" error in "test_id:5912" when using a
// default storage class without accessMode.
// The real cause should bee somewhere else but this fixes it for the moment.
storageProfile, err = f.CdiClient.CdiV1beta1().StorageProfiles().Get(context.TODO(), name, metav1.GetOptions{})
Expect(err).ToNot(HaveOccurred())
storageProfile.Spec = spec
err = client.Update(context.TODO(), storageProfile)
Expect(err).ToNot(HaveOccurred())
Eventually(func() error {
err := client.Get(context.TODO(), types.NamespacedName{Name: name}, storageProfile)
Expect(err).ToNot(HaveOccurred())
storageProfile.Spec = spec
return client.Update(context.TODO(), storageProfile)
}, 15*time.Second, time.Second).Should(BeNil())
}

configureStorageProfile := func(client client.Client,
Expand Down Expand Up @@ -2385,7 +2380,7 @@ var _ = Describe("[vendor:cnv-qe@redhat.com][level:component]DataVolume tests",

table.DescribeTable("import DV using StorageSpec without AccessModes, PVC is created only when", func(scName string, scFunc func(string)) {
if utils.IsDefaultSCNoProvisioner() {
Skip("Default storage class is no provisioner. The new storage class won't work")
Skip("Default storage class has no provisioner. The new storage class won't work")
}

By(fmt.Sprintf("verifying no storage class %s", testScName))
Expand Down Expand Up @@ -2455,7 +2450,7 @@ var _ = Describe("[vendor:cnv-qe@redhat.com][level:component]DataVolume tests",

table.DescribeTable("import DV with AccessModes, PVC is pending until", func(scName string, scFunc func(string), dvFunc func(string) *cdiv1.DataVolume) {
if utils.IsDefaultSCNoProvisioner() {
Skip("Default storage class is no provisioner. The new storage class won't work")
Skip("Default storage class has no provisioner. The new storage class won't work")
}

By(fmt.Sprintf("verifying no storage class %s", testScName))
Expand Down
12 changes: 7 additions & 5 deletions tests/external_population_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,14 +140,14 @@ var _ = Describe("Population tests", func() {

It("Should provision storage with any volume data source", func() {
if utils.DefaultStorageClassCsiDriver == nil {
Skip("No CSI drivers available - Population not supported")
Skip("No CSI drivers available in default SC - Population not supported")
}
if !isAnyVolumeDataSourceEnabled() {
Skip("No AnyVolumeDataSource feature gate")
}

By(fmt.Sprintf("Creating new datavolume %s", dataVolumeName))
dataVolume := utils.NewDataVolumeWithExternalPopulationAndStorageSpec(dataVolumeName, "100Mi", f.CsiCloneSCName, corev1.PersistentVolumeMode(corev1.PersistentVolumeBlock), nil, dataSourceRef)
dataVolume := utils.NewDataVolumeWithExternalPopulationAndStorageSpec(dataVolumeName, "100Mi", utils.DefaultStorageClass.Name, corev1.PersistentVolumeMode(corev1.PersistentVolumeFilesystem), nil, dataSourceRef)
controller.AddAnnotation(dataVolume, controller.AnnDeleteAfterCompletion, "false")
dataVolume, err := utils.CreateDataVolumeFromDefinition(f.CdiClient, f.Namespace.Name, dataVolume)
Expect(err).ToNot(HaveOccurred())
Expand All @@ -163,7 +163,8 @@ var _ = Describe("Population tests", func() {
f.ExpectEvent(dataVolume.Namespace).Should(ContainSubstring(dvc.ExternalPopulationSucceeded))
expectetHash := []byte(expectedContent)
expectedHashString := fmt.Sprintf("%x", md5.Sum(expectetHash))
md5, err := f.GetMD5(f.Namespace, pvc, utils.DefaultPvcMountPath, int64(len(expectedContent)))
filePath := fmt.Sprintf("%s/%s", utils.DefaultPvcMountPath, fileName)
md5, err := f.GetMD5(f.Namespace, pvc, filePath, int64(len(expectedContent)))
Expect(err).ToNot(HaveOccurred())
Expect(md5).To(Equal(expectedHashString))

Expand All @@ -181,7 +182,7 @@ var _ = Describe("Population tests", func() {
})

It("Should not populate PVC when AnyVolumeDataSource is disabled", func() {
if utils.DefaultStorageClassCsiDriver == nil {
if !f.IsCSIVolumeCloneStorageClassAvailable() {
Skip("No CSI drivers available - Population not supported")
}
if isAnyVolumeDataSourceEnabled() {
Expand Down Expand Up @@ -241,7 +242,7 @@ var _ = Describe("Population tests", func() {

Context("Legacy population", func() {
It("Should perform a CSI PVC clone by manually populating the DataSource field", func() {
if utils.DefaultStorageClassCsiDriver == nil {
if !f.IsCSIVolumeCloneStorageClassAvailable() {
Skip("No CSI drivers available - Population not supported")
}

Expand All @@ -256,6 +257,7 @@ var _ = Describe("Population tests", func() {

By(fmt.Sprintf("Creating target datavolume %s", dataVolumeName))
dataVolume := utils.NewDataVolumeWithExternalPopulationAndStorageSpec(dataVolumeName, "100Mi", f.CsiCloneSCName, corev1.PersistentVolumeMode(corev1.PersistentVolumeFilesystem), dataSource, nil)
dataVolume.Spec.Storage.StorageClassName = nil
controller.AddAnnotation(dataVolume, controller.AnnDeleteAfterCompletion, "false")
dataVolume, err := utils.CreateDataVolumeFromDefinition(f.CdiClient, f.Namespace.Name, dataVolume)
Expect(err).ToNot(HaveOccurred())
Expand Down

0 comments on commit bd9e52c

Please sign in to comment.