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"
|
2020-07-20 12:39:50 +00:00
|
|
|
"sync"
|
2019-06-14 09:42:48 +00:00
|
|
|
|
2020-07-20 12:39:50 +00:00
|
|
|
"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-04-16 14:47:43 +00:00
|
|
|
v1 "k8s.io/api/core/v1"
|
|
|
|
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 (
|
|
|
|
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 {
|
2020-09-03 09:34:29 +00:00
|
|
|
e2elog.Failf("failed to read content from %s with error %v", rbdDirPath+rbdProvisionerRBAC, 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", rbdDirPath+rbdProvisionerRBAC, err)
|
2020-02-26 08:11:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
data, err = replaceNamespaceInTemplate(rbdDirPath + rbdNodePluginRBAC)
|
|
|
|
if err != nil {
|
2020-09-03 09:34:29 +00:00
|
|
|
e2elog.Failf("failed to read content from %s with error %v", rbdDirPath+rbdNodePluginRBAC, 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", rbdDirPath+rbdNodePluginRBAC, err)
|
2020-02-26 08:11:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
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-09-03 09:34:29 +00:00
|
|
|
e2elog.Failf("failed to read content from %s with error %v", rbdDirPath+rbdProvisioner, err)
|
2019-08-07 14:53:39 +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", "-")
|
2019-08-07 14:53:39 +00:00
|
|
|
if err != nil {
|
2020-09-03 09:34:29 +00:00
|
|
|
e2elog.Failf("failed to %s rbd provisioner with error %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-09-03 09:34:29 +00:00
|
|
|
e2elog.Failf("failed to read content from %s with error %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-09-03 09:34:29 +00:00
|
|
|
e2elog.Failf("failed to %s 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(rbdDirPath + rbdProvisionerPSP)
|
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", 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-09-03 09:34:29 +00:00
|
|
|
e2elog.Failf("failed to %s provisioner psp with error %v", action, err)
|
2020-02-26 08:11:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
data, err = replaceNamespaceInTemplate(rbdDirPath + rbdNodePlugin)
|
|
|
|
if err != nil {
|
2020-09-03 09:34:29 +00:00
|
|
|
e2elog.Failf("failed to read content from %s with error %v", rbdDirPath+rbdNodePlugin, err)
|
2020-02-26 08:11:05 +00:00
|
|
|
}
|
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 {
|
2020-09-03 09:34:29 +00:00
|
|
|
e2elog.Failf("failed to %s nodeplugin with error %v", action, err)
|
2020-02-26 08:11:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
data, err = replaceNamespaceInTemplate(rbdDirPath + rbdNodePluginRBAC)
|
|
|
|
if err != nil {
|
2020-09-03 09:34:29 +00:00
|
|
|
e2elog.Failf("failed to read content from %s with error %v", rbdDirPath+rbdNodePluginRBAC, 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 nodeplugin rbac with error %v", action, err)
|
2020-02-26 08:11:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
data, err = replaceNamespaceInTemplate(rbdDirPath + rbdNodePluginPSP)
|
|
|
|
if err != nil {
|
2020-09-03 09:34:29 +00:00
|
|
|
e2elog.Failf("failed to read content from %s with error %v", rbdDirPath+rbdNodePluginPSP, 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 nodeplugin psp with error %v", action, err)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func validateRBDImageCount(f *framework.Framework, count int) {
|
|
|
|
imageList, err := listRBDImages(f)
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to list rbd images with error %v", err)
|
|
|
|
}
|
|
|
|
if len(imageList) != count {
|
|
|
|
e2elog.Failf("backend images not matching kubernetes resource count,image count %d kubernetes resource count %d", len(imageList), 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("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() {
|
2020-07-25 16:40:28 +00:00
|
|
|
if !testRBD || upgradeTesting {
|
2020-07-08 11:46:31 +00:00
|
|
|
Skip("Skipping RBD E2E")
|
|
|
|
}
|
2019-12-18 08:41:20 +00:00
|
|
|
c = f.ClientSet
|
2020-02-25 08:00:23 +00:00
|
|
|
if deployRBD {
|
2020-09-03 09:34:29 +00:00
|
|
|
err := createNodeLabel(f, nodeRegionLabel, regionValue)
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to create node label with error %v", err)
|
|
|
|
}
|
|
|
|
err = createNodeLabel(f, nodeZoneLabel, zoneValue)
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to create node label with error %v", err)
|
|
|
|
}
|
2020-02-25 11:45:54 +00:00
|
|
|
if cephCSINamespace != defaultNs {
|
2020-09-03 09:34:29 +00:00
|
|
|
err = createNamespace(c, cephCSINamespace)
|
2020-02-26 08:11:05 +00:00
|
|
|
if err != nil {
|
2020-09-03 09:34:29 +00:00
|
|
|
e2elog.Failf("failed to create namespace with error %v", err)
|
2020-02-25 11:45:54 +00:00
|
|
|
}
|
|
|
|
}
|
2020-02-25 08:00:23 +00:00
|
|
|
deployRBDPlugin()
|
|
|
|
}
|
2020-09-03 09:34:29 +00:00
|
|
|
err := createConfigMap(rbdDirPath, f.ClientSet, f)
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to create configmap with error %v", err)
|
|
|
|
}
|
|
|
|
err = createRBDStorageClass(f.ClientSet, f, nil, nil)
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to create storageclass with error %v", err)
|
|
|
|
}
|
|
|
|
err = createRBDSecret(f.ClientSet, f)
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to create secret with error %v", err)
|
|
|
|
}
|
2020-01-29 11:44:45 +00:00
|
|
|
deployVault(f.ClientSet, deployTimeout)
|
2019-05-31 09:34:04 +00:00
|
|
|
})
|
|
|
|
|
|
|
|
AfterEach(func() {
|
2020-07-25 16:40:28 +00:00
|
|
|
if !testRBD || upgradeTesting {
|
2020-07-08 11:46:31 +00:00
|
|
|
Skip("Skipping RBD 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-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
|
|
|
|
2020-09-03 09:34:29 +00:00
|
|
|
err := deleteConfigMap(rbdDirPath)
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to delete configmap with error %v", err)
|
|
|
|
}
|
|
|
|
err = deleteResource(rbdExamplePath + "secret.yaml")
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to delete secret with error %v", err)
|
|
|
|
}
|
|
|
|
err = deleteResource(rbdExamplePath + "storageclass.yaml")
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to delete storageclass with error %v", err)
|
|
|
|
}
|
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-09-03 09:34:29 +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 with error %v", err)
|
2020-02-25 11:45:54 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2020-09-03 09:34:29 +00:00
|
|
|
err = deleteNodeLabel(c, nodeRegionLabel)
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to delete node label with error %v", err)
|
|
|
|
}
|
|
|
|
err = deleteNodeLabel(c, nodeZoneLabel)
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to delete node label with error %v", err)
|
|
|
|
}
|
2020-03-27 18:21:18 +00:00
|
|
|
// Remove the CSI labels that get added
|
2020-09-03 09:34:29 +00:00
|
|
|
err = deleteNodeLabel(c, nodeCSIRegionLabel)
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to delete node label with error %v", err)
|
|
|
|
}
|
|
|
|
err = deleteNodeLabel(c, nodeCSIZoneLabel)
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to delete node label with error %v", err)
|
|
|
|
}
|
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"
|
2020-07-08 12:59:38 +00:00
|
|
|
pvcSmartClonePath := rbdExamplePath + "pvc-clone.yaml"
|
2020-04-16 07:09:59 +00:00
|
|
|
appClonePath := rbdExamplePath + "pod-restore.yaml"
|
2020-07-08 12:59:38 +00:00
|
|
|
appSmartClonePath := rbdExamplePath + "pod-clone.yaml"
|
2020-04-16 07:09:59 +00:00
|
|
|
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 {
|
2020-09-03 09:34:29 +00:00
|
|
|
e2elog.Failf("timeout waiting for deployment %s with error %v", rbdDeploymentName, err)
|
2020-03-27 18:21:18 +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() {
|
2020-03-27 18:21:18 +00:00
|
|
|
err := waitForDaemonSets(rbdDaemonsetName, cephCSINamespace, f.ClientSet, deployTimeout)
|
|
|
|
if err != nil {
|
2020-09-03 09:34:29 +00:00
|
|
|
e2elog.Failf("timeout waiting for daemonset %s with error %v", rbdDaemonsetName, err)
|
2020-03-27 18:21:18 +00:00
|
|
|
}
|
|
|
|
})
|
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", func() {
|
|
|
|
err := validatePVCAndAppBinding(pvcPath, appPath, f)
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to validate pvc and application binding with error %v", err)
|
2020-08-17 08:37:19 +00:00
|
|
|
}
|
2020-09-03 09:34:29 +00:00
|
|
|
// validate created backend rbd images
|
|
|
|
validateRBDImageCount(f, 0)
|
2019-05-31 09:34:04 +00:00
|
|
|
})
|
2019-06-11 12:40:31 +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 pvc and application bidning with error %v", err)
|
2020-08-17 08:37:19 +00:00
|
|
|
}
|
2020-09-03 09:34:29 +00:00
|
|
|
// validate created backend rbd images
|
|
|
|
validateRBDImageCount(f, 0)
|
2019-06-11 12:40:31 +00:00
|
|
|
})
|
2019-09-19 17:11:32 +00:00
|
|
|
|
2020-09-03 09:34:29 +00:00
|
|
|
By("create a PVC and bind it to an app with ext4 as the FS ", func() {
|
|
|
|
err := deleteResource(rbdExamplePath + "storageclass.yaml")
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to delete storageclass with error %v", err)
|
|
|
|
}
|
|
|
|
err = createRBDStorageClass(f.ClientSet, f, nil, map[string]string{"csi.storage.k8s.io/fstype": "ext4"})
|
|
|
|
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 binding with error %v", err)
|
|
|
|
}
|
2020-08-17 08:37:19 +00:00
|
|
|
// validate created backend rbd images
|
2020-09-03 09:34:29 +00:00
|
|
|
validateRBDImageCount(f, 0)
|
|
|
|
err = deleteResource(rbdExamplePath + "storageclass.yaml")
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to delete storageclass with error %v", err)
|
|
|
|
}
|
|
|
|
err = createRBDStorageClass(f.ClientSet, f, nil, nil)
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to create storageclass with error %v", err)
|
2020-08-17 08:37:19 +00:00
|
|
|
}
|
2019-09-19 17:11:32 +00:00
|
|
|
})
|
|
|
|
|
2020-09-03 09:34:29 +00:00
|
|
|
By("create a PVC and bind it to an app with encrypted RBD volume", func() {
|
|
|
|
err := deleteResource(rbdExamplePath + "storageclass.yaml")
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to delete storageclass with error %v", err)
|
|
|
|
}
|
|
|
|
err = createRBDStorageClass(f.ClientSet, f, nil, map[string]string{"encrypted": "true"})
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to create storageclass with error %v", err)
|
|
|
|
}
|
|
|
|
err = validateEncryptedPVCAndAppBinding(pvcPath, appPath, "", f)
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to validate encrypted pvc with error %v", err)
|
|
|
|
}
|
2020-08-17 08:37:19 +00:00
|
|
|
// validate created backend rbd images
|
2020-09-03 09:34:29 +00:00
|
|
|
validateRBDImageCount(f, 0)
|
|
|
|
err = deleteResource(rbdExamplePath + "storageclass.yaml")
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to delete storageclass with error %v", err)
|
|
|
|
}
|
|
|
|
err = createRBDStorageClass(f.ClientSet, f, nil, nil)
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to create storageclass with error %v", err)
|
2020-08-17 08:37:19 +00:00
|
|
|
}
|
2020-01-29 11:44:45 +00:00
|
|
|
})
|
|
|
|
|
2020-09-03 09:34:29 +00:00
|
|
|
By("create a PVC and bind it to an app with encrypted RBD volume with Vault KMS", func() {
|
|
|
|
err := deleteResource(rbdExamplePath + "storageclass.yaml")
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to delete storageclass with error %v", err)
|
|
|
|
}
|
2020-01-29 11:44:45 +00:00
|
|
|
scOpts := map[string]string{
|
|
|
|
"encrypted": "true",
|
|
|
|
"encryptionKMSID": "vault-test",
|
|
|
|
}
|
2020-09-03 09:34:29 +00:00
|
|
|
err = createRBDStorageClass(f.ClientSet, f, nil, scOpts)
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to create storageclass with error %v", err)
|
|
|
|
}
|
|
|
|
err = validateEncryptedPVCAndAppBinding(pvcPath, appPath, "vault", f)
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to validate encrypted pvc with error %v", err)
|
|
|
|
}
|
2020-08-17 08:37:19 +00:00
|
|
|
// validate created backend rbd images
|
2020-09-03 09:34:29 +00:00
|
|
|
validateRBDImageCount(f, 0)
|
|
|
|
err = deleteResource(rbdExamplePath + "storageclass.yaml")
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to delete storageclass with error %v", err)
|
|
|
|
}
|
|
|
|
err = createRBDStorageClass(f.ClientSet, f, nil, nil)
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to create storageclass with error %v", err)
|
2020-08-17 08:37:19 +00:00
|
|
|
}
|
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-09-03 09:34:29 +00:00
|
|
|
e2elog.Failf("failed to get server version with error with error %v", err)
|
2020-04-16 07:09:59 +00:00
|
|
|
}
|
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") {
|
2020-07-20 12:39:50 +00:00
|
|
|
var wg sync.WaitGroup
|
|
|
|
totalCount := 10
|
|
|
|
wg.Add(totalCount)
|
2020-09-03 09:34:29 +00:00
|
|
|
err = createRBDSnapshotClass(f)
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to create storageclass with error %v", err)
|
|
|
|
}
|
2020-04-16 07:34:44 +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-04-16 07:34:44 +00:00
|
|
|
}
|
2019-08-13 09:40:08 +00:00
|
|
|
|
2020-04-16 07:34:44 +00:00
|
|
|
pvc.Namespace = f.UniqueName
|
|
|
|
err = createPVCAndvalidatePV(f.ClientSet, pvc, deployTimeout)
|
|
|
|
if err != nil {
|
2020-09-03 09:34:29 +00:00
|
|
|
e2elog.Failf("failed to create PVC with error %v", err)
|
2020-04-16 07:34:44 +00:00
|
|
|
}
|
2020-09-03 09:34:29 +00:00
|
|
|
validateRBDImageCount(f, 1)
|
2020-04-16 07:34:44 +00:00
|
|
|
snap := getSnapshot(snapshotPath)
|
|
|
|
snap.Namespace = f.UniqueName
|
|
|
|
snap.Spec.Source.PersistentVolumeClaimName = &pvc.Name
|
2020-06-09 09:21:03 +00:00
|
|
|
// create snapshot
|
|
|
|
for i := 0; i < totalCount; i++ {
|
2020-07-20 12:39:50 +00:00
|
|
|
go func(w *sync.WaitGroup, n int, s v1beta1.VolumeSnapshot) {
|
|
|
|
s.Name = fmt.Sprintf("%s%d", f.UniqueName, n)
|
|
|
|
err = createSnapshot(&s, deployTimeout)
|
|
|
|
if err != nil {
|
2020-09-03 09:34:29 +00:00
|
|
|
e2elog.Failf("failed to create snapshot with error %v", err)
|
2020-07-20 12:39:50 +00:00
|
|
|
}
|
|
|
|
w.Done()
|
|
|
|
}(&wg, i, snap)
|
2020-06-09 09:21:03 +00:00
|
|
|
}
|
2020-07-20 12:39:50 +00:00
|
|
|
wg.Wait()
|
2020-06-09 09:21:03 +00:00
|
|
|
|
|
|
|
// total images in cluster is 1 parent rbd image+ total snaps
|
2020-09-03 09:34:29 +00:00
|
|
|
validateRBDImageCount(f, totalCount+1)
|
2020-06-09 09:21:03 +00:00
|
|
|
pvcClone, err := loadPVC(pvcClonePath)
|
2020-04-16 07:34:44 +00:00
|
|
|
if err != nil {
|
2020-09-03 09:34:29 +00:00
|
|
|
e2elog.Failf("failed to load PVC with error %v", err)
|
2020-04-16 07:34:44 +00:00
|
|
|
}
|
2020-06-09 09:21:03 +00:00
|
|
|
appClone, err := loadApp(appClonePath)
|
2020-04-16 07:34:44 +00:00
|
|
|
if err != nil {
|
2020-09-03 09:34:29 +00:00
|
|
|
e2elog.Failf("failed to load application with error %v", err)
|
2020-04-16 07:34:44 +00:00
|
|
|
}
|
2020-07-20 12:39:50 +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)
|
2020-06-09 09:21:03 +00:00
|
|
|
for i := 0; i < totalCount; i++ {
|
2020-07-20 12:39:50 +00:00
|
|
|
go func(w *sync.WaitGroup, n int, p v1.PersistentVolumeClaim, a v1.Pod) {
|
|
|
|
name := fmt.Sprintf("%s%d", f.UniqueName, n)
|
|
|
|
err = createPVCAndApp(name, f, &p, &a, deployTimeout)
|
|
|
|
if err != nil {
|
2020-09-03 09:34:29 +00:00
|
|
|
e2elog.Failf("failed to create PVC and application with error %v", err)
|
2020-07-20 12:39:50 +00:00
|
|
|
}
|
|
|
|
w.Done()
|
|
|
|
}(&wg, i, *pvcClone, *appClone)
|
2020-04-16 07:34:44 +00:00
|
|
|
}
|
2020-07-20 12:39:50 +00:00
|
|
|
wg.Wait()
|
2020-04-16 07:09:59 +00:00
|
|
|
|
2020-06-09 09:21:03 +00:00
|
|
|
// total images in cluster is 1 parent rbd image+ total
|
|
|
|
// snaps+ total clones
|
|
|
|
totalCloneCount := totalCount + totalCount + 1
|
2020-09-03 09:34:29 +00:00
|
|
|
validateRBDImageCount(f, totalCloneCount)
|
2020-07-20 12:39:50 +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
|
|
|
|
err = deletePVCAndApp(name, f, &p, &a)
|
|
|
|
if err != nil {
|
2020-09-03 09:34:29 +00:00
|
|
|
e2elog.Failf("failed to delete PVC and app with error %v", err)
|
2020-07-20 12:39:50 +00:00
|
|
|
}
|
|
|
|
w.Done()
|
|
|
|
}(&wg, i, *pvcClone, *appClone)
|
|
|
|
}
|
|
|
|
wg.Wait()
|
|
|
|
|
2020-09-03 09:34:29 +00:00
|
|
|
// total images in cluster is 1 parent rbd image+ total
|
|
|
|
// snaps
|
|
|
|
validateRBDImageCount(f, totalCount+1)
|
2020-07-20 12:39:50 +00:00
|
|
|
// 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
|
|
|
|
err = createPVCAndApp(name, f, &p, &a, deployTimeout)
|
|
|
|
if err != nil {
|
2020-09-03 09:34:29 +00:00
|
|
|
e2elog.Failf("failed to create PVC and app with error %v", err)
|
2020-07-20 12:39:50 +00:00
|
|
|
}
|
|
|
|
w.Done()
|
|
|
|
}(&wg, i, *pvcClone, *appClone)
|
|
|
|
}
|
|
|
|
wg.Wait()
|
|
|
|
|
|
|
|
// total images in cluster is 1 parent rbd image+ total
|
|
|
|
// snaps+ total clones
|
|
|
|
totalCloneCount = totalCount + totalCount + 1
|
2020-09-03 09:34:29 +00:00
|
|
|
validateRBDImageCount(f, totalCloneCount)
|
2020-06-09 09:21:03 +00:00
|
|
|
// delete parent pvc
|
2020-04-16 07:34:44 +00:00
|
|
|
err = deletePVCAndValidatePV(f.ClientSet, pvc, deployTimeout)
|
|
|
|
if err != nil {
|
2020-09-03 09:34:29 +00:00
|
|
|
e2elog.Failf("failed to delete PVC with error %v", err)
|
2020-04-16 07:34:44 +00:00
|
|
|
}
|
2020-06-09 09:21:03 +00:00
|
|
|
|
|
|
|
// total images in cluster is total snaps+ total clones
|
2020-09-03 09:34:29 +00:00
|
|
|
totalSnapCount := totalCount + totalCount
|
|
|
|
validateRBDImageCount(f, totalSnapCount)
|
2020-07-20 12:39:50 +00:00
|
|
|
wg.Add(totalCount)
|
|
|
|
// delete snapshot
|
2020-06-09 09:21:03 +00:00
|
|
|
for i := 0; i < totalCount; i++ {
|
2020-07-20 12:39:50 +00:00
|
|
|
go func(w *sync.WaitGroup, n int, s v1beta1.VolumeSnapshot) {
|
|
|
|
s.Name = fmt.Sprintf("%s%d", f.UniqueName, n)
|
|
|
|
err = deleteSnapshot(&s, deployTimeout)
|
|
|
|
if err != nil {
|
2020-09-03 09:34:29 +00:00
|
|
|
e2elog.Failf("failed to delete snapshot with error %v", err)
|
2020-07-20 12:39:50 +00:00
|
|
|
}
|
|
|
|
w.Done()
|
|
|
|
}(&wg, i, snap)
|
2020-06-09 09:21:03 +00:00
|
|
|
}
|
2020-07-20 12:39:50 +00:00
|
|
|
wg.Wait()
|
2020-06-09 09:21:03 +00:00
|
|
|
|
2020-09-03 09:34:29 +00:00
|
|
|
validateRBDImageCount(f, totalCount)
|
2020-07-20 12:39:50 +00:00
|
|
|
wg.Add(totalCount)
|
|
|
|
// delete clone and app
|
2020-06-09 09:21:03 +00:00
|
|
|
for i := 0; i < totalCount; i++ {
|
2020-07-20 12:39:50 +00:00
|
|
|
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
|
|
|
|
err = deletePVCAndApp(name, f, &p, &a)
|
|
|
|
if err != nil {
|
2020-09-03 09:34:29 +00:00
|
|
|
e2elog.Failf("failed to delete PVC and application with error %v", err)
|
2020-07-20 12:39:50 +00:00
|
|
|
}
|
|
|
|
w.Done()
|
|
|
|
}(&wg, i, *pvcClone, *appClone)
|
2020-06-09 09:21:03 +00:00
|
|
|
}
|
2020-07-20 12:39:50 +00:00
|
|
|
wg.Wait()
|
2020-08-17 08:37:19 +00:00
|
|
|
// validate created backend rbd images
|
2020-09-03 09:34:29 +00:00
|
|
|
validateRBDImageCount(f, 0)
|
2020-04-16 07:09:59 +00:00
|
|
|
}
|
|
|
|
})
|
2019-06-14 09:26:17 +00:00
|
|
|
|
2020-07-08 12:59:38 +00:00
|
|
|
By("create a PVC-PVC clone and bind it to an app", func() {
|
|
|
|
v, err := f.ClientSet.Discovery().ServerVersion()
|
|
|
|
if err != nil {
|
2020-09-03 09:34:29 +00:00
|
|
|
e2elog.Failf("failed to get server version with error %v", err)
|
2020-07-08 12:59:38 +00:00
|
|
|
}
|
|
|
|
// pvc clone is only supported from v1.16+
|
|
|
|
if v.Major > "1" || (v.Major == "1" && v.Minor >= "16") {
|
2020-07-20 12:39:50 +00:00
|
|
|
var wg sync.WaitGroup
|
|
|
|
totalCount := 10
|
2020-07-08 12:59:38 +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-07-08 12:59:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
pvc.Namespace = f.UniqueName
|
|
|
|
err = createPVCAndvalidatePV(f.ClientSet, pvc, deployTimeout)
|
|
|
|
if err != nil {
|
2020-09-03 09:34:29 +00:00
|
|
|
e2elog.Failf("failed to create PVC with error %v", err)
|
2020-07-08 12:59:38 +00:00
|
|
|
}
|
|
|
|
// validate created backend rbd images
|
2020-09-03 09:34:29 +00:00
|
|
|
validateRBDImageCount(f, 1)
|
2020-07-08 12:59:38 +00:00
|
|
|
pvcClone, err := loadPVC(pvcSmartClonePath)
|
|
|
|
if err != nil {
|
2020-09-03 09:34:29 +00:00
|
|
|
e2elog.Failf("failed to load PVC with error %v", err)
|
2020-07-08 12:59:38 +00:00
|
|
|
}
|
|
|
|
pvcClone.Spec.DataSource.Name = pvc.Name
|
|
|
|
pvcClone.Namespace = f.UniqueName
|
|
|
|
appClone, err := loadApp(appSmartClonePath)
|
|
|
|
if err != nil {
|
2020-09-03 09:34:29 +00:00
|
|
|
e2elog.Failf("failed to load application with error %v", err)
|
2020-07-08 12:59:38 +00:00
|
|
|
}
|
|
|
|
appClone.Namespace = f.UniqueName
|
2020-07-20 12:39:50 +00:00
|
|
|
wg.Add(totalCount)
|
2020-07-08 12:59:38 +00:00
|
|
|
// create clone and bind it to an app
|
|
|
|
for i := 0; i < totalCount; i++ {
|
2020-07-20 12:39:50 +00:00
|
|
|
go func(w *sync.WaitGroup, n int, p v1.PersistentVolumeClaim, a v1.Pod) {
|
|
|
|
name := fmt.Sprintf("%s%d", f.UniqueName, n)
|
|
|
|
err = createPVCAndApp(name, f, &p, &a, deployTimeout)
|
|
|
|
if err != nil {
|
2020-09-03 09:34:29 +00:00
|
|
|
e2elog.Failf("failed to create PVC with error %v", err)
|
2020-07-20 12:39:50 +00:00
|
|
|
}
|
|
|
|
w.Done()
|
|
|
|
}(&wg, i, *pvcClone, *appClone)
|
2020-07-08 12:59:38 +00:00
|
|
|
}
|
2020-07-20 12:39:50 +00:00
|
|
|
wg.Wait()
|
2020-07-08 12:59:38 +00:00
|
|
|
|
|
|
|
// total images in cluster is 1 parent rbd image+ total
|
|
|
|
// temporary clone+ total clones
|
|
|
|
totalCloneCount := totalCount + totalCount + 1
|
2020-09-03 09:34:29 +00:00
|
|
|
validateRBDImageCount(f, totalCloneCount)
|
2020-07-08 12:59:38 +00:00
|
|
|
// delete parent pvc
|
|
|
|
err = deletePVCAndValidatePV(f.ClientSet, pvc, deployTimeout)
|
|
|
|
if err != nil {
|
2020-09-03 09:34:29 +00:00
|
|
|
e2elog.Failf("failed to delete PVC with error %v", err)
|
2020-07-08 12:59:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
totalCloneCount = totalCount + totalCount
|
2020-09-03 09:34:29 +00:00
|
|
|
validateRBDImageCount(f, totalCloneCount)
|
2020-07-20 12:39:50 +00:00
|
|
|
wg.Add(totalCount)
|
2020-07-08 12:59:38 +00:00
|
|
|
// delete clone and app
|
|
|
|
for i := 0; i < totalCount; i++ {
|
2020-07-20 12:39:50 +00:00
|
|
|
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
|
|
|
|
err = deletePVCAndApp(name, f, &p, &a)
|
|
|
|
if err != nil {
|
2020-09-03 09:34:29 +00:00
|
|
|
e2elog.Failf("failed to delete PVC and application with error %v", err)
|
2020-07-20 12:39:50 +00:00
|
|
|
}
|
|
|
|
w.Done()
|
|
|
|
}(&wg, i, *pvcClone, *appClone)
|
2020-07-08 12:59:38 +00:00
|
|
|
}
|
2020-07-20 12:39:50 +00:00
|
|
|
wg.Wait()
|
2020-09-03 09:34:29 +00:00
|
|
|
validateRBDImageCount(f, 0)
|
2020-07-08 12:59:38 +00:00
|
|
|
}
|
|
|
|
})
|
|
|
|
|
2020-09-03 09:34:29 +00:00
|
|
|
By("create a block type PVC and bind it to an app", func() {
|
|
|
|
err := validatePVCAndAppBinding(rawPvcPath, rawAppPath, f)
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to validate pvc and application binding with error %v", err)
|
|
|
|
}
|
2019-12-18 08:36:47 +00:00
|
|
|
})
|
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 {
|
2020-09-03 09:34:29 +00:00
|
|
|
e2elog.Failf("failed to load PVC with error %v", err)
|
2019-06-18 07:07:11 +00:00
|
|
|
}
|
|
|
|
pvc.Namespace = f.UniqueName
|
|
|
|
|
|
|
|
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)
|
2019-06-18 07:07:11 +00:00
|
|
|
}
|
|
|
|
app.Namespace = f.UniqueName
|
2020-09-03 09:34:29 +00:00
|
|
|
// create PVC and app
|
2019-06-18 07:07:11 +00:00
|
|
|
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 {
|
2020-09-03 09:34:29 +00:00
|
|
|
e2elog.Failf("failed to create PVC and application with error %v", err)
|
2019-06-18 07:07:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
// validate created backend rbd images
|
2020-09-03 09:34:29 +00:00
|
|
|
validateRBDImageCount(f, totalCount)
|
|
|
|
// delete PVC and app
|
2019-06-18 07:07:11 +00:00
|
|
|
for i := 0; i < totalCount; i++ {
|
|
|
|
name := fmt.Sprintf("%s%d", f.UniqueName, i)
|
|
|
|
err := deletePVCAndApp(name, f, pvc, app)
|
|
|
|
if err != nil {
|
2020-09-03 09:34:29 +00:00
|
|
|
e2elog.Failf("failed to delete PVC and application with error %v", err)
|
2019-06-18 07:07:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
// validate created backend rbd images
|
2020-09-03 09:34:29 +00:00
|
|
|
validateRBDImageCount(f, 0)
|
2019-06-14 09:26:17 +00:00
|
|
|
})
|
2019-07-03 10:02:36 +00:00
|
|
|
|
2020-09-03 09:34:29 +00:00
|
|
|
By("check data persist after recreating pod", func() {
|
2019-07-03 10:02:36 +00:00
|
|
|
err := checkDataPersist(pvcPath, appPath, f)
|
|
|
|
if err != nil {
|
2020-09-03 09:34:29 +00:00
|
|
|
e2elog.Failf("failed to check data persist with error %v", err)
|
2019-07-03 10:02:36 +00:00
|
|
|
}
|
2020-08-17 08:37:19 +00:00
|
|
|
// validate created backend rbd images
|
2020-09-03 09:34:29 +00:00
|
|
|
validateRBDImageCount(f, 0)
|
2019-07-03 10:02:36 +00:00
|
|
|
})
|
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 {
|
2020-09-03 09:34:29 +00:00
|
|
|
e2elog.Failf("failed to get server version with error with error %v", err)
|
2019-11-27 12:15:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// 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 {
|
2020-09-03 09:34:29 +00:00
|
|
|
e2elog.Failf("failed to resize filesystem PVC %v", err)
|
2019-11-27 12:15:49 +00:00
|
|
|
}
|
|
|
|
|
2020-09-03 09:34:29 +00:00
|
|
|
err = deleteResource(rbdExamplePath + "storageclass.yaml")
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to delete storageclass with error %v", err)
|
|
|
|
}
|
|
|
|
err = createRBDStorageClass(f.ClientSet, f, nil, map[string]string{"csi.storage.k8s.io/fstype": "xfs"})
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to create storageclass with error %v", err)
|
|
|
|
}
|
2019-12-13 10:29:33 +00:00
|
|
|
err = resizePVCAndValidateSize(pvcPath, appPath, f)
|
|
|
|
if err != nil {
|
2020-09-03 09:34:29 +00:00
|
|
|
e2elog.Failf("failed to resize filesystem PVC with error %v", err)
|
2019-12-13 10:29:33 +00:00
|
|
|
|
|
|
|
}
|
2020-08-17 08:37:19 +00:00
|
|
|
// validate created backend rbd images
|
2020-09-03 09:34:29 +00:00
|
|
|
validateRBDImageCount(f, 0)
|
2019-12-13 10:29:33 +00:00
|
|
|
}
|
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 {
|
2020-09-03 09:34:29 +00:00
|
|
|
e2elog.Failf("failed to get server version with error with error %v", err)
|
2019-12-18 10:35:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// 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 {
|
2020-09-03 09:34:29 +00:00
|
|
|
e2elog.Failf("failed to resize block PVC with error %v", err)
|
2019-12-18 10:35:48 +00:00
|
|
|
}
|
2020-08-17 08:37:19 +00:00
|
|
|
// validate created backend rbd images
|
2020-09-03 09:34:29 +00:00
|
|
|
validateRBDImageCount(f, 0)
|
2019-12-18 10:35:48 +00:00
|
|
|
}
|
|
|
|
})
|
|
|
|
|
2019-09-19 12:19:57 +00:00
|
|
|
By("Test unmount after nodeplugin restart", func() {
|
|
|
|
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)
|
2019-09-19 12:19:57 +00:00
|
|
|
}
|
|
|
|
pvc.Namespace = f.UniqueName
|
|
|
|
|
|
|
|
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)
|
2019-09-19 12:19:57 +00:00
|
|
|
}
|
|
|
|
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 {
|
2020-09-03 09:34:29 +00:00
|
|
|
e2elog.Failf("failed to create PVC and application with error %v", err)
|
2019-09-19 12:19:57 +00:00
|
|
|
}
|
|
|
|
|
2020-08-17 08:37:19 +00:00
|
|
|
// validate created backend rbd images
|
2020-09-03 09:34:29 +00:00
|
|
|
validateRBDImageCount(f, 1)
|
2019-09-19 12:19:57 +00:00
|
|
|
// 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 {
|
2020-09-03 09:34:29 +00:00
|
|
|
e2elog.Failf("fail to delete pod with error %v", err)
|
2019-09-19 12:19:57 +00:00
|
|
|
}
|
|
|
|
// 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 {
|
2020-09-03 09:34:29 +00:00
|
|
|
e2elog.Failf("timeout waiting for daemonset pods with error %v", err)
|
2019-09-19 12:19:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
err = deletePVCAndApp("", f, pvc, app)
|
|
|
|
if err != nil {
|
2020-09-03 09:34:29 +00:00
|
|
|
e2elog.Failf("failed to delete PVC and application with error %v", err)
|
2019-09-19 12:19:57 +00:00
|
|
|
}
|
2020-08-17 08:37:19 +00:00
|
|
|
// validate created backend rbd images
|
2020-09-03 09:34:29 +00:00
|
|
|
validateRBDImageCount(f, 0)
|
2019-09-19 12:19:57 +00:00
|
|
|
})
|
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-"
|
2020-09-03 09:34:29 +00:00
|
|
|
err := deleteResource(rbdExamplePath + "storageclass.yaml")
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to delete storageclass with error %v", err)
|
|
|
|
}
|
|
|
|
err = createRBDStorageClass(f.ClientSet, f, nil, map[string]string{"volumeNamePrefix": volumeNamePrefix})
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to create storageclass with error %v", err)
|
|
|
|
}
|
2020-02-24 13:19:42 +00:00
|
|
|
// set up PVC
|
|
|
|
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-02-24 13:19:42 +00:00
|
|
|
}
|
|
|
|
pvc.Namespace = f.UniqueName
|
|
|
|
err = createPVCAndvalidatePV(f.ClientSet, pvc, deployTimeout)
|
|
|
|
if err != nil {
|
2020-09-03 09:34:29 +00:00
|
|
|
e2elog.Failf("failed to create PVC with error %v", err)
|
2020-02-24 13:19:42 +00:00
|
|
|
}
|
|
|
|
|
2020-08-17 08:37:19 +00:00
|
|
|
// validate created backend rbd images
|
2020-09-03 09:34:29 +00:00
|
|
|
validateRBDImageCount(f, 1)
|
2020-02-24 13:19:42 +00:00
|
|
|
// list RBD images and check if one of them has the same prefix
|
|
|
|
foundIt := false
|
2020-09-03 09:34:29 +00:00
|
|
|
images, err := listRBDImages(f)
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to list rbd images with error %v", err)
|
|
|
|
}
|
|
|
|
for _, imgName := range images {
|
2020-02-24 13:19:42 +00:00
|
|
|
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 {
|
2020-09-03 09:34:29 +00:00
|
|
|
e2elog.Failf("failed to delete PVC with error %v", err)
|
2020-02-24 13:19:42 +00:00
|
|
|
}
|
2020-08-17 08:37:19 +00:00
|
|
|
// validate created backend rbd images
|
2020-09-03 09:34:29 +00:00
|
|
|
validateRBDImageCount(f, 0)
|
2020-02-24 13:19:42 +00:00
|
|
|
|
2020-09-03 09:34:29 +00:00
|
|
|
err = deleteResource(rbdExamplePath + "storageclass.yaml")
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to delete storageclass with error %v", err)
|
|
|
|
}
|
|
|
|
err = createRBDStorageClass(f.ClientSet, f, nil, nil)
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to create storageclass with error %v", err)
|
|
|
|
}
|
2020-02-24 13:19:42 +00:00
|
|
|
if !foundIt {
|
2020-09-03 09:34:29 +00:00
|
|
|
e2elog.Failf("could not find image with prefix %s", volumeNamePrefix)
|
2020-02-24 13:19:42 +00:00
|
|
|
}
|
|
|
|
})
|
|
|
|
|
2020-01-20 07:11:21 +00:00
|
|
|
By("validate RBD static FileSystem PVC", func() {
|
|
|
|
err := validateRBDStaticPV(f, appPath, false)
|
|
|
|
if err != nil {
|
2020-09-03 09:34:29 +00:00
|
|
|
e2elog.Failf("failed to validate rbd static pv with error %v", err)
|
2020-01-20 07:11:21 +00:00
|
|
|
}
|
2020-08-17 08:37:19 +00:00
|
|
|
// validate created backend rbd images
|
2020-09-03 09:34:29 +00:00
|
|
|
validateRBDImageCount(f, 0)
|
2020-01-20 07:11:21 +00:00
|
|
|
})
|
|
|
|
|
|
|
|
By("validate RBD static Block PVC", func() {
|
|
|
|
err := validateRBDStaticPV(f, rawAppPath, true)
|
|
|
|
if err != nil {
|
2020-09-03 09:34:29 +00:00
|
|
|
e2elog.Failf("failed to validate rbd block pv with error %v", err)
|
2020-01-20 07:11:21 +00:00
|
|
|
}
|
2020-08-17 08:37:19 +00:00
|
|
|
// validate created backend rbd images
|
2020-09-03 09:34:29 +00:00
|
|
|
validateRBDImageCount(f, 0)
|
2020-01-20 07:11:21 +00:00
|
|
|
})
|
|
|
|
|
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 {
|
2020-09-03 09:34:29 +00:00
|
|
|
e2elog.Failf("failed to check mount options with error %v", err)
|
2020-03-02 08:31:44 +00:00
|
|
|
}
|
2020-08-17 08:37:19 +00:00
|
|
|
// validate created backend rbd images
|
2020-09-03 09:34:29 +00:00
|
|
|
validateRBDImageCount(f, 0)
|
2020-03-02 08:31:44 +00:00
|
|
|
})
|
|
|
|
|
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() {
|
2020-09-03 09:34:29 +00:00
|
|
|
err := checkNodeHasLabel(f.ClientSet, nodeCSIRegionLabel, regionValue)
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to check node label with error %v", err)
|
|
|
|
}
|
|
|
|
err = checkNodeHasLabel(f.ClientSet, nodeCSIZoneLabel, zoneValue)
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to check node label with error %v", err)
|
|
|
|
}
|
2020-03-27 18:21:18 +00:00
|
|
|
})
|
|
|
|
|
|
|
|
By("creating a StorageClass with delayed binding mode and CSI topology parameter")
|
2020-09-03 09:34:29 +00:00
|
|
|
err := deleteResource(rbdExamplePath + "storageclass.yaml")
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to delete storageclass with error %v", err)
|
|
|
|
}
|
2020-03-27 18:21:18 +00:00
|
|
|
topologyConstraint := "[{\"poolName\":\"" + rbdTopologyPool + "\",\"domainSegments\":" +
|
|
|
|
"[{\"domainLabel\":\"region\",\"value\":\"" + regionValue + "\"}," +
|
|
|
|
"{\"domainLabel\":\"zone\",\"value\":\"" + zoneValue + "\"}]}]"
|
2020-09-03 09:34:29 +00:00
|
|
|
err = createRBDStorageClass(f.ClientSet, f,
|
2020-03-27 18:21:18 +00:00
|
|
|
map[string]string{"volumeBindingMode": "WaitForFirstConsumer"},
|
|
|
|
map[string]string{"topologyConstrainedPools": topologyConstraint})
|
2020-09-03 09:34:29 +00:00
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to create storageclass with error %v", err)
|
|
|
|
}
|
2020-03-27 18:21:18 +00:00
|
|
|
|
|
|
|
By("creating an app using a PV from the delayed binding mode StorageClass")
|
2020-09-03 09:34:29 +00:00
|
|
|
pvc, app, err := createPVCAndAppBinding(pvcPath, appPath, f, 0)
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to create PVC and application with error %v", err)
|
|
|
|
}
|
2020-03-27 18:21:18 +00:00
|
|
|
By("ensuring created PV has required node selector values populated")
|
2020-09-03 09:34:29 +00:00
|
|
|
err = checkPVSelectorValuesForPVC(f, pvc)
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to check pv selector values with error %v", err)
|
|
|
|
}
|
2020-03-27 18:21:18 +00:00
|
|
|
By("ensuring created PV has its image in the topology specific pool")
|
2020-09-03 09:34:29 +00:00
|
|
|
err = checkPVCImageInPool(f, pvc, rbdTopologyPool)
|
2020-03-27 18:21:18 +00:00
|
|
|
if err != nil {
|
2020-09-03 09:34:29 +00:00
|
|
|
e2elog.Failf("failed to check image in pool with error %v", err)
|
2020-03-27 18:21:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
By("ensuring created PV has its image journal in the topology specific pool")
|
|
|
|
err = checkPVCImageJournalInPool(f, pvc, rbdTopologyPool)
|
|
|
|
if err != nil {
|
2020-09-03 09:34:29 +00:00
|
|
|
e2elog.Failf("failed to check image journal with error %v", err)
|
2020-03-27 18:21:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
By("ensuring created PV has its CSI journal in the CSI journal specific pool")
|
|
|
|
err = checkPVCCSIJournalInPool(f, pvc, "replicapool")
|
|
|
|
if err != nil {
|
2020-09-03 09:34:29 +00:00
|
|
|
e2elog.Failf("failed to check csi journal in pool with error %v", err)
|
2020-03-27 18:21:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
err = deletePVCAndApp("", f, pvc, app)
|
|
|
|
if err != nil {
|
2020-09-03 09:34:29 +00:00
|
|
|
e2elog.Failf("failed to delete PVC and application with error %v", err)
|
2020-03-27 18:21:18 +00:00
|
|
|
}
|
2020-04-06 20:19:13 +00:00
|
|
|
|
|
|
|
By("checking if data pool parameter is honored", func() {
|
2020-09-03 09:34:29 +00:00
|
|
|
err = deleteResource(rbdExamplePath + "storageclass.yaml")
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to delete storageclass with error %v", err)
|
|
|
|
}
|
2020-04-06 20:19:13 +00:00
|
|
|
topologyConstraint := "[{\"poolName\":\"" + rbdTopologyPool + "\",\"dataPool\":\"" + rbdTopologyDataPool +
|
|
|
|
"\",\"domainSegments\":" +
|
|
|
|
"[{\"domainLabel\":\"region\",\"value\":\"" + regionValue + "\"}," +
|
|
|
|
"{\"domainLabel\":\"zone\",\"value\":\"" + zoneValue + "\"}]}]"
|
2020-09-03 09:34:29 +00:00
|
|
|
err = createRBDStorageClass(f.ClientSet, f,
|
2020-04-06 20:19:13 +00:00
|
|
|
map[string]string{"volumeBindingMode": "WaitForFirstConsumer"},
|
|
|
|
map[string]string{"topologyConstrainedPools": topologyConstraint})
|
2020-09-03 09:34:29 +00:00
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to create storageclass with error %v", err)
|
|
|
|
}
|
2020-04-06 20:19:13 +00:00
|
|
|
By("creating an app using a PV from the delayed binding mode StorageClass with a data pool")
|
2020-09-03 09:34:29 +00:00
|
|
|
pvc, app, err = createPVCAndAppBinding(pvcPath, appPath, f, 0)
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to create PVC and application with error %v", err)
|
|
|
|
}
|
2020-04-06 20:19:13 +00:00
|
|
|
|
|
|
|
By("ensuring created PV has its image in the topology specific pool")
|
|
|
|
err = checkPVCImageInPool(f, pvc, rbdTopologyPool)
|
|
|
|
if err != nil {
|
2020-09-03 09:34:29 +00:00
|
|
|
e2elog.Failf("failed to check pvc image in pool with error %v", err)
|
2020-04-06 20:19:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
By("ensuring created image has the right data pool parameter set")
|
|
|
|
err = checkPVCDataPoolForImageInPool(f, pvc, rbdTopologyPool, rbdTopologyDataPool)
|
|
|
|
if err != nil {
|
2020-09-03 09:34:29 +00:00
|
|
|
e2elog.Failf("failed to check data pool for image with error %v", err)
|
2020-04-06 20:19:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// cleanup and undo changes made by the test
|
|
|
|
err = deletePVCAndApp("", f, pvc, app)
|
|
|
|
if err != nil {
|
2020-09-03 09:34:29 +00:00
|
|
|
e2elog.Failf("failed to delete PVC and application with error %v", err)
|
2020-04-06 20:19:13 +00:00
|
|
|
}
|
|
|
|
})
|
|
|
|
|
|
|
|
// cleanup and undo changes made by the test
|
2020-09-03 09:34:29 +00:00
|
|
|
err = deleteResource(rbdExamplePath + "storageclass.yaml")
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to delete storageclass with error %v", err)
|
|
|
|
}
|
|
|
|
err = createRBDStorageClass(f.ClientSet, f, nil, nil)
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to create storageclass with error %v", err)
|
|
|
|
}
|
2020-03-27 18:21:18 +00:00
|
|
|
})
|
|
|
|
|
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() {
|
2020-09-03 09:34:29 +00:00
|
|
|
err := deleteResource(rbdExamplePath + "storageclass.yaml")
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to delete storageclass with error %v", err)
|
|
|
|
}
|
|
|
|
err = createRBDStorageClass(f.ClientSet, f, map[string]string{rbdmountOptions: "debug,invalidOption"}, nil)
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to create storageclass with error %v", err)
|
|
|
|
}
|
2020-05-18 13:07:58 +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-05-18 13:07:58 +00:00
|
|
|
}
|
|
|
|
pvc.Namespace = f.UniqueName
|
|
|
|
|
|
|
|
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-05-18 13:07:58 +00:00
|
|
|
}
|
|
|
|
app.Namespace = f.UniqueName
|
|
|
|
err = createPVCAndvalidatePV(f.ClientSet, pvc, deployTimeout)
|
|
|
|
if err != nil {
|
2020-09-03 09:34:29 +00:00
|
|
|
e2elog.Failf("failed to create PVC with error %v", err)
|
2020-05-18 13:07:58 +00:00
|
|
|
}
|
2020-08-17 08:37:19 +00:00
|
|
|
// validate created backend rbd images
|
2020-09-03 09:34:29 +00:00
|
|
|
validateRBDImageCount(f, 1)
|
|
|
|
|
2020-07-03 10:03:11 +00:00
|
|
|
// create an app and wait for 1 min for it to go to running state
|
|
|
|
err = createApp(f.ClientSet, app, 1)
|
2020-05-18 13:07:58 +00:00
|
|
|
if err == nil {
|
2020-09-03 09:34:29 +00:00
|
|
|
e2elog.Failf("application should not go to running state due to invalid mount option")
|
2020-05-18 13:07:58 +00:00
|
|
|
}
|
|
|
|
err = deletePVCAndApp("", f, pvc, app)
|
|
|
|
if err != nil {
|
2020-09-03 09:34:29 +00:00
|
|
|
e2elog.Failf("failed to delete PVC and application with error %v", err)
|
2020-05-18 13:07:58 +00:00
|
|
|
}
|
|
|
|
|
2020-08-17 08:37:19 +00:00
|
|
|
// validate created backend rbd images
|
2020-09-03 09:34:29 +00:00
|
|
|
validateRBDImageCount(f, 0)
|
|
|
|
err = deleteResource(rbdExamplePath + "storageclass.yaml")
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to delete storageclass with error %v", err)
|
|
|
|
}
|
|
|
|
err = createRBDStorageClass(f.ClientSet, f, nil, nil)
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to create storageclass with error %v", err)
|
2020-08-17 08:37:19 +00:00
|
|
|
}
|
2020-05-18 13:07:58 +00:00
|
|
|
})
|
|
|
|
|
2020-04-16 14:47:43 +00:00
|
|
|
By("create ROX PVC clone and mount it to multiple pods", func() {
|
|
|
|
v, err := f.ClientSet.Discovery().ServerVersion()
|
|
|
|
if err != nil {
|
2020-09-03 09:34:29 +00:00
|
|
|
e2elog.Failf("failed to get server version with error %v", err)
|
2020-04-16 14:47:43 +00:00
|
|
|
}
|
|
|
|
// snapshot beta is only supported from v1.17+
|
|
|
|
if v.Major > "1" || (v.Major == "1" && v.Minor >= "17") {
|
2020-09-03 09:34:29 +00:00
|
|
|
// create PVC and bind it to an app
|
2020-04-16 14:47:43 +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-04-16 14:47:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
pvc.Namespace = f.UniqueName
|
|
|
|
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-04-16 14:47:43 +00:00
|
|
|
}
|
|
|
|
app.Namespace = f.UniqueName
|
|
|
|
err = createPVCAndApp("", f, pvc, app, deployTimeout)
|
|
|
|
if err != nil {
|
2020-09-03 09:34:29 +00:00
|
|
|
e2elog.Failf("failed to create PVC and application with error %v", err)
|
2020-04-16 14:47:43 +00:00
|
|
|
}
|
2020-08-17 08:37:19 +00:00
|
|
|
// validate created backend rbd images
|
2020-09-03 09:34:29 +00:00
|
|
|
validateRBDImageCount(f, 1)
|
2020-04-16 14:47:43 +00:00
|
|
|
// delete pod as we should not create snapshot for in-use pvc
|
|
|
|
err = deletePod(app.Name, app.Namespace, f.ClientSet, deployTimeout)
|
|
|
|
if err != nil {
|
2020-09-03 09:34:29 +00:00
|
|
|
e2elog.Failf("failed to delete application with error %v", err)
|
2020-04-16 14:47:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
snap := getSnapshot(snapshotPath)
|
|
|
|
snap.Namespace = f.UniqueName
|
|
|
|
snap.Spec.Source.PersistentVolumeClaimName = &pvc.Name
|
|
|
|
|
|
|
|
err = createSnapshot(&snap, deployTimeout)
|
|
|
|
if err != nil {
|
2020-09-03 09:34:29 +00:00
|
|
|
e2elog.Failf("failed to create snapshot with error %v", err)
|
2020-04-16 14:47:43 +00:00
|
|
|
}
|
2020-08-17 08:37:19 +00:00
|
|
|
// validate created backend rbd images
|
|
|
|
// parent PVC + snapshot
|
|
|
|
totalImages := 2
|
2020-09-03 09:34:29 +00:00
|
|
|
validateRBDImageCount(f, totalImages)
|
2020-04-16 14:47:43 +00:00
|
|
|
pvcClone, err := loadPVC(pvcClonePath)
|
|
|
|
if err != nil {
|
2020-09-03 09:34:29 +00:00
|
|
|
e2elog.Failf("failed to load PVC with error %v", err)
|
2020-04-16 14:47:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// create clone PVC as ROX
|
|
|
|
pvcClone.Namespace = f.UniqueName
|
|
|
|
pvcClone.Spec.AccessModes = []v1.PersistentVolumeAccessMode{v1.ReadOnlyMany}
|
|
|
|
err = createPVCAndvalidatePV(f.ClientSet, pvcClone, deployTimeout)
|
|
|
|
if err != nil {
|
2020-09-03 09:34:29 +00:00
|
|
|
e2elog.Failf("failed to create PVC with error %v", err)
|
2020-04-16 14:47:43 +00:00
|
|
|
}
|
2020-08-17 08:37:19 +00:00
|
|
|
// validate created backend rbd images
|
|
|
|
// parent pvc+ snapshot + clone
|
|
|
|
totalImages = 3
|
2020-09-03 09:34:29 +00:00
|
|
|
validateRBDImageCount(f, totalImages)
|
|
|
|
|
2020-04-16 14:47:43 +00:00
|
|
|
appClone, err := loadApp(appClonePath)
|
|
|
|
if err != nil {
|
2020-09-03 09:34:29 +00:00
|
|
|
e2elog.Failf("failed to load application with error %v", err)
|
2020-04-16 14:47:43 +00:00
|
|
|
}
|
|
|
|
|
2020-07-03 10:03:11 +00:00
|
|
|
totalCount := 2
|
2020-04-16 14:47:43 +00:00
|
|
|
appClone.Namespace = f.UniqueName
|
|
|
|
appClone.Spec.Volumes[0].PersistentVolumeClaim.ClaimName = pvcClone.Name
|
|
|
|
|
2020-09-03 09:34:29 +00:00
|
|
|
// create PVC and app
|
2020-04-16 14:47:43 +00:00
|
|
|
for i := 0; i < totalCount; i++ {
|
|
|
|
name := fmt.Sprintf("%s%d", f.UniqueName, i)
|
|
|
|
label := map[string]string{
|
|
|
|
"app": name,
|
|
|
|
}
|
|
|
|
appClone.Labels = label
|
|
|
|
appClone.Name = name
|
|
|
|
err = createApp(f.ClientSet, appClone, deployTimeout)
|
|
|
|
if err != nil {
|
2020-09-03 09:34:29 +00:00
|
|
|
e2elog.Failf("failed to create application with error %v", err)
|
2020-04-16 14:47:43 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
for i := 0; i < totalCount; i++ {
|
|
|
|
name := fmt.Sprintf("%s%d", f.UniqueName, i)
|
|
|
|
opt := metav1.ListOptions{
|
|
|
|
LabelSelector: fmt.Sprintf("app=%s", name),
|
|
|
|
}
|
|
|
|
|
|
|
|
filePath := appClone.Spec.Containers[0].VolumeMounts[0].MountPath + "/test"
|
|
|
|
_, stdErr := execCommandInPodAndAllowFail(f, fmt.Sprintf("echo 'Hello World' > %s", filePath), appClone.Namespace, &opt)
|
|
|
|
readOnlyErr := fmt.Sprintf("cannot create %s: Read-only file system", filePath)
|
|
|
|
if !strings.Contains(stdErr, readOnlyErr) {
|
2020-09-03 09:34:29 +00:00
|
|
|
e2elog.Failf(stdErr)
|
2020-04-16 14:47:43 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// delete app
|
|
|
|
for i := 0; i < totalCount; i++ {
|
|
|
|
name := fmt.Sprintf("%s%d", f.UniqueName, i)
|
|
|
|
appClone.Name = name
|
|
|
|
err = deletePod(appClone.Name, appClone.Namespace, f.ClientSet, deployTimeout)
|
|
|
|
if err != nil {
|
2020-09-03 09:34:29 +00:00
|
|
|
e2elog.Failf("failed to delete application with error %v", err)
|
2020-04-16 14:47:43 +00:00
|
|
|
}
|
|
|
|
}
|
2020-09-03 09:34:29 +00:00
|
|
|
// delete PVC clone
|
2020-04-16 14:47:43 +00:00
|
|
|
err = deletePVCAndValidatePV(f.ClientSet, pvcClone, deployTimeout)
|
|
|
|
if err != nil {
|
2020-09-03 09:34:29 +00:00
|
|
|
e2elog.Failf("failed to delete PVC with error %v", err)
|
2020-04-16 14:47:43 +00:00
|
|
|
}
|
|
|
|
// delete snapshot
|
|
|
|
err = deleteSnapshot(&snap, deployTimeout)
|
|
|
|
if err != nil {
|
2020-09-03 09:34:29 +00:00
|
|
|
e2elog.Failf("failed to delete snapshot with error %v", err)
|
2020-04-16 14:47:43 +00:00
|
|
|
}
|
|
|
|
// delete parent pvc
|
|
|
|
err = deletePVCAndValidatePV(f.ClientSet, pvc, deployTimeout)
|
|
|
|
if err != nil {
|
2020-09-03 09:34:29 +00:00
|
|
|
e2elog.Failf("failed to delete PVC with error %v", err)
|
2020-04-16 14:47:43 +00:00
|
|
|
}
|
2020-08-17 08:37:19 +00:00
|
|
|
// validate created backend rbd images
|
2020-09-03 09:34:29 +00:00
|
|
|
validateRBDImageCount(f, 0)
|
2020-04-16 14:47:43 +00:00
|
|
|
}
|
|
|
|
})
|
|
|
|
|
2020-06-02 19:19:57 +00:00
|
|
|
By("ensuring all operations will work within a rados namespace", func() {
|
|
|
|
updateConfigMap := func(radosNS string) {
|
|
|
|
radosNamespace = radosNS
|
2020-09-03 09:34:29 +00:00
|
|
|
err := deleteConfigMap(rbdDirPath)
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to delete configmap with Error: %v", err)
|
|
|
|
}
|
|
|
|
err = createConfigMap(rbdDirPath, f.ClientSet, f)
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to create configmap with error %v", err)
|
|
|
|
}
|
|
|
|
err = createRadosNamespace(f)
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to create rados namespace with error %v", err)
|
|
|
|
}
|
2020-06-02 19:19:57 +00:00
|
|
|
// delete csi pods
|
2020-09-03 09:34:29 +00:00
|
|
|
err = deletePodWithLabel("app in (ceph-csi-rbd, csi-rbdplugin, csi-rbdplugin-provisioner)",
|
2020-06-02 19:19:57 +00:00
|
|
|
cephCSINamespace, false)
|
|
|
|
if err != nil {
|
2020-09-03 09:34:29 +00:00
|
|
|
e2elog.Failf("failed to delete pods with labels with error %v", err)
|
2020-06-02 19:19:57 +00:00
|
|
|
}
|
|
|
|
// wait for csi pods to come up
|
|
|
|
err = waitForDaemonSets(rbdDaemonsetName, cephCSINamespace, f.ClientSet, deployTimeout)
|
|
|
|
if err != nil {
|
2020-09-03 09:34:29 +00:00
|
|
|
e2elog.Failf("timeout waiting for daemonset pods with error %v", err)
|
2020-06-02 19:19:57 +00:00
|
|
|
}
|
|
|
|
err = waitForDeploymentComplete(rbdDeploymentName, cephCSINamespace, f.ClientSet, deployTimeout)
|
|
|
|
if err != nil {
|
2020-09-03 09:34:29 +00:00
|
|
|
e2elog.Failf("timeout waiting for deployment to be in running state with error %v", err)
|
2020-06-02 19:19:57 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
updateConfigMap("e2e-ns")
|
|
|
|
|
2020-09-03 09:34:29 +00:00
|
|
|
// Create a PVC and bind it to an app within the namesapce
|
|
|
|
err := validatePVCAndAppBinding(pvcPath, appPath, f)
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to validate pvc and application binding with error %v", err)
|
|
|
|
}
|
2020-06-02 19:19:57 +00:00
|
|
|
v, err := f.ClientSet.Discovery().ServerVersion()
|
|
|
|
if err != nil {
|
2020-09-03 09:34:29 +00:00
|
|
|
e2elog.Failf("failed to get server version with error with error %v", err)
|
2020-06-02 19:19:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Resize Block PVC and check Device size within the namespace
|
|
|
|
// 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 {
|
2020-09-03 09:34:29 +00:00
|
|
|
e2elog.Failf("failed to resize block PVC with error %v", err)
|
2020-06-02 19:19:57 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Create a PVC clone and bind it to an app within the namespace
|
|
|
|
// snapshot beta is only supported from v1.17+
|
|
|
|
if v.Major > "1" || (v.Major == "1" && v.Minor >= "17") {
|
|
|
|
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-02 19:19:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
pvc.Namespace = f.UniqueName
|
|
|
|
err = createPVCAndvalidatePV(f.ClientSet, pvc, deployTimeout)
|
|
|
|
if err != nil {
|
2020-09-03 09:34:29 +00:00
|
|
|
e2elog.Failf("failed to create PVC with error %v", err)
|
2020-06-02 19:19:57 +00:00
|
|
|
}
|
|
|
|
// validate created backend rbd images
|
2020-09-03 09:34:29 +00:00
|
|
|
validateRBDImageCount(f, 1)
|
|
|
|
|
2020-06-02 19:19:57 +00:00
|
|
|
snap := getSnapshot(snapshotPath)
|
|
|
|
snap.Namespace = f.UniqueName
|
|
|
|
snap.Spec.Source.PersistentVolumeClaimName = &pvc.Name
|
|
|
|
err = createSnapshot(&snap, deployTimeout)
|
|
|
|
if err != nil {
|
2020-09-03 09:34:29 +00:00
|
|
|
e2elog.Failf("failed to create snapshot with error %v", err)
|
2020-06-02 19:19:57 +00:00
|
|
|
}
|
2020-09-03 09:34:29 +00:00
|
|
|
validateRBDImageCount(f, 2)
|
2020-06-02 19:19:57 +00:00
|
|
|
|
2020-09-03 09:34:29 +00:00
|
|
|
err = validatePVCAndAppBinding(pvcClonePath, appClonePath, f)
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to validate pvc and application binding with error %v", err)
|
|
|
|
}
|
2020-06-02 19:19:57 +00:00
|
|
|
err = deleteSnapshot(&snap, deployTimeout)
|
|
|
|
if err != nil {
|
2020-09-03 09:34:29 +00:00
|
|
|
e2elog.Failf("failed to delete snapshot with error %v", err)
|
2020-06-02 19:19:57 +00:00
|
|
|
}
|
2020-09-22 05:44:21 +00:00
|
|
|
// as snapshot is deleted the image count should be one
|
|
|
|
validateRBDImageCount(f, 1)
|
|
|
|
|
2020-06-02 19:19:57 +00:00
|
|
|
err = deletePVCAndValidatePV(f.ClientSet, pvc, deployTimeout)
|
|
|
|
if err != nil {
|
2020-09-03 09:34:29 +00:00
|
|
|
e2elog.Failf("failed to delete PVC with error %v", err)
|
2020-06-02 19:19:57 +00:00
|
|
|
}
|
2020-09-22 05:44:21 +00:00
|
|
|
validateRBDImageCount(f, 0)
|
2020-06-02 19:19:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
updateConfigMap("")
|
|
|
|
})
|
|
|
|
|
2020-05-19 07:46:39 +00:00
|
|
|
By("Mount pvc as readonly in pod", func() {
|
2020-09-03 09:34:29 +00:00
|
|
|
// create PVC and bind it to an app
|
2020-05-19 07:46:39 +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-05-19 07:46:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
pvc.Namespace = f.UniqueName
|
|
|
|
|
|
|
|
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-05-19 07:46:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
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 {
|
2020-09-03 09:34:29 +00:00
|
|
|
e2elog.Failf("failed to create PVC and application with error %v", err)
|
2020-05-19 07:46:39 +00:00
|
|
|
}
|
2020-08-17 08:37:19 +00:00
|
|
|
// validate created backend rbd images
|
2020-09-03 09:34:29 +00:00
|
|
|
validateRBDImageCount(f, 1)
|
2020-05-19 07:46:39 +00:00
|
|
|
|
|
|
|
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) {
|
2020-09-03 09:34:29 +00:00
|
|
|
e2elog.Failf(stdErr)
|
2020-05-19 07:46:39 +00:00
|
|
|
}
|
|
|
|
|
2020-09-03 09:34:29 +00:00
|
|
|
// delete PVC and app
|
2020-05-19 07:46:39 +00:00
|
|
|
err = deletePVCAndApp("", f, pvc, app)
|
|
|
|
if err != nil {
|
2020-09-03 09:34:29 +00:00
|
|
|
e2elog.Failf("failed to delete PVC and application with error %v", err)
|
2020-05-19 07:46:39 +00:00
|
|
|
}
|
2020-08-17 08:37:19 +00:00
|
|
|
// validate created backend rbd images
|
2020-09-03 09:34:29 +00:00
|
|
|
validateRBDImageCount(f, 0)
|
2020-05-19 07:46:39 +00:00
|
|
|
})
|
|
|
|
|
2020-09-08 05:23:28 +00:00
|
|
|
By("create a PVC and Bind it to an app for mapped rbd image with options", func() {
|
|
|
|
err := deleteResource(rbdExamplePath + "storageclass.yaml")
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to delete storageclass with error %v", err)
|
|
|
|
}
|
|
|
|
err = createRBDStorageClass(f.ClientSet, f, nil, map[string]string{
|
|
|
|
"mapOptions": "lock_on_read,queue_depth=1024",
|
|
|
|
"unmapOptions": "force"})
|
|
|
|
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 binding with error %v", err)
|
|
|
|
}
|
|
|
|
err = deleteResource(rbdExamplePath + "storageclass.yaml")
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to delete storageclass with error %v", err)
|
|
|
|
}
|
|
|
|
err = createRBDStorageClass(f.ClientSet, f, nil, nil)
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to create storageclass with error %v", err)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
2020-01-31 08:49:11 +00:00
|
|
|
// Make sure this should be last testcase in this file, because
|
|
|
|
// it deletes pool
|
2020-09-03 09:34:29 +00:00
|
|
|
By("Create a PVC and delete PVC when backend pool deleted", func() {
|
2020-01-31 08:49:11 +00:00
|
|
|
err := pvcDeleteWhenPoolNotFound(pvcPath, false, f)
|
|
|
|
if err != nil {
|
2020-09-03 09:34:29 +00:00
|
|
|
e2elog.Failf("failed to delete PVC when pool not found with error %v", err)
|
2020-01-31 08:49:11 +00:00
|
|
|
}
|
|
|
|
})
|
2019-05-31 09:34:04 +00:00
|
|
|
})
|
|
|
|
})
|
|
|
|
})
|