2019-05-31 09:34:04 +00:00
|
|
|
package e2e
|
|
|
|
|
|
|
|
import (
|
2019-06-18 07:07:11 +00:00
|
|
|
"fmt"
|
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
|
|
|
|
2020-08-03 17:48:24 +00:00
|
|
|
vs "github.com/kubernetes-csi/external-snapshotter/v2/pkg/apis/volumesnapshot/v1beta1"
|
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 (
|
|
|
|
cephfsProvisioner = "csi-cephfsplugin-provisioner.yaml"
|
|
|
|
cephfsProvisionerRBAC = "csi-provisioner-rbac.yaml"
|
2020-01-21 08:22:43 +00:00
|
|
|
cephfsProvisionerPSP = "csi-provisioner-psp.yaml"
|
2019-05-31 09:34:04 +00:00
|
|
|
cephfsNodePlugin = "csi-cephfsplugin.yaml"
|
|
|
|
cephfsNodePluginRBAC = "csi-nodeplugin-rbac.yaml"
|
2020-01-21 08:22:43 +00:00
|
|
|
cephfsNodePluginPSP = "csi-nodeplugin-psp.yaml"
|
2019-06-10 08:00:40 +00:00
|
|
|
cephfsDeploymentName = "csi-cephfsplugin-provisioner"
|
|
|
|
cephfsDeamonSetName = "csi-cephfsplugin"
|
2019-12-19 15:35:58 +00:00
|
|
|
cephfsDirPath = "../deploy/cephfs/kubernetes/"
|
2019-06-10 08:00:40 +00:00
|
|
|
cephfsExamplePath = "../examples/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
|
|
|
|
|
|
|
data, err := replaceNamespaceInTemplate(cephfsDirPath + cephfsProvisionerRBAC)
|
|
|
|
if err != nil {
|
2020-09-03 09:34:29 +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 {
|
2020-09-03 09:34:29 +00:00
|
|
|
e2elog.Failf("failed to delete provisioner rbac %s with error %v", cephfsDirPath+cephfsProvisionerRBAC, err)
|
2020-02-26 08:11:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
data, err = replaceNamespaceInTemplate(cephfsDirPath + cephfsNodePluginRBAC)
|
|
|
|
if err != nil {
|
2020-09-03 09:34:29 +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 {
|
2020-09-03 09:34:29 +00:00
|
|
|
e2elog.Failf("failed to delete nodeplugin rbac %s with error %v", cephfsDirPath+cephfsNodePluginRBAC, err)
|
2020-02-26 08:11:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
createORDeleteCephfsResouces("create")
|
2019-05-31 09:34:04 +00:00
|
|
|
}
|
|
|
|
|
2019-08-07 14:53:39 +00:00
|
|
|
func deleteCephfsPlugin() {
|
2020-02-26 08:11:05 +00:00
|
|
|
createORDeleteCephfsResouces("delete")
|
|
|
|
}
|
|
|
|
|
|
|
|
func createORDeleteCephfsResouces(action string) {
|
|
|
|
data, err := replaceNamespaceInTemplate(cephfsDirPath + cephfsProvisioner)
|
|
|
|
if err != nil {
|
2020-09-03 09:34:29 +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)
|
2020-04-14 06:59:04 +00:00
|
|
|
_, err = framework.RunKubectlInput(cephCSINamespace, data, action, ns, "-f", "-")
|
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
|
|
|
}
|
|
|
|
data, err = replaceNamespaceInTemplate(cephfsDirPath + cephfsProvisionerRBAC)
|
2020-09-03 09:34:29 +00:00
|
|
|
|
2019-08-07 14:53:39 +00:00
|
|
|
if err != nil {
|
2020-09-03 09:34:29 +00:00
|
|
|
e2elog.Failf("failed to read content from %s with error %v", cephfsDirPath+cephfsProvisionerRBAC, err)
|
2019-08-07 14:53:39 +00:00
|
|
|
}
|
2020-04-14 06:59:04 +00:00
|
|
|
_, err = framework.RunKubectlInput(cephCSINamespace, data, action, ns, "-f", "-")
|
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
|
|
|
|
|
|
|
data, err = replaceNamespaceInTemplate(cephfsDirPath + cephfsProvisionerPSP)
|
|
|
|
if err != nil {
|
2020-09-03 09:34:29 +00:00
|
|
|
e2elog.Failf("failed to read content from %s with error %v", cephfsDirPath+cephfsProvisionerPSP, err)
|
2020-02-26 08:11:05 +00:00
|
|
|
}
|
2020-04-14 06:59:04 +00:00
|
|
|
_, err = framework.RunKubectlInput(cephCSINamespace, data, action, ns, "-f", "-")
|
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
|
|
|
}
|
|
|
|
|
|
|
|
data, err = replaceNamespaceInTemplate(cephfsDirPath + cephfsNodePlugin)
|
2020-01-21 08:22:43 +00:00
|
|
|
if err != nil {
|
2020-09-03 09:34:29 +00:00
|
|
|
e2elog.Failf("failed to read content from %s with error %v", cephfsDirPath+cephfsNodePlugin, err)
|
2020-01-21 08:22:43 +00:00
|
|
|
}
|
2020-04-14 06:59:04 +00:00
|
|
|
_, err = framework.RunKubectlInput(cephCSINamespace, data, action, ns, "-f", "-")
|
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
|
|
|
|
|
|
|
data, err = replaceNamespaceInTemplate(cephfsDirPath + cephfsNodePluginRBAC)
|
2019-08-07 14:53:39 +00:00
|
|
|
if err != nil {
|
2020-09-03 09:34:29 +00:00
|
|
|
e2elog.Failf("failed to read content from %s with error %v", cephfsDirPath+cephfsNodePluginRBAC, err)
|
2019-08-07 14:53:39 +00:00
|
|
|
}
|
2020-04-14 06:59:04 +00:00
|
|
|
_, err = framework.RunKubectlInput(cephCSINamespace, data, action, ns, "-f", "-")
|
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
|
|
|
}
|
|
|
|
|
|
|
|
data, err = replaceNamespaceInTemplate(cephfsDirPath + cephfsNodePluginPSP)
|
2020-01-21 08:22:43 +00:00
|
|
|
if err != nil {
|
2020-09-03 09:34:29 +00:00
|
|
|
e2elog.Failf("failed to read content from %s with error %v", cephfsDirPath+cephfsNodePluginPSP, err)
|
2020-02-26 08:11:05 +00:00
|
|
|
}
|
2020-04-14 06:59:04 +00:00
|
|
|
_, err = framework.RunKubectlInput(cephCSINamespace, data, action, ns, "-f", "-")
|
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
|
|
|
}
|
|
|
|
|
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()
|
|
|
|
}
|
2020-09-03 09:34:29 +00:00
|
|
|
err := createConfigMap(cephfsDirPath, f.ClientSet, f)
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to create configmap with error %v", err)
|
|
|
|
}
|
|
|
|
err = createCephfsSecret(f.ClientSet, f)
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to create secret with error %v", err)
|
|
|
|
}
|
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)
|
2019-12-18 08:41:20 +00:00
|
|
|
// log provisoner
|
|
|
|
logsCSIPods("app=csi-cephfsplugin-provisioner", c)
|
|
|
|
// log node plugin
|
|
|
|
logsCSIPods("app=csi-cephfsplugin", c)
|
|
|
|
}
|
2020-09-03 09:34:29 +00:00
|
|
|
err := deleteConfigMap(cephfsDirPath)
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to delete configmap with error %v", err)
|
|
|
|
}
|
|
|
|
err = deleteResource(cephfsExamplePath + "secret.yaml")
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to delete secret with error %v", err)
|
|
|
|
}
|
|
|
|
err = deleteResource(cephfsExamplePath + "storageclass.yaml")
|
|
|
|
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() {
|
2019-06-18 07:07:11 +00:00
|
|
|
pvcPath := cephfsExamplePath + "pvc.yaml"
|
|
|
|
appPath := cephfsExamplePath + "pod.yaml"
|
2020-08-03 17:48:24 +00:00
|
|
|
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() {
|
|
|
|
err := waitForDeploymentComplete(cephfsDeploymentName, cephCSINamespace, f.ClientSet, deployTimeout)
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("timeout waiting for deployment %s with error %v", cephfsDeploymentName, err)
|
|
|
|
}
|
|
|
|
})
|
2019-05-31 09:34:04 +00:00
|
|
|
|
2020-09-03 09:34:29 +00:00
|
|
|
By("checking nodeplugin deamonset pods are running", func() {
|
|
|
|
err := waitForDaemonSets(cephfsDeamonSetName, cephCSINamespace, f.ClientSet, deployTimeout)
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("timeout waiting for daemonset %s with error %v", cephfsDeamonSetName, err)
|
|
|
|
}
|
|
|
|
})
|
2019-05-31 09:34:04 +00:00
|
|
|
|
2020-05-14 01:48:09 +00:00
|
|
|
By("check static PVC", func() {
|
|
|
|
scPath := cephfsExamplePath + "secret.yaml"
|
|
|
|
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)
|
|
|
|
}
|
|
|
|
err = deleteResource(cephfsExamplePath + "storageclass.yaml")
|
|
|
|
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-"
|
|
|
|
err := createCephfsStorageClass(f.ClientSet, f, false, map[string]string{"volumeNamePrefix": volumeNamePrefix})
|
|
|
|
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
|
|
|
|
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)
|
|
|
|
err = deleteResource(cephfsExamplePath + "storageclass.yaml")
|
|
|
|
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)
|
|
|
|
}
|
|
|
|
err = deleteResource(cephfsExamplePath + "storageclass.yaml")
|
|
|
|
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)
|
|
|
|
}
|
|
|
|
err = deleteResource(cephfsExamplePath + "storageclass.yaml")
|
|
|
|
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
|
|
|
}
|
|
|
|
|
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
|
|
|
|
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() {
|
|
|
|
err := deleteResource(cephfsExamplePath + "storageclass.yaml")
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to delete storageclass with error %v", err)
|
|
|
|
}
|
|
|
|
// re-define configmap with information of multiple clusters.
|
|
|
|
subvolgrpInfo := map[string]string{
|
|
|
|
"clusterID-1": "subvolgrp1",
|
|
|
|
"clusterID-2": "subvolgrp2",
|
|
|
|
}
|
|
|
|
err = createCustomConfigMap(f.ClientSet, cephfsDirPath, subvolgrpInfo)
|
|
|
|
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)
|
|
|
|
}
|
|
|
|
err = deleteResource(cephfsExamplePath + "storageclass.yaml")
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to delete storageclass with error %v", err)
|
|
|
|
}
|
|
|
|
// verify subvolumegroup creation.
|
|
|
|
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)
|
|
|
|
}
|
|
|
|
err = deleteResource(cephfsExamplePath + "storageclass.yaml")
|
|
|
|
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)
|
|
|
|
}
|
|
|
|
err = deleteConfigMap(cephfsDirPath)
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to delete configmap with error %v", err)
|
|
|
|
}
|
|
|
|
err = createConfigMap(cephfsDirPath, f.ClientSet, f)
|
|
|
|
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"
|
|
|
|
_, stdErr := execCommandInPodAndAllowFail(f, fmt.Sprintf("echo 'Hello World' > %s", filePath), app.Namespace, &opt)
|
|
|
|
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)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
|
|
|
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-09-03 09:34:29 +00:00
|
|
|
wErr := writeDataInPod(app, f)
|
|
|
|
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++ {
|
|
|
|
go func(w *sync.WaitGroup, n int, s vs.VolumeSnapshot) {
|
|
|
|
s.Name = fmt.Sprintf("%s%d", f.UniqueName, n)
|
2020-11-04 14:45:06 +00:00
|
|
|
wgErrs[n] = createSnapshot(&s, deployTimeout)
|
2020-09-03 09:34:29 +00:00
|
|
|
w.Done()
|
|
|
|
}(&wg, i, snap)
|
|
|
|
}
|
|
|
|
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++ {
|
|
|
|
|
|
|
|
go func(w *sync.WaitGroup, n int, p v1.PersistentVolumeClaim, a v1.Pod) {
|
|
|
|
name := fmt.Sprintf("%s%d", f.UniqueName, n)
|
2020-11-04 14:45:06 +00:00
|
|
|
wgErrs[n] = createPVCAndApp(name, f, &p, &a, deployTimeout)
|
2020-09-03 09:34:29 +00:00
|
|
|
w.Done()
|
|
|
|
}(&wg, 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++ {
|
|
|
|
go func(w *sync.WaitGroup, n int, p v1.PersistentVolumeClaim, a v1.Pod) {
|
|
|
|
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)
|
2020-09-03 09:34:29 +00:00
|
|
|
w.Done()
|
|
|
|
}(&wg, i, *pvcClone, *appClone)
|
|
|
|
}
|
|
|
|
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)
|
|
|
|
// create clones from different snapshosts and bind it to an
|
|
|
|
// app
|
|
|
|
wg.Add(totalCount)
|
|
|
|
for i := 0; i < totalCount; i++ {
|
|
|
|
go func(w *sync.WaitGroup, n int, p v1.PersistentVolumeClaim, a v1.Pod) {
|
|
|
|
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)
|
2020-09-03 09:34:29 +00:00
|
|
|
w.Done()
|
|
|
|
}(&wg, i, *pvcClone, *appClone)
|
|
|
|
}
|
|
|
|
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++ {
|
|
|
|
go func(w *sync.WaitGroup, n int, s vs.VolumeSnapshot) {
|
|
|
|
s.Name = fmt.Sprintf("%s%d", f.UniqueName, n)
|
2020-11-04 14:45:06 +00:00
|
|
|
wgErrs[n] = deleteSnapshot(&s, deployTimeout)
|
2020-09-03 09:34:29 +00:00
|
|
|
w.Done()
|
|
|
|
}(&wg, i, snap)
|
|
|
|
}
|
|
|
|
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++ {
|
|
|
|
go func(w *sync.WaitGroup, n int, p v1.PersistentVolumeClaim, a v1.Pod) {
|
|
|
|
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)
|
2020-09-03 09:34:29 +00:00
|
|
|
w.Done()
|
|
|
|
}(&wg, i, *pvcClone, *appClone)
|
|
|
|
}
|
|
|
|
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-09-03 09:34:29 +00:00
|
|
|
wErr := writeDataInPod(app, f)
|
|
|
|
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++ {
|
|
|
|
go func(w *sync.WaitGroup, n int, p v1.PersistentVolumeClaim, a v1.Pod) {
|
|
|
|
name := fmt.Sprintf("%s%d", f.UniqueName, n)
|
2020-11-04 14:45:06 +00:00
|
|
|
wgErrs[n] = createPVCAndApp(name, f, &p, &a, deployTimeout)
|
2020-09-03 09:34:29 +00:00
|
|
|
w.Done()
|
|
|
|
}(&wg, 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++ {
|
|
|
|
go func(w *sync.WaitGroup, n int, p v1.PersistentVolumeClaim, a v1.Pod) {
|
|
|
|
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)
|
2020-09-03 09:34:29 +00:00
|
|
|
w.Done()
|
|
|
|
}(&wg, i, *pvcClone, *appClone)
|
|
|
|
}
|
|
|
|
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"
|
|
|
|
_, stdErr := execCommandInPodAndAllowFail(f, fmt.Sprintf("echo 'Hello World' > %s", filePath), app.Namespace, &opt)
|
|
|
|
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
|
|
|
})
|
2019-06-14 09:26:17 +00:00
|
|
|
|
2019-05-31 09:34:04 +00:00
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
})
|