diff --git a/cmd/csi-sanity/main.go b/cmd/csi-sanity/main.go index 637af49b..cdf9d15c 100644 --- a/cmd/csi-sanity/main.go +++ b/cmd/csi-sanity/main.go @@ -90,6 +90,7 @@ func main() { stringVar(&config.TestVolumeParametersFile, "testvolumeparameters", "YAML file of volume parameters for provisioned volumes") stringVar(&config.TestVolumeMutableParametersFile, "testvolumemutableparameters", "YAML file of mutable parameters for modifying volumes") stringVar(&config.TestSnapshotParametersFile, "testsnapshotparameters", "YAML file of snapshot parameters for provisioned snapshots") + stringVar(&config.TestTopologyRequirementsFile, "testtopologyrequirements", "YAML file of topology requirements for provisioned volumes") boolVar(&config.TestNodeVolumeAttachLimit, "testnodevolumeattachlimit", "Test node volume attach limit") flag.Var(flag.Lookup("ginkgo.junit-report").Value, prefix+"junitfile", "JUnit XML output file where test results will be written (deprecated: use ginkgo.junit-report instead)") diff --git a/pkg/sanity/controller.go b/pkg/sanity/controller.go index 60c37774..febb9d6a 100644 --- a/pkg/sanity/controller.go +++ b/pkg/sanity/controller.go @@ -1504,6 +1504,10 @@ func MakeCreateVolumeReq(sc *TestContext, name string) *csi.CreateVolumeRequest Parameters: sc.Config.TestVolumeParameters, } + if sc.Config.TestTopologyRequirements != nil { + req.AccessibilityRequirements = sc.Config.TestTopologyRequirements + } + if sc.Secrets != nil { req.Secrets = sc.Secrets.CreateVolumeSecret } diff --git a/pkg/sanity/sanity.go b/pkg/sanity/sanity.go index b57d76dc..54e29534 100644 --- a/pkg/sanity/sanity.go +++ b/pkg/sanity/sanity.go @@ -26,6 +26,7 @@ import ( "strings" "time" + "github.com/container-storage-interface/spec/lib/go/csi" "github.com/kubernetes-csi/csi-test/v5/utils" yaml "gopkg.in/yaml.v2" @@ -106,6 +107,10 @@ type TestConfig struct { TestVolumeMutableParametersFile string TestVolumeMutableParameters map[string]string + // TestTopologyRequirementsFile for setting CreateVolumeRequest.AccessibilityRequirements. + TestTopologyRequirementsFile string + TestTopologyRequirements *csi.TopologyRequirement + // Callback functions to customize the creation of target and staging // directories. Returns the new paths for mount and staging. // If not defined, directories are created in the default way at TargetPath @@ -252,6 +257,8 @@ func (sc *TestContext) Setup() { loadFromFile(sc.Config.TestSnapshotParametersFile, &sc.Config.TestSnapshotParameters) // Get VolumeAttributeClass parameters from TestVolumeMutableParametersFile loadFromFile(sc.Config.TestVolumeMutableParametersFile, &sc.Config.TestVolumeMutableParameters) + // Get TopologyRequirement parameters from TestTopologyRequirementsFile + loadFromFile(sc.Config.TestTopologyRequirementsFile, &sc.Config.TestTopologyRequirements) if len(sc.Config.SecretsFile) > 0 { sc.Secrets, err = loadSecrets(sc.Config.SecretsFile)