mirror of
https://github.com/ceph/ceph-csi.git
synced 2024-12-18 02:50:30 +00:00
Skip snapshot testing in CI
Signed-off-by: Madhu Rajanna <madhupr007@gmail.com>
This commit is contained in:
parent
46d3afbe12
commit
90fef919d5
99
e2e/rbd.go
99
e2e/rbd.go
@ -76,7 +76,7 @@ var _ = Describe("RBD", func() {
|
|||||||
deleteRBDPool()
|
deleteRBDPool()
|
||||||
deleteResource(rbdExamplePath + "secret.yaml")
|
deleteResource(rbdExamplePath + "secret.yaml")
|
||||||
deleteResource(rbdExamplePath + "storageclass.yaml")
|
deleteResource(rbdExamplePath + "storageclass.yaml")
|
||||||
deleteResource(rbdExamplePath + "snapshotclass.yaml")
|
// deleteResource(rbdExamplePath + "snapshotclass.yaml")
|
||||||
})
|
})
|
||||||
|
|
||||||
Context("Test RBD CSI", func() {
|
Context("Test RBD CSI", func() {
|
||||||
@ -85,9 +85,9 @@ var _ = Describe("RBD", func() {
|
|||||||
appPath := rbdExamplePath + "pod.yaml"
|
appPath := rbdExamplePath + "pod.yaml"
|
||||||
// rawPvcPath := rbdExamplePath + "raw-block-pvc.yaml"
|
// rawPvcPath := rbdExamplePath + "raw-block-pvc.yaml"
|
||||||
// rawAppPath := rbdExamplePath + "raw-block-pod.yaml"
|
// rawAppPath := rbdExamplePath + "raw-block-pod.yaml"
|
||||||
pvcClonePath := rbdExamplePath + "pvc-restore.yaml"
|
// pvcClonePath := rbdExamplePath + "pvc-restore.yaml"
|
||||||
appClonePath := rbdExamplePath + "pod-restore.yaml"
|
// appClonePath := rbdExamplePath + "pod-restore.yaml"
|
||||||
snapshotPath := rbdExamplePath + "snapshot.yaml"
|
// snapshotPath := rbdExamplePath + "snapshot.yaml"
|
||||||
|
|
||||||
By("checking provisioner statefulset/deployment is running")
|
By("checking provisioner statefulset/deployment is running")
|
||||||
timeout := time.Duration(deployTimeout) * time.Minute
|
timeout := time.Duration(deployTimeout) * time.Minute
|
||||||
@ -115,55 +115,56 @@ var _ = Describe("RBD", func() {
|
|||||||
By("create a PVC and Bind it to an app with normal user", func() {
|
By("create a PVC and Bind it to an app with normal user", func() {
|
||||||
validateNormalUserPVCAccess(pvcPath, f)
|
validateNormalUserPVCAccess(pvcPath, f)
|
||||||
})
|
})
|
||||||
|
// skipping snapshot testing
|
||||||
|
|
||||||
By("create a PVC clone and Bind it to an app", func() {
|
// By("create a PVC clone and Bind it to an app", func() {
|
||||||
createRBDSnapshotClass(f)
|
// createRBDSnapshotClass(f)
|
||||||
pvc, err := loadPVC(pvcPath)
|
// pvc, err := loadPVC(pvcPath)
|
||||||
if err != nil {
|
// if err != nil {
|
||||||
Fail(err.Error())
|
// Fail(err.Error())
|
||||||
}
|
// }
|
||||||
|
|
||||||
pvc.Namespace = f.UniqueName
|
// pvc.Namespace = f.UniqueName
|
||||||
e2elog.Logf("The PVC template %+v", pvc)
|
// e2elog.Logf("The PVC template %+v", pvc)
|
||||||
err = createPVCAndvalidatePV(f.ClientSet, pvc, deployTimeout)
|
// err = createPVCAndvalidatePV(f.ClientSet, pvc, deployTimeout)
|
||||||
if err != nil {
|
// if err != nil {
|
||||||
Fail(err.Error())
|
// Fail(err.Error())
|
||||||
}
|
// }
|
||||||
// validate created backend rbd images
|
// // validate created backend rbd images
|
||||||
images := listRBDImages(f)
|
// images := listRBDImages(f)
|
||||||
if len(images) != 1 {
|
// if len(images) != 1 {
|
||||||
e2elog.Logf("backend image count %d expected image count %d", len(images), 1)
|
// e2elog.Logf("backend image count %d expected image count %d", len(images), 1)
|
||||||
Fail("validate backend image failed")
|
// Fail("validate backend image failed")
|
||||||
}
|
// }
|
||||||
snap := getSnapshot(snapshotPath)
|
// snap := getSnapshot(snapshotPath)
|
||||||
snap.Namespace = f.UniqueName
|
// snap.Namespace = f.UniqueName
|
||||||
snap.Spec.Source.Name = pvc.Name
|
// snap.Spec.Source.Name = pvc.Name
|
||||||
snap.Spec.Source.Kind = "PersistentVolumeClaim"
|
// snap.Spec.Source.Kind = "PersistentVolumeClaim"
|
||||||
err = createSnapshot(&snap, deployTimeout)
|
// err = createSnapshot(&snap, deployTimeout)
|
||||||
if err != nil {
|
// if err != nil {
|
||||||
Fail(err.Error())
|
// Fail(err.Error())
|
||||||
}
|
// }
|
||||||
pool := "replicapool"
|
// pool := "replicapool"
|
||||||
snapList, err := listSnapshots(f, pool, images[0])
|
// snapList, err := listSnapshots(f, pool, images[0])
|
||||||
if err != nil {
|
// if err != nil {
|
||||||
Fail(err.Error())
|
// Fail(err.Error())
|
||||||
}
|
// }
|
||||||
if len(snapList) != 1 {
|
// if len(snapList) != 1 {
|
||||||
e2elog.Logf("backend snapshot not matching kube snap count,snap count = % kube snap count %d", len(snapList), 1)
|
// e2elog.Logf("backend snapshot not matching kube snap count,snap count = % kube snap count %d", len(snapList), 1)
|
||||||
Fail("validate backend snapshot failed")
|
// Fail("validate backend snapshot failed")
|
||||||
}
|
// }
|
||||||
|
|
||||||
validatePVCAndAppBinding(pvcClonePath, appClonePath, f)
|
// validatePVCAndAppBinding(pvcClonePath, appClonePath, f)
|
||||||
|
|
||||||
err = deleteSnapshot(&snap, deployTimeout)
|
// err = deleteSnapshot(&snap, deployTimeout)
|
||||||
if err != nil {
|
// if err != nil {
|
||||||
Fail(err.Error())
|
// Fail(err.Error())
|
||||||
}
|
// }
|
||||||
err = deletePVCAndValidatePV(f.ClientSet, pvc, deployTimeout)
|
// err = deletePVCAndValidatePV(f.ClientSet, pvc, deployTimeout)
|
||||||
if err != nil {
|
// if err != nil {
|
||||||
Fail(err.Error())
|
// Fail(err.Error())
|
||||||
}
|
// }
|
||||||
})
|
// })
|
||||||
|
|
||||||
// skipped raw pvc test in travis
|
// skipped raw pvc test in travis
|
||||||
// By("create a block type PVC and Bind it to an app", func() {
|
// By("create a block type PVC and Bind it to an app", func() {
|
||||||
|
232
e2e/utils.go
232
e2e/utils.go
@ -10,8 +10,8 @@ import (
|
|||||||
|
|
||||||
"k8s.io/klog"
|
"k8s.io/klog"
|
||||||
|
|
||||||
"github.com/kubernetes-csi/external-snapshotter/pkg/apis/volumesnapshot/v1alpha1"
|
_ "github.com/kubernetes-csi/external-snapshotter/pkg/apis/volumesnapshot/v1alpha1" // nolint
|
||||||
snapClient "github.com/kubernetes-csi/external-snapshotter/pkg/client/clientset/versioned/typed/volumesnapshot/v1alpha1"
|
_ "github.com/kubernetes-csi/external-snapshotter/pkg/client/clientset/versioned/typed/volumesnapshot/v1alpha1" // nolint
|
||||||
. "github.com/onsi/ginkgo" // nolint
|
. "github.com/onsi/ginkgo" // nolint
|
||||||
. "github.com/onsi/gomega" // nolint
|
. "github.com/onsi/gomega" // nolint
|
||||||
apps "k8s.io/api/apps/v1"
|
apps "k8s.io/api/apps/v1"
|
||||||
@ -31,12 +31,12 @@ import (
|
|||||||
|
|
||||||
var poll = 2 * time.Second
|
var poll = 2 * time.Second
|
||||||
|
|
||||||
type snapInfo struct {
|
// type snapInfo struct {
|
||||||
ID int64 `json:"id"`
|
// ID int64 `json:"id"`
|
||||||
Name string `json:"name"`
|
// Name string `json:"name"`
|
||||||
Size int64 `json:"size"`
|
// Size int64 `json:"size"`
|
||||||
Timestamp string `json:"timestamp"`
|
// Timestamp string `json:"timestamp"`
|
||||||
}
|
// }
|
||||||
|
|
||||||
func deployProvAsSTS(c clientset.Interface) bool {
|
func deployProvAsSTS(c clientset.Interface) bool {
|
||||||
// kubeMinor to use deployment instead of statefulset for provisioner
|
// kubeMinor to use deployment instead of statefulset for provisioner
|
||||||
@ -175,21 +175,21 @@ func getStorageClass(path string) scv1.StorageClass {
|
|||||||
return sc
|
return sc
|
||||||
}
|
}
|
||||||
|
|
||||||
func getSnapshotClass(path string) v1alpha1.VolumeSnapshotClass {
|
// func getSnapshotClass(path string) v1alpha1.VolumeSnapshotClass {
|
||||||
sc := v1alpha1.VolumeSnapshotClass{}
|
// sc := v1alpha1.VolumeSnapshotClass{}
|
||||||
sc.Kind = "VolumeSnapshotClass"
|
// sc.Kind = "VolumeSnapshotClass"
|
||||||
sc.APIVersion = "snapshot.storage.k8s.io/v1alpha1"
|
// sc.APIVersion = "snapshot.storage.k8s.io/v1alpha1"
|
||||||
err := unmarshal(path, &sc)
|
// err := unmarshal(path, &sc)
|
||||||
Expect(err).Should(BeNil())
|
// Expect(err).Should(BeNil())
|
||||||
return sc
|
// return sc
|
||||||
}
|
// }
|
||||||
|
|
||||||
func getSnapshot(path string) v1alpha1.VolumeSnapshot {
|
// func getSnapshot(path string) v1alpha1.VolumeSnapshot {
|
||||||
sc := v1alpha1.VolumeSnapshot{}
|
// sc := v1alpha1.VolumeSnapshot{}
|
||||||
err := unmarshal(path, &sc)
|
// err := unmarshal(path, &sc)
|
||||||
Expect(err).Should(BeNil())
|
// Expect(err).Should(BeNil())
|
||||||
return sc
|
// return sc
|
||||||
}
|
// }
|
||||||
|
|
||||||
func createCephfsStorageClass(c kubernetes.Interface, f *framework.Framework, enablePool bool) {
|
func createCephfsStorageClass(c kubernetes.Interface, f *framework.Framework, enablePool bool) {
|
||||||
scPath := fmt.Sprintf("%s/%s", cephfsExamplePath, "storageclass.yaml")
|
scPath := fmt.Sprintf("%s/%s", cephfsExamplePath, "storageclass.yaml")
|
||||||
@ -226,33 +226,33 @@ func createRBDStorageClass(c kubernetes.Interface, f *framework.Framework) {
|
|||||||
Expect(err).Should(BeNil())
|
Expect(err).Should(BeNil())
|
||||||
}
|
}
|
||||||
|
|
||||||
func newSnapshotClient() (*snapClient.SnapshotV1alpha1Client, error) {
|
// func newSnapshotClient() (*snapClient.SnapshotV1alpha1Client, error) {
|
||||||
config, err := framework.LoadConfig()
|
// config, err := framework.LoadConfig()
|
||||||
if err != nil {
|
// if err != nil {
|
||||||
return nil, fmt.Errorf("error creating client: %v", err.Error())
|
// return nil, fmt.Errorf("error creating client: %v", err.Error())
|
||||||
}
|
// }
|
||||||
c, err := snapClient.NewForConfig(config)
|
// c, err := snapClient.NewForConfig(config)
|
||||||
if err != nil {
|
// if err != nil {
|
||||||
return nil, fmt.Errorf("error creating snapshot client: %v", err.Error())
|
// return nil, fmt.Errorf("error creating snapshot client: %v", err.Error())
|
||||||
}
|
// }
|
||||||
return c, err
|
// return c, err
|
||||||
}
|
// }
|
||||||
func createRBDSnapshotClass(f *framework.Framework) {
|
// func createRBDSnapshotClass(f *framework.Framework) {
|
||||||
scPath := fmt.Sprintf("%s/%s", rbdExamplePath, "snapshotclass.yaml")
|
// scPath := fmt.Sprintf("%s/%s", rbdExamplePath, "snapshotclass.yaml")
|
||||||
sc := getSnapshotClass(scPath)
|
// sc := getSnapshotClass(scPath)
|
||||||
|
|
||||||
opt := metav1.ListOptions{
|
// opt := metav1.ListOptions{
|
||||||
LabelSelector: "app=rook-ceph-tools",
|
// LabelSelector: "app=rook-ceph-tools",
|
||||||
}
|
// }
|
||||||
fsID := execCommandInPod(f, "ceph fsid", rookNS, &opt)
|
// fsID := execCommandInPod(f, "ceph fsid", rookNS, &opt)
|
||||||
// remove new line present in fsID
|
// // remove new line present in fsID
|
||||||
fsID = strings.Trim(fsID, "\n")
|
// fsID = strings.Trim(fsID, "\n")
|
||||||
sc.Parameters["clusterID"] = fsID
|
// sc.Parameters["clusterID"] = fsID
|
||||||
sclient, err := newSnapshotClient()
|
// sclient, err := newSnapshotClient()
|
||||||
Expect(err).Should(BeNil())
|
// Expect(err).Should(BeNil())
|
||||||
_, err = sclient.VolumeSnapshotClasses().Create(&sc)
|
// _, err = sclient.VolumeSnapshotClasses().Create(&sc)
|
||||||
Expect(err).Should(BeNil())
|
// Expect(err).Should(BeNil())
|
||||||
}
|
// }
|
||||||
|
|
||||||
func deleteConfiMap(pluginPath string) {
|
func deleteConfiMap(pluginPath string) {
|
||||||
path := pluginPath + configMap
|
path := pluginPath + configMap
|
||||||
@ -678,72 +678,72 @@ func validateNormalUserPVCAccess(pvcPath string, f *framework.Framework) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func createSnapshot(snap *v1alpha1.VolumeSnapshot, t int) error {
|
// func createSnapshot(snap *v1alpha1.VolumeSnapshot, t int) error {
|
||||||
|
|
||||||
sclient, err := newSnapshotClient()
|
// sclient, err := newSnapshotClient()
|
||||||
if err != nil {
|
// if err != nil {
|
||||||
return err
|
// return err
|
||||||
}
|
// }
|
||||||
_, err = sclient.VolumeSnapshots(snap.Namespace).Create(snap)
|
// _, err = sclient.VolumeSnapshots(snap.Namespace).Create(snap)
|
||||||
if err != nil {
|
// if err != nil {
|
||||||
return err
|
// return err
|
||||||
}
|
// }
|
||||||
e2elog.Logf("snapshot with name %v created in %v namespace", snap.Name, snap.Namespace)
|
// e2elog.Logf("snapshot with name %v created in %v namespace", snap.Name, snap.Namespace)
|
||||||
|
|
||||||
timeout := time.Duration(t) * time.Minute
|
// timeout := time.Duration(t) * time.Minute
|
||||||
name := snap.Name
|
// name := snap.Name
|
||||||
start := time.Now()
|
// start := time.Now()
|
||||||
e2elog.Logf("Waiting up to %v to be in Ready state", snap)
|
// e2elog.Logf("Waiting up to %v to be in Ready state", snap)
|
||||||
|
|
||||||
return wait.PollImmediate(poll, timeout, func() (bool, error) {
|
// return wait.PollImmediate(poll, timeout, func() (bool, error) {
|
||||||
e2elog.Logf("waiting for snapshot %s (%d seconds elapsed)", snap.Name, int(time.Since(start).Seconds()))
|
// e2elog.Logf("waiting for snapshot %s (%d seconds elapsed)", snap.Name, int(time.Since(start).Seconds()))
|
||||||
snaps, err := sclient.VolumeSnapshots(snap.Namespace).Get(name, metav1.GetOptions{})
|
// snaps, err := sclient.VolumeSnapshots(snap.Namespace).Get(name, metav1.GetOptions{})
|
||||||
if err != nil {
|
// if err != nil {
|
||||||
e2elog.Logf("Error getting snapshot in namespace: '%s': %v", snap.Namespace, err)
|
// e2elog.Logf("Error getting snapshot in namespace: '%s': %v", snap.Namespace, err)
|
||||||
if testutils.IsRetryableAPIError(err) {
|
// if testutils.IsRetryableAPIError(err) {
|
||||||
return false, nil
|
// return false, nil
|
||||||
}
|
// }
|
||||||
if apierrs.IsNotFound(err) {
|
// if apierrs.IsNotFound(err) {
|
||||||
return false, nil
|
// return false, nil
|
||||||
}
|
// }
|
||||||
return false, err
|
// return false, err
|
||||||
}
|
// }
|
||||||
if snaps.Status.ReadyToUse {
|
// if snaps.Status.ReadyToUse {
|
||||||
return true, nil
|
// return true, nil
|
||||||
}
|
// }
|
||||||
return false, nil
|
// return false, nil
|
||||||
})
|
// })
|
||||||
}
|
// }
|
||||||
|
|
||||||
func deleteSnapshot(snap *v1alpha1.VolumeSnapshot, t int) error {
|
// func deleteSnapshot(snap *v1alpha1.VolumeSnapshot, t int) error {
|
||||||
sclient, err := newSnapshotClient()
|
// sclient, err := newSnapshotClient()
|
||||||
if err != nil {
|
// if err != nil {
|
||||||
return err
|
// return err
|
||||||
}
|
// }
|
||||||
err = sclient.VolumeSnapshots(snap.Namespace).Delete(snap.Name, &metav1.DeleteOptions{})
|
// err = sclient.VolumeSnapshots(snap.Namespace).Delete(snap.Name, &metav1.DeleteOptions{})
|
||||||
if err != nil {
|
// if err != nil {
|
||||||
return err
|
// return err
|
||||||
}
|
// }
|
||||||
|
|
||||||
timeout := time.Duration(t) * time.Minute
|
// timeout := time.Duration(t) * time.Minute
|
||||||
name := snap.Name
|
// name := snap.Name
|
||||||
start := time.Now()
|
// start := time.Now()
|
||||||
e2elog.Logf("Waiting up to %v to be deleted", snap)
|
// e2elog.Logf("Waiting up to %v to be deleted", snap)
|
||||||
|
|
||||||
return wait.PollImmediate(poll, timeout, func() (bool, error) {
|
// return wait.PollImmediate(poll, timeout, func() (bool, error) {
|
||||||
e2elog.Logf("deleting snapshot %s (%d seconds elapsed)", name, int(time.Since(start).Seconds()))
|
// e2elog.Logf("deleting snapshot %s (%d seconds elapsed)", name, int(time.Since(start).Seconds()))
|
||||||
_, err := sclient.VolumeSnapshots(snap.Namespace).Get(name, metav1.GetOptions{})
|
// _, err := sclient.VolumeSnapshots(snap.Namespace).Get(name, metav1.GetOptions{})
|
||||||
if err == nil {
|
// if err == nil {
|
||||||
return false, nil
|
// return false, nil
|
||||||
}
|
// }
|
||||||
|
|
||||||
if !apierrs.IsNotFound(err) {
|
// if !apierrs.IsNotFound(err) {
|
||||||
return false, fmt.Errorf("get on deleted snapshot %v failed with error other than \"not found\": %v", name, err)
|
// return false, fmt.Errorf("get on deleted snapshot %v failed with error other than \"not found\": %v", name, err)
|
||||||
}
|
// }
|
||||||
|
|
||||||
return true, nil
|
// return true, nil
|
||||||
})
|
// })
|
||||||
}
|
// }
|
||||||
|
|
||||||
func listRBDImages(f *framework.Framework) []string {
|
func listRBDImages(f *framework.Framework) []string {
|
||||||
|
|
||||||
@ -761,18 +761,18 @@ func listRBDImages(f *framework.Framework) []string {
|
|||||||
return imgInfos
|
return imgInfos
|
||||||
}
|
}
|
||||||
|
|
||||||
func listSnapshots(f *framework.Framework, pool, imageName string) ([]snapInfo, error) {
|
// func listSnapshots(f *framework.Framework, pool, imageName string) ([]snapInfo, error) {
|
||||||
opt := metav1.ListOptions{
|
// opt := metav1.ListOptions{
|
||||||
LabelSelector: "app=rook-ceph-tools",
|
// LabelSelector: "app=rook-ceph-tools",
|
||||||
}
|
// }
|
||||||
command := fmt.Sprintf("rbd snap ls %s/%s --format=json", pool, imageName)
|
// command := fmt.Sprintf("rbd snap ls %s/%s --format=json", pool, imageName)
|
||||||
stdout := execCommandInPod(f, command, rookNS, &opt)
|
// stdout := execCommandInPod(f, command, rookNS, &opt)
|
||||||
|
|
||||||
var snapInfos []snapInfo
|
// var snapInfos []snapInfo
|
||||||
|
|
||||||
err := json.Unmarshal([]byte(stdout), &snapInfos)
|
// err := json.Unmarshal([]byte(stdout), &snapInfos)
|
||||||
return snapInfos, err
|
// return snapInfos, err
|
||||||
}
|
// }
|
||||||
|
|
||||||
func checkDataPersist(pvcPath, appPath string, f *framework.Framework) error {
|
func checkDataPersist(pvcPath, appPath string, f *framework.Framework) error {
|
||||||
data := "checking data persist"
|
data := "checking data persist"
|
||||||
|
Loading…
Reference in New Issue
Block a user