Skip to content

Commit 7fe873b

Browse files
authored
[manila-csi-plugin] Allow manila e2e testing with DHSS=true (#3045)
When using manila DHSS=true the network needs to be specified to allow using/creating the share. To allow e2e testing in a DHSS=true env I added an option to specify network via an environment variable keeping backward compatibility while allowing testing with DHSS=true
1 parent e862efc commit 7fe873b

File tree

2 files changed

+27
-4
lines changed

2 files changed

+27
-4
lines changed

tests/e2e/csi/manila/manilavolume.go

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package test
33
import (
44
"bytes"
55
"context"
6+
"os"
67
"os/exec"
78
"strconv"
89
"strings"
@@ -13,6 +14,10 @@ import (
1314
storageframework "k8s.io/kubernetes/test/e2e/storage/framework"
1415
)
1516

17+
// Environment variable for DHSS=True mode share network.
18+
// This must match the variable in testdriver.go.
19+
var manilaShareNetworkIDForVolume = os.Getenv("MANILA_SHARE_NETWORK_ID")
20+
1621
func runCmd(name string, args ...string) ([]byte, error) {
1722
var stdout, stderr bytes.Buffer
1823
cmd := exec.Command(name, args...)
@@ -47,9 +52,8 @@ func manilaCreateVolume(
4752
ginkgo.By("Creating a test Manila volume externally")
4853

4954
// Create share.
50-
51-
out, err := runCmd(
52-
"openstack",
55+
// Build command arguments, optionally including share network for DHSS=True mode.
56+
args := []string{
5357
"share",
5458
"create",
5559
shareProto,
@@ -58,7 +62,14 @@ func manilaCreateVolume(
5862
"--format=value",
5963
"--column=id",
6064
"--wait",
61-
)
65+
}
66+
67+
// Support for DHSS=True mode: include share network ID if specified
68+
if manilaShareNetworkIDForVolume != "" {
69+
args = append(args, "--share-network="+manilaShareNetworkIDForVolume)
70+
}
71+
72+
out, err := runCmd("openstack", args...)
6273

6374
shareID := strings.TrimSpace(string(out))
6475

tests/e2e/csi/manila/testdriver.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package test
33
import (
44
"context"
55
"fmt"
6+
"os"
67

78
"github.com/onsi/gomega"
89
v1 "k8s.io/api/core/v1"
@@ -30,6 +31,12 @@ const (
3031
manilaShareSizeGiB = 1
3132
)
3233

34+
// Environment variables for DHSS=True (driver_handles_share_servers) mode.
35+
// Set MANILA_SHARE_NETWORK_ID to enable testing with share networks.
36+
var (
37+
manilaShareNetworkID = os.Getenv("MANILA_SHARE_NETWORK_ID")
38+
)
39+
3340
type manilaTestDriver struct {
3441
driverInfo storageframework.DriverInfo
3542
volumeAttributes []map[string]string
@@ -129,6 +136,11 @@ func (d *manilaTestDriver) GetDynamicProvisionStorageClass(ctx context.Context,
129136
"csi.storage.k8s.io/node-publish-secret-namespace": manilaSecretNamespace,
130137
}
131138

139+
// Support for DHSS=True mode: include share network ID if specified
140+
if manilaShareNetworkID != "" {
141+
parameters["shareNetworkID"] = manilaShareNetworkID
142+
}
143+
132144
sc := storageframework.GetStorageClass(
133145
d.driverInfo.Name,
134146
parameters,

0 commit comments

Comments
 (0)