2019-05-31 09:34:04 +00:00
|
|
|
package e2e
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"strings"
|
2019-08-29 08:06:44 +00:00
|
|
|
"time"
|
2019-05-31 09:34:04 +00:00
|
|
|
|
|
|
|
. "github.com/onsi/gomega" // nolint
|
|
|
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
|
|
|
"k8s.io/client-go/kubernetes"
|
|
|
|
"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 (
|
|
|
|
rookURL = "https://raw.githubusercontent.com/rook/rook/$version/cluster/examples/kubernetes/ceph"
|
|
|
|
)
|
|
|
|
|
|
|
|
var rookNS = "rook-ceph"
|
|
|
|
|
|
|
|
func formRookURL(version string) {
|
|
|
|
rookURL = strings.Replace(rookURL, "$version", version, 1)
|
|
|
|
}
|
|
|
|
|
|
|
|
func getK8sClient() kubernetes.Interface {
|
2019-06-24 07:58:39 +00:00
|
|
|
e2elog.Logf("Creating a kubernetes client")
|
2019-05-31 09:34:04 +00:00
|
|
|
client, err := framework.LoadClientset()
|
|
|
|
Expect(err).Should(BeNil())
|
|
|
|
return client
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
func deployCommon() {
|
|
|
|
commonPath := fmt.Sprintf("%s/%s", rookURL, "common.yaml")
|
|
|
|
framework.RunKubectlOrDie("create", "-f", commonPath)
|
|
|
|
}
|
|
|
|
|
|
|
|
func createFileSystem(c kubernetes.Interface) {
|
|
|
|
commonPath := fmt.Sprintf("%s/%s", rookURL, "filesystem-test.yaml")
|
|
|
|
framework.RunKubectlOrDie("create", "-f", commonPath)
|
2019-06-10 06:48:41 +00:00
|
|
|
opt := &metav1.ListOptions{
|
2019-05-31 09:34:04 +00:00
|
|
|
LabelSelector: "app=rook-ceph-mds",
|
|
|
|
}
|
|
|
|
err := checkCephPods(rookNS, c, 1, deployTimeout, opt)
|
|
|
|
Expect(err).Should(BeNil())
|
|
|
|
}
|
|
|
|
|
|
|
|
func createRBDPool() {
|
|
|
|
commonPath := fmt.Sprintf("%s/%s", rookURL, "pool-test.yaml")
|
|
|
|
framework.RunKubectlOrDie("create", "-f", commonPath)
|
|
|
|
}
|
|
|
|
func deleteFileSystem() {
|
2019-06-07 05:57:02 +00:00
|
|
|
commonPath := fmt.Sprintf("%s/%s", rookURL, "filesystem-test.yaml")
|
2019-06-18 07:07:11 +00:00
|
|
|
_, err := framework.RunKubectl("delete", "-f", commonPath)
|
|
|
|
if err != nil {
|
2019-06-24 07:58:39 +00:00
|
|
|
e2elog.Logf("failed to delete file-system %v", err)
|
2019-06-18 07:07:11 +00:00
|
|
|
}
|
2019-05-31 09:34:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func deleteRBDPool() {
|
|
|
|
commonPath := fmt.Sprintf("%s/%s", rookURL, "pool-test.yaml")
|
2019-06-18 07:07:11 +00:00
|
|
|
_, err := framework.RunKubectl("delete", "-f", commonPath)
|
|
|
|
if err != nil {
|
2019-06-24 07:58:39 +00:00
|
|
|
e2elog.Logf("failed to delete pool %v", err)
|
2019-06-18 07:07:11 +00:00
|
|
|
}
|
2019-05-31 09:34:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func deployOperator(c kubernetes.Interface) {
|
|
|
|
opPath := fmt.Sprintf("%s/%s", rookURL, "operator.yaml")
|
|
|
|
|
2019-06-18 07:07:11 +00:00
|
|
|
_, err := framework.RunKubectl("create", "-f", opPath)
|
|
|
|
Expect(err).Should(BeNil())
|
2019-05-31 09:34:04 +00:00
|
|
|
err = waitForDaemonSets("rook-discover", rookNS, c, deployTimeout)
|
|
|
|
Expect(err).Should(BeNil())
|
|
|
|
err = waitForDeploymentComplete("rook-ceph-operator", rookNS, c, deployTimeout)
|
|
|
|
Expect(err).Should(BeNil())
|
|
|
|
}
|
|
|
|
|
|
|
|
func deployCluster(c kubernetes.Interface) {
|
|
|
|
opPath := fmt.Sprintf("%s/%s", rookURL, "cluster-test.yaml")
|
|
|
|
framework.RunKubectlOrDie("create", "-f", opPath)
|
2019-06-08 05:06:03 +00:00
|
|
|
err := waitForDaemonSets("rook-ceph-agent", rookNS, c, deployTimeout)
|
|
|
|
Expect(err).Should(BeNil())
|
2019-06-10 06:48:41 +00:00
|
|
|
opt := &metav1.ListOptions{
|
2019-05-31 09:34:04 +00:00
|
|
|
LabelSelector: "app=rook-ceph-mon",
|
|
|
|
}
|
2019-06-08 05:06:03 +00:00
|
|
|
err = checkCephPods(rookNS, c, 1, deployTimeout, opt)
|
2019-05-31 09:34:04 +00:00
|
|
|
Expect(err).Should(BeNil())
|
|
|
|
}
|
|
|
|
|
|
|
|
func deployToolBox(c kubernetes.Interface) {
|
|
|
|
opPath := fmt.Sprintf("%s/%s", rookURL, "toolbox.yaml")
|
|
|
|
framework.RunKubectlOrDie("create", "-f", opPath)
|
2019-06-10 06:48:41 +00:00
|
|
|
opt := &metav1.ListOptions{
|
2019-05-31 09:34:04 +00:00
|
|
|
LabelSelector: "app=rook-ceph-tools",
|
|
|
|
}
|
|
|
|
|
|
|
|
name := getPodName(rookNS, c, opt)
|
|
|
|
err := waitForPodInRunningState(name, rookNS, c, deployTimeout)
|
|
|
|
Expect(err).Should(BeNil())
|
2019-08-29 08:06:44 +00:00
|
|
|
// this is a workaround, as we are hitting "unable to get monitor info from DNS SRV with service name: ceph-mon"
|
|
|
|
time.Sleep(30 * time.Second)
|
2019-05-31 09:34:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func deployRook() {
|
|
|
|
c := getK8sClient()
|
|
|
|
deployCommon()
|
|
|
|
deployOperator(c)
|
|
|
|
deployCluster(c)
|
|
|
|
deployToolBox(c)
|
|
|
|
}
|
|
|
|
|
|
|
|
func tearDownRook() {
|
|
|
|
opPath := fmt.Sprintf("%s/%s", rookURL, "cluster-test.yaml")
|
|
|
|
framework.Cleanup(opPath, rookNS, "app=rook-ceph-mon")
|
|
|
|
opPath = fmt.Sprintf("%s/%s", rookURL, "toolbox.yaml")
|
|
|
|
framework.Cleanup(opPath, rookNS, "app=rook-ceph-tools")
|
|
|
|
|
|
|
|
opPath = fmt.Sprintf("%s/%s", rookURL, "operator.yaml")
|
2019-06-10 06:48:41 +00:00
|
|
|
// TODO need to add selector for cleanup validation
|
2019-05-31 09:34:04 +00:00
|
|
|
framework.Cleanup(opPath, rookNS)
|
|
|
|
commonPath := fmt.Sprintf("%s/%s", rookURL, "common.yaml")
|
2019-06-18 07:07:11 +00:00
|
|
|
_, err := framework.RunKubectl("delete", "-f", commonPath)
|
|
|
|
if err != nil {
|
2019-06-24 07:58:39 +00:00
|
|
|
e2elog.Logf("failed to delete rook common %v", err)
|
2019-06-18 07:07:11 +00:00
|
|
|
}
|
2019-05-31 09:34:04 +00:00
|
|
|
}
|