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