2019-05-31 09:34:04 +00:00
|
|
|
package e2e
|
|
|
|
|
|
|
|
import (
|
2019-06-14 09:42:48 +00:00
|
|
|
"time"
|
|
|
|
|
2019-05-31 09:34:04 +00:00
|
|
|
. "github.com/onsi/ginkgo" // nolint
|
|
|
|
|
|
|
|
"k8s.io/kubernetes/test/e2e/framework"
|
|
|
|
)
|
|
|
|
|
|
|
|
var (
|
|
|
|
cephfsProvisioner = "csi-cephfsplugin-provisioner.yaml"
|
|
|
|
cephfsProvisionerRBAC = "csi-provisioner-rbac.yaml"
|
|
|
|
cephfsNodePlugin = "csi-cephfsplugin.yaml"
|
|
|
|
cephfsNodePluginRBAC = "csi-nodeplugin-rbac.yaml"
|
2019-06-10 08:00:40 +00:00
|
|
|
cephfsDeploymentName = "csi-cephfsplugin-provisioner"
|
|
|
|
cephfsDeamonSetName = "csi-cephfsplugin"
|
|
|
|
cephfsDirPath = "../deploy/cephfs/kubernetes/"
|
|
|
|
cephfsExamplePath = "../examples/cephfs/"
|
2019-05-31 09:34:04 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
func deployCephfsPlugin() {
|
2019-06-10 06:48:41 +00:00
|
|
|
// deploy provisioner
|
2019-05-31 09:34:04 +00:00
|
|
|
framework.RunKubectlOrDie("create", "-f", cephfsDirPath+cephfsProvisioner)
|
|
|
|
framework.RunKubectlOrDie("apply", "-f", cephfsDirPath+cephfsProvisionerRBAC)
|
2019-06-10 06:48:41 +00:00
|
|
|
// deploy nodeplugin
|
2019-05-31 09:34:04 +00:00
|
|
|
framework.RunKubectlOrDie("create", "-f", cephfsDirPath+cephfsNodePlugin)
|
|
|
|
framework.RunKubectlOrDie("apply", "-f", cephfsDirPath+cephfsNodePluginRBAC)
|
|
|
|
}
|
|
|
|
|
|
|
|
var _ = Describe("cephfs", func() {
|
|
|
|
f := framework.NewDefaultFramework("cephfs")
|
2019-06-10 06:48:41 +00:00
|
|
|
// deploy cephfs CSI
|
2019-05-31 09:34:04 +00:00
|
|
|
BeforeEach(func() {
|
|
|
|
createFileSystem(f.ClientSet)
|
2019-06-07 06:52:58 +00:00
|
|
|
createConfigMap(f.ClientSet, f)
|
2019-05-31 09:34:04 +00:00
|
|
|
deployCephfsPlugin()
|
2019-06-07 06:52:58 +00:00
|
|
|
createCephfsStorageClass(f.ClientSet, f)
|
2019-05-31 09:34:04 +00:00
|
|
|
createCephfsSecret(f.ClientSet, f)
|
|
|
|
})
|
|
|
|
|
|
|
|
AfterEach(func() {
|
|
|
|
cephfsFiles := getFilesinDirectory(cephfsDirPath)
|
|
|
|
for _, file := range cephfsFiles {
|
|
|
|
res, err := framework.RunKubectl("delete", "-f", cephfsDirPath+file.Name())
|
|
|
|
framework.Logf("failed to delete resource in %s with err %v", res, err)
|
|
|
|
}
|
2019-06-14 09:26:17 +00:00
|
|
|
deleteResource(cephfsExamplePath + "secret.yaml")
|
|
|
|
deleteResource(cephfsExamplePath + "storageclass.yaml")
|
2019-05-31 09:34:04 +00:00
|
|
|
deleteFileSystem()
|
|
|
|
})
|
|
|
|
|
|
|
|
Context("Test cephfs CSI", func() {
|
|
|
|
It("Test cephfs CSI", func() {
|
2019-06-14 09:42:48 +00:00
|
|
|
By("checking provisioner statefulset is running")
|
|
|
|
timeout := time.Duration(deployTimeout) * time.Minute
|
|
|
|
err := framework.WaitForStatefulSetReplicasReady(cephfsDeploymentName, namespace, f.ClientSet, 1*time.Second, timeout)
|
2019-05-31 09:34:04 +00:00
|
|
|
if err != nil {
|
|
|
|
Fail(err.Error())
|
|
|
|
}
|
|
|
|
|
|
|
|
By("checking nodeplugin deamonsets is running")
|
2019-06-10 08:00:40 +00:00
|
|
|
err = waitForDaemonSets(cephfsDeamonSetName, namespace, f.ClientSet, deployTimeout)
|
2019-05-31 09:34:04 +00:00
|
|
|
if err != nil {
|
|
|
|
Fail(err.Error())
|
|
|
|
}
|
|
|
|
|
|
|
|
By("create and delete a PVC", func() {
|
|
|
|
By("create a PVC and Bind it to an app", func() {
|
|
|
|
pvcPath := cephfsExamplePath + "pvc.yaml"
|
|
|
|
appPath := cephfsExamplePath + "pod.yaml"
|
|
|
|
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() {
|
|
|
|
pvcPath := cephfsExamplePath + "pvc.yaml"
|
|
|
|
validateNormalUserPVCAccess(pvcPath, f)
|
|
|
|
})
|
2019-05-31 09:34:04 +00:00
|
|
|
})
|
2019-06-14 09:26:17 +00:00
|
|
|
|
2019-05-31 09:34:04 +00:00
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
})
|