Merge pull request #11158 from Rakshith-R/add-nfs-snap-clone-e2e

csi: Add nfs snap & clone ci
This commit is contained in:
Travis Nielsen authored and GitHub committed 2022-10-18 11:26:12 -06:00
commit 57d6020c4e
5 files changed
+54 -12

No files matched your search

+10
View File
@@ -109,3 +109,13 @@ func (f *NFSOperation) CreateStorageClass(fsName, nfsClusterName, systemNamespac
return f.k8sh.ResourceOperation("apply", f.manifests.GetNFSStorageClass(fsName, nfsClusterName, server, storageClassName))
}
// CreateSnapshotClass creates a Snapshot class for NFS clients
func (f *NFSOperation) CreateSnapshotClass(fsName, snapshotClassName string) error {
return f.k8sh.ResourceOperation("apply", f.manifests.GetNFSSnapshotClass(fsName, snapshotClassName))
}
// DeleteSnapshotClass deletes a Snapshot class for NFS clients
func (f *NFSOperation) DeleteSnapshotClass(fsName, snapshotClassName string) error {
return f.k8sh.ResourceOperation("delete", f.manifests.GetNFSSnapshotClass(fsName, snapshotClassName))
}
@@ -38,6 +38,7 @@ type CephManifests interface {
GetBlockStorageClass(poolName, storageClassName, reclaimPolicy string) string
GetFileStorageClass(fsName, storageClassName string) string
GetNFSStorageClass(fsName, nfsClusterName, server, storageClassName string) string
GetNFSSnapshotClass(fsName, snapshotClassName string) string
GetBlockSnapshotClass(snapshotClassName, reclaimPolicy string) string
GetFileStorageSnapshotClass(snapshotClassName, reclaimPolicy string) string
GetFilesystem(name string, activeCount int) string
@@ -378,6 +379,22 @@ mountOptions:
return sc
}
func (m *CephManifestsMaster) GetNFSSnapshotClass(snapshotClassName, reclaimPolicy string) string {
// return NFS CSI snapshotclass object.
return `
apiVersion: snapshot.storage.k8s.io/v1
kind: VolumeSnapshotClass
metadata:
name: ` + snapshotClassName + `
driver: ` + m.settings.OperatorNamespace + `.nfs.csi.ceph.com
deletionPolicy: ` + reclaimPolicy + `
parameters:
clusterID: ` + m.settings.Namespace + `
csi.storage.k8s.io/snapshotter-secret-name: rook-csi-cephfs-provisioner
csi.storage.k8s.io/snapshotter-secret-namespace: ` + m.settings.Namespace + `
`
}
// GetFilesystem returns the manifest to create a Rook filesystem resource with the given config.
func (m *CephManifestsMaster) GetFilesystem(name string, activeCount int) string {
return `apiVersion: ceph.rook.io/v1
@@ -113,6 +113,10 @@ func (m *CephManifestsPreviousVersion) GetNFSStorageClass(fsName, nfsClusterName
return m.latest.GetNFSStorageClass(fsName, nfsClusterName, server, storageClassName)
}
func (m *CephManifestsPreviousVersion) GetNFSSnapshotClass(fsName, snapshotClassName string) string {
return m.latest.GetNFSSnapshotClass(fsName, snapshotClassName)
}
// GetFilesystem returns the manifest to create a Rook filesystem resource with the given config.
func (m *CephManifestsPreviousVersion) GetFilesystem(name string, activeCount int) string {
return m.latest.GetFilesystem(name, activeCount)
@@ -135,27 +139,27 @@ func (m *CephManifestsPreviousVersion) GetObjectStoreUser(name, displayName, sto
return m.latest.GetObjectStoreUser(name, displayName, store, usercaps, maxsize, maxbuckets, maxobjects)
}
//GetBucketStorageClass returns the manifest to create object bucket
// GetBucketStorageClass returns the manifest to create object bucket
func (m *CephManifestsPreviousVersion) GetBucketStorageClass(storeName, storageClassName, reclaimPolicy string) string {
return m.latest.GetBucketStorageClass(storeName, storageClassName, reclaimPolicy)
}
//GetOBC returns the manifest to create object bucket claim
// GetOBC returns the manifest to create object bucket claim
func (m *CephManifestsPreviousVersion) GetOBC(claimName, storageClassName, objectBucketName, maxObject string, varBucketName bool) string {
return m.latest.GetOBC(claimName, storageClassName, objectBucketName, maxObject, varBucketName)
}
//GetOBCNotification returns the manifest to create object bucket claim
// GetOBCNotification returns the manifest to create object bucket claim
func (m *CephManifestsPreviousVersion) GetOBCNotification(claimName, storageClassName, objectBucketName, notificationName string, varBucketName bool) string {
return m.latest.GetOBCNotification(claimName, storageClassName, objectBucketName, notificationName, varBucketName)
}
//GetBucketNotification returns the manifest to create ceph bucket notification
// GetBucketNotification returns the manifest to create ceph bucket notification
func (m *CephManifestsPreviousVersion) GetBucketNotification(notificationName, topicName string) string {
return m.latest.GetBucketNotification(notificationName, topicName)
}
//GetBucketTopic returns the manifest to create ceph bucket topic
// GetBucketTopic returns the manifest to create ceph bucket topic
func (m *CephManifestsPreviousVersion) GetBucketTopic(topicName, storeName, httpEndpointService string) string {
return m.latest.GetBucketTopic(topicName, storeName, httpEndpointService)
}
+14 -7
View File
@@ -116,7 +116,7 @@ func fileSystemCSICloneTest(helper *clients.TestClient, k8sh *utils.K8sHelper, s
assert.True(s.T(), k8sh.WaitUntilPVCIsDeleted(defaultNamespace, pvcName))
}
func fileSystemCSISnapshotTest(helper *clients.TestClient, k8sh *utils.K8sHelper, s *suite.Suite, storageClassName, namespace string) {
func fileSystemCSISnapshotTest(helper *clients.TestClient, k8sh *utils.K8sHelper, s *suite.Suite, storageClassName, namespace string, testNFS bool) {
logger.Infof("install snapshot CRD")
err := k8sh.CreateSnapshotCRD()
require.NoError(s.T(), err)
@@ -142,7 +142,11 @@ func fileSystemCSISnapshotTest(helper *clients.TestClient, k8sh *utils.K8sHelper
snapshotDeletePolicy := "Delete"
snapshotClassName := "snapshot-testing"
logger.Infof("create snapshotclass")
err = helper.FSClient.CreateSnapshotClass(snapshotClassName, snapshotDeletePolicy, namespace)
if !testNFS {
err = helper.FSClient.CreateSnapshotClass(snapshotClassName, snapshotDeletePolicy, namespace)
} else {
err = helper.NFSClient.CreateSnapshotClass(snapshotClassName, snapshotDeletePolicy)
}
require.NoError(s.T(), err)
// create pvc and app
pvcSize := "1Gi"
@@ -171,11 +175,11 @@ func fileSystemCSISnapshotTest(helper *clients.TestClient, k8sh *utils.K8sHelper
pvcChecksum := strings.Fields(resp)
require.Equal(s.T(), len(pvcChecksum), 2)
// create a snapshot
snapshotName := "rbd-pvc-snapshot"
snapshotName := "fs-pvc-snapshot"
logger.Infof("create a snapshot from pvc")
err = helper.FSClient.CreateSnapshot(snapshotName, pvcName, snapshotClassName, defaultNamespace)
require.NoError(s.T(), err)
restorePVCName := "restore-block-pvc"
restorePVCName := "restore-fs-pvc"
// check snapshot is in ready state
ready, err := k8sh.CheckSnapshotISReadyToUse(snapshotName, defaultNamespace, 15)
require.NoError(s.T(), err)
@@ -233,8 +237,11 @@ func fileSystemCSISnapshotTest(helper *clients.TestClient, k8sh *utils.K8sHelper
assert.True(s.T(), k8sh.WaitUntilPVCIsDeleted(defaultNamespace, pvcName))
logger.Infof("delete snapshotclass")
err = helper.FSClient.DeleteSnapshotClass(snapshotClassName, snapshotDeletePolicy, namespace)
if !testNFS {
err = helper.FSClient.DeleteSnapshotClass(snapshotClassName, snapshotDeletePolicy, namespace)
} else {
err = helper.NFSClient.DeleteSnapshotClass(snapshotClassName, snapshotDeletePolicy)
}
require.NoError(s.T(), err)
logger.Infof("delete snapshot-controller")
}
@@ -465,7 +472,7 @@ func runFileE2ETestLite(helper *clients.TestClient, k8sh *utils.K8sHelper, s *su
err := helper.FSClient.CreateStorageClass(filesystemName, settings.OperatorNamespace, settings.Namespace, storageClassName)
assert.NoError(s.T(), err)
assert.NoError(s.T(), err)
fileSystemCSISnapshotTest(helper, k8sh, s, storageClassName, settings.Namespace)
fileSystemCSISnapshotTest(helper, k8sh, s, storageClassName, settings.Namespace, false)
fileSystemCSICloneTest(helper, k8sh, s, storageClassName, settings.Namespace)
cleanupFilesystem(helper, k8sh, s, settings.Namespace, filesystemName)
+4
View File
@@ -50,6 +50,10 @@ func runNFSFileE2ETest(helper *clients.TestClient, k8sh *utils.K8sHelper, s *sui
cleanupFilesystemConsumer(helper, k8sh, s, settings.Namespace, filePodName)
assert.NoError(s.T(), err)
fileSystemCSISnapshotTest(helper, k8sh, s, storageClassName, settings.Namespace, true)
fileSystemCSICloneTest(helper, k8sh, s, storageClassName, settings.Namespace)
}
err = helper.NFSClient.Delete(settings.Namespace, nfsClusterName)