From 60442fa916d5a901014ddd44f51561e2fd7d0bbe Mon Sep 17 00:00:00 2001 From: Niels de Vos Date: Fri, 15 Apr 2022 16:27:28 +0200 Subject: [PATCH] e2e: use ResourceDeployer for CephFS Signed-off-by: Niels de Vos --- e2e/cephfs.go | 117 +++++++++++++++++--------------------------------- 1 file changed, 39 insertions(+), 78 deletions(-) diff --git a/e2e/cephfs.go b/e2e/cephfs.go index 18dcffced..c55fead11 100644 --- a/e2e/cephfs.go +++ b/e2e/cephfs.go @@ -19,7 +19,6 @@ package e2e import ( "context" "fmt" - "os" "strings" "sync" @@ -69,86 +68,48 @@ func deleteCephfsPlugin() { } func createORDeleteCephfsResources(action kubectlAction) { - csiDriver, err := os.ReadFile(cephFSDirPath + csiDriverObject) - if err != nil { - // createORDeleteRbdResources is used for upgrade testing as csidriverObject is - // newly added, discarding file not found error. - if !os.IsNotExist(err) { - e2elog.Failf("failed to read content from %s: %v", cephFSDirPath+csiDriverObject, err) - } - } else { - err = retryKubectlInput(cephCSINamespace, action, string(csiDriver), deployTimeout) + resources := []ResourceDeployer{ + &yamlResource{ + filename: cephFSDirPath + csiDriverObject, + allowMissing: true, + }, + &yamlResource{ + filename: examplePath + cephConfconfigMap, + allowMissing: true, + }, + &yamlResourceNamespaced{ + filename: cephFSDirPath + cephFSProvisioner, + namespace: cephCSINamespace, + oneReplica: true, + }, + &yamlResourceNamespaced{ + filename: cephFSDirPath + cephFSProvisionerRBAC, + namespace: cephCSINamespace, + }, + &yamlResourceNamespaced{ + filename: cephFSDirPath + cephFSProvisionerPSP, + namespace: cephCSINamespace, + }, + &yamlResourceNamespaced{ + filename: cephFSDirPath + cephFSNodePlugin, + namespace: cephCSINamespace, + }, + &yamlResourceNamespaced{ + filename: cephFSDirPath + cephFSNodePluginRBAC, + namespace: cephCSINamespace, + }, + &yamlResourceNamespaced{ + filename: cephFSDirPath + cephFSNodePluginPSP, + namespace: cephCSINamespace, + }, + } + + for _, r := range resources { + err := r.Do(action) if err != nil { - e2elog.Failf("failed to %s CSIDriver object: %v", action, err) + e2elog.Failf("failed to %s resource: %v", action, err) } } - cephConf, err := os.ReadFile(examplePath + cephConfconfigMap) - if err != nil { - // createORDeleteCephfsResources is used for upgrade testing as cephConfConfigmap is - // newly added, discarding file not found error. - if !os.IsNotExist(err) { - e2elog.Failf("failed to read content from %s: %v", examplePath+cephConfconfigMap, err) - } - } else { - err = retryKubectlInput(cephCSINamespace, action, string(cephConf), deployTimeout) - if err != nil { - e2elog.Failf("failed to %s ceph-conf configmap object: %v", action, err) - } - } - data, err := replaceNamespaceInTemplate(cephFSDirPath + cephFSProvisioner) - if err != nil { - e2elog.Failf("failed to read content from %s: %v", cephFSDirPath+cephFSProvisioner, err) - } - data = oneReplicaDeployYaml(data) - err = retryKubectlInput(cephCSINamespace, action, data, deployTimeout) - if err != nil { - e2elog.Failf("failed to %s CephFS provisioner: %v", action, err) - } - data, err = replaceNamespaceInTemplate(cephFSDirPath + cephFSProvisionerRBAC) - - if err != nil { - e2elog.Failf("failed to read content from %s: %v", cephFSDirPath+cephFSProvisionerRBAC, err) - } - err = retryKubectlInput(cephCSINamespace, action, data, deployTimeout) - if err != nil { - e2elog.Failf("failed to %s CephFS provisioner rbac: %v", action, err) - } - - data, err = replaceNamespaceInTemplate(cephFSDirPath + cephFSProvisionerPSP) - if err != nil { - e2elog.Failf("failed to read content from %s: %v", cephFSDirPath+cephFSProvisionerPSP, err) - } - err = retryKubectlInput(cephCSINamespace, action, data, deployTimeout) - if err != nil { - e2elog.Failf("failed to %s CephFS provisioner psp: %v", action, err) - } - - data, err = replaceNamespaceInTemplate(cephFSDirPath + cephFSNodePlugin) - if err != nil { - e2elog.Failf("failed to read content from %s: %v", cephFSDirPath+cephFSNodePlugin, err) - } - err = retryKubectlInput(cephCSINamespace, action, data, deployTimeout) - if err != nil { - e2elog.Failf("failed to %s CephFS nodeplugin: %v", action, err) - } - - data, err = replaceNamespaceInTemplate(cephFSDirPath + cephFSNodePluginRBAC) - if err != nil { - e2elog.Failf("failed to read content from %s: %v", cephFSDirPath+cephFSNodePluginRBAC, err) - } - err = retryKubectlInput(cephCSINamespace, action, data, deployTimeout) - if err != nil { - e2elog.Failf("failed to %s CephFS nodeplugin rbac: %v", action, err) - } - - data, err = replaceNamespaceInTemplate(cephFSDirPath + cephFSNodePluginPSP) - if err != nil { - e2elog.Failf("failed to read content from %s: %v", cephFSDirPath+cephFSNodePluginPSP, err) - } - err = retryKubectlInput(cephCSINamespace, action, data, deployTimeout) - if err != nil { - e2elog.Failf("failed to %s CephFS nodeplugin psp: %v", action, err) - } } func validateSubvolumeCount(f *framework.Framework, count int, fileSystemName, subvolumegroup string) {