2019-05-31 09:34:04 +00:00
|
|
|
package e2e
|
|
|
|
|
|
|
|
import (
|
|
|
|
"flag"
|
|
|
|
"fmt"
|
|
|
|
"log"
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
. "github.com/onsi/ginkgo"
|
|
|
|
. "github.com/onsi/gomega"
|
|
|
|
"k8s.io/kubernetes/test/e2e/framework"
|
2019-08-12 05:32:59 +00:00
|
|
|
e2elog "k8s.io/kubernetes/test/e2e/framework/log"
|
2019-05-31 09:34:04 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
var (
|
|
|
|
RookVersion string
|
|
|
|
rookRequired bool
|
|
|
|
deployTimeout int
|
|
|
|
)
|
|
|
|
|
|
|
|
func init() {
|
|
|
|
log.SetOutput(GinkgoWriter)
|
2019-10-17 04:44:45 +00:00
|
|
|
flag.StringVar(&RookVersion, "rook-version", "v1.1.2", "rook version to pull yaml files")
|
2019-05-31 09:34:04 +00:00
|
|
|
|
|
|
|
flag.BoolVar(&rookRequired, "deploy-rook", true, "deploy rook on kubernetes")
|
|
|
|
flag.IntVar(&deployTimeout, "deploy-timeout", 10, "timeout to wait for created kubernetes resources")
|
|
|
|
// Register framework flags, then handle flags
|
|
|
|
framework.HandleFlags()
|
|
|
|
framework.AfterReadingAllFlags(&framework.TestContext)
|
|
|
|
|
|
|
|
formRookURL(RookVersion)
|
|
|
|
fmt.Println("timeout for deploytimeout ", deployTimeout)
|
|
|
|
}
|
|
|
|
|
2019-08-12 05:32:59 +00:00
|
|
|
// removeCephCSIResource is a temporary fix for CI to remove the ceph-csi resources deployed by rook
|
|
|
|
func removeCephCSIResource() {
|
|
|
|
// cleanup rbd and cephfs deamonset deployed by rook
|
|
|
|
_, err := framework.RunKubectl("delete", "-nrook-ceph", "daemonset", "csi-cephfsplugin")
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Logf("failed to delete rbd daemonset %v", err)
|
|
|
|
}
|
|
|
|
_, err = framework.RunKubectl("delete", "-nrook-ceph", "daemonset", "csi-rbdplugin")
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Logf("failed to delete cephfs daemonset %v", err)
|
|
|
|
}
|
|
|
|
|
2019-11-20 11:49:43 +00:00
|
|
|
// if kube version is <1.14.0 rook deploys cephfs and rbd provisioner as statefulset
|
|
|
|
_, err = framework.RunKubectl("delete", "--ignore-not-found", "-nrook-ceph", "statefulset", "csi-rbdplugin-provisioner")
|
2019-08-12 05:32:59 +00:00
|
|
|
if err != nil {
|
|
|
|
e2elog.Logf("failed to delete rbd statefulset %v", err)
|
|
|
|
}
|
2019-11-20 11:49:43 +00:00
|
|
|
_, err = framework.RunKubectl("delete", "--ignore-not-found", "-nrook-ceph", "statefulset", "csi-cephfsplugin-provisioner")
|
2019-08-12 05:32:59 +00:00
|
|
|
if err != nil {
|
|
|
|
e2elog.Logf("failed to delete cephfs statefulset %v", err)
|
|
|
|
}
|
|
|
|
|
2019-11-20 11:49:43 +00:00
|
|
|
// if kube version is >=1.14.0 rook deploys cephfs and rbd provisioner as deployment
|
|
|
|
_, err = framework.RunKubectl("delete", "--ignore-not-found", "-nrook-ceph", "deployment", "csi-rbdplugin-provisioner")
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Logf("failed to delete rbd deployment %v", err)
|
|
|
|
}
|
|
|
|
_, err = framework.RunKubectl("delete", "--ignore-not-found", "-nrook-ceph", "deployment", "csi-cephfsplugin-provisioner")
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Logf("failed to delete cephfs deployment %v", err)
|
|
|
|
}
|
|
|
|
|
2019-08-12 05:32:59 +00:00
|
|
|
// cleanup rbd cluster roles deployed by rook
|
|
|
|
rbdPath := fmt.Sprintf("%s/%s/", rbdDirPath, "v1.13")
|
2019-08-13 07:51:03 +00:00
|
|
|
_, err = framework.RunKubectl("delete", "--ignore-not-found", "-f", rbdPath+rbdProvisionerRBAC)
|
2019-08-12 05:32:59 +00:00
|
|
|
if err != nil {
|
|
|
|
e2elog.Logf("failed to delete provisioner rbac %v", err)
|
|
|
|
}
|
2019-08-13 07:51:03 +00:00
|
|
|
_, err = framework.RunKubectl("delete", "--ignore-not-found", "-f", rbdPath+rbdNodePluginRBAC)
|
2019-08-12 05:32:59 +00:00
|
|
|
if err != nil {
|
|
|
|
e2elog.Logf("failed to delete nodeplugin rbac %v", err)
|
|
|
|
}
|
|
|
|
|
|
|
|
// cleanup cephfs cluster roles deployed by rook
|
|
|
|
cephfsPath := fmt.Sprintf("%s/%s/", cephfsDirPath, "v1.13")
|
2019-08-13 07:51:03 +00:00
|
|
|
_, err = framework.RunKubectl("delete", "--ignore-not-found", "-f", cephfsPath+cephfsProvisionerRBAC)
|
2019-08-12 05:32:59 +00:00
|
|
|
if err != nil {
|
|
|
|
e2elog.Logf("failed to delete provisioner rbac %v", err)
|
|
|
|
}
|
2019-08-13 07:51:03 +00:00
|
|
|
_, err = framework.RunKubectl("delete", "--ignore-not-found", "-f", cephfsPath+cephfsNodePluginRBAC)
|
2019-08-12 05:32:59 +00:00
|
|
|
if err != nil {
|
|
|
|
e2elog.Logf("failed to delete nodeplugin rbac %v", err)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-06-10 06:48:41 +00:00
|
|
|
// BeforeSuite deploys the rook-operator and ceph cluster
|
2019-05-31 09:34:04 +00:00
|
|
|
var _ = BeforeSuite(func() {
|
|
|
|
if rookRequired {
|
|
|
|
deployRook()
|
2019-08-12 05:32:59 +00:00
|
|
|
removeCephCSIResource()
|
2019-05-31 09:34:04 +00:00
|
|
|
}
|
|
|
|
})
|
|
|
|
|
2019-06-10 06:48:41 +00:00
|
|
|
// AfterSuite removes the rook-operator and ceph cluster
|
2019-05-31 09:34:04 +00:00
|
|
|
var _ = AfterSuite(func() {
|
|
|
|
if rookRequired {
|
|
|
|
tearDownRook()
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
|
|
|
func TestE2E(t *testing.T) {
|
|
|
|
RegisterFailHandler(Fail)
|
|
|
|
RunSpecs(t, "E2e Suite")
|
|
|
|
}
|