Skip to content

Commit 0e15d26

Browse files
authored
Merge pull request kubernetes#86077 from pohly/external-docs
e2e storage: improve instructions for external driver testing
2 parents 4f52cca + 3cc926f commit 0e15d26

File tree

2 files changed

+83
-79
lines changed

2 files changed

+83
-79
lines changed

test/e2e/storage/external/README.md

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,29 @@
11
When a test suite like test/e2e/e2e.test from Kubernetes includes this
2-
package, the -storage.testdriver parameter can be used one or more
2+
package, the `-storage.testdriver` parameter can be used one or more
33
times to enabling testing of a certain pre-installed storage driver.
44

55
The parameter takes as argument the name of a .yaml or .json file. The
6-
filename can be absolute or relative to --repo-root. The content of
6+
filename can be absolute or relative to `--repo-root`. The content of
77
the file is used to populate a struct that defines how to test the
8-
driver. For a full definition of the struct see the external.go file.
8+
driver. For a full definition of the content see:
9+
- `struct driverDefinition` in [external.go](./external.go)
10+
- `struct TestDriver` and the `Cap` capability constants in [testdriver.go](../testsuites/testdriver.go)
911

10-
Here is an example for the CSI hostpath driver:
12+
Here is a minimal example for the CSI hostpath driver:
1113

12-
ShortName: mytest
1314
StorageClass:
1415
FromName: true
1516
SnapshotClass:
1617
FromName: true
1718
DriverInfo:
18-
Name: csi-hostpath
19+
Name: hostpath.csi.k8s.io
1920
Capabilities:
2021
persistence: true
21-
dataSource: true
22-
multipods: true
22+
23+
The `prow.sh` script of the different CSI hostpath driver releases
24+
generates the actual definition that is used during CI testing, for
25+
example in
26+
[v1.2.0](https://github.com/kubernetes-csi/csi-driver-host-path/blob/v1.2.0/release-tools/prow.sh#L748-L763).
2327

2428
Currently there is no checking for unknown fields, i.e. only file
2529
entries that match with struct entries are used and other entries are

test/e2e/storage/external/external.go

Lines changed: 71 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,77 @@ import (
3939
"github.com/onsi/ginkgo"
4040
)
4141

42+
// DriverDefinition needs to be filled in via a .yaml or .json
43+
// file. Its methods then implement the TestDriver interface, using
44+
// nothing but the information in this struct.
45+
type driverDefinition struct {
46+
// DriverInfo is the static information that the storage testsuite
47+
// expects from a test driver. See test/e2e/storage/testsuites/testdriver.go
48+
// for details. The only field with a non-zero default is the list of
49+
// supported file systems (SupportedFsType): it is set so that tests using
50+
// the default file system are enabled.
51+
DriverInfo testsuites.DriverInfo
52+
53+
// StorageClass must be set to enable dynamic provisioning tests.
54+
// The default is to not run those tests.
55+
StorageClass struct {
56+
// FromName set to true enables the usage of a storage
57+
// class with DriverInfo.Name as provisioner and no
58+
// parameters.
59+
FromName bool
60+
61+
// FromFile is used only when FromName is false. It
62+
// loads a storage class from the given .yaml or .json
63+
// file. File names are resolved by the
64+
// framework.testfiles package, which typically means
65+
// that they can be absolute or relative to the test
66+
// suite's --repo-root parameter.
67+
//
68+
// This can be used when the storage class is meant to have
69+
// additional parameters.
70+
FromFile string
71+
}
72+
73+
// SnapshotClass must be set to enable snapshotting tests.
74+
// The default is to not run those tests.
75+
SnapshotClass struct {
76+
// FromName set to true enables the usage of a
77+
// snapshotter class with DriverInfo.Name as provisioner.
78+
FromName bool
79+
80+
// TODO (?): load from file
81+
}
82+
83+
// InlineVolumes defines one or more volumes for use as inline
84+
// ephemeral volumes. At least one such volume has to be
85+
// defined to enable testing of inline ephemeral volumes. If
86+
// a test needs more volumes than defined, some of the defined
87+
// volumes will be used multiple times.
88+
//
89+
// DriverInfo.Name is used as name of the driver in the inline volume.
90+
InlineVolumes []struct {
91+
// Attributes are passed as NodePublishVolumeReq.volume_context.
92+
// Can be empty.
93+
Attributes map[string]string
94+
// Shared defines whether the resulting volume is
95+
// shared between different pods (i.e. changes made
96+
// in one pod are visible in another)
97+
Shared bool
98+
// ReadOnly must be set to true if the driver does not
99+
// support mounting as read/write.
100+
ReadOnly bool
101+
}
102+
103+
// SupportedSizeRange defines the desired size of dynamically
104+
// provisioned volumes.
105+
SupportedSizeRange volume.SizeRange
106+
107+
// ClientNodeName selects a specific node for scheduling test pods.
108+
// Can be left empty. Most drivers should not need this and instead
109+
// use topology to ensure that pods land on the right node(s).
110+
ClientNodeName string
111+
}
112+
42113
// List of testSuites to be executed for each external driver.
43114
var csiTestSuites = []func() testsuites.TestSuite{
44115
testsuites.InitEphemeralTestSuite,
@@ -142,77 +213,6 @@ var _ testsuites.EphemeralTestDriver = &driverDefinition{}
142213
// an implementation.
143214
var _ runtime.Object = &driverDefinition{}
144215

145-
// DriverDefinition needs to be filled in via a .yaml or .json
146-
// file. It's methods then implement the TestDriver interface, using
147-
// nothing but the information in this struct.
148-
type driverDefinition struct {
149-
// DriverInfo is the static information that the storage testsuite
150-
// expects from a test driver. See test/e2e/storage/testsuites/testdriver.go
151-
// for details. The only field with a non-zero default is the list of
152-
// supported file systems (SupportedFsType): it is set so that tests using
153-
// the default file system are enabled.
154-
DriverInfo testsuites.DriverInfo
155-
156-
// StorageClass must be set to enable dynamic provisioning tests.
157-
// The default is to not run those tests.
158-
StorageClass struct {
159-
// FromName set to true enables the usage of a storage
160-
// class with DriverInfo.Name as provisioner and no
161-
// parameters.
162-
FromName bool
163-
164-
// FromFile is used only when FromName is false. It
165-
// loads a storage class from the given .yaml or .json
166-
// file. File names are resolved by the
167-
// framework.testfiles package, which typically means
168-
// that they can be absolute or relative to the test
169-
// suite's --repo-root parameter.
170-
//
171-
// This can be used when the storage class is meant to have
172-
// additional parameters.
173-
FromFile string
174-
}
175-
176-
// SnapshotClass must be set to enable snapshotting tests.
177-
// The default is to not run those tests.
178-
SnapshotClass struct {
179-
// FromName set to true enables the usage of a
180-
// snapshotter class with DriverInfo.Name as provisioner.
181-
FromName bool
182-
183-
// TODO (?): load from file
184-
}
185-
186-
// InlineVolumes defines one or more volumes for use as inline
187-
// ephemeral volumes. At least one such volume has to be
188-
// defined to enable testing of inline ephemeral volumes. If
189-
// a test needs more volumes than defined, some of the defined
190-
// volumes will be used multiple times.
191-
//
192-
// DriverInfo.Name is used as name of the driver in the inline volume.
193-
InlineVolumes []struct {
194-
// Attributes are passed as NodePublishVolumeReq.volume_context.
195-
// Can be empty.
196-
Attributes map[string]string
197-
// Shared defines whether the resulting volume is
198-
// shared between different pods (i.e. changes made
199-
// in one pod are visible in another)
200-
Shared bool
201-
// ReadOnly must be set to true if the driver does not
202-
// support mounting as read/write.
203-
ReadOnly bool
204-
}
205-
206-
// SupportedSizeRange defines the desired size of dynamically
207-
// provisioned volumes.
208-
SupportedSizeRange volume.SizeRange
209-
210-
// ClientNodeName selects a specific node for scheduling test pods.
211-
// Can be left empty. Most drivers should not need this and instead
212-
// use topology to ensure that pods land on the right node(s).
213-
ClientNodeName string
214-
}
215-
216216
func (d *driverDefinition) DeepCopyObject() runtime.Object {
217217
return nil
218218
}

0 commit comments

Comments
 (0)