mirror of
https://github.com/ceph/ceph-csi.git
synced 2024-11-22 14:20:19 +00:00
e2e: pass SC parameters to createCephfsStorageClass()
Signed-off-by: Niels de Vos <ndevos@redhat.com>
This commit is contained in:
parent
6f2f972f5b
commit
85df59531b
@ -220,7 +220,7 @@ var _ = Describe("cephfs", func() {
|
|||||||
})
|
})
|
||||||
|
|
||||||
By("create a storageclass with pool and a PVC then bind it to an app", func() {
|
By("create a storageclass with pool and a PVC then bind it to an app", func() {
|
||||||
err := createCephfsStorageClass(f.ClientSet, f, true, "")
|
err := createCephfsStorageClass(f.ClientSet, f, true, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
e2elog.Failf("failed to create CephFS storageclass with error %v", err)
|
e2elog.Failf("failed to create CephFS storageclass with error %v", err)
|
||||||
}
|
}
|
||||||
@ -235,7 +235,7 @@ var _ = Describe("cephfs", func() {
|
|||||||
})
|
})
|
||||||
|
|
||||||
By("create a PVC and bind it to an app", func() {
|
By("create a PVC and bind it to an app", func() {
|
||||||
err := createCephfsStorageClass(f.ClientSet, f, false, "")
|
err := createCephfsStorageClass(f.ClientSet, f, false, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
e2elog.Failf("failed to create CephFS storageclass with error %v", err)
|
e2elog.Failf("failed to create CephFS storageclass with error %v", err)
|
||||||
}
|
}
|
||||||
@ -332,7 +332,10 @@ var _ = Describe("cephfs", func() {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
e2elog.Failf("failed to create configmap with error %v", err)
|
e2elog.Failf("failed to create configmap with error %v", err)
|
||||||
}
|
}
|
||||||
err = createCephfsStorageClass(f.ClientSet, f, false, "clusterID-1")
|
params := map[string]string{
|
||||||
|
"clusterID": "clusterID-1",
|
||||||
|
}
|
||||||
|
err = createCephfsStorageClass(f.ClientSet, f, false, params)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
e2elog.Failf("failed to create storageclass with error %v", err)
|
e2elog.Failf("failed to create storageclass with error %v", err)
|
||||||
}
|
}
|
||||||
@ -352,7 +355,8 @@ var _ = Describe("cephfs", func() {
|
|||||||
|
|
||||||
// create resources and verify subvolume group creation
|
// create resources and verify subvolume group creation
|
||||||
// for the second cluster.
|
// for the second cluster.
|
||||||
err = createCephfsStorageClass(f.ClientSet, f, false, "clusterID-2")
|
params["clusterID"] = "clusterID-2"
|
||||||
|
err = createCephfsStorageClass(f.ClientSet, f, false, params)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
e2elog.Failf("failed to create storageclass with error %v", err)
|
e2elog.Failf("failed to create storageclass with error %v", err)
|
||||||
}
|
}
|
||||||
@ -376,7 +380,7 @@ var _ = Describe("cephfs", func() {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
e2elog.Failf("failed to create configmap with error %v", err)
|
e2elog.Failf("failed to create configmap with error %v", err)
|
||||||
}
|
}
|
||||||
err = createCephfsStorageClass(f.ClientSet, f, false, "")
|
err = createCephfsStorageClass(f.ClientSet, f, false, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
e2elog.Failf("failed to create storageclass with error %v", err)
|
e2elog.Failf("failed to create storageclass with error %v", err)
|
||||||
}
|
}
|
||||||
|
@ -34,7 +34,7 @@ func validateSubvolumegroup(f *framework.Framework, subvolgrp string) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func createCephfsStorageClass(c kubernetes.Interface, f *framework.Framework, enablePool bool, clusterID string) error {
|
func createCephfsStorageClass(c kubernetes.Interface, f *framework.Framework, enablePool bool, params map[string]string) error {
|
||||||
scPath := fmt.Sprintf("%s/%s", cephfsExamplePath, "storageclass.yaml")
|
scPath := fmt.Sprintf("%s/%s", cephfsExamplePath, "storageclass.yaml")
|
||||||
sc, err := getStorageClass(scPath)
|
sc, err := getStorageClass(scPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -53,20 +53,29 @@ func createCephfsStorageClass(c kubernetes.Interface, f *framework.Framework, en
|
|||||||
if enablePool {
|
if enablePool {
|
||||||
sc.Parameters["pool"] = "myfs-data0"
|
sc.Parameters["pool"] = "myfs-data0"
|
||||||
}
|
}
|
||||||
fsID, stdErr, err := execCommandInToolBoxPod(f, "ceph fsid", rookNamespace)
|
|
||||||
if err != nil {
|
// overload any parameters that were passed
|
||||||
return err
|
if params == nil {
|
||||||
|
// create an empty params, so that params["clusterID"] below
|
||||||
|
// does not panic
|
||||||
|
params = map[string]string{}
|
||||||
}
|
}
|
||||||
if stdErr != "" {
|
for param, value := range params {
|
||||||
return fmt.Errorf("error getting fsid %v", stdErr)
|
sc.Parameters[param] = value
|
||||||
}
|
}
|
||||||
// remove new line present in fsID
|
|
||||||
fsID = strings.Trim(fsID, "\n")
|
// fetch and set fsID from the cluster if not set in params
|
||||||
if clusterID != "" {
|
if _, found := params["clusterID"]; !found {
|
||||||
fsID = clusterID
|
fsID, stdErr, failErr := execCommandInToolBoxPod(f, "ceph fsid", rookNamespace)
|
||||||
|
if failErr != nil {
|
||||||
|
return failErr
|
||||||
|
}
|
||||||
|
if stdErr != "" {
|
||||||
|
return fmt.Errorf("error getting fsid %v", stdErr)
|
||||||
|
}
|
||||||
|
sc.Parameters["clusterID"] = strings.Trim(fsID, "\n")
|
||||||
}
|
}
|
||||||
sc.Namespace = cephCSINamespace
|
sc.Namespace = cephCSINamespace
|
||||||
sc.Parameters["clusterID"] = fsID
|
|
||||||
_, err = c.StorageV1().StorageClasses().Create(context.TODO(), &sc, metav1.CreateOptions{})
|
_, err = c.StorageV1().StorageClasses().Create(context.TODO(), &sc, metav1.CreateOptions{})
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -55,7 +55,7 @@ var _ = Describe("CephFS Upgrade Testing", func() {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
e2elog.Failf("failed to create secret with error %v", err)
|
e2elog.Failf("failed to create secret with error %v", err)
|
||||||
}
|
}
|
||||||
err = createCephfsStorageClass(f.ClientSet, f, true, "")
|
err = createCephfsStorageClass(f.ClientSet, f, true, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
e2elog.Failf("failed to create storageclass with error %v", err)
|
e2elog.Failf("failed to create storageclass with error %v", err)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user