2019-05-31 09:34:04 +00:00
|
|
|
package e2e
|
|
|
|
|
|
|
|
import (
|
2021-02-22 11:13:40 +00:00
|
|
|
"context"
|
2019-06-18 07:07:11 +00:00
|
|
|
"fmt"
|
2021-03-30 05:33:01 +00:00
|
|
|
"io/ioutil"
|
|
|
|
"os"
|
2020-06-16 10:56:14 +00:00
|
|
|
"strings"
|
2020-08-03 17:48:24 +00:00
|
|
|
"sync"
|
2019-06-14 09:42:48 +00:00
|
|
|
|
2021-06-23 07:33:59 +00:00
|
|
|
snapapi "github.com/kubernetes-csi/external-snapshotter/client/v4/apis/volumesnapshot/v1"
|
2019-05-31 09:34:04 +00:00
|
|
|
. "github.com/onsi/ginkgo" // nolint
|
2020-06-16 11:06:15 +00:00
|
|
|
v1 "k8s.io/api/core/v1"
|
2020-06-16 10:56:14 +00:00
|
|
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
2019-07-25 06:49:44 +00:00
|
|
|
clientset "k8s.io/client-go/kubernetes"
|
2019-05-31 09:34:04 +00:00
|
|
|
"k8s.io/kubernetes/test/e2e/framework"
|
2019-06-24 07:58:39 +00:00
|
|
|
e2elog "k8s.io/kubernetes/test/e2e/framework/log"
|
2019-05-31 09:34:04 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
var (
|
2021-09-20 10:16:55 +00:00
|
|
|
cephFSProvisioner = "csi-cephfsplugin-provisioner.yaml"
|
|
|
|
cephFSProvisionerRBAC = "csi-provisioner-rbac.yaml"
|
|
|
|
cephFSProvisionerPSP = "csi-provisioner-psp.yaml"
|
|
|
|
cephFSNodePlugin = "csi-cephfsplugin.yaml"
|
|
|
|
cephFSNodePluginRBAC = "csi-nodeplugin-rbac.yaml"
|
|
|
|
cephFSNodePluginPSP = "csi-nodeplugin-psp.yaml"
|
|
|
|
cephFSDeploymentName = "csi-cephfsplugin-provisioner"
|
|
|
|
cephFSDeamonSetName = "csi-cephfsplugin"
|
|
|
|
cephFSContainerName = "csi-cephfsplugin"
|
|
|
|
cephFSDirPath = "../deploy/cephfs/kubernetes/"
|
|
|
|
cephFSExamplePath = examplePath + "cephfs/"
|
2020-07-25 16:39:50 +00:00
|
|
|
subvolumegroup = "e2e"
|
2020-08-10 05:32:10 +00:00
|
|
|
fileSystemName = "myfs"
|
2019-05-31 09:34:04 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
func deployCephfsPlugin() {
|
2019-12-11 08:48:36 +00:00
|
|
|
// delete objects deployed by rook
|
2020-02-26 08:11:05 +00:00
|
|
|
|
2021-09-20 10:16:55 +00:00
|
|
|
data, err := replaceNamespaceInTemplate(cephFSDirPath + cephFSProvisionerRBAC)
|
2020-02-26 08:11:05 +00:00
|
|
|
if err != nil {
|
2021-09-20 10:16:55 +00:00
|
|
|
e2elog.Failf("failed to read content from %s with error %v", cephFSDirPath+cephFSProvisionerRBAC, err)
|
2020-02-26 08:11:05 +00:00
|
|
|
}
|
2020-04-14 06:59:04 +00:00
|
|
|
_, err = framework.RunKubectlInput(cephCSINamespace, data, "--ignore-not-found=true", ns, "delete", "-f", "-")
|
2020-02-26 08:11:05 +00:00
|
|
|
if err != nil {
|
2021-09-20 10:16:55 +00:00
|
|
|
e2elog.Failf("failed to delete provisioner rbac %s with error %v", cephFSDirPath+cephFSProvisionerRBAC, err)
|
2020-02-26 08:11:05 +00:00
|
|
|
}
|
|
|
|
|
2021-09-20 10:16:55 +00:00
|
|
|
data, err = replaceNamespaceInTemplate(cephFSDirPath + cephFSNodePluginRBAC)
|
2020-02-26 08:11:05 +00:00
|
|
|
if err != nil {
|
2021-09-20 10:16:55 +00:00
|
|
|
e2elog.Failf("failed to read content from %s with error %v", cephFSDirPath+cephFSNodePluginRBAC, err)
|
2020-02-26 08:11:05 +00:00
|
|
|
}
|
2020-04-14 06:59:04 +00:00
|
|
|
_, err = framework.RunKubectlInput(cephCSINamespace, data, "delete", "--ignore-not-found=true", ns, "-f", "-")
|
2020-02-26 08:11:05 +00:00
|
|
|
|
|
|
|
if err != nil {
|
2021-09-20 10:16:55 +00:00
|
|
|
e2elog.Failf("failed to delete nodeplugin rbac %s with error %v", cephFSDirPath+cephFSNodePluginRBAC, err)
|
2020-02-26 08:11:05 +00:00
|
|
|
}
|
|
|
|
|
2021-07-26 15:48:49 +00:00
|
|
|
createORDeleteCephfsResources(kubectlCreate)
|
2019-05-31 09:34:04 +00:00
|
|
|
}
|
|
|
|
|
2019-08-07 14:53:39 +00:00
|
|
|
func deleteCephfsPlugin() {
|
2021-07-26 15:48:49 +00:00
|
|
|
createORDeleteCephfsResources(kubectlDelete)
|
2020-02-26 08:11:05 +00:00
|
|
|
}
|
|
|
|
|
2021-07-26 15:48:49 +00:00
|
|
|
func createORDeleteCephfsResources(action kubectlAction) {
|
2021-09-20 10:16:55 +00:00
|
|
|
csiDriver, err := ioutil.ReadFile(cephFSDirPath + csiDriverObject)
|
2021-03-30 05:33:01 +00:00
|
|
|
if err != nil {
|
2021-06-10 11:39:03 +00:00
|
|
|
// createORDeleteRbdResources is used for upgrade testing as csidriverObject is
|
2021-03-30 05:33:01 +00:00
|
|
|
// newly added, discarding file not found error.
|
|
|
|
if !os.IsNotExist(err) {
|
2021-09-20 10:16:55 +00:00
|
|
|
e2elog.Failf("failed to read content from %s with error %v", cephFSDirPath+csiDriverObject, err)
|
2021-03-30 05:33:01 +00:00
|
|
|
}
|
|
|
|
} else {
|
2021-07-26 15:48:49 +00:00
|
|
|
err = retryKubectlInput(cephCSINamespace, action, string(csiDriver), deployTimeout)
|
2021-03-30 05:33:01 +00:00
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to %s CSIDriver object with error %v", action, err)
|
|
|
|
}
|
|
|
|
}
|
2021-09-02 05:06:21 +00:00
|
|
|
cephConf, err := ioutil.ReadFile(examplePath + cephConfconfigMap)
|
|
|
|
if err != nil {
|
|
|
|
// createORDeleteCephfsResources is used for upgrade testing as cephConfConfigmap is
|
|
|
|
// newly added, discarding file not found error.
|
|
|
|
if !os.IsNotExist(err) {
|
|
|
|
e2elog.Failf("failed to read content from %s with error %v", examplePath+cephConfconfigMap, err)
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
err = retryKubectlInput(cephCSINamespace, action, string(cephConf), deployTimeout)
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to %s ceph-conf configmap object with error %v", action, err)
|
|
|
|
}
|
|
|
|
}
|
2021-09-20 10:16:55 +00:00
|
|
|
data, err := replaceNamespaceInTemplate(cephFSDirPath + cephFSProvisioner)
|
2020-02-26 08:11:05 +00:00
|
|
|
if err != nil {
|
2021-09-20 10:16:55 +00:00
|
|
|
e2elog.Failf("failed to read content from %s with error %v", cephFSDirPath+cephFSProvisioner, err)
|
2020-02-26 08:11:05 +00:00
|
|
|
}
|
2020-09-20 00:43:26 +00:00
|
|
|
data = oneReplicaDeployYaml(data)
|
2021-07-26 15:48:49 +00:00
|
|
|
err = retryKubectlInput(cephCSINamespace, action, data, deployTimeout)
|
2020-02-26 08:11:05 +00:00
|
|
|
if err != nil {
|
2020-09-03 09:34:29 +00:00
|
|
|
e2elog.Failf("failed to %s CephFS provisioner with error %v", action, err)
|
2020-02-26 08:11:05 +00:00
|
|
|
}
|
2021-09-20 10:16:55 +00:00
|
|
|
data, err = replaceNamespaceInTemplate(cephFSDirPath + cephFSProvisionerRBAC)
|
2020-09-03 09:34:29 +00:00
|
|
|
|
2019-08-07 14:53:39 +00:00
|
|
|
if err != nil {
|
2021-09-20 10:16:55 +00:00
|
|
|
e2elog.Failf("failed to read content from %s with error %v", cephFSDirPath+cephFSProvisionerRBAC, err)
|
2019-08-07 14:53:39 +00:00
|
|
|
}
|
2021-07-26 15:48:49 +00:00
|
|
|
err = retryKubectlInput(cephCSINamespace, action, data, deployTimeout)
|
2019-08-07 14:53:39 +00:00
|
|
|
if err != nil {
|
2020-09-03 09:34:29 +00:00
|
|
|
e2elog.Failf("failed to %s CephFS provisioner rbac with error %v", action, err)
|
2019-08-07 14:53:39 +00:00
|
|
|
}
|
2020-02-26 08:11:05 +00:00
|
|
|
|
2021-09-20 10:16:55 +00:00
|
|
|
data, err = replaceNamespaceInTemplate(cephFSDirPath + cephFSProvisionerPSP)
|
2020-02-26 08:11:05 +00:00
|
|
|
if err != nil {
|
2021-09-20 10:16:55 +00:00
|
|
|
e2elog.Failf("failed to read content from %s with error %v", cephFSDirPath+cephFSProvisionerPSP, err)
|
2020-02-26 08:11:05 +00:00
|
|
|
}
|
2021-07-26 15:48:49 +00:00
|
|
|
err = retryKubectlInput(cephCSINamespace, action, data, deployTimeout)
|
2020-02-26 08:11:05 +00:00
|
|
|
if err != nil {
|
2020-09-03 09:34:29 +00:00
|
|
|
e2elog.Failf("failed to %s CephFS provisioner psp with error %v", action, err)
|
2020-02-26 08:11:05 +00:00
|
|
|
}
|
|
|
|
|
2021-09-20 10:16:55 +00:00
|
|
|
data, err = replaceNamespaceInTemplate(cephFSDirPath + cephFSNodePlugin)
|
2020-01-21 08:22:43 +00:00
|
|
|
if err != nil {
|
2021-09-20 10:16:55 +00:00
|
|
|
e2elog.Failf("failed to read content from %s with error %v", cephFSDirPath+cephFSNodePlugin, err)
|
2020-01-21 08:22:43 +00:00
|
|
|
}
|
2021-07-26 15:48:49 +00:00
|
|
|
err = retryKubectlInput(cephCSINamespace, action, data, deployTimeout)
|
2019-08-07 14:53:39 +00:00
|
|
|
if err != nil {
|
2020-09-03 09:34:29 +00:00
|
|
|
e2elog.Failf("failed to %s CephFS nodeplugin with error %v", action, err)
|
2019-08-07 14:53:39 +00:00
|
|
|
}
|
2020-02-26 08:11:05 +00:00
|
|
|
|
2021-09-20 10:16:55 +00:00
|
|
|
data, err = replaceNamespaceInTemplate(cephFSDirPath + cephFSNodePluginRBAC)
|
2019-08-07 14:53:39 +00:00
|
|
|
if err != nil {
|
2021-09-20 10:16:55 +00:00
|
|
|
e2elog.Failf("failed to read content from %s with error %v", cephFSDirPath+cephFSNodePluginRBAC, err)
|
2019-08-07 14:53:39 +00:00
|
|
|
}
|
2021-07-26 15:48:49 +00:00
|
|
|
err = retryKubectlInput(cephCSINamespace, action, data, deployTimeout)
|
2020-02-26 08:11:05 +00:00
|
|
|
if err != nil {
|
2020-09-03 09:34:29 +00:00
|
|
|
e2elog.Failf("failed to %s CephFS nodeplugin rbac with error %v", action, err)
|
2020-02-26 08:11:05 +00:00
|
|
|
}
|
|
|
|
|
2021-09-20 10:16:55 +00:00
|
|
|
data, err = replaceNamespaceInTemplate(cephFSDirPath + cephFSNodePluginPSP)
|
2020-01-21 08:22:43 +00:00
|
|
|
if err != nil {
|
2021-09-20 10:16:55 +00:00
|
|
|
e2elog.Failf("failed to read content from %s with error %v", cephFSDirPath+cephFSNodePluginPSP, err)
|
2020-02-26 08:11:05 +00:00
|
|
|
}
|
2021-07-26 15:48:49 +00:00
|
|
|
err = retryKubectlInput(cephCSINamespace, action, data, deployTimeout)
|
2020-02-26 08:11:05 +00:00
|
|
|
if err != nil {
|
2020-09-03 09:34:29 +00:00
|
|
|
e2elog.Failf("failed to %s CephFS nodeplugin psp with error %v", action, err)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func validateSubvolumeCount(f *framework.Framework, count int, fileSystemName, subvolumegroup string) {
|
|
|
|
subVol, err := listCephFSSubVolumes(f, fileSystemName, subvolumegroup)
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to list CephFS subvolumes with error %v", err)
|
|
|
|
}
|
|
|
|
if len(subVol) != count {
|
|
|
|
e2elog.Failf("subvolumes [%v]. subvolume count %d not matching expected count %v", subVol, len(subVol), count)
|
2020-01-21 08:22:43 +00:00
|
|
|
}
|
2019-08-07 14:53:39 +00:00
|
|
|
}
|
|
|
|
|
2021-02-09 10:32:40 +00:00
|
|
|
func validateSubvolumePath(f *framework.Framework, pvcName, pvcNamespace, fileSystemName, subvolumegroup string) error {
|
|
|
|
_, pv, err := getPVCAndPV(f.ClientSet, pvcName, pvcNamespace)
|
|
|
|
if err != nil {
|
|
|
|
return fmt.Errorf("failed to get PVC %s in namespace %s with error %w", pvcName, pvcNamespace, err)
|
|
|
|
}
|
|
|
|
subVolumePathInPV := pv.Spec.CSI.VolumeAttributes["subvolumePath"]
|
|
|
|
subVolume := pv.Spec.CSI.VolumeAttributes["subvolumeName"]
|
|
|
|
if subVolumePathInPV == "" {
|
|
|
|
return fmt.Errorf("subvolumePath is not set in %s PVC", pvcName)
|
|
|
|
}
|
|
|
|
if subVolume == "" {
|
|
|
|
return fmt.Errorf("subvolumeName is not set in %s PVC", pvcName)
|
|
|
|
}
|
|
|
|
subVolumePath, err := getSubvolumePath(f, fileSystemName, subvolumegroup, subVolume)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
if subVolumePath != subVolumePathInPV {
|
2021-06-25 12:31:28 +00:00
|
|
|
return fmt.Errorf(
|
|
|
|
"subvolumePath %s is not matching the subvolumePath %s in PV",
|
|
|
|
subVolumePath,
|
|
|
|
subVolumePathInPV)
|
2021-02-09 10:32:40 +00:00
|
|
|
}
|
2021-07-22 05:45:17 +00:00
|
|
|
|
2021-02-09 10:32:40 +00:00
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2019-05-31 09:34:04 +00:00
|
|
|
var _ = Describe("cephfs", func() {
|
|
|
|
f := framework.NewDefaultFramework("cephfs")
|
2019-12-18 08:41:20 +00:00
|
|
|
var c clientset.Interface
|
2020-09-03 09:34:29 +00:00
|
|
|
// deploy CephFS CSI
|
2019-05-31 09:34:04 +00:00
|
|
|
BeforeEach(func() {
|
2020-07-25 16:39:50 +00:00
|
|
|
if !testCephFS || upgradeTesting {
|
2020-07-08 11:46:31 +00:00
|
|
|
Skip("Skipping CephFS E2E")
|
|
|
|
}
|
2019-12-18 08:41:20 +00:00
|
|
|
c = f.ClientSet
|
2020-02-25 08:00:23 +00:00
|
|
|
if deployCephFS {
|
2020-02-25 11:45:54 +00:00
|
|
|
if cephCSINamespace != defaultNs {
|
2020-02-26 08:11:05 +00:00
|
|
|
err := createNamespace(c, cephCSINamespace)
|
|
|
|
if err != nil {
|
2020-09-03 09:34:29 +00:00
|
|
|
e2elog.Failf("failed to create namespace %s with error %v", cephCSINamespace, err)
|
2020-02-25 11:45:54 +00:00
|
|
|
}
|
|
|
|
}
|
2020-02-25 08:00:23 +00:00
|
|
|
deployCephfsPlugin()
|
|
|
|
}
|
2021-09-20 10:16:55 +00:00
|
|
|
err := createConfigMap(cephFSDirPath, f.ClientSet, f)
|
2020-09-03 09:34:29 +00:00
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to create configmap with error %v", err)
|
|
|
|
}
|
2021-02-22 11:13:40 +00:00
|
|
|
// create cephFS provisioner secret
|
|
|
|
key, err := createCephUser(f, keyringCephFSProvisionerUsername, cephFSProvisionerCaps())
|
2020-09-03 09:34:29 +00:00
|
|
|
if err != nil {
|
2021-02-22 11:13:40 +00:00
|
|
|
e2elog.Failf("failed to create user %s with error %v", keyringCephFSProvisionerUsername, err)
|
|
|
|
}
|
|
|
|
err = createCephfsSecret(f, cephFSProvisionerSecretName, keyringCephFSProvisionerUsername, key)
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to create provisioner secret with error %v", err)
|
|
|
|
}
|
|
|
|
// create cephFS plugin secret
|
|
|
|
key, err = createCephUser(f, keyringCephFSNodePluginUsername, cephFSNodePluginCaps())
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to create user %s with error %v", keyringCephFSNodePluginUsername, err)
|
|
|
|
}
|
|
|
|
err = createCephfsSecret(f, cephFSNodePluginSecretName, keyringCephFSNodePluginUsername, key)
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to create node secret with error %v", err)
|
2020-09-03 09:34:29 +00:00
|
|
|
}
|
2019-05-31 09:34:04 +00:00
|
|
|
})
|
|
|
|
|
|
|
|
AfterEach(func() {
|
2020-07-25 16:39:50 +00:00
|
|
|
if !testCephFS || upgradeTesting {
|
2020-07-08 11:46:31 +00:00
|
|
|
Skip("Skipping CephFS E2E")
|
|
|
|
}
|
2019-12-18 08:41:20 +00:00
|
|
|
if CurrentGinkgoTestDescription().Failed {
|
2020-04-01 07:20:43 +00:00
|
|
|
// log pods created by helm chart
|
|
|
|
logsCSIPods("app=ceph-csi-cephfs", c)
|
2021-06-10 11:39:03 +00:00
|
|
|
// log provisioner
|
2019-12-18 08:41:20 +00:00
|
|
|
logsCSIPods("app=csi-cephfsplugin-provisioner", c)
|
|
|
|
// log node plugin
|
|
|
|
logsCSIPods("app=csi-cephfsplugin", c)
|
2020-12-03 11:00:22 +00:00
|
|
|
|
|
|
|
// log all details from the namespace where Ceph-CSI is deployed
|
|
|
|
framework.DumpAllNamespaceInfo(c, cephCSINamespace)
|
2019-12-18 08:41:20 +00:00
|
|
|
}
|
2021-09-20 10:16:55 +00:00
|
|
|
err := deleteConfigMap(cephFSDirPath)
|
2020-09-03 09:34:29 +00:00
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to delete configmap with error %v", err)
|
|
|
|
}
|
2021-06-25 12:31:28 +00:00
|
|
|
err = c.CoreV1().
|
|
|
|
Secrets(cephCSINamespace).
|
|
|
|
Delete(context.TODO(), cephFSProvisionerSecretName, metav1.DeleteOptions{})
|
2021-02-22 11:13:40 +00:00
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to delete provisioner secret with error %v", err)
|
|
|
|
}
|
2021-06-25 12:31:28 +00:00
|
|
|
err = c.CoreV1().
|
|
|
|
Secrets(cephCSINamespace).
|
|
|
|
Delete(context.TODO(), cephFSNodePluginSecretName, metav1.DeleteOptions{})
|
2020-09-03 09:34:29 +00:00
|
|
|
if err != nil {
|
2021-02-22 11:13:40 +00:00
|
|
|
e2elog.Failf("failed to delete node secret with error %v", err)
|
2020-09-03 09:34:29 +00:00
|
|
|
}
|
2021-09-20 10:16:55 +00:00
|
|
|
err = deleteResource(cephFSExamplePath + "storageclass.yaml")
|
2020-09-03 09:34:29 +00:00
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to delete storageclass with error %v", err)
|
|
|
|
}
|
2020-02-25 11:45:54 +00:00
|
|
|
if deployCephFS {
|
|
|
|
deleteCephfsPlugin()
|
|
|
|
if cephCSINamespace != defaultNs {
|
2020-02-26 08:11:05 +00:00
|
|
|
err := deleteNamespace(c, cephCSINamespace)
|
2020-02-25 11:45:54 +00:00
|
|
|
if err != nil {
|
2020-09-03 09:34:29 +00:00
|
|
|
e2elog.Failf("failed to delete namespace %s with error %v", cephCSINamespace, err)
|
2020-02-25 11:45:54 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2019-05-31 09:34:04 +00:00
|
|
|
})
|
|
|
|
|
2020-09-03 09:34:29 +00:00
|
|
|
Context("Test CephFS CSI", func() {
|
|
|
|
It("Test CephFS CSI", func() {
|
2021-09-20 10:16:55 +00:00
|
|
|
pvcPath := cephFSExamplePath + "pvc.yaml"
|
|
|
|
appPath := cephFSExamplePath + "pod.yaml"
|
|
|
|
pvcClonePath := cephFSExamplePath + "pvc-restore.yaml"
|
|
|
|
pvcSmartClonePath := cephFSExamplePath + "pvc-clone.yaml"
|
|
|
|
appClonePath := cephFSExamplePath + "pod-restore.yaml"
|
|
|
|
appSmartClonePath := cephFSExamplePath + "pod-clone.yaml"
|
|
|
|
snapshotPath := cephFSExamplePath + "snapshot.yaml"
|
2019-07-25 06:49:44 +00:00
|
|
|
|
2020-09-03 09:34:29 +00:00
|
|
|
By("checking provisioner deployment is running", func() {
|
2021-09-20 10:16:55 +00:00
|
|
|
err := waitForDeploymentComplete(cephFSDeploymentName, cephCSINamespace, f.ClientSet, deployTimeout)
|
2020-09-03 09:34:29 +00:00
|
|
|
if err != nil {
|
2021-09-20 10:16:55 +00:00
|
|
|
e2elog.Failf("timeout waiting for deployment %s with error %v", cephFSDeploymentName, err)
|
2020-09-03 09:34:29 +00:00
|
|
|
}
|
|
|
|
})
|
2019-05-31 09:34:04 +00:00
|
|
|
|
2020-09-03 09:34:29 +00:00
|
|
|
By("checking nodeplugin deamonset pods are running", func() {
|
2021-09-20 10:16:55 +00:00
|
|
|
err := waitForDaemonSets(cephFSDeamonSetName, cephCSINamespace, f.ClientSet, deployTimeout)
|
2020-09-03 09:34:29 +00:00
|
|
|
if err != nil {
|
2021-09-20 10:16:55 +00:00
|
|
|
e2elog.Failf("timeout waiting for daemonset %s with error %v", cephFSDeamonSetName, err)
|
2020-09-03 09:34:29 +00:00
|
|
|
}
|
|
|
|
})
|
2019-05-31 09:34:04 +00:00
|
|
|
|
2021-04-22 06:57:55 +00:00
|
|
|
// test only if ceph-csi is deployed via helm
|
|
|
|
if helmTest {
|
|
|
|
By("verify PVC and app binding on helm installation", func() {
|
|
|
|
err := validatePVCAndAppBinding(pvcPath, appPath, f)
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to validate CephFS pvc and application binding with error %v", err)
|
|
|
|
}
|
|
|
|
// Deleting the storageclass and secret created by helm
|
2021-09-20 10:16:55 +00:00
|
|
|
err = deleteResource(cephFSExamplePath + "storageclass.yaml")
|
2021-04-22 06:57:55 +00:00
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to delete CephFS storageclass with error %v", err)
|
|
|
|
}
|
2021-09-20 10:16:55 +00:00
|
|
|
err = deleteResource(cephFSExamplePath + "secret.yaml")
|
2021-04-22 06:57:55 +00:00
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to delete CephFS storageclass with error %v", err)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2020-05-14 01:48:09 +00:00
|
|
|
By("check static PVC", func() {
|
2021-09-20 10:16:55 +00:00
|
|
|
scPath := cephFSExamplePath + "secret.yaml"
|
2020-05-14 01:48:09 +00:00
|
|
|
err := validateCephFsStaticPV(f, appPath, scPath)
|
|
|
|
if err != nil {
|
2020-09-03 09:34:29 +00:00
|
|
|
e2elog.Failf("failed to validate CephFS static pv with error %v", err)
|
2020-05-14 01:48:09 +00:00
|
|
|
}
|
|
|
|
})
|
|
|
|
|
2020-09-03 09:34:29 +00:00
|
|
|
By("create a storageclass with pool and a PVC then bind it to an app", func() {
|
2020-09-21 14:56:15 +00:00
|
|
|
err := createCephfsStorageClass(f.ClientSet, f, true, nil)
|
2020-09-03 09:34:29 +00:00
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to create CephFS storageclass with error %v", err)
|
|
|
|
}
|
|
|
|
err = validatePVCAndAppBinding(pvcPath, appPath, f)
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to validate CephFS pvc and application binding with error %v", err)
|
|
|
|
}
|
2021-09-20 10:16:55 +00:00
|
|
|
err = deleteResource(cephFSExamplePath + "storageclass.yaml")
|
2020-09-03 09:34:29 +00:00
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to delete CephFS storageclass with error %v", err)
|
|
|
|
}
|
2019-08-05 15:40:48 +00:00
|
|
|
})
|
|
|
|
|
2021-02-19 06:01:27 +00:00
|
|
|
By("create PVC in storageClass with volumeNamePrefix", func() {
|
|
|
|
volumeNamePrefix := "foo-bar-"
|
2021-06-25 12:31:28 +00:00
|
|
|
err := createCephfsStorageClass(
|
|
|
|
f.ClientSet,
|
|
|
|
f,
|
|
|
|
false,
|
|
|
|
map[string]string{"volumeNamePrefix": volumeNamePrefix})
|
2021-02-19 06:01:27 +00:00
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to create storageclass with error %v", err)
|
|
|
|
}
|
|
|
|
// set up PVC
|
|
|
|
pvc, err := loadPVC(pvcPath)
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to load PVC with error %v", err)
|
|
|
|
}
|
|
|
|
pvc.Namespace = f.UniqueName
|
|
|
|
err = createPVCAndvalidatePV(f.ClientSet, pvc, deployTimeout)
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to create PVC with error %v", err)
|
|
|
|
}
|
|
|
|
|
|
|
|
validateSubvolumeCount(f, 1, fileSystemName, subvolumegroup)
|
|
|
|
// list subvolumes and check if one of them has the same prefix
|
|
|
|
foundIt := false
|
|
|
|
subvolumes, err := listCephFSSubVolumes(f, fileSystemName, subvolumegroup)
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to list subvolumes with error %v", err)
|
|
|
|
}
|
|
|
|
for _, subVol := range subvolumes {
|
|
|
|
fmt.Printf("Checking prefix on %s\n", subVol)
|
|
|
|
if strings.HasPrefix(subVol.Name, volumeNamePrefix) {
|
|
|
|
foundIt = true
|
2021-07-22 05:45:17 +00:00
|
|
|
|
2021-02-19 06:01:27 +00:00
|
|
|
break
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// clean up after ourselves
|
|
|
|
err = deletePVCAndValidatePV(f.ClientSet, pvc, deployTimeout)
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to delete PVC with error %v", err)
|
|
|
|
}
|
|
|
|
validateSubvolumeCount(f, 0, fileSystemName, subvolumegroup)
|
2021-09-20 10:16:55 +00:00
|
|
|
err = deleteResource(cephFSExamplePath + "storageclass.yaml")
|
2021-02-19 06:01:27 +00:00
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to delete storageclass with error %v", err)
|
|
|
|
}
|
|
|
|
if !foundIt {
|
|
|
|
e2elog.Failf("could not find subvolume with prefix %s", volumeNamePrefix)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
2020-09-21 15:03:21 +00:00
|
|
|
By("create a storageclass with ceph-fuse and a PVC then bind it to an app", func() {
|
|
|
|
params := map[string]string{
|
|
|
|
"mounter": "fuse",
|
|
|
|
}
|
|
|
|
err := createCephfsStorageClass(f.ClientSet, f, true, params)
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to create CephFS storageclass with error %v", err)
|
|
|
|
}
|
|
|
|
err = validatePVCAndAppBinding(pvcPath, appPath, f)
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to validate CephFS pvc and application binding with error %v", err)
|
|
|
|
}
|
2021-09-20 10:16:55 +00:00
|
|
|
err = deleteResource(cephFSExamplePath + "storageclass.yaml")
|
2020-09-21 15:03:21 +00:00
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to delete CephFS storageclass with error %v", err)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
|
|
|
By("create a storageclass with ceph-fuse, mount-options and a PVC then bind it to an app", func() {
|
|
|
|
params := map[string]string{
|
|
|
|
"mounter": "fuse",
|
|
|
|
"fuseMountOptions": "debug",
|
|
|
|
}
|
|
|
|
err := createCephfsStorageClass(f.ClientSet, f, true, params)
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to create CephFS storageclass with error %v", err)
|
|
|
|
}
|
|
|
|
err = validatePVCAndAppBinding(pvcPath, appPath, f)
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to validate CephFS pvc and application binding with error %v", err)
|
|
|
|
}
|
2021-09-20 10:16:55 +00:00
|
|
|
err = deleteResource(cephFSExamplePath + "storageclass.yaml")
|
2020-09-21 15:03:21 +00:00
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to delete CephFS storageclass with error %v", err)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
2020-09-03 09:34:29 +00:00
|
|
|
By("create a PVC and bind it to an app", func() {
|
2020-09-21 14:56:15 +00:00
|
|
|
err := createCephfsStorageClass(f.ClientSet, f, false, nil)
|
2020-09-03 09:34:29 +00:00
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to create CephFS storageclass with error %v", err)
|
|
|
|
}
|
|
|
|
err = validatePVCAndAppBinding(pvcPath, appPath, f)
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to validate CephFS pvc and application binding with error %v", err)
|
|
|
|
}
|
|
|
|
})
|
2019-05-31 09:34:04 +00:00
|
|
|
|
2020-09-03 09:34:29 +00:00
|
|
|
By("create a PVC and bind it to an app with normal user", func() {
|
|
|
|
err := validateNormalUserPVCAccess(pvcPath, f)
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to validate normal user CephFS pvc and application binding with error %v", err)
|
|
|
|
}
|
|
|
|
})
|
2019-05-31 09:34:04 +00:00
|
|
|
|
2020-09-03 09:34:29 +00:00
|
|
|
By("create/delete multiple PVCs and Apps", func() {
|
|
|
|
totalCount := 2
|
|
|
|
pvc, err := loadPVC(pvcPath)
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to load PVC with error %v", err)
|
|
|
|
}
|
|
|
|
pvc.Namespace = f.UniqueName
|
2019-06-18 07:07:11 +00:00
|
|
|
|
2020-09-03 09:34:29 +00:00
|
|
|
app, err := loadApp(appPath)
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to load application with error %v", err)
|
|
|
|
}
|
|
|
|
app.Namespace = f.UniqueName
|
|
|
|
// create PVC and app
|
|
|
|
for i := 0; i < totalCount; i++ {
|
|
|
|
name := fmt.Sprintf("%s%d", f.UniqueName, i)
|
|
|
|
err = createPVCAndApp(name, f, pvc, app, deployTimeout)
|
2019-06-18 07:07:11 +00:00
|
|
|
if err != nil {
|
2020-09-03 09:34:29 +00:00
|
|
|
e2elog.Failf("failed to create PVC or application with error %v", err)
|
2019-06-18 07:07:11 +00:00
|
|
|
}
|
2021-02-09 10:32:40 +00:00
|
|
|
err = validateSubvolumePath(f, pvc.Name, pvc.Namespace, fileSystemName, subvolumegroup)
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to validate subvolumePath with error %v", err)
|
|
|
|
}
|
2020-09-03 09:34:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
validateSubvolumeCount(f, totalCount, fileSystemName, subvolumegroup)
|
|
|
|
// delete PVC and app
|
|
|
|
for i := 0; i < totalCount; i++ {
|
|
|
|
name := fmt.Sprintf("%s%d", f.UniqueName, i)
|
|
|
|
err = deletePVCAndApp(name, f, pvc, app)
|
2019-06-18 07:07:11 +00:00
|
|
|
if err != nil {
|
2020-09-03 09:34:29 +00:00
|
|
|
e2elog.Failf("failed to delete PVC or application with error %v", err)
|
2019-06-18 07:07:11 +00:00
|
|
|
}
|
|
|
|
|
2020-09-03 09:34:29 +00:00
|
|
|
}
|
|
|
|
validateSubvolumeCount(f, 0, fileSystemName, subvolumegroup)
|
|
|
|
})
|
2019-06-18 07:07:11 +00:00
|
|
|
|
2020-09-03 09:34:29 +00:00
|
|
|
By("check data persist after recreating pod", func() {
|
|
|
|
err := checkDataPersist(pvcPath, appPath, f)
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to check data persist in pvc with error %v", err)
|
|
|
|
}
|
|
|
|
})
|
2019-06-18 07:07:11 +00:00
|
|
|
|
2021-03-22 06:17:42 +00:00
|
|
|
By("Create PVC, bind it to an app, unmount volume and check app deletion", func() {
|
|
|
|
pvc, app, err := createPVCAndAppBinding(pvcPath, appPath, f, deployTimeout)
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to create PVC or application with error %v", err)
|
|
|
|
}
|
|
|
|
|
|
|
|
err = unmountCephFSVolume(f, app.Name, pvc.Name)
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to unmount volume with error %v", err)
|
|
|
|
}
|
|
|
|
|
|
|
|
err = deletePVCAndApp("", f, pvc, app)
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to delete PVC or application with error %v", err)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
2020-09-03 09:34:29 +00:00
|
|
|
By("create PVC, delete backing subvolume and check pv deletion", func() {
|
|
|
|
pvc, err := loadPVC(pvcPath)
|
2020-10-20 09:55:09 +00:00
|
|
|
if err != nil {
|
2020-09-03 09:34:29 +00:00
|
|
|
e2elog.Failf("failed to load PVC with error %v", err)
|
|
|
|
}
|
|
|
|
pvc.Namespace = f.UniqueName
|
2020-01-23 01:47:02 +00:00
|
|
|
|
2020-09-03 09:34:29 +00:00
|
|
|
err = createPVCAndvalidatePV(f.ClientSet, pvc, deployTimeout)
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to create PVC with error %v", err)
|
|
|
|
}
|
2020-01-23 01:47:02 +00:00
|
|
|
|
2020-09-03 09:34:29 +00:00
|
|
|
err = deleteBackingCephFSVolume(f, pvc)
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to delete CephFS subvolume with error %v", err)
|
|
|
|
}
|
2020-01-23 01:47:02 +00:00
|
|
|
|
2020-09-03 09:34:29 +00:00
|
|
|
err = deletePVCAndValidatePV(f.ClientSet, pvc, deployTimeout)
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to delete PVC with error %v", err)
|
|
|
|
}
|
|
|
|
})
|
2020-01-23 01:47:02 +00:00
|
|
|
|
2020-09-03 09:34:29 +00:00
|
|
|
By("validate multiple subvolumegroup creation", func() {
|
2021-09-20 10:16:55 +00:00
|
|
|
err := deleteResource(cephFSExamplePath + "storageclass.yaml")
|
2020-09-03 09:34:29 +00:00
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to delete storageclass with error %v", err)
|
|
|
|
}
|
2021-10-01 04:06:06 +00:00
|
|
|
|
2020-09-03 09:34:29 +00:00
|
|
|
// re-define configmap with information of multiple clusters.
|
2021-10-01 04:06:06 +00:00
|
|
|
clusterInfo := map[string]map[string]string{}
|
|
|
|
clusterID1 := "clusterID-1"
|
|
|
|
clusterID2 := "clusterID-2"
|
|
|
|
clusterInfo[clusterID1] = map[string]string{}
|
|
|
|
clusterInfo[clusterID1]["subvolumeGroup"] = "subvolgrp1"
|
|
|
|
clusterInfo[clusterID2] = map[string]string{}
|
|
|
|
clusterInfo[clusterID2]["subvolumeGroup"] = "subvolgrp2"
|
|
|
|
|
|
|
|
err = createCustomConfigMap(f.ClientSet, cephFSDirPath, clusterInfo)
|
2020-09-03 09:34:29 +00:00
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to create configmap with error %v", err)
|
|
|
|
}
|
2020-09-21 14:56:15 +00:00
|
|
|
params := map[string]string{
|
|
|
|
"clusterID": "clusterID-1",
|
|
|
|
}
|
|
|
|
err = createCephfsStorageClass(f.ClientSet, f, false, params)
|
2020-09-03 09:34:29 +00:00
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to create storageclass with error %v", err)
|
|
|
|
}
|
|
|
|
err = validatePVCAndAppBinding(pvcPath, appPath, f)
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to validate pvc and application with error %v", err)
|
|
|
|
}
|
2021-09-20 10:16:55 +00:00
|
|
|
err = deleteResource(cephFSExamplePath + "storageclass.yaml")
|
2020-09-03 09:34:29 +00:00
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to delete storageclass with error %v", err)
|
|
|
|
}
|
2021-06-10 11:39:03 +00:00
|
|
|
// verify subvolume group creation.
|
2020-09-03 09:34:29 +00:00
|
|
|
err = validateSubvolumegroup(f, "subvolgrp1")
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to validate subvolume group with error %v", err)
|
|
|
|
}
|
2020-06-25 13:48:48 +00:00
|
|
|
|
2020-09-03 09:34:29 +00:00
|
|
|
// create resources and verify subvolume group creation
|
|
|
|
// for the second cluster.
|
2020-09-21 14:56:15 +00:00
|
|
|
params["clusterID"] = "clusterID-2"
|
|
|
|
err = createCephfsStorageClass(f.ClientSet, f, false, params)
|
2020-09-03 09:34:29 +00:00
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to create storageclass with error %v", err)
|
|
|
|
}
|
|
|
|
err = validatePVCAndAppBinding(pvcPath, appPath, f)
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to validate pvc and application with error %v", err)
|
|
|
|
}
|
2021-09-20 10:16:55 +00:00
|
|
|
err = deleteResource(cephFSExamplePath + "storageclass.yaml")
|
2020-09-03 09:34:29 +00:00
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to delete storageclass with error %v", err)
|
|
|
|
}
|
|
|
|
err = validateSubvolumegroup(f, "subvolgrp2")
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to validate subvolume group with error %v", err)
|
|
|
|
}
|
2021-09-20 10:16:55 +00:00
|
|
|
err = deleteConfigMap(cephFSDirPath)
|
2020-09-03 09:34:29 +00:00
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to delete configmap with error %v", err)
|
|
|
|
}
|
2021-09-20 10:16:55 +00:00
|
|
|
err = createConfigMap(cephFSDirPath, f.ClientSet, f)
|
2020-09-03 09:34:29 +00:00
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to create configmap with error %v", err)
|
|
|
|
}
|
2020-09-21 14:56:15 +00:00
|
|
|
err = createCephfsStorageClass(f.ClientSet, f, false, nil)
|
2020-09-03 09:34:29 +00:00
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to create storageclass with error %v", err)
|
|
|
|
}
|
|
|
|
})
|
2020-06-25 13:48:48 +00:00
|
|
|
|
2020-09-03 09:34:29 +00:00
|
|
|
By("Resize PVC and check application directory size", func() {
|
|
|
|
// Resize 0.3.0 is only supported from v1.15+
|
2020-10-14 09:00:25 +00:00
|
|
|
if k8sVersionGreaterEquals(f.ClientSet, 1, 15) {
|
2020-09-03 09:34:29 +00:00
|
|
|
err := resizePVCAndValidateSize(pvcPath, appPath, f)
|
2019-11-25 11:09:24 +00:00
|
|
|
if err != nil {
|
2020-09-03 09:34:29 +00:00
|
|
|
e2elog.Failf("failed to resize PVC with error %v", err)
|
2019-11-25 11:09:24 +00:00
|
|
|
}
|
2020-09-03 09:34:29 +00:00
|
|
|
}
|
|
|
|
})
|
2019-11-25 11:09:24 +00:00
|
|
|
|
2020-09-03 09:34:29 +00:00
|
|
|
By("Mount pvc as readonly in pod", func() {
|
|
|
|
// create PVC and bind it to an app
|
|
|
|
pvc, err := loadPVC(pvcPath)
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to load PVC with error %v", err)
|
|
|
|
}
|
|
|
|
pvc.Namespace = f.UniqueName
|
|
|
|
|
|
|
|
app, err := loadApp(appPath)
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to load application with error %v", err)
|
|
|
|
}
|
|
|
|
|
|
|
|
app.Namespace = f.UniqueName
|
|
|
|
label := map[string]string{
|
|
|
|
"app": app.Name,
|
|
|
|
}
|
|
|
|
app.Labels = label
|
|
|
|
app.Spec.Volumes[0].PersistentVolumeClaim.ClaimName = pvc.Name
|
|
|
|
app.Spec.Volumes[0].PersistentVolumeClaim.ReadOnly = true
|
|
|
|
err = createPVCAndApp("", f, pvc, app, deployTimeout)
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to create PVC or application with error %v", err)
|
|
|
|
}
|
|
|
|
|
|
|
|
opt := metav1.ListOptions{
|
|
|
|
LabelSelector: fmt.Sprintf("app=%s", app.Name),
|
|
|
|
}
|
2019-11-25 11:09:24 +00:00
|
|
|
|
2020-09-03 09:34:29 +00:00
|
|
|
filePath := app.Spec.Containers[0].VolumeMounts[0].MountPath + "/test"
|
2021-06-25 12:31:28 +00:00
|
|
|
_, stdErr := execCommandInPodAndAllowFail(
|
|
|
|
f,
|
|
|
|
fmt.Sprintf("echo 'Hello World' > %s", filePath),
|
|
|
|
app.Namespace,
|
|
|
|
&opt)
|
2020-09-03 09:34:29 +00:00
|
|
|
readOnlyErr := fmt.Sprintf("cannot create %s: Read-only file system", filePath)
|
|
|
|
if !strings.Contains(stdErr, readOnlyErr) {
|
|
|
|
e2elog.Failf(stdErr)
|
|
|
|
}
|
2019-07-03 10:02:36 +00:00
|
|
|
|
2020-09-03 09:34:29 +00:00
|
|
|
// delete PVC and app
|
|
|
|
err = deletePVCAndApp("", f, pvc, app)
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to delete PVC or application with error %v", err)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
2021-02-10 08:19:40 +00:00
|
|
|
By("Delete snapshot after deleting subvolume and snapshot from backend", func() {
|
|
|
|
// snapshot beta is only supported from v1.17+
|
|
|
|
if k8sVersionGreaterEquals(f.ClientSet, 1, 17) {
|
|
|
|
err := createCephFSSnapshotClass(f)
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to create CephFS snapshotclass with error %v", err)
|
|
|
|
}
|
|
|
|
pvc, err := loadPVC(pvcPath)
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to load PVC with error %v", err)
|
|
|
|
}
|
|
|
|
|
|
|
|
pvc.Namespace = f.UniqueName
|
|
|
|
err = createPVCAndvalidatePV(f.ClientSet, pvc, deployTimeout)
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to create PVC with error %v", err)
|
|
|
|
}
|
|
|
|
|
|
|
|
snap := getSnapshot(snapshotPath)
|
|
|
|
snap.Namespace = f.UniqueName
|
|
|
|
snap.Spec.Source.PersistentVolumeClaimName = &pvc.Name
|
|
|
|
// create snapshot
|
|
|
|
snap.Name = f.UniqueName
|
|
|
|
err = createSnapshot(&snap, deployTimeout)
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to create snapshot (%s): %v", snap.Name, err)
|
|
|
|
}
|
|
|
|
|
|
|
|
err = deleteBackingCephFSSubvolumeSnapshot(f, pvc, &snap)
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to delete backing snapshot for snapname with error=%s", err)
|
|
|
|
}
|
|
|
|
|
|
|
|
err = deleteBackingCephFSVolume(f, pvc)
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to delete backing subvolume error=%s", err)
|
|
|
|
}
|
|
|
|
|
|
|
|
err = deleteSnapshot(&snap, deployTimeout)
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to delete snapshot with error=%s", err)
|
|
|
|
} else {
|
|
|
|
e2elog.Logf("successfully deleted snapshot")
|
|
|
|
}
|
|
|
|
|
|
|
|
err = deletePVCAndValidatePV(f.ClientSet, pvc, deployTimeout)
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to delete PVC with error %v", err)
|
|
|
|
}
|
|
|
|
|
2021-09-20 10:16:55 +00:00
|
|
|
err = deleteResource(cephFSExamplePath + "snapshotclass.yaml")
|
2021-02-10 08:19:40 +00:00
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to delete CephFS snapshotclass with error %v", err)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
2021-02-18 08:32:38 +00:00
|
|
|
By("Test snapshot retention feature", func() {
|
|
|
|
// Delete the PVC after creating a snapshot,
|
|
|
|
// this should work because of the snapshot
|
|
|
|
// retention feature. Restore a PVC from that
|
|
|
|
// snapshot.
|
|
|
|
// snapshot beta is only supported from v1.17+
|
|
|
|
if k8sVersionGreaterEquals(f.ClientSet, 1, 17) {
|
|
|
|
err := createCephFSSnapshotClass(f)
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to create CephFS snapshotclass with error %v", err)
|
|
|
|
}
|
|
|
|
pvc, err := loadPVC(pvcPath)
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to load PVC with error %v", err)
|
|
|
|
}
|
|
|
|
|
|
|
|
pvc.Namespace = f.UniqueName
|
|
|
|
err = createPVCAndvalidatePV(f.ClientSet, pvc, deployTimeout)
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to create PVC with error %v", err)
|
|
|
|
}
|
|
|
|
|
|
|
|
snap := getSnapshot(snapshotPath)
|
|
|
|
snap.Namespace = f.UniqueName
|
|
|
|
snap.Spec.Source.PersistentVolumeClaimName = &pvc.Name
|
|
|
|
// create snapshot
|
|
|
|
snap.Name = f.UniqueName
|
|
|
|
err = createSnapshot(&snap, deployTimeout)
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to create snapshot (%s): %v", snap.Name, err)
|
|
|
|
}
|
|
|
|
|
|
|
|
// Delete the parent pvc before restoring
|
|
|
|
// another one from snapshot.
|
|
|
|
err = deletePVCAndValidatePV(f.ClientSet, pvc, deployTimeout)
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to delete PVC with error %v", err)
|
|
|
|
}
|
|
|
|
|
|
|
|
pvcClone, err := loadPVC(pvcClonePath)
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to load PVC with error %v", err)
|
|
|
|
}
|
|
|
|
|
|
|
|
appClone, err := loadApp(appClonePath)
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to load application with error %v", err)
|
|
|
|
}
|
|
|
|
|
|
|
|
pvcClone.Namespace = f.UniqueName
|
|
|
|
appClone.Namespace = f.UniqueName
|
|
|
|
pvcClone.Spec.DataSource.Name = snap.Name
|
|
|
|
|
|
|
|
// create PVC from the snapshot
|
|
|
|
name := f.UniqueName
|
|
|
|
err = createPVCAndApp(name, f, pvcClone, appClone, deployTimeout)
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Logf("failed to create PVC and app (%s): %v", f.UniqueName, err)
|
|
|
|
}
|
|
|
|
|
|
|
|
// delete clone and app
|
|
|
|
err = deletePVCAndApp(name, f, pvcClone, appClone)
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to delete PVC and app (%s): %v", f.UniqueName, err)
|
|
|
|
}
|
|
|
|
|
|
|
|
// delete snapshot
|
|
|
|
err = deleteSnapshot(&snap, deployTimeout)
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to delete snapshot (%s): %v", f.UniqueName, err)
|
|
|
|
}
|
|
|
|
|
2021-09-20 10:16:55 +00:00
|
|
|
err = deleteResource(cephFSExamplePath + "snapshotclass.yaml")
|
2021-02-18 08:32:38 +00:00
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to delete CephFS snapshotclass with error %v", err)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
2020-09-03 09:34:29 +00:00
|
|
|
By("create a PVC clone and bind it to an app", func() {
|
|
|
|
// snapshot beta is only supported from v1.17+
|
2020-10-14 09:00:25 +00:00
|
|
|
if k8sVersionGreaterEquals(f.ClientSet, 1, 17) {
|
2020-09-03 09:34:29 +00:00
|
|
|
var wg sync.WaitGroup
|
|
|
|
totalCount := 3
|
2020-11-04 14:45:06 +00:00
|
|
|
wgErrs := make([]error, totalCount)
|
2020-09-03 09:34:29 +00:00
|
|
|
// totalSubvolumes represents the subvolumes in backend
|
|
|
|
// always totalCount+parentPVC
|
|
|
|
totalSubvolumes := totalCount + 1
|
|
|
|
wg.Add(totalCount)
|
2020-10-14 09:00:25 +00:00
|
|
|
err := createCephFSSnapshotClass(f)
|
2020-09-03 09:34:29 +00:00
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to delete CephFS storageclass with error %v", err)
|
|
|
|
}
|
2020-06-16 10:56:14 +00:00
|
|
|
pvc, err := loadPVC(pvcPath)
|
|
|
|
if err != nil {
|
2020-09-03 09:34:29 +00:00
|
|
|
e2elog.Failf("failed to load PVC with error %v", err)
|
2020-06-16 10:56:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
pvc.Namespace = f.UniqueName
|
2020-09-03 09:34:29 +00:00
|
|
|
err = createPVCAndvalidatePV(f.ClientSet, pvc, deployTimeout)
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to create PVC with error %v", err)
|
|
|
|
}
|
2020-06-16 10:56:14 +00:00
|
|
|
|
|
|
|
app, err := loadApp(appPath)
|
|
|
|
if err != nil {
|
2020-09-03 09:34:29 +00:00
|
|
|
e2elog.Failf("failed to load application with error %v", err)
|
2020-06-16 10:56:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
app.Namespace = f.UniqueName
|
|
|
|
app.Spec.Volumes[0].PersistentVolumeClaim.ClaimName = pvc.Name
|
2020-10-13 05:34:55 +00:00
|
|
|
label := make(map[string]string)
|
|
|
|
label[appKey] = appLabel
|
|
|
|
app.Labels = label
|
|
|
|
opt := metav1.ListOptions{
|
|
|
|
LabelSelector: fmt.Sprintf("%s=%s", appKey, label[appKey]),
|
|
|
|
}
|
|
|
|
wErr := writeDataInPod(app, &opt, f)
|
2020-09-03 09:34:29 +00:00
|
|
|
if wErr != nil {
|
|
|
|
e2elog.Failf("failed to write data with error %v", wErr)
|
2020-06-16 10:56:14 +00:00
|
|
|
}
|
|
|
|
|
2020-09-03 09:34:29 +00:00
|
|
|
snap := getSnapshot(snapshotPath)
|
|
|
|
snap.Namespace = f.UniqueName
|
|
|
|
snap.Spec.Source.PersistentVolumeClaimName = &pvc.Name
|
|
|
|
// create snapshot
|
|
|
|
for i := 0; i < totalCount; i++ {
|
2021-06-28 09:56:48 +00:00
|
|
|
go func(n int, s snapapi.VolumeSnapshot) {
|
2020-09-03 09:34:29 +00:00
|
|
|
s.Name = fmt.Sprintf("%s%d", f.UniqueName, n)
|
2020-11-04 14:45:06 +00:00
|
|
|
wgErrs[n] = createSnapshot(&s, deployTimeout)
|
2021-06-28 09:56:48 +00:00
|
|
|
wg.Done()
|
|
|
|
}(i, snap)
|
2020-09-03 09:34:29 +00:00
|
|
|
}
|
|
|
|
wg.Wait()
|
|
|
|
|
2020-11-04 14:45:06 +00:00
|
|
|
failed := 0
|
|
|
|
for i, err := range wgErrs {
|
|
|
|
if err != nil {
|
|
|
|
// not using Failf() as it aborts the test and does not log other errors
|
|
|
|
e2elog.Logf("failed to create snapshot (%s%d): %v", f.UniqueName, i, err)
|
|
|
|
failed++
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if failed != 0 {
|
|
|
|
e2elog.Failf("creating snapshots failed, %d errors were logged", failed)
|
|
|
|
}
|
|
|
|
|
2020-09-03 09:34:29 +00:00
|
|
|
pvcClone, err := loadPVC(pvcClonePath)
|
2020-06-16 10:56:14 +00:00
|
|
|
if err != nil {
|
2020-09-03 09:34:29 +00:00
|
|
|
e2elog.Failf("failed to load PVC with error %v", err)
|
2020-06-16 10:56:14 +00:00
|
|
|
}
|
2020-09-03 09:34:29 +00:00
|
|
|
appClone, err := loadApp(appClonePath)
|
2020-08-03 17:48:24 +00:00
|
|
|
if err != nil {
|
2020-09-03 09:34:29 +00:00
|
|
|
e2elog.Failf("failed to load application with error %v", err)
|
2020-08-03 17:48:24 +00:00
|
|
|
}
|
2020-09-03 09:34:29 +00:00
|
|
|
pvcClone.Namespace = f.UniqueName
|
|
|
|
appClone.Namespace = f.UniqueName
|
|
|
|
pvcClone.Spec.DataSource.Name = fmt.Sprintf("%s%d", f.UniqueName, 0)
|
|
|
|
|
|
|
|
// create multiple PVC from same snapshot
|
|
|
|
wg.Add(totalCount)
|
|
|
|
for i := 0; i < totalCount; i++ {
|
2021-06-28 09:56:48 +00:00
|
|
|
go func(n int, p v1.PersistentVolumeClaim, a v1.Pod) {
|
2020-09-03 09:34:29 +00:00
|
|
|
name := fmt.Sprintf("%s%d", f.UniqueName, n)
|
2020-11-04 14:45:06 +00:00
|
|
|
wgErrs[n] = createPVCAndApp(name, f, &p, &a, deployTimeout)
|
2021-02-09 10:32:40 +00:00
|
|
|
if wgErrs[n] == nil {
|
|
|
|
err = validateSubvolumePath(f, p.Name, p.Namespace, fileSystemName, subvolumegroup)
|
|
|
|
if err != nil {
|
|
|
|
wgErrs[n] = err
|
|
|
|
}
|
|
|
|
}
|
2021-06-28 09:56:48 +00:00
|
|
|
wg.Done()
|
|
|
|
}(i, *pvcClone, *appClone)
|
2020-08-03 17:48:24 +00:00
|
|
|
}
|
2020-09-03 09:34:29 +00:00
|
|
|
wg.Wait()
|
2020-08-03 17:48:24 +00:00
|
|
|
|
2020-11-04 14:45:06 +00:00
|
|
|
for i, err := range wgErrs {
|
|
|
|
if err != nil {
|
|
|
|
// not using Failf() as it aborts the test and does not log other errors
|
|
|
|
e2elog.Logf("failed to create PVC and app (%s%d): %v", f.UniqueName, i, err)
|
|
|
|
failed++
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if failed != 0 {
|
|
|
|
e2elog.Failf("creating PVCs and apps failed, %d errors were logged", failed)
|
|
|
|
}
|
|
|
|
|
2020-09-03 09:34:29 +00:00
|
|
|
validateSubvolumeCount(f, totalSubvolumes, fileSystemName, subvolumegroup)
|
|
|
|
|
|
|
|
wg.Add(totalCount)
|
|
|
|
// delete clone and app
|
|
|
|
for i := 0; i < totalCount; i++ {
|
2021-06-28 09:56:48 +00:00
|
|
|
go func(n int, p v1.PersistentVolumeClaim, a v1.Pod) {
|
2020-09-03 09:34:29 +00:00
|
|
|
name := fmt.Sprintf("%s%d", f.UniqueName, n)
|
|
|
|
p.Spec.DataSource.Name = name
|
2020-11-04 14:45:06 +00:00
|
|
|
wgErrs[n] = deletePVCAndApp(name, f, &p, &a)
|
2021-06-28 09:56:48 +00:00
|
|
|
wg.Done()
|
|
|
|
}(i, *pvcClone, *appClone)
|
2020-09-03 09:34:29 +00:00
|
|
|
}
|
|
|
|
wg.Wait()
|
|
|
|
|
2020-11-04 14:45:06 +00:00
|
|
|
for i, err := range wgErrs {
|
|
|
|
if err != nil {
|
|
|
|
// not using Failf() as it aborts the test and does not log other errors
|
|
|
|
e2elog.Logf("failed to delete PVC and app (%s%d): %v", f.UniqueName, i, err)
|
|
|
|
failed++
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if failed != 0 {
|
|
|
|
e2elog.Failf("deleting PVCs and apps failed, %d errors were logged", failed)
|
|
|
|
}
|
|
|
|
|
2020-09-03 09:34:29 +00:00
|
|
|
parentPVCCount := totalSubvolumes - totalCount
|
|
|
|
validateSubvolumeCount(f, parentPVCCount, fileSystemName, subvolumegroup)
|
2021-06-10 11:39:03 +00:00
|
|
|
// create clones from different snapshots and bind it to an
|
2020-09-03 09:34:29 +00:00
|
|
|
// app
|
|
|
|
wg.Add(totalCount)
|
|
|
|
for i := 0; i < totalCount; i++ {
|
2021-06-28 09:56:48 +00:00
|
|
|
go func(n int, p v1.PersistentVolumeClaim, a v1.Pod) {
|
2020-09-03 09:34:29 +00:00
|
|
|
name := fmt.Sprintf("%s%d", f.UniqueName, n)
|
|
|
|
p.Spec.DataSource.Name = name
|
2020-11-04 14:45:06 +00:00
|
|
|
wgErrs[n] = createPVCAndApp(name, f, &p, &a, deployTimeout)
|
2021-02-09 10:32:40 +00:00
|
|
|
if wgErrs[n] == nil {
|
|
|
|
err = validateSubvolumePath(f, p.Name, p.Namespace, fileSystemName, subvolumegroup)
|
|
|
|
if err != nil {
|
|
|
|
wgErrs[n] = err
|
|
|
|
}
|
|
|
|
}
|
2021-06-28 09:56:48 +00:00
|
|
|
wg.Done()
|
|
|
|
}(i, *pvcClone, *appClone)
|
2020-09-03 09:34:29 +00:00
|
|
|
}
|
|
|
|
wg.Wait()
|
|
|
|
|
2020-11-04 14:45:06 +00:00
|
|
|
for i, err := range wgErrs {
|
|
|
|
if err != nil {
|
|
|
|
// not using Failf() as it aborts the test and does not log other errors
|
|
|
|
e2elog.Logf("failed to create PVC and app (%s%d): %v", f.UniqueName, i, err)
|
|
|
|
failed++
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if failed != 0 {
|
|
|
|
e2elog.Failf("creating PVCs and apps failed, %d errors were logged", failed)
|
|
|
|
}
|
|
|
|
|
2020-09-03 09:34:29 +00:00
|
|
|
validateSubvolumeCount(f, totalSubvolumes, fileSystemName, subvolumegroup)
|
|
|
|
|
|
|
|
wg.Add(totalCount)
|
|
|
|
// delete snapshot
|
|
|
|
for i := 0; i < totalCount; i++ {
|
2021-06-28 09:56:48 +00:00
|
|
|
go func(n int, s snapapi.VolumeSnapshot) {
|
2020-09-03 09:34:29 +00:00
|
|
|
s.Name = fmt.Sprintf("%s%d", f.UniqueName, n)
|
2020-11-04 14:45:06 +00:00
|
|
|
wgErrs[n] = deleteSnapshot(&s, deployTimeout)
|
2021-06-28 09:56:48 +00:00
|
|
|
wg.Done()
|
|
|
|
}(i, snap)
|
2020-09-03 09:34:29 +00:00
|
|
|
}
|
|
|
|
wg.Wait()
|
|
|
|
|
2020-11-04 14:45:06 +00:00
|
|
|
for i, err := range wgErrs {
|
|
|
|
if err != nil {
|
|
|
|
// not using Failf() as it aborts the test and does not log other errors
|
|
|
|
e2elog.Logf("failed to delete snapshot (%s%d): %v", f.UniqueName, i, err)
|
|
|
|
failed++
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if failed != 0 {
|
|
|
|
e2elog.Failf("deleting snapshots failed, %d errors were logged", failed)
|
|
|
|
}
|
|
|
|
|
2020-09-03 09:34:29 +00:00
|
|
|
wg.Add(totalCount)
|
|
|
|
// delete clone and app
|
|
|
|
for i := 0; i < totalCount; i++ {
|
2021-06-28 09:56:48 +00:00
|
|
|
go func(n int, p v1.PersistentVolumeClaim, a v1.Pod) {
|
2020-09-03 09:34:29 +00:00
|
|
|
name := fmt.Sprintf("%s%d", f.UniqueName, n)
|
|
|
|
p.Spec.DataSource.Name = name
|
2020-11-04 14:45:06 +00:00
|
|
|
wgErrs[n] = deletePVCAndApp(name, f, &p, &a)
|
2021-06-28 09:56:48 +00:00
|
|
|
wg.Done()
|
|
|
|
}(i, *pvcClone, *appClone)
|
2020-09-03 09:34:29 +00:00
|
|
|
}
|
|
|
|
wg.Wait()
|
|
|
|
|
2020-11-04 14:45:06 +00:00
|
|
|
for i, err := range wgErrs {
|
|
|
|
if err != nil {
|
|
|
|
// not using Failf() as it aborts the test and does not log other errors
|
|
|
|
e2elog.Logf("failed to delete PVC and app (%s%d): %v", f.UniqueName, i, err)
|
|
|
|
failed++
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if failed != 0 {
|
|
|
|
e2elog.Failf("deleting PVCs and apps failed, %d errors were logged", failed)
|
|
|
|
}
|
|
|
|
|
2020-09-03 09:34:29 +00:00
|
|
|
validateSubvolumeCount(f, parentPVCCount, fileSystemName, subvolumegroup)
|
|
|
|
// delete parent pvc
|
|
|
|
err = deletePVCAndApp("", f, pvc, app)
|
2020-08-03 17:48:24 +00:00
|
|
|
if err != nil {
|
2020-09-03 09:34:29 +00:00
|
|
|
e2elog.Failf("failed to delete PVC or application with error %v", err)
|
2020-08-03 17:48:24 +00:00
|
|
|
}
|
|
|
|
|
2020-09-03 09:34:29 +00:00
|
|
|
validateSubvolumeCount(f, 0, fileSystemName, subvolumegroup)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
|
|
|
By("create a PVC-PVC clone and bind it to an app", func() {
|
|
|
|
// pvc clone is only supported from v1.16+
|
2020-10-14 09:00:25 +00:00
|
|
|
if k8sVersionGreaterEquals(f.ClientSet, 1, 16) {
|
2020-09-03 09:34:29 +00:00
|
|
|
var wg sync.WaitGroup
|
|
|
|
totalCount := 3
|
2020-11-04 14:45:06 +00:00
|
|
|
wgErrs := make([]error, totalCount)
|
2020-09-03 09:34:29 +00:00
|
|
|
// totalSubvolumes represents the subvolumes in backend
|
|
|
|
// always totalCount+parentPVC
|
|
|
|
totalSubvolumes := totalCount + 1
|
2020-06-16 11:06:15 +00:00
|
|
|
pvc, err := loadPVC(pvcPath)
|
|
|
|
if err != nil {
|
2020-09-03 09:34:29 +00:00
|
|
|
e2elog.Failf("failed to load PVC with error %v", err)
|
2020-06-16 11:06:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
pvc.Namespace = f.UniqueName
|
2020-09-03 09:34:29 +00:00
|
|
|
err = createPVCAndvalidatePV(f.ClientSet, pvc, deployTimeout)
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to create PVC with error %v", err)
|
|
|
|
}
|
2020-06-16 11:06:15 +00:00
|
|
|
app, err := loadApp(appPath)
|
|
|
|
if err != nil {
|
2020-09-03 09:34:29 +00:00
|
|
|
e2elog.Failf("failed to load application with error %v", err)
|
2020-06-16 11:06:15 +00:00
|
|
|
}
|
|
|
|
app.Namespace = f.UniqueName
|
|
|
|
app.Spec.Volumes[0].PersistentVolumeClaim.ClaimName = pvc.Name
|
2020-10-13 05:34:55 +00:00
|
|
|
label := make(map[string]string)
|
|
|
|
label[appKey] = appLabel
|
|
|
|
app.Labels = label
|
|
|
|
opt := metav1.ListOptions{
|
|
|
|
LabelSelector: fmt.Sprintf("%s=%s", appKey, label[appKey]),
|
|
|
|
}
|
|
|
|
wErr := writeDataInPod(app, &opt, f)
|
2020-09-03 09:34:29 +00:00
|
|
|
if wErr != nil {
|
|
|
|
e2elog.Failf("failed to write data from application %v", wErr)
|
2020-06-16 11:06:15 +00:00
|
|
|
}
|
|
|
|
|
2020-09-03 09:34:29 +00:00
|
|
|
pvcClone, err := loadPVC(pvcSmartClonePath)
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to load PVC with error %v", err)
|
2020-06-16 11:06:15 +00:00
|
|
|
}
|
2020-09-03 09:34:29 +00:00
|
|
|
pvcClone.Spec.DataSource.Name = pvc.Name
|
|
|
|
pvcClone.Namespace = f.UniqueName
|
|
|
|
appClone, err := loadApp(appSmartClonePath)
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to load application with error %v", err)
|
|
|
|
}
|
|
|
|
appClone.Namespace = f.UniqueName
|
|
|
|
wg.Add(totalCount)
|
|
|
|
// create clone and bind it to an app
|
|
|
|
for i := 0; i < totalCount; i++ {
|
2021-06-28 09:56:48 +00:00
|
|
|
go func(n int, p v1.PersistentVolumeClaim, a v1.Pod) {
|
2020-09-03 09:34:29 +00:00
|
|
|
name := fmt.Sprintf("%s%d", f.UniqueName, n)
|
2020-11-04 14:45:06 +00:00
|
|
|
wgErrs[n] = createPVCAndApp(name, f, &p, &a, deployTimeout)
|
2021-06-28 09:56:48 +00:00
|
|
|
wg.Done()
|
|
|
|
}(i, *pvcClone, *appClone)
|
2020-06-16 11:06:15 +00:00
|
|
|
}
|
2020-09-03 09:34:29 +00:00
|
|
|
wg.Wait()
|
|
|
|
|
2020-11-04 14:45:06 +00:00
|
|
|
failed := 0
|
|
|
|
for i, err := range wgErrs {
|
|
|
|
if err != nil {
|
|
|
|
// not using Failf() as it aborts the test and does not log other errors
|
|
|
|
e2elog.Logf("failed to create PVC or application (%s%d): %v", f.UniqueName, i, err)
|
|
|
|
failed++
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if failed != 0 {
|
|
|
|
e2elog.Failf("deleting PVCs and apps failed, %d errors were logged", failed)
|
|
|
|
}
|
|
|
|
|
2020-09-03 09:34:29 +00:00
|
|
|
validateSubvolumeCount(f, totalSubvolumes, fileSystemName, subvolumegroup)
|
2020-06-16 11:06:15 +00:00
|
|
|
|
2020-09-03 09:34:29 +00:00
|
|
|
// delete parent pvc
|
2020-06-16 11:06:15 +00:00
|
|
|
err = deletePVCAndApp("", f, pvc, app)
|
|
|
|
if err != nil {
|
2020-09-03 09:34:29 +00:00
|
|
|
e2elog.Failf("failed to delete PVC or application with error %v", err)
|
2020-06-16 11:06:15 +00:00
|
|
|
}
|
2020-01-31 08:49:11 +00:00
|
|
|
|
2020-09-03 09:34:29 +00:00
|
|
|
wg.Add(totalCount)
|
|
|
|
// delete clone and app
|
|
|
|
for i := 0; i < totalCount; i++ {
|
2021-06-28 09:56:48 +00:00
|
|
|
go func(n int, p v1.PersistentVolumeClaim, a v1.Pod) {
|
2020-09-03 09:34:29 +00:00
|
|
|
name := fmt.Sprintf("%s%d", f.UniqueName, n)
|
|
|
|
p.Spec.DataSource.Name = name
|
2020-11-04 14:45:06 +00:00
|
|
|
wgErrs[n] = deletePVCAndApp(name, f, &p, &a)
|
2021-06-28 09:56:48 +00:00
|
|
|
wg.Done()
|
|
|
|
}(i, *pvcClone, *appClone)
|
2020-09-03 09:34:29 +00:00
|
|
|
}
|
|
|
|
wg.Wait()
|
|
|
|
|
2020-11-04 14:45:06 +00:00
|
|
|
for i, err := range wgErrs {
|
|
|
|
if err != nil {
|
|
|
|
// not using Failf() as it aborts the test and does not log other errors
|
|
|
|
e2elog.Logf("failed to delete PVC or application (%s%d): %v", f.UniqueName, i, err)
|
|
|
|
failed++
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if failed != 0 {
|
|
|
|
e2elog.Failf("deleting PVCs and apps failed, %d errors were logged", failed)
|
|
|
|
}
|
|
|
|
|
2020-09-03 09:34:29 +00:00
|
|
|
validateSubvolumeCount(f, 0, fileSystemName, subvolumegroup)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
|
|
|
By("Create ROX PVC and bind it to an app", func() {
|
|
|
|
// create PVC and bind it to an app
|
|
|
|
pvc, err := loadPVC(pvcPath)
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to load PVC with error %v", err)
|
|
|
|
}
|
|
|
|
|
|
|
|
pvc.Namespace = f.UniqueName
|
2020-09-10 09:46:53 +00:00
|
|
|
err = createPVCAndvalidatePV(f.ClientSet, pvc, deployTimeout)
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to create PVC with error %v", err)
|
|
|
|
}
|
|
|
|
|
|
|
|
pvcClone, err := loadPVC(pvcSmartClonePath)
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to load PVC with error %v", err)
|
|
|
|
}
|
|
|
|
pvcClone.Namespace = f.UniqueName
|
|
|
|
pvcClone.Spec.DataSource.Name = pvc.Name
|
|
|
|
pvcClone.Spec.AccessModes = []v1.PersistentVolumeAccessMode{v1.ReadOnlyMany}
|
2020-09-03 09:34:29 +00:00
|
|
|
app, err := loadApp(appPath)
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to load application with error %v", err)
|
|
|
|
}
|
|
|
|
|
|
|
|
app.Namespace = f.UniqueName
|
|
|
|
label := map[string]string{
|
|
|
|
"app": app.Name,
|
|
|
|
}
|
|
|
|
app.Labels = label
|
2020-09-10 09:46:53 +00:00
|
|
|
app.Spec.Volumes[0].PersistentVolumeClaim.ClaimName = pvcClone.Name
|
|
|
|
err = createPVCAndApp("", f, pvcClone, app, deployTimeout)
|
2020-09-03 09:34:29 +00:00
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to create PVC or application with error %v", err)
|
|
|
|
}
|
|
|
|
|
|
|
|
opt := metav1.ListOptions{
|
|
|
|
LabelSelector: fmt.Sprintf("app=%s", app.Name),
|
|
|
|
}
|
|
|
|
|
|
|
|
filePath := app.Spec.Containers[0].VolumeMounts[0].MountPath + "/test"
|
2021-06-25 12:31:28 +00:00
|
|
|
_, stdErr := execCommandInPodAndAllowFail(
|
|
|
|
f,
|
|
|
|
fmt.Sprintf("echo 'Hello World' > %s", filePath),
|
|
|
|
app.Namespace,
|
|
|
|
&opt)
|
2020-09-03 09:34:29 +00:00
|
|
|
readOnlyErr := fmt.Sprintf("cannot create %s: Read-only file system", filePath)
|
|
|
|
if !strings.Contains(stdErr, readOnlyErr) {
|
|
|
|
e2elog.Failf(stdErr)
|
|
|
|
}
|
|
|
|
|
2020-09-10 09:46:53 +00:00
|
|
|
// delete cloned ROX pvc and app
|
|
|
|
err = deletePVCAndApp("", f, pvcClone, app)
|
2020-09-03 09:34:29 +00:00
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to delete PVC or application with error %v", err)
|
|
|
|
}
|
2020-09-10 09:46:53 +00:00
|
|
|
|
|
|
|
// delete parent pvc
|
|
|
|
err = deletePVCAndValidatePV(f.ClientSet, pvc, deployTimeout)
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to delete PVC with error %v", err)
|
|
|
|
}
|
2020-09-03 09:34:29 +00:00
|
|
|
})
|
|
|
|
// Make sure this should be last testcase in this file, because
|
|
|
|
// it deletes pool
|
|
|
|
By("Create a PVC and delete PVC when backend pool deleted", func() {
|
|
|
|
err := pvcDeleteWhenPoolNotFound(pvcPath, true, f)
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to delete PVC with error %v", err)
|
|
|
|
}
|
2019-05-31 09:34:04 +00:00
|
|
|
})
|
2021-02-22 11:13:40 +00:00
|
|
|
// delete cephFS provisioner secret
|
|
|
|
err := deleteCephUser(f, keyringCephFSProvisionerUsername)
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to delete user %s with error %v", keyringCephFSProvisionerUsername, err)
|
|
|
|
}
|
|
|
|
// delete cephFS plugin secret
|
|
|
|
err = deleteCephUser(f, keyringCephFSNodePluginUsername)
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to delete user %s with error %v", keyringCephFSNodePluginUsername, err)
|
|
|
|
}
|
2019-05-31 09:34:04 +00:00
|
|
|
})
|
|
|
|
})
|
|
|
|
})
|