2019-05-31 09:34:04 +00:00
|
|
|
package e2e
|
|
|
|
|
|
|
|
import (
|
2019-06-18 07:07:11 +00:00
|
|
|
"fmt"
|
2020-02-24 13:19:42 +00:00
|
|
|
"strings"
|
2019-06-14 09:42:48 +00:00
|
|
|
|
2019-05-31 09:34:04 +00:00
|
|
|
. "github.com/onsi/ginkgo" // nolint
|
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 (
|
|
|
|
rbdProvisioner = "csi-rbdplugin-provisioner.yaml"
|
|
|
|
rbdProvisionerRBAC = "csi-provisioner-rbac.yaml"
|
2020-01-21 08:22:43 +00:00
|
|
|
rbdProvisionerPSP = "csi-provisioner-psp.yaml"
|
2019-05-31 09:34:04 +00:00
|
|
|
rbdNodePlugin = "csi-rbdplugin.yaml"
|
|
|
|
rbdNodePluginRBAC = "csi-nodeplugin-rbac.yaml"
|
2020-01-21 08:22:43 +00:00
|
|
|
rbdNodePluginPSP = "csi-nodeplugin-psp.yaml"
|
2019-07-25 06:49:44 +00:00
|
|
|
configMap = "csi-config-map.yaml"
|
2019-12-19 15:35:58 +00:00
|
|
|
rbdDirPath = "../deploy/rbd/kubernetes/"
|
2019-06-10 08:00:40 +00:00
|
|
|
rbdExamplePath = "../examples/rbd/"
|
|
|
|
rbdDeploymentName = "csi-rbdplugin-provisioner"
|
|
|
|
rbdDaemonsetName = "csi-rbdplugin"
|
2020-05-05 03:53:24 +00:00
|
|
|
defaultRBDPool = "replicapool"
|
2020-03-27 18:21:18 +00:00
|
|
|
// Topology related variables
|
2020-04-06 20:19:13 +00:00
|
|
|
nodeRegionLabel = "test.failure-domain/region"
|
|
|
|
regionValue = "testregion"
|
|
|
|
nodeZoneLabel = "test.failure-domain/zone"
|
|
|
|
zoneValue = "testzone"
|
|
|
|
nodeCSIRegionLabel = "topology.rbd.csi.ceph.com/region"
|
|
|
|
nodeCSIZoneLabel = "topology.rbd.csi.ceph.com/zone"
|
|
|
|
rbdTopologyPool = "newrbdpool"
|
|
|
|
rbdTopologyDataPool = "replicapool" // NOTE: should be different than rbdTopologyPool for test to be effective
|
2019-05-31 09:34:04 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
func deployRBDPlugin() {
|
2019-12-11 08:48:36 +00:00
|
|
|
// delete objects deployed by rook
|
2020-02-26 08:11:05 +00:00
|
|
|
data, err := replaceNamespaceInTemplate(rbdDirPath + rbdProvisionerRBAC)
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Logf("failed to read content from %s %v", rbdDirPath+rbdProvisionerRBAC, err)
|
|
|
|
}
|
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 {
|
|
|
|
e2elog.Logf("failed to delete provisioner rbac %s %v", rbdDirPath+rbdProvisionerRBAC, err)
|
|
|
|
}
|
|
|
|
|
|
|
|
data, err = replaceNamespaceInTemplate(rbdDirPath + rbdNodePluginRBAC)
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Logf("failed to read content from %s %v", rbdDirPath+rbdNodePluginRBAC, err)
|
|
|
|
}
|
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 {
|
|
|
|
e2elog.Logf("failed to delete nodeplugin rbac %s %v", rbdDirPath+rbdNodePluginRBAC, err)
|
|
|
|
}
|
|
|
|
|
|
|
|
createORDeleteRbdResouces("create")
|
2019-05-31 09:34:04 +00:00
|
|
|
}
|
|
|
|
|
2019-08-07 14:53:39 +00:00
|
|
|
func deleteRBDPlugin() {
|
2020-02-26 08:11:05 +00:00
|
|
|
createORDeleteRbdResouces("delete")
|
|
|
|
}
|
|
|
|
|
|
|
|
func createORDeleteRbdResouces(action string) {
|
|
|
|
data, err := replaceNamespaceInTemplate(rbdDirPath + rbdProvisioner)
|
2019-08-07 14:53:39 +00:00
|
|
|
if err != nil {
|
2020-02-26 08:11:05 +00:00
|
|
|
e2elog.Logf("failed to read content from %s %v", rbdDirPath+rbdProvisioner, 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-02-26 08:11:05 +00:00
|
|
|
e2elog.Logf("failed to %s rbd provisioner %v", action, err)
|
2019-08-07 14:53:39 +00:00
|
|
|
}
|
2020-02-26 08:11:05 +00:00
|
|
|
|
|
|
|
data, err = replaceNamespaceInTemplate(rbdDirPath + rbdProvisionerRBAC)
|
2020-01-21 08:22:43 +00:00
|
|
|
if err != nil {
|
2020-02-26 08:11:05 +00:00
|
|
|
e2elog.Logf("failed to read content from %s %v", rbdDirPath+rbdProvisionerRBAC, 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-02-26 08:11:05 +00:00
|
|
|
e2elog.Logf("failed to %s provisioner rbac %v", action, err)
|
2019-08-07 14:53:39 +00:00
|
|
|
}
|
2020-02-26 08:11:05 +00:00
|
|
|
|
|
|
|
data, err = replaceNamespaceInTemplate(rbdDirPath + rbdProvisionerPSP)
|
2019-08-07 14:53:39 +00:00
|
|
|
if err != nil {
|
2020-02-26 08:11:05 +00:00
|
|
|
e2elog.Logf("failed to read content from %s %v", rbdDirPath+rbdProvisionerPSP, err)
|
2019-08-07 14:53:39 +00:00
|
|
|
}
|
2020-04-14 06:59:04 +00:00
|
|
|
_, err = framework.RunKubectlInput(cephCSINamespace, data, action, "-f", "-")
|
2020-01-21 08:22:43 +00:00
|
|
|
if err != nil {
|
2020-02-26 08:11:05 +00:00
|
|
|
e2elog.Logf("failed to %s provisioner psp %v", action, err)
|
|
|
|
}
|
|
|
|
|
|
|
|
data, err = replaceNamespaceInTemplate(rbdDirPath + rbdNodePlugin)
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Logf("failed to read content from %s %v", rbdDirPath+rbdNodePlugin, err)
|
|
|
|
}
|
2020-03-27 18:21:18 +00:00
|
|
|
|
|
|
|
domainLabel := nodeRegionLabel + "," + nodeZoneLabel
|
|
|
|
data = addTopologyDomainsToDSYaml(data, domainLabel)
|
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 {
|
|
|
|
e2elog.Logf("failed to %s nodeplugin %v", action, err)
|
2020-03-27 18:21:18 +00:00
|
|
|
Fail(err.Error())
|
2020-02-26 08:11:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
data, err = replaceNamespaceInTemplate(rbdDirPath + rbdNodePluginRBAC)
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Logf("failed to read content from %s %v", rbdDirPath+rbdNodePluginRBAC, err)
|
|
|
|
}
|
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 {
|
|
|
|
e2elog.Logf("failed to %s nodeplugin rbac %v", action, err)
|
|
|
|
}
|
|
|
|
|
|
|
|
data, err = replaceNamespaceInTemplate(rbdDirPath + rbdNodePluginPSP)
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Logf("failed to read content from %s %v", rbdDirPath+rbdNodePluginPSP, err)
|
|
|
|
}
|
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 {
|
|
|
|
e2elog.Logf("failed to %s nodeplugin psp %v", action, err)
|
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("RBD", func() {
|
|
|
|
f := framework.NewDefaultFramework("rbd")
|
2019-12-18 08:41:20 +00:00
|
|
|
var c clientset.Interface
|
2019-06-10 06:48:41 +00:00
|
|
|
// deploy RBD CSI
|
2019-05-31 09:34:04 +00:00
|
|
|
BeforeEach(func() {
|
2019-12-18 08:41:20 +00:00
|
|
|
c = f.ClientSet
|
2020-02-25 08:00:23 +00:00
|
|
|
if deployRBD {
|
2020-04-06 20:19:13 +00:00
|
|
|
createNodeLabel(f, nodeRegionLabel, regionValue)
|
|
|
|
createNodeLabel(f, nodeZoneLabel, zoneValue)
|
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-02-25 11:45:54 +00:00
|
|
|
Fail(err.Error())
|
|
|
|
}
|
|
|
|
}
|
2020-02-25 08:00:23 +00:00
|
|
|
deployRBDPlugin()
|
|
|
|
}
|
2020-02-26 08:11:05 +00:00
|
|
|
createConfigMap(rbdDirPath, f.ClientSet, f)
|
2020-03-27 18:21:18 +00:00
|
|
|
createRBDStorageClass(f.ClientSet, f, nil, nil)
|
2019-05-31 09:34:04 +00:00
|
|
|
createRBDSecret(f.ClientSet, f)
|
2020-01-29 11:44:45 +00:00
|
|
|
deployVault(f.ClientSet, deployTimeout)
|
2019-05-31 09:34:04 +00:00
|
|
|
})
|
|
|
|
|
|
|
|
AfterEach(func() {
|
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-rbd", c)
|
2019-12-18 08:41:20 +00:00
|
|
|
// log provisoner
|
|
|
|
logsCSIPods("app=csi-rbdplugin-provisioner", c)
|
|
|
|
// log node plugin
|
|
|
|
logsCSIPods("app=csi-rbdplugin", c)
|
|
|
|
}
|
2020-02-25 11:45:54 +00:00
|
|
|
|
2019-12-04 01:35:02 +00:00
|
|
|
deleteConfigMap(rbdDirPath)
|
2019-06-14 09:26:17 +00:00
|
|
|
deleteResource(rbdExamplePath + "secret.yaml")
|
|
|
|
deleteResource(rbdExamplePath + "storageclass.yaml")
|
2019-08-13 09:40:08 +00:00
|
|
|
// deleteResource(rbdExamplePath + "snapshotclass.yaml")
|
2020-01-29 11:44:45 +00:00
|
|
|
deleteVault()
|
2020-02-25 11:45:54 +00:00
|
|
|
if deployRBD {
|
|
|
|
deleteRBDPlugin()
|
|
|
|
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 {
|
|
|
|
Fail(err.Error())
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2020-03-27 18:21:18 +00:00
|
|
|
deleteNodeLabel(c, nodeRegionLabel)
|
|
|
|
deleteNodeLabel(c, nodeZoneLabel)
|
|
|
|
// Remove the CSI labels that get added
|
|
|
|
deleteNodeLabel(c, nodeCSIRegionLabel)
|
|
|
|
deleteNodeLabel(c, nodeCSIZoneLabel)
|
2019-05-31 09:34:04 +00:00
|
|
|
})
|
|
|
|
|
|
|
|
Context("Test RBD CSI", func() {
|
|
|
|
It("Test RBD CSI", func() {
|
2019-06-18 09:18:28 +00:00
|
|
|
pvcPath := rbdExamplePath + "pvc.yaml"
|
|
|
|
appPath := rbdExamplePath + "pod.yaml"
|
2019-12-18 08:36:47 +00:00
|
|
|
rawPvcPath := rbdExamplePath + "raw-block-pvc.yaml"
|
|
|
|
rawAppPath := rbdExamplePath + "raw-block-pod.yaml"
|
2020-04-16 07:09:59 +00:00
|
|
|
pvcClonePath := rbdExamplePath + "pvc-restore.yaml"
|
|
|
|
appClonePath := rbdExamplePath + "pod-restore.yaml"
|
|
|
|
snapshotPath := rbdExamplePath + "snapshot.yaml"
|
2019-06-18 07:07:11 +00:00
|
|
|
|
2020-03-27 18:21:18 +00:00
|
|
|
By("checking provisioner deployment is running", func() {
|
|
|
|
err := waitForDeploymentComplete(rbdDeploymentName, cephCSINamespace, f.ClientSet, deployTimeout)
|
|
|
|
if err != nil {
|
|
|
|
Fail(err.Error())
|
|
|
|
}
|
|
|
|
})
|
2019-05-31 09:34:04 +00:00
|
|
|
|
2020-03-27 18:21:18 +00:00
|
|
|
By("checking nodeplugin deamonsets is running", func() {
|
|
|
|
err := waitForDaemonSets(rbdDaemonsetName, cephCSINamespace, f.ClientSet, deployTimeout)
|
|
|
|
if err != nil {
|
|
|
|
Fail(err.Error())
|
|
|
|
}
|
|
|
|
})
|
2019-05-31 09:34:04 +00:00
|
|
|
|
|
|
|
By("create a PVC and Bind it to an app", func() {
|
|
|
|
validatePVCAndAppBinding(pvcPath, appPath, f)
|
|
|
|
})
|
2019-06-11 12:40:31 +00:00
|
|
|
|
|
|
|
By("create a PVC and Bind it to an app with normal user", func() {
|
|
|
|
validateNormalUserPVCAccess(pvcPath, f)
|
|
|
|
})
|
2019-09-19 17:11:32 +00:00
|
|
|
|
|
|
|
By("create a PVC and Bind it to an app with ext4 as the FS ", func() {
|
|
|
|
deleteResource(rbdExamplePath + "storageclass.yaml")
|
2020-03-27 18:21:18 +00:00
|
|
|
createRBDStorageClass(f.ClientSet, f, nil, map[string]string{"csi.storage.k8s.io/fstype": "ext4"})
|
2019-09-19 17:11:32 +00:00
|
|
|
validatePVCAndAppBinding(pvcPath, appPath, f)
|
|
|
|
deleteResource(rbdExamplePath + "storageclass.yaml")
|
2020-03-27 18:21:18 +00:00
|
|
|
createRBDStorageClass(f.ClientSet, f, nil, nil)
|
2019-09-19 17:11:32 +00:00
|
|
|
})
|
|
|
|
|
2019-12-13 11:41:32 +00:00
|
|
|
By("create a PVC and Bind it to an app with encrypted RBD volume", func() {
|
|
|
|
deleteResource(rbdExamplePath + "storageclass.yaml")
|
2020-03-27 18:21:18 +00:00
|
|
|
createRBDStorageClass(f.ClientSet, f, nil, map[string]string{"encrypted": "true"})
|
2020-01-29 11:44:45 +00:00
|
|
|
validateEncryptedPVCAndAppBinding(pvcPath, appPath, "", f)
|
|
|
|
deleteResource(rbdExamplePath + "storageclass.yaml")
|
2020-03-27 18:21:18 +00:00
|
|
|
createRBDStorageClass(f.ClientSet, f, nil, nil)
|
2020-01-29 11:44:45 +00:00
|
|
|
})
|
|
|
|
|
|
|
|
By("create a PVC and Bind it to an app with encrypted RBD volume with Vault KMS", func() {
|
|
|
|
deleteResource(rbdExamplePath + "storageclass.yaml")
|
|
|
|
scOpts := map[string]string{
|
|
|
|
"encrypted": "true",
|
|
|
|
"encryptionKMSID": "vault-test",
|
|
|
|
}
|
2020-03-27 18:21:18 +00:00
|
|
|
createRBDStorageClass(f.ClientSet, f, nil, scOpts)
|
2020-01-29 11:44:45 +00:00
|
|
|
validateEncryptedPVCAndAppBinding(pvcPath, appPath, "vault", f)
|
2019-12-13 11:41:32 +00:00
|
|
|
deleteResource(rbdExamplePath + "storageclass.yaml")
|
2020-03-27 18:21:18 +00:00
|
|
|
createRBDStorageClass(f.ClientSet, f, nil, nil)
|
2019-12-13 11:41:32 +00:00
|
|
|
})
|
|
|
|
|
2020-05-15 08:34:59 +00:00
|
|
|
By("create a PVC clone and bind it to an app", func() {
|
2020-04-16 07:34:44 +00:00
|
|
|
v, err := f.ClientSet.Discovery().ServerVersion()
|
2020-04-16 07:09:59 +00:00
|
|
|
if err != nil {
|
2020-04-16 07:34:44 +00:00
|
|
|
e2elog.Logf("failed to get server version with error %v", err)
|
2020-04-16 07:09:59 +00:00
|
|
|
Fail(err.Error())
|
|
|
|
}
|
2020-04-16 07:34:44 +00:00
|
|
|
// snapshot beta is only supported from v1.17+
|
|
|
|
if v.Major > "1" || (v.Major == "1" && v.Minor >= "17") {
|
|
|
|
createRBDSnapshotClass(f)
|
|
|
|
pvc, err := loadPVC(pvcPath)
|
|
|
|
if err != nil {
|
|
|
|
Fail(err.Error())
|
|
|
|
}
|
2019-08-13 09:40:08 +00:00
|
|
|
|
2020-04-16 07:34:44 +00:00
|
|
|
pvc.Namespace = f.UniqueName
|
|
|
|
e2elog.Logf("The PVC template %+v", pvc)
|
|
|
|
err = createPVCAndvalidatePV(f.ClientSet, pvc, deployTimeout)
|
|
|
|
if err != nil {
|
|
|
|
Fail(err.Error())
|
|
|
|
}
|
|
|
|
// validate created backend rbd images
|
|
|
|
images := listRBDImages(f)
|
|
|
|
if len(images) != 1 {
|
|
|
|
e2elog.Logf("backend image count %d expected image count %d", len(images), 1)
|
|
|
|
Fail("validate backend image failed")
|
|
|
|
}
|
|
|
|
snap := getSnapshot(snapshotPath)
|
|
|
|
snap.Namespace = f.UniqueName
|
|
|
|
snap.Spec.Source.PersistentVolumeClaimName = &pvc.Name
|
|
|
|
err = createSnapshot(&snap, deployTimeout)
|
|
|
|
if err != nil {
|
|
|
|
Fail(err.Error())
|
|
|
|
}
|
2020-05-05 03:53:24 +00:00
|
|
|
pool := defaultRBDPool
|
2020-04-16 07:34:44 +00:00
|
|
|
snapList, err := listSnapshots(f, pool, images[0])
|
|
|
|
if err != nil {
|
|
|
|
Fail(err.Error())
|
|
|
|
}
|
|
|
|
if len(snapList) != 1 {
|
2020-05-15 08:34:59 +00:00
|
|
|
e2elog.Logf("backend snapshot not matching kubernetes snap count,snap count = % kubernetes snap count %d", len(snapList), 1)
|
2020-04-16 07:34:44 +00:00
|
|
|
Fail("validate backend snapshot failed")
|
|
|
|
}
|
2020-04-16 07:09:59 +00:00
|
|
|
|
2020-04-16 07:34:44 +00:00
|
|
|
validatePVCAndAppBinding(pvcClonePath, appClonePath, f)
|
2020-04-16 07:09:59 +00:00
|
|
|
|
2020-04-16 07:34:44 +00:00
|
|
|
err = deleteSnapshot(&snap, deployTimeout)
|
|
|
|
if err != nil {
|
|
|
|
Fail(err.Error())
|
|
|
|
}
|
|
|
|
err = deletePVCAndValidatePV(f.ClientSet, pvc, deployTimeout)
|
|
|
|
if err != nil {
|
|
|
|
Fail(err.Error())
|
|
|
|
}
|
2020-04-16 07:09:59 +00:00
|
|
|
}
|
|
|
|
})
|
2019-06-14 09:26:17 +00:00
|
|
|
|
2019-12-18 08:36:47 +00:00
|
|
|
By("create a block type PVC and Bind it to an app", func() {
|
|
|
|
validatePVCAndAppBinding(rawPvcPath, rawAppPath, f)
|
|
|
|
})
|
2019-06-18 07:07:11 +00:00
|
|
|
|
|
|
|
By("create/delete multiple PVCs and Apps", func() {
|
|
|
|
totalCount := 2
|
|
|
|
pvc, err := loadPVC(pvcPath)
|
|
|
|
if err != nil {
|
|
|
|
Fail(err.Error())
|
|
|
|
}
|
|
|
|
pvc.Namespace = f.UniqueName
|
|
|
|
|
|
|
|
app, err := loadApp(appPath)
|
|
|
|
if err != nil {
|
|
|
|
Fail(err.Error())
|
|
|
|
}
|
|
|
|
app.Namespace = f.UniqueName
|
|
|
|
// create pvc and app
|
|
|
|
for i := 0; i < totalCount; i++ {
|
|
|
|
name := fmt.Sprintf("%s%d", f.UniqueName, i)
|
2020-03-27 18:21:18 +00:00
|
|
|
err := createPVCAndApp(name, f, pvc, app, deployTimeout)
|
2019-06-18 07:07:11 +00:00
|
|
|
if err != nil {
|
|
|
|
Fail(err.Error())
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
// validate created backend rbd images
|
|
|
|
images := listRBDImages(f)
|
|
|
|
if len(images) != totalCount {
|
2020-03-27 18:21:18 +00:00
|
|
|
e2elog.Logf("backend image creation not matching pvc count, image count = % pvc count %d", len(images), totalCount)
|
2019-06-18 07:07:11 +00:00
|
|
|
Fail("validate multiple pvc failed")
|
|
|
|
}
|
|
|
|
|
|
|
|
// delete pvc and app
|
|
|
|
for i := 0; i < totalCount; i++ {
|
|
|
|
name := fmt.Sprintf("%s%d", f.UniqueName, i)
|
|
|
|
err := deletePVCAndApp(name, f, pvc, app)
|
|
|
|
if err != nil {
|
|
|
|
Fail(err.Error())
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
// validate created backend rbd images
|
|
|
|
images = listRBDImages(f)
|
|
|
|
if len(images) > 0 {
|
2019-06-24 07:58:39 +00:00
|
|
|
e2elog.Logf("left out rbd backend images count %d", len(images))
|
2019-06-18 07:07:11 +00:00
|
|
|
Fail("validate multiple pvc failed")
|
|
|
|
}
|
2019-06-14 09:26:17 +00:00
|
|
|
})
|
2019-07-03 10:02:36 +00:00
|
|
|
|
|
|
|
By("check data persist after recreating pod with same pvc", func() {
|
|
|
|
err := checkDataPersist(pvcPath, appPath, f)
|
|
|
|
if err != nil {
|
|
|
|
Fail(err.Error())
|
|
|
|
}
|
|
|
|
})
|
2019-09-19 12:19:57 +00:00
|
|
|
|
2019-12-18 10:35:48 +00:00
|
|
|
By("Resize Filesystem PVC and check application directory size", func() {
|
2019-11-27 12:15:49 +00:00
|
|
|
v, err := f.ClientSet.Discovery().ServerVersion()
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Logf("failed to get server version with error %v", err)
|
|
|
|
Fail(err.Error())
|
|
|
|
}
|
|
|
|
|
|
|
|
// Resize 0.3.0 is only supported from v1.15+
|
|
|
|
if v.Major > "1" || (v.Major == "1" && v.Minor >= "15") {
|
|
|
|
err := resizePVCAndValidateSize(pvcPath, appPath, f)
|
|
|
|
if err != nil {
|
2019-12-18 10:35:48 +00:00
|
|
|
e2elog.Logf("failed to resize filesystem PVC %v", err)
|
2019-11-27 12:15:49 +00:00
|
|
|
Fail(err.Error())
|
|
|
|
}
|
|
|
|
|
2019-12-13 10:29:33 +00:00
|
|
|
deleteResource(rbdExamplePath + "storageclass.yaml")
|
2020-03-27 18:21:18 +00:00
|
|
|
createRBDStorageClass(f.ClientSet, f, nil, map[string]string{"csi.storage.k8s.io/fstype": "xfs"})
|
2019-12-13 10:29:33 +00:00
|
|
|
err = resizePVCAndValidateSize(pvcPath, appPath, f)
|
|
|
|
if err != nil {
|
2019-12-18 10:35:48 +00:00
|
|
|
e2elog.Logf("failed to resize filesystem PVC %v", err)
|
2019-12-13 10:29:33 +00:00
|
|
|
Fail(err.Error())
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
2019-11-27 12:15:49 +00:00
|
|
|
})
|
|
|
|
|
2019-12-18 10:35:48 +00:00
|
|
|
By("Resize Block PVC and check Device size", func() {
|
|
|
|
v, err := f.ClientSet.Discovery().ServerVersion()
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Logf("failed to get server version with error %v", err)
|
|
|
|
Fail(err.Error())
|
|
|
|
}
|
|
|
|
|
|
|
|
// Block PVC resize is supported in kubernetes 1.16+
|
|
|
|
if v.Major > "1" || (v.Major == "1" && v.Minor >= "16") {
|
|
|
|
err := resizePVCAndValidateSize(rawPvcPath, rawAppPath, f)
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Logf("failed to resize block PVC %v", err)
|
|
|
|
Fail(err.Error())
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
2019-09-19 12:19:57 +00:00
|
|
|
By("Test unmount after nodeplugin restart", func() {
|
|
|
|
pvc, err := loadPVC(pvcPath)
|
|
|
|
if err != nil {
|
|
|
|
Fail(err.Error())
|
|
|
|
}
|
|
|
|
pvc.Namespace = f.UniqueName
|
|
|
|
|
|
|
|
app, err := loadApp(appPath)
|
|
|
|
if err != nil {
|
|
|
|
Fail(err.Error())
|
|
|
|
}
|
|
|
|
app.Namespace = f.UniqueName
|
2020-03-27 18:21:18 +00:00
|
|
|
err = createPVCAndApp("", f, pvc, app, deployTimeout)
|
2019-09-19 12:19:57 +00:00
|
|
|
if err != nil {
|
|
|
|
Fail(err.Error())
|
|
|
|
}
|
|
|
|
|
|
|
|
// delete rbd nodeplugin pods
|
2020-04-01 07:20:43 +00:00
|
|
|
err = deletePodWithLabel("app=csi-rbdplugin", cephCSINamespace, false)
|
2019-09-19 12:19:57 +00:00
|
|
|
if err != nil {
|
|
|
|
Fail(err.Error())
|
|
|
|
}
|
|
|
|
// wait for nodeplugin pods to come up
|
2020-02-25 11:45:54 +00:00
|
|
|
err = waitForDaemonSets(rbdDaemonsetName, cephCSINamespace, f.ClientSet, deployTimeout)
|
2019-09-19 12:19:57 +00:00
|
|
|
if err != nil {
|
|
|
|
Fail(err.Error())
|
|
|
|
}
|
|
|
|
|
|
|
|
err = deletePVCAndApp("", f, pvc, app)
|
|
|
|
if err != nil {
|
|
|
|
Fail(err.Error())
|
|
|
|
}
|
|
|
|
})
|
2020-01-31 08:49:11 +00:00
|
|
|
|
2020-02-24 13:19:42 +00:00
|
|
|
By("create PVC in storageClass with volumeNamePrefix", func() {
|
|
|
|
volumeNamePrefix := "foo-bar-"
|
|
|
|
deleteResource(rbdExamplePath + "storageclass.yaml")
|
2020-03-27 18:21:18 +00:00
|
|
|
createRBDStorageClass(f.ClientSet, f, nil, map[string]string{"volumeNamePrefix": volumeNamePrefix})
|
2020-02-24 13:19:42 +00:00
|
|
|
|
|
|
|
// set up PVC
|
|
|
|
pvc, err := loadPVC(pvcPath)
|
|
|
|
if err != nil {
|
|
|
|
Fail(err.Error())
|
|
|
|
}
|
|
|
|
pvc.Namespace = f.UniqueName
|
|
|
|
err = createPVCAndvalidatePV(f.ClientSet, pvc, deployTimeout)
|
|
|
|
if err != nil {
|
|
|
|
Fail(err.Error())
|
|
|
|
}
|
|
|
|
|
|
|
|
// list RBD images and check if one of them has the same prefix
|
|
|
|
foundIt := false
|
|
|
|
for _, imgName := range listRBDImages(f) {
|
|
|
|
fmt.Printf("Checking prefix on %s\n", imgName)
|
|
|
|
if strings.HasPrefix(imgName, volumeNamePrefix) {
|
|
|
|
foundIt = true
|
|
|
|
break
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// clean up after ourselves
|
|
|
|
err = deletePVCAndValidatePV(f.ClientSet, pvc, deployTimeout)
|
|
|
|
if err != nil {
|
|
|
|
Fail(err.Error())
|
|
|
|
}
|
|
|
|
deleteResource(rbdExamplePath + "storageclass.yaml")
|
2020-03-27 18:21:18 +00:00
|
|
|
createRBDStorageClass(f.ClientSet, f, nil, nil)
|
2020-02-24 13:19:42 +00:00
|
|
|
|
|
|
|
if !foundIt {
|
|
|
|
Fail(fmt.Sprintf("could not find image with prefix %s", volumeNamePrefix))
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
2020-01-20 07:11:21 +00:00
|
|
|
By("validate RBD static FileSystem PVC", func() {
|
|
|
|
err := validateRBDStaticPV(f, appPath, false)
|
|
|
|
if err != nil {
|
|
|
|
Fail(err.Error())
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
|
|
|
By("validate RBD static Block PVC", func() {
|
|
|
|
err := validateRBDStaticPV(f, rawAppPath, true)
|
|
|
|
if err != nil {
|
|
|
|
Fail(err.Error())
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
2020-03-02 08:31:44 +00:00
|
|
|
By("validate mount options in app pod", func() {
|
|
|
|
mountFlags := []string{"discard"}
|
|
|
|
err := checkMountOptions(pvcPath, appPath, f, mountFlags)
|
|
|
|
if err != nil {
|
|
|
|
Fail(err.Error())
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
2020-03-27 18:21:18 +00:00
|
|
|
By("creating an app with a PVC, using a topology constrained StorageClass", func() {
|
|
|
|
By("checking node has required CSI topology labels set", func() {
|
|
|
|
checkNodeHasLabel(f.ClientSet, nodeCSIRegionLabel, regionValue)
|
|
|
|
checkNodeHasLabel(f.ClientSet, nodeCSIZoneLabel, zoneValue)
|
|
|
|
})
|
|
|
|
|
|
|
|
By("creating a StorageClass with delayed binding mode and CSI topology parameter")
|
|
|
|
deleteResource(rbdExamplePath + "storageclass.yaml")
|
|
|
|
topologyConstraint := "[{\"poolName\":\"" + rbdTopologyPool + "\",\"domainSegments\":" +
|
|
|
|
"[{\"domainLabel\":\"region\",\"value\":\"" + regionValue + "\"}," +
|
|
|
|
"{\"domainLabel\":\"zone\",\"value\":\"" + zoneValue + "\"}]}]"
|
|
|
|
createRBDStorageClass(f.ClientSet, f,
|
|
|
|
map[string]string{"volumeBindingMode": "WaitForFirstConsumer"},
|
|
|
|
map[string]string{"topologyConstrainedPools": topologyConstraint})
|
|
|
|
|
|
|
|
By("creating an app using a PV from the delayed binding mode StorageClass")
|
|
|
|
pvc, app := createPVCAndAppBinding(pvcPath, appPath, f, 0)
|
|
|
|
|
|
|
|
By("ensuring created PV has required node selector values populated")
|
|
|
|
checkPVSelectorValuesForPVC(f, pvc)
|
|
|
|
|
|
|
|
By("ensuring created PV has its image in the topology specific pool")
|
|
|
|
err := checkPVCImageInPool(f, pvc, rbdTopologyPool)
|
|
|
|
if err != nil {
|
|
|
|
Fail(err.Error())
|
|
|
|
}
|
|
|
|
|
|
|
|
By("ensuring created PV has its image journal in the topology specific pool")
|
|
|
|
err = checkPVCImageJournalInPool(f, pvc, rbdTopologyPool)
|
|
|
|
if err != nil {
|
|
|
|
Fail(err.Error())
|
|
|
|
}
|
|
|
|
|
|
|
|
By("ensuring created PV has its CSI journal in the CSI journal specific pool")
|
|
|
|
err = checkPVCCSIJournalInPool(f, pvc, "replicapool")
|
|
|
|
if err != nil {
|
|
|
|
Fail(err.Error())
|
|
|
|
}
|
|
|
|
|
|
|
|
err = deletePVCAndApp("", f, pvc, app)
|
|
|
|
if err != nil {
|
|
|
|
Fail(err.Error())
|
|
|
|
}
|
2020-04-06 20:19:13 +00:00
|
|
|
|
|
|
|
By("checking if data pool parameter is honored", func() {
|
|
|
|
deleteResource(rbdExamplePath + "storageclass.yaml")
|
|
|
|
topologyConstraint := "[{\"poolName\":\"" + rbdTopologyPool + "\",\"dataPool\":\"" + rbdTopologyDataPool +
|
|
|
|
"\",\"domainSegments\":" +
|
|
|
|
"[{\"domainLabel\":\"region\",\"value\":\"" + regionValue + "\"}," +
|
|
|
|
"{\"domainLabel\":\"zone\",\"value\":\"" + zoneValue + "\"}]}]"
|
|
|
|
createRBDStorageClass(f.ClientSet, f,
|
|
|
|
map[string]string{"volumeBindingMode": "WaitForFirstConsumer"},
|
|
|
|
map[string]string{"topologyConstrainedPools": topologyConstraint})
|
|
|
|
|
|
|
|
By("creating an app using a PV from the delayed binding mode StorageClass with a data pool")
|
|
|
|
pvc, app = createPVCAndAppBinding(pvcPath, appPath, f, 0)
|
|
|
|
|
|
|
|
By("ensuring created PV has its image in the topology specific pool")
|
|
|
|
err = checkPVCImageInPool(f, pvc, rbdTopologyPool)
|
|
|
|
if err != nil {
|
|
|
|
Fail(err.Error())
|
|
|
|
}
|
|
|
|
|
|
|
|
By("ensuring created image has the right data pool parameter set")
|
|
|
|
err = checkPVCDataPoolForImageInPool(f, pvc, rbdTopologyPool, rbdTopologyDataPool)
|
|
|
|
if err != nil {
|
|
|
|
Fail(err.Error())
|
|
|
|
}
|
|
|
|
|
|
|
|
// cleanup and undo changes made by the test
|
|
|
|
err = deletePVCAndApp("", f, pvc, app)
|
|
|
|
if err != nil {
|
|
|
|
Fail(err.Error())
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
|
|
|
// cleanup and undo changes made by the test
|
2020-03-27 18:21:18 +00:00
|
|
|
deleteResource(rbdExamplePath + "storageclass.yaml")
|
|
|
|
createRBDStorageClass(f.ClientSet, f, nil, nil)
|
|
|
|
})
|
|
|
|
|
2020-05-18 13:07:58 +00:00
|
|
|
// Mount pvc to pod with invalid mount option,expected that
|
|
|
|
// mounting will fail
|
|
|
|
By("Mount pvc to pod with invalid mount option", func() {
|
|
|
|
deleteResource(rbdExamplePath + "storageclass.yaml")
|
|
|
|
createRBDStorageClass(f.ClientSet, f, map[string]string{rbdmountOptions: "debug,invalidOption"}, nil)
|
|
|
|
pvc, err := loadPVC(pvcPath)
|
|
|
|
if err != nil {
|
|
|
|
Fail(err.Error())
|
|
|
|
}
|
|
|
|
pvc.Namespace = f.UniqueName
|
|
|
|
|
|
|
|
app, err := loadApp(appPath)
|
|
|
|
if err != nil {
|
|
|
|
Fail(err.Error())
|
|
|
|
}
|
|
|
|
app.Namespace = f.UniqueName
|
|
|
|
err = createPVCAndvalidatePV(f.ClientSet, pvc, deployTimeout)
|
|
|
|
if err != nil {
|
|
|
|
Fail(err.Error())
|
|
|
|
}
|
|
|
|
// create an app and wait for 2 min for it to go to running state
|
|
|
|
err = createApp(f.ClientSet, app, 2)
|
|
|
|
if err == nil {
|
|
|
|
Fail("application should not go to running state due to invalid mount option")
|
|
|
|
}
|
|
|
|
err = deletePVCAndApp("", f, pvc, app)
|
|
|
|
if err != nil {
|
|
|
|
Fail(err.Error())
|
|
|
|
}
|
|
|
|
|
|
|
|
deleteResource(rbdExamplePath + "storageclass.yaml")
|
|
|
|
createRBDStorageClass(f.ClientSet, f, nil, nil)
|
|
|
|
})
|
|
|
|
|
2020-01-31 08:49:11 +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, false, f)
|
|
|
|
if err != nil {
|
|
|
|
Fail(err.Error())
|
|
|
|
}
|
|
|
|
})
|
2019-05-31 09:34:04 +00:00
|
|
|
})
|
|
|
|
})
|
|
|
|
})
|