e2e: change createCustomConfigmap to be more general

createCustomConfigmap helps to create a custom cluster entry in
the configmap, however this was coupled with subvolumegroup filling
in the cluster configuration. This commit helps to make it more
general and the subvolumegroup filling is controlled now with a flag

Signed-off-by: Humble Chirammal <hchiramm@redhat.com>
This commit is contained in:
Humble Chirammal 2021-10-01 09:36:06 +05:30 committed by mergify[bot]
parent 90d246fc55
commit a4a2dc93c1
2 changed files with 35 additions and 9 deletions

View File

@ -533,12 +533,17 @@ var _ = Describe("cephfs", func() {
if err != nil { if err != nil {
e2elog.Failf("failed to delete storageclass with error %v", err) e2elog.Failf("failed to delete storageclass with error %v", err)
} }
// re-define configmap with information of multiple clusters. // re-define configmap with information of multiple clusters.
subvolgrpInfo := map[string]string{ clusterInfo := map[string]map[string]string{}
"clusterID-1": "subvolgrp1", clusterID1 := "clusterID-1"
"clusterID-2": "subvolgrp2", clusterID2 := "clusterID-2"
} clusterInfo[clusterID1] = map[string]string{}
err = createCustomConfigMap(f.ClientSet, cephFSDirPath, subvolgrpInfo) clusterInfo[clusterID1]["subvolumeGroup"] = "subvolgrp1"
clusterInfo[clusterID2] = map[string]string{}
clusterInfo[clusterID2]["subvolumeGroup"] = "subvolgrp2"
err = createCustomConfigMap(f.ClientSet, cephFSDirPath, clusterInfo)
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)
} }

View File

@ -76,7 +76,10 @@ func createConfigMap(pluginPath string, c kubernetes.Interface, f *framework.Fra
} }
// createCustomConfigMap provides multiple clusters information. // createCustomConfigMap provides multiple clusters information.
func createCustomConfigMap(c kubernetes.Interface, pluginPath string, subvolgrpInfo map[string]string) error { func createCustomConfigMap(
c kubernetes.Interface,
pluginPath string,
clusterInfo map[string]map[string]string) error {
path := pluginPath + configMap path := pluginPath + configMap
cm := v1.ConfigMap{} cm := v1.ConfigMap{}
err := unmarshal(path, &cm) err := unmarshal(path, &cm)
@ -90,7 +93,7 @@ func createCustomConfigMap(c kubernetes.Interface, pluginPath string, subvolgrpI
} }
// get clusterIDs // get clusterIDs
var clusterID []string var clusterID []string
for key := range subvolgrpInfo { for key := range clusterInfo {
clusterID = append(clusterID, key) clusterID = append(clusterID, key)
} }
conmap := []util.ClusterInfo{ conmap := []util.ClusterInfo{
@ -103,9 +106,27 @@ func createCustomConfigMap(c kubernetes.Interface, pluginPath string, subvolgrpI
Monitors: mons, Monitors: mons,
}, },
} }
for i := 0; i < len(subvolgrpInfo); i++ {
conmap[i].CephFS.SubvolumeGroup = subvolgrpInfo[clusterID[i]] // fill radosNamespace and subvolgroups
for cluster, confItems := range clusterInfo {
for i, j := range confItems {
switch i {
case "subvolumeGroup":
for c := range conmap {
if conmap[c].ClusterID == cluster {
conmap[c].CephFS.SubvolumeGroup = j
}
}
case "radosNamespace":
for c := range conmap {
if conmap[c].ClusterID == cluster {
conmap[c].RadosNamespace = j
}
}
}
}
} }
data, err := json.Marshal(conmap) data, err := json.Marshal(conmap)
if err != nil { if err != nil {
return err return err