1
0
mirror of https://github.com/ceph/ceph-csi.git synced 2024-12-22 13:00:19 +00:00

Merge pull request from Madhu-1/fix-e2e-dep

Fix issues in E2E cleanup
This commit is contained in:
Madhu Rajanna 2019-08-12 10:47:10 +05:30 committed by GitHub
commit d631cd6cd9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 50 additions and 23 deletions

View File

@ -36,6 +36,25 @@ func deployCephfsPlugin() {
framework.RunKubectlOrDie("apply", "-f", cephfsDirPath+cephfsNodePluginRBAC) framework.RunKubectlOrDie("apply", "-f", cephfsDirPath+cephfsNodePluginRBAC)
} }
func deleteCephfsPlugin() {
_, err := framework.RunKubectl("delete", "-f", cephfsDirPath+cephfsProvisioner)
if err != nil {
e2elog.Logf("failed to delete cephfs provisioner %v", err)
}
_, err = framework.RunKubectl("delete", "-f", cephfsDirPath+cephfsProvisionerRBAC)
if err != nil {
e2elog.Logf("failed to delete cephfs provisioner rbac %v", err)
}
_, err = framework.RunKubectl("delete", "-f", cephfsDirPath+cephfsNodePlugin)
if err != nil {
e2elog.Logf("failed to delete cephfs nodeplugin %v", err)
}
_, err = framework.RunKubectl("delete", "-f", cephfsDirPath+cephfsNodePluginRBAC)
if err != nil {
e2elog.Logf("failed to delete cephfs nodeplugin rbac %v", err)
}
}
var _ = Describe("cephfs", func() { var _ = Describe("cephfs", func() {
f := framework.NewDefaultFramework("cephfs") f := framework.NewDefaultFramework("cephfs")
// deploy cephfs CSI // deploy cephfs CSI
@ -48,13 +67,8 @@ var _ = Describe("cephfs", func() {
}) })
AfterEach(func() { AfterEach(func() {
cephfsFiles := getFilesinDirectory(cephfsDirPath) deleteCephfsPlugin()
for _, file := range cephfsFiles { deleteConfiMap(cephfsDirPath)
res, err := framework.RunKubectl("delete", "-f", cephfsDirPath+file.Name())
if err != nil {
e2elog.Logf("failed to delete resource in %s with err %v", res, err)
}
}
deleteResource(cephfsExamplePath + "secret.yaml") deleteResource(cephfsExamplePath + "secret.yaml")
deleteResource(cephfsExamplePath + "storageclass.yaml") deleteResource(cephfsExamplePath + "storageclass.yaml")
deleteFileSystem() deleteFileSystem()

View File

@ -38,6 +38,25 @@ func deployRBDPlugin() {
framework.RunKubectlOrDie("apply", "-f", rbdDirPath+rbdNodePluginRBAC) framework.RunKubectlOrDie("apply", "-f", rbdDirPath+rbdNodePluginRBAC)
} }
func deleteRBDPlugin() {
_, err := framework.RunKubectl("delete", "-f", rbdDirPath+rbdProvisioner)
if err != nil {
e2elog.Logf("failed to delete rbd provisioner %v", err)
}
_, err = framework.RunKubectl("delete", "-f", rbdDirPath+rbdProvisionerRBAC)
if err != nil {
e2elog.Logf("failed to delete provisioner rbac %v", err)
}
_, err = framework.RunKubectl("delete", "-f", rbdDirPath+rbdNodePlugin)
if err != nil {
e2elog.Logf("failed to delete nodeplugin %v", err)
}
_, err = framework.RunKubectl("delete", "-f", rbdDirPath+rbdNodePluginRBAC)
if err != nil {
e2elog.Logf("failed to delete nodeplugin rbac %v", err)
}
}
var _ = Describe("RBD", func() { var _ = Describe("RBD", func() {
f := framework.NewDefaultFramework("rbd") f := framework.NewDefaultFramework("rbd")
// deploy RBD CSI // deploy RBD CSI
@ -52,13 +71,8 @@ var _ = Describe("RBD", func() {
}) })
AfterEach(func() { AfterEach(func() {
rbdFiles := getFilesinDirectory(rbdDirPath) deleteRBDPlugin()
for _, file := range rbdFiles { deleteConfiMap(rbdDirPath)
res, err := framework.RunKubectl("delete", "-f", rbdDirPath+file.Name())
if err != nil {
e2elog.Logf("failed to delete resource in %s with err %v", res, err)
}
}
deleteRBDPool() deleteRBDPool()
deleteResource(rbdExamplePath + "secret.yaml") deleteResource(rbdExamplePath + "secret.yaml")
deleteResource(rbdExamplePath + "storageclass.yaml") deleteResource(rbdExamplePath + "storageclass.yaml")

View File

@ -5,7 +5,6 @@ import (
"encoding/json" "encoding/json"
"fmt" "fmt"
"io/ioutil" "io/ioutil"
"os"
"strings" "strings"
"time" "time"
@ -30,14 +29,6 @@ import (
testutils "k8s.io/kubernetes/test/utils" testutils "k8s.io/kubernetes/test/utils"
) )
func getFilesinDirectory(path string) []os.FileInfo {
files, err := ioutil.ReadDir(path)
if err != nil {
framework.ExpectNoError(err)
}
return files
}
var poll = 2 * time.Second var poll = 2 * time.Second
type snapInfo struct { type snapInfo struct {
@ -263,6 +254,14 @@ func createRBDSnapshotClass(f *framework.Framework) {
Expect(err).Should(BeNil()) Expect(err).Should(BeNil())
} }
func deleteConfiMap(pluginPath string) {
path := pluginPath + configMap
_, err := framework.RunKubectl("delete", "-f", path)
if err != nil {
e2elog.Logf("failed to delete configmap %v", err)
}
}
func createConfigMap(pluginPath string, c kubernetes.Interface, f *framework.Framework) { func createConfigMap(pluginPath string, c kubernetes.Interface, f *framework.Framework) {
path := pluginPath + configMap path := pluginPath + configMap
cm := v1.ConfigMap{} cm := v1.ConfigMap{}