e2e: use ResourceDeployer for RBD

Signed-off-by: Niels de Vos <ndevos@redhat.com>
This commit is contained in:
Niels de Vos 2022-04-15 16:27:35 +02:00 committed by mergify[bot]
parent 60442fa916
commit e3d061075c

View File

@ -20,7 +20,6 @@ import (
"context" "context"
"errors" "errors"
"fmt" "fmt"
"os"
"strings" "strings"
"time" "time"
@ -131,89 +130,49 @@ func deleteRBDPlugin() {
} }
func createORDeleteRbdResources(action kubectlAction) { func createORDeleteRbdResources(action kubectlAction) {
csiDriver, err := os.ReadFile(rbdDirPath + csiDriverObject) resources := []ResourceDeployer{
if err != nil { &yamlResource{
// createORDeleteRbdResources is used for upgrade testing as csidriverObject is filename: rbdDirPath + csiDriverObject,
// newly added, discarding file not found error. allowMissing: true,
if !os.IsNotExist(err) { },
e2elog.Failf("failed to read content from %s: %v", rbdDirPath+csiDriverObject, err) &yamlResource{
} filename: examplePath + cephConfconfigMap,
} else { allowMissing: true,
err = retryKubectlInput(cephCSINamespace, action, string(csiDriver), deployTimeout) },
if err != nil { &yamlResourceNamespaced{
e2elog.Failf("failed to %s CSIDriver object: %v", action, err) filename: rbdDirPath + rbdProvisioner,
} namespace: cephCSINamespace,
} oneReplica: true,
cephConf, err := os.ReadFile(examplePath + cephConfconfigMap) enableTopology: true,
if err != nil { },
// createORDeleteRbdResources is used for upgrade testing as cephConf Configmap is &yamlResourceNamespaced{
// newly added, discarding file not found error. filename: rbdDirPath + rbdProvisionerRBAC,
if !os.IsNotExist(err) { namespace: cephCSINamespace,
e2elog.Failf("failed to read content from %s: %v", examplePath+cephConfconfigMap, err) },
} &yamlResourceNamespaced{
} else { filename: rbdDirPath + rbdProvisionerPSP,
err = retryKubectlInput(cephCSINamespace, action, string(cephConf), deployTimeout) namespace: cephCSINamespace,
if err != nil { },
e2elog.Failf("failed to %s ceph-conf configmap object: %v", action, err) &yamlResourceNamespaced{
} filename: rbdDirPath + rbdNodePlugin,
} namespace: cephCSINamespace,
data, err := replaceNamespaceInTemplate(rbdDirPath + rbdProvisioner) domainLabel: nodeRegionLabel + "," + nodeZoneLabel,
if err != nil { },
e2elog.Failf("failed to read content from %s: %v", rbdDirPath+rbdProvisioner, err) &yamlResourceNamespaced{
} filename: rbdDirPath + rbdNodePluginRBAC,
data = oneReplicaDeployYaml(data) namespace: cephCSINamespace,
data = enableTopologyInTemplate(data) },
err = retryKubectlInput(cephCSINamespace, action, data, deployTimeout) &yamlResourceNamespaced{
if err != nil { filename: rbdDirPath + rbdNodePluginPSP,
e2elog.Failf("failed to %s rbd provisioner: %v", action, err) namespace: cephCSINamespace,
},
} }
data, err = replaceNamespaceInTemplate(rbdDirPath + rbdProvisionerRBAC) for _, r := range resources {
err := r.Do(action)
if err != nil { if err != nil {
e2elog.Failf("failed to read content from %s: %v", rbdDirPath+rbdProvisionerRBAC, err) e2elog.Failf("failed to %s resource: %v", action, err)
} }
err = retryKubectlInput(cephCSINamespace, action, data, deployTimeout)
if err != nil {
e2elog.Failf("failed to %s provisioner rbac: %v", action, err)
}
data, err = replaceNamespaceInTemplate(rbdDirPath + rbdProvisionerPSP)
if err != nil {
e2elog.Failf("failed to read content from %s: %v", rbdDirPath+rbdProvisionerPSP, err)
}
err = retryKubectlInput(cephCSINamespace, action, data, deployTimeout)
if err != nil {
e2elog.Failf("failed to %s provisioner psp: %v", action, err)
}
data, err = replaceNamespaceInTemplate(rbdDirPath + rbdNodePlugin)
if err != nil {
e2elog.Failf("failed to read content from %s: %v", rbdDirPath+rbdNodePlugin, err)
}
domainLabel := nodeRegionLabel + "," + nodeZoneLabel
data = addTopologyDomainsToDSYaml(data, domainLabel)
err = retryKubectlInput(cephCSINamespace, action, data, deployTimeout)
if err != nil {
e2elog.Failf("failed to %s nodeplugin: %v", action, err)
}
data, err = replaceNamespaceInTemplate(rbdDirPath + rbdNodePluginRBAC)
if err != nil {
e2elog.Failf("failed to read content from %s: %v", rbdDirPath+rbdNodePluginRBAC, err)
}
err = retryKubectlInput(cephCSINamespace, action, data, deployTimeout)
if err != nil {
e2elog.Failf("failed to %s nodeplugin rbac: %v", action, err)
}
data, err = replaceNamespaceInTemplate(rbdDirPath + rbdNodePluginPSP)
if err != nil {
e2elog.Failf("failed to read content from %s: %v", rbdDirPath+rbdNodePluginPSP, err)
}
err = retryKubectlInput(cephCSINamespace, action, data, deployTimeout)
if err != nil {
e2elog.Failf("failed to %s nodeplugin psp: %v", action, err)
} }
} }