Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

e2e: ceph-csi-operator deployment support #4947

Draft
wants to merge 4 commits into
base: devel
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 16 additions & 4 deletions e2e/cephfs.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ var (
subvolumegroup = "e2e"
fileSystemName = "myfs"
fileSystemPoolName = "myfs-replicated"

operatorCephFSDeploymentName = "cephfs.csi.ceph.com-ctrlplugin"
operatorCephFSDaemonsetName = "cephfs.csi.ceph.com-nodeplugin"
)

func deployCephfsPlugin() {
Expand Down Expand Up @@ -175,6 +178,11 @@ var _ = Describe(cephfsType, func() {
Skip("Skipping CephFS E2E")
}
c = f.ClientSet
if operatorDeployment {
cephFSDeploymentName = operatorCephFSDeploymentName
cephFSDeamonSetName = operatorCephFSDaemonsetName
}

if deployCephFS {
if cephCSINamespace != defaultNs {
err := createNamespace(c, cephCSINamespace)
Expand Down Expand Up @@ -209,11 +217,15 @@ var _ = Describe(cephfsType, func() {
deployVault(f.ClientSet, deployTimeout)

// wait for cluster name update in deployment
containers := []string{cephFSContainerName}
err = waitForContainersArgsUpdate(c, cephCSINamespace, cephFSDeploymentName,
"clustername", defaultClusterName, containers, deployTimeout)
if operatorDeployment {
err = setClusterName(defaultClusterName)
} else {
containers := []string{cephFSContainerName}
err = waitForContainersArgsUpdate(c, cephCSINamespace, cephFSDeploymentName,
"clustername", defaultClusterName, containers, deployTimeout)
}
if err != nil {
framework.Failf("timeout waiting for deployment update %s/%s: %v", cephCSINamespace, cephFSDeploymentName, err)
framework.Failf("timeout waiting for clustername arg update %s/%s: %v", cephCSINamespace, rbdDeploymentName, err)
}

err = createSubvolumegroup(f, fileSystemName, subvolumegroup)
Expand Down
12 changes: 0 additions & 12 deletions e2e/deployment.go
Original file line number Diff line number Diff line change
Expand Up @@ -235,13 +235,9 @@ type yamlResourceNamespaced struct {
filename string
namespace string
domainLabel string
crushLocationLabels string

// set the number of replicas in a Deployment to 1.
oneReplica bool

// enable read affinity support (for RBD)
enableReadAffinity bool
}

func (yrn *yamlResourceNamespaced) Do(action kubectlAction) error {
Expand All @@ -260,14 +256,6 @@ func (yrn *yamlResourceNamespaced) Do(action kubectlAction) error {
data = addTopologyDomainsToDSYaml(data, yrn.domainLabel)
}

if yrn.enableReadAffinity {
data = enableReadAffinityInTemplate(data)
}

if yrn.crushLocationLabels != "" {
data = addCrsuhLocationLabels(data, yrn.crushLocationLabels)
}

err = retryKubectlInput(yrn.namespace, action, data, deployTimeout)
if err != nil {
return fmt.Errorf("failed to %s resource %q in namespace %q: %w", action, yrn.filename, yrn.namespace, err)
Expand Down
1 change: 1 addition & 0 deletions e2e/e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ func init() {
flag.StringVar(&fileSystemName, "filesystem", "myfs", "CephFS filesystem to use")
flag.StringVar(&clusterID, "clusterid", "", "Ceph cluster ID to use (defaults to `ceph fsid` detection)")
flag.StringVar(&nfsDriverName, "nfs-driver", "nfs.csi.ceph.com", "name of the driver for NFS-volumes")
flag.BoolVar(&operatorDeployment, "operator-deployment", false, "test running on deployment via operator")
setDefaultKubeconfig()

// Register framework flags, then handle flags
Expand Down
7 changes: 7 additions & 0 deletions e2e/nfs.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ var (

// FIXME: some tests change the subvolumegroup to "e2e".
defaultSubvolumegroup = "csi"

operatorNFSDeploymentName = "nfs.csi.ceph.com-ctrlplugin"
operatorNFSDaemonsetName = "nfs.csi.ceph.com-nodeplugin"
)

func deployNFSPlugin(f *framework.Framework) {
Expand Down Expand Up @@ -242,6 +245,10 @@ var _ = Describe("nfs", func() {
Skip("Skipping NFS E2E")
}
c = f.ClientSet
if operatorDeployment {
nfsDeploymentName = operatorNFSDeploymentName
nfsDeamonSetName = operatorNFSDaemonsetName
}
if deployNFS {
if cephCSINamespace != defaultNs {
err := createNamespace(c, cephCSINamespace)
Expand Down
62 changes: 62 additions & 0 deletions e2e/operator.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
/*
Copyright 2024 The Ceph-CSI Authors.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package e2e

import (
"fmt"
)

const (
OperatorConfigName = "ceph-csi-operator-config"
OperatorNamespace = "ceph-csi-operator-system"
)

func setEnableMetadata(value bool) error{
command := []string{
"operatorconfigs.csi.ceph.io",
OperatorConfigName,
"--type=merge",
"-p",
fmt.Sprintf(`{"spec": {"driverSpecDefaults": {"enableMetadata": %t}}}`, value),
}

// Patch the operator config
err := retryKubectlArgs(OperatorNamespace, kubectlPatch, deployTimeout, command...)
if err != nil {
return err
}

return nil
}

func setClusterName(value string) error {
command := []string{
"operatorconfigs.csi.ceph.io",
OperatorConfigName,
"--type=merge",
"-p",
fmt.Sprintf(`{"spec": {"driverSpecDefaults": {"clusterName": %s}}}`, value),
}

// Patch the operator config
err := retryKubectlArgs(OperatorNamespace, kubectlPatch, deployTimeout, command...)
if err != nil {
return err
}

return nil
}
59 changes: 40 additions & 19 deletions e2e/rbd.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,10 @@ var (
volSnapNameKey = "csi.storage.k8s.io/volumesnapshot/name"
volSnapNamespaceKey = "csi.storage.k8s.io/volumesnapshot/namespace"
volSnapContentNameKey = "csi.storage.k8s.io/volumesnapshotcontent/name"

operatorRBDDeploymentName = "rbd.csi.ceph.com-ctrlplugin"
operatorRBDDaemonsetName = "rbd.csi.ceph.com-nodeplugin"
rbdPodSelector = fmt.Sprintf("app in (ceph-csi-rbd, %s, %s, %s, %s)", rbdDeploymentName, rbdDaemonsetName, operatorRBDDeploymentName, operatorRBDDaemonsetName)
)

func deployRBDPlugin() {
Expand Down Expand Up @@ -167,11 +171,9 @@ func createORDeleteRbdResources(action kubectlAction) {
},
// the node-plugin itself
&yamlResourceNamespaced{
filename: rbdDirPath + rbdNodePlugin,
namespace: cephCSINamespace,
domainLabel: nodeRegionLabel + "," + nodeZoneLabel,
enableReadAffinity: true,
crushLocationLabels: crushLocationRegionLabel + "," + crushLocationZoneLabel,
filename: rbdDirPath + rbdNodePlugin,
namespace: cephCSINamespace,
domainLabel: nodeRegionLabel + "," + nodeZoneLabel,
},
}

Expand Down Expand Up @@ -274,6 +276,10 @@ var _ = Describe("RBD", func() {
Skip("Skipping RBD E2E")
}
c = f.ClientSet
if operatorDeployment {
rbdDeploymentName = operatorRBDDeploymentName
rbdDaemonsetName = operatorRBDDaemonsetName
}
if deployRBD {
err := addLabelsToNodes(f, map[string]string{
nodeRegionLabel: regionValue,
Expand Down Expand Up @@ -346,11 +352,15 @@ var _ = Describe("RBD", func() {
}

// wait for cluster name update in deployment
containers := []string{"csi-rbdplugin", "csi-rbdplugin-controller"}
err = waitForContainersArgsUpdate(c, cephCSINamespace, rbdDeploymentName,
"clustername", defaultClusterName, containers, deployTimeout)
if operatorDeployment {
err = setClusterName(defaultClusterName)
} else {
containers := []string{"csi-rbdplugin", "csi-rbdplugin-controller"}
err = waitForContainersArgsUpdate(c, cephCSINamespace, rbdDeploymentName,
"clustername", defaultClusterName, containers, deployTimeout)
}
if err != nil {
framework.Failf("timeout waiting for deployment update %s/%s: %v", cephCSINamespace, rbdDeploymentName, err)
framework.Failf("timeout waiting for clustername arg update %s/%s: %v", cephCSINamespace, rbdDeploymentName, err)
}
})

Expand Down Expand Up @@ -2816,7 +2826,11 @@ var _ = Describe("RBD", func() {
validateRBDImageCount(f, 1, defaultRBDPool)
validateOmapCount(f, 1, rbdType, defaultRBDPool, volumesType)
// delete rbd nodeplugin pods
err = deletePodWithLabel("app=csi-rbdplugin", cephCSINamespace, false)
selector, err := getDaemonSetLabelSelector(f, cephCSINamespace, rbdDaemonsetName)
if err != nil {
framework.Failf("failed to get the labels: %v", err)
}
err = deletePodWithLabel(selector, cephCSINamespace, false)
if err != nil {
framework.Failf("fail to delete pod: %v", err)
}
Expand Down Expand Up @@ -3783,8 +3797,7 @@ var _ = Describe("RBD", func() {
framework.Failf("failed to create rados namespace: %v", err)
}
// delete csi pods
err = deletePodWithLabel("app in (ceph-csi-rbd, csi-rbdplugin, csi-rbdplugin-provisioner)",
cephCSINamespace, false)
err = deletePodWithLabel(rbdPodSelector, cephCSINamespace, false)
if err != nil {
framework.Failf("failed to delete pods with labels: %v", err)
}
Expand Down Expand Up @@ -4602,10 +4615,14 @@ var _ = Describe("RBD", func() {

// wait for cluster name update in deployment
containers := []string{"csi-rbdplugin", "csi-rbdplugin-controller"}
err = waitForContainersArgsUpdate(c, cephCSINamespace, rbdDeploymentName,
"setmetadata", "false", containers, deployTimeout)
if operatorDeployment {
err = setEnableMetadata(false)
} else {
err = waitForContainersArgsUpdate(c, cephCSINamespace, rbdDeploymentName,
"setmetadata", "false", containers, deployTimeout)
}
if err != nil {
framework.Failf("timeout waiting for deployment update %s/%s: %v", cephCSINamespace, rbdDeploymentName, err)
framework.Failf("failed to update setmetadata arg in %s/%s: %v", cephCSINamespace, rbdDeploymentName, err)
}
pvcSmartClone, err := loadPVC(pvcSmartClonePath)
if err != nil {
Expand Down Expand Up @@ -4705,11 +4722,15 @@ var _ = Describe("RBD", func() {
validateRBDImageCount(f, 0, defaultRBDPool)
validateOmapCount(f, 0, rbdType, defaultRBDPool, volumesType)
validateOmapCount(f, 0, rbdType, defaultRBDPool, snapsType)
// wait for cluster name update in deployment
err = waitForContainersArgsUpdate(c, cephCSINamespace, rbdDeploymentName,
"setmetadata", "true", containers, deployTimeout)
if operatorDeployment {
err = setEnableMetadata(true)
} else {
// wait for cluster name update in deployment
err = waitForContainersArgsUpdate(c, cephCSINamespace, rbdDeploymentName,
"setmetadata", "true", containers, deployTimeout)
}
if err != nil {
framework.Failf("timeout waiting for deployment update %s/%s: %v", cephCSINamespace, rbdDeploymentName, err)
framework.Failf("failed to update setmetadata arg in %s/%s: %v", cephCSINamespace, rbdDeploymentName, err)
}
})

Expand Down
43 changes: 23 additions & 20 deletions e2e/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,26 +80,27 @@ const (

var (
// cli flags.
deployTimeout int
deployCephFS bool
deployRBD bool
deployNFS bool
testCephFS bool
testCephFSFscrypt bool
testRBD bool
testRBDFSCrypt bool
testNBD bool
testNFS bool
helmTest bool
upgradeTesting bool
upgradeVersion string
cephCSINamespace string
rookNamespace string
radosNamespace string
poll = 2 * time.Second
isOpenShift bool
clusterID string
nfsDriverName string
deployTimeout int
deployCephFS bool
deployRBD bool
deployNFS bool
testCephFS bool
testCephFSFscrypt bool
testRBD bool
testRBDFSCrypt bool
testNBD bool
testNFS bool
helmTest bool
upgradeTesting bool
upgradeVersion string
cephCSINamespace string
rookNamespace string
radosNamespace string
poll = 2 * time.Second
isOpenShift bool
clusterID string
nfsDriverName string
operatorDeployment bool
)

type cephfsFilesystem struct {
Expand Down Expand Up @@ -1620,6 +1621,8 @@ const (
kubectlCreate = kubectlAction("create")
// kubectlDelete tells retryKubectlInput() to run "delete".
kubectlDelete = kubectlAction("delete")
// kubectlPatch tells retryKubectlInput() to run "patch".
kubectlPatch = kubectlAction("patch")
)

// String returns the string format of the kubectlAction, this is automatically
Expand Down
Loading
Loading