Skip to content
Merged
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
1 change: 1 addition & 0 deletions cmd/csi-sanity/sanity_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ func init() {
flag.StringVar(&config.StagingPath, prefix+"stagingdir", os.TempDir()+"/csi", "Mount point for NodeStage if staging is supported")
flag.StringVar(&config.SecretsFile, prefix+"secrets", "", "CSI secrets file")
flag.Int64Var(&config.TestVolumeSize, prefix+"testvolumesize", sanity.DefTestVolumeSize, "Base volume size used for provisioned volumes")
flag.StringVar(&config.TestVolumeParametersFile, prefix+"testvolumeparameters", "", "YAML file of volume parameters for provisioned volumes")
flag.Parse()
}

Expand Down
16 changes: 16 additions & 0 deletions pkg/sanity/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ var _ = DescribeSanity("Controller Service", func(sc *SanityContext) {
context.Background(),
&csi.CreateVolumeRequest{
ControllerCreateSecrets: sc.Secrets.CreateVolumeSecret,
Parameters: sc.Config.TestVolumeParameters,
},
)
cl.MaybeRegisterVolume("", vol, err)
Expand All @@ -202,6 +203,7 @@ var _ = DescribeSanity("Controller Service", func(sc *SanityContext) {
&csi.CreateVolumeRequest{
Name: name,
ControllerCreateSecrets: sc.Secrets.CreateVolumeSecret,
Parameters: sc.Config.TestVolumeParameters,
},
)
cl.MaybeRegisterVolume(name, vol, err)
Expand Down Expand Up @@ -232,6 +234,7 @@ var _ = DescribeSanity("Controller Service", func(sc *SanityContext) {
},
},
ControllerCreateSecrets: sc.Secrets.CreateVolumeSecret,
Parameters: sc.Config.TestVolumeParameters,
},
)
Expect(err).NotTo(HaveOccurred())
Expand Down Expand Up @@ -276,6 +279,7 @@ var _ = DescribeSanity("Controller Service", func(sc *SanityContext) {
RequiredBytes: TestVolumeSize(sc),
},
ControllerCreateSecrets: sc.Secrets.CreateVolumeSecret,
Parameters: sc.Config.TestVolumeParameters,
},
)
if serverError, ok := status.FromError(err); ok &&
Expand Down Expand Up @@ -325,6 +329,7 @@ var _ = DescribeSanity("Controller Service", func(sc *SanityContext) {
RequiredBytes: size,
},
ControllerCreateSecrets: sc.Secrets.CreateVolumeSecret,
Parameters: sc.Config.TestVolumeParameters,
},
)
Expect(err).NotTo(HaveOccurred())
Expand Down Expand Up @@ -352,6 +357,7 @@ var _ = DescribeSanity("Controller Service", func(sc *SanityContext) {
RequiredBytes: size,
},
ControllerCreateSecrets: sc.Secrets.CreateVolumeSecret,
Parameters: sc.Config.TestVolumeParameters,
},
)
Expect(err).NotTo(HaveOccurred())
Expand Down Expand Up @@ -398,6 +404,7 @@ var _ = DescribeSanity("Controller Service", func(sc *SanityContext) {
LimitBytes: size1,
},
ControllerCreateSecrets: sc.Secrets.CreateVolumeSecret,
Parameters: sc.Config.TestVolumeParameters,
},
)
Expect(err).ToNot(HaveOccurred())
Expand Down Expand Up @@ -426,6 +433,7 @@ var _ = DescribeSanity("Controller Service", func(sc *SanityContext) {
LimitBytes: size2,
},
ControllerCreateSecrets: sc.Secrets.CreateVolumeSecret,
Parameters: sc.Config.TestVolumeParameters,
},
)
Expect(err).To(HaveOccurred())
Expand Down Expand Up @@ -474,6 +482,7 @@ var _ = DescribeSanity("Controller Service", func(sc *SanityContext) {
RequiredBytes: size,
},
ControllerCreateSecrets: sc.Secrets.CreateVolumeSecret,
Parameters: sc.Config.TestVolumeParameters,
},
)
Expect(err).NotTo(HaveOccurred())
Expand Down Expand Up @@ -552,6 +561,7 @@ var _ = DescribeSanity("Controller Service", func(sc *SanityContext) {
},
},
ControllerCreateSecrets: sc.Secrets.CreateVolumeSecret,
Parameters: sc.Config.TestVolumeParameters,
},
)
Expect(err).NotTo(HaveOccurred())
Expand Down Expand Up @@ -623,6 +633,7 @@ var _ = DescribeSanity("Controller Service", func(sc *SanityContext) {
},
},
ControllerCreateSecrets: sc.Secrets.CreateVolumeSecret,
Parameters: sc.Config.TestVolumeParameters,
},
)
Expect(err).NotTo(HaveOccurred())
Expand Down Expand Up @@ -767,6 +778,7 @@ var _ = DescribeSanity("Controller Service", func(sc *SanityContext) {
},
},
ControllerCreateSecrets: sc.Secrets.CreateVolumeSecret,
Parameters: sc.Config.TestVolumeParameters,
},
)
Expect(err).NotTo(HaveOccurred())
Expand Down Expand Up @@ -884,6 +896,7 @@ var _ = DescribeSanity("Controller Service", func(sc *SanityContext) {
},
},
ControllerCreateSecrets: sc.Secrets.CreateVolumeSecret,
Parameters: sc.Config.TestVolumeParameters,
},
)
Expect(err).NotTo(HaveOccurred())
Expand Down Expand Up @@ -953,6 +966,7 @@ var _ = DescribeSanity("Controller Service", func(sc *SanityContext) {
},
},
ControllerCreateSecrets: sc.Secrets.CreateVolumeSecret,
Parameters: sc.Config.TestVolumeParameters,
},
)
Expect(err).NotTo(HaveOccurred())
Expand Down Expand Up @@ -1074,6 +1088,7 @@ var _ = DescribeSanity("Controller Service", func(sc *SanityContext) {
},
},
ControllerCreateSecrets: sc.Secrets.CreateVolumeSecret,
Parameters: sc.Config.TestVolumeParameters,
},
)
Expect(err).NotTo(HaveOccurred())
Expand Down Expand Up @@ -1628,6 +1643,7 @@ func MakeCreateVolumeReq(sc *SanityContext, name string) *csi.CreateVolumeReques
RequiredBytes: size1,
LimitBytes: size1,
},
Parameters: sc.Config.TestVolumeParameters,
}

if sc.Secrets != nil {
Expand Down
25 changes: 20 additions & 5 deletions pkg/sanity/sanity.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,14 @@ type CSISecrets struct {
// Config provides the configuration for the sanity tests. It
// needs to be initialized by the user of the sanity package.
type Config struct {
TargetPath string
StagingPath string
Address string
SecretsFile string
TestVolumeSize int64
TargetPath string
StagingPath string
Address string
SecretsFile string

TestVolumeSize int64
TestVolumeParametersFile string
TestVolumeParameters map[string]string
}

// SanityContext holds the variables that each test can depend on. It
Expand All @@ -67,6 +70,18 @@ type SanityContext struct {
// Test will test the CSI driver at the specified address by
// setting up a Ginkgo suite and running it.
func Test(t *testing.T, reqConfig *Config) {
path := reqConfig.TestVolumeParametersFile
if len(path) != 0 {
yamlFile, err := ioutil.ReadFile(path)
if err != nil {
panic(fmt.Sprintf("failed to read file %q: %v", path, err))
}
err = yaml.Unmarshal(yamlFile, &reqConfig.TestVolumeParameters)
if err != nil {
panic(fmt.Sprintf("error unmarshaling yaml: %v", err))
}
}

sc := &SanityContext{
Config: reqConfig,
}
Expand Down