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 (
|
|
|
|
rbdProvisioner = "csi-rbdplugin-provisioner.yaml"
|
|
|
|
rbdProvisionerRBAC = "csi-provisioner-rbac.yaml"
|
|
|
|
rbdNodePlugin = "csi-rbdplugin.yaml"
|
|
|
|
rbdNodePluginRBAC = "csi-nodeplugin-rbac.yaml"
|
|
|
|
rbdConfigMap = "csi-config-map.yaml"
|
2019-06-10 08:00:40 +00:00
|
|
|
rbdDirPath = "../deploy/rbd/kubernetes/"
|
|
|
|
rbdExamplePath = "../examples/rbd/"
|
|
|
|
rbdDeploymentName = "csi-rbdplugin-provisioner"
|
|
|
|
rbdDaemonsetName = "csi-rbdplugin"
|
|
|
|
namespace = "default"
|
2019-05-31 09:34:04 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
func deployRBDPlugin() {
|
|
|
|
// deploy provisioner
|
|
|
|
framework.RunKubectlOrDie("create", "-f", rbdDirPath+rbdProvisioner)
|
|
|
|
framework.RunKubectlOrDie("apply", "-f", rbdDirPath+rbdProvisionerRBAC)
|
2019-06-10 06:48:41 +00:00
|
|
|
// deploy nodeplugin
|
2019-05-31 09:34:04 +00:00
|
|
|
framework.RunKubectlOrDie("create", "-f", rbdDirPath+rbdNodePlugin)
|
|
|
|
framework.RunKubectlOrDie("apply", "-f", rbdDirPath+rbdNodePluginRBAC)
|
|
|
|
}
|
|
|
|
|
|
|
|
var _ = Describe("RBD", func() {
|
|
|
|
f := framework.NewDefaultFramework("rbd")
|
2019-06-10 06:48:41 +00:00
|
|
|
// deploy RBD CSI
|
2019-05-31 09:34:04 +00:00
|
|
|
BeforeEach(func() {
|
|
|
|
createRBDPool()
|
2019-06-07 06:52:58 +00:00
|
|
|
createConfigMap(f.ClientSet, f)
|
2019-05-31 09:34:04 +00:00
|
|
|
deployRBDPlugin()
|
|
|
|
createRBDStorageClass(f.ClientSet, f)
|
|
|
|
createRBDSecret(f.ClientSet, f)
|
|
|
|
})
|
|
|
|
|
|
|
|
AfterEach(func() {
|
|
|
|
rbdFiles := getFilesinDirectory(rbdDirPath)
|
|
|
|
for _, file := range rbdFiles {
|
|
|
|
res, err := framework.RunKubectl("delete", "-f", rbdDirPath+file.Name())
|
|
|
|
framework.Logf("failed to delete resource in %s with err %v", res, err)
|
|
|
|
}
|
|
|
|
deleteRBDPool()
|
|
|
|
deleteSecret(rbdExamplePath + "secret.yaml")
|
|
|
|
deleteStorageClass(rbdExamplePath + "storageclass.yaml")
|
|
|
|
})
|
|
|
|
|
|
|
|
Context("Test RBD CSI", func() {
|
|
|
|
It("Test RBD 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(rbdDeploymentName, 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(rbdDaemonsetName, namespace, f.ClientSet, deployTimeout)
|
2019-05-31 09:34:04 +00:00
|
|
|
if err != nil {
|
|
|
|
Fail(err.Error())
|
|
|
|
}
|
|
|
|
|
|
|
|
By("create a PVC and Bind it to an app", func() {
|
|
|
|
pvcPath := rbdExamplePath + "pvc.yaml"
|
|
|
|
appPath := rbdExamplePath + "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 := rbdExamplePath + "pvc.yaml"
|
|
|
|
validateNormalUserPVCAccess(pvcPath, f)
|
|
|
|
})
|
2019-05-31 09:34:04 +00:00
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
})
|