-
Notifications
You must be signed in to change notification settings - Fork 39.3k
/
testpattern.go
407 lines (368 loc) · 14.5 KB
/
testpattern.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
/*
Copyright 2018 The Kubernetes 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 framework
import (
v1 "k8s.io/api/core/v1"
storagev1 "k8s.io/api/storage/v1"
e2evolume "k8s.io/kubernetes/test/e2e/framework/volume"
)
const (
// MinFileSize represents minimum file size (1 MiB) for testing
MinFileSize = 1 * e2evolume.MiB
// FileSizeSmall represents small file size (1 MiB) for testing
FileSizeSmall = 1 * e2evolume.MiB
// FileSizeMedium represents medium file size (100 MiB) for testing
FileSizeMedium = 100 * e2evolume.MiB
// FileSizeLarge represents large file size (1 GiB) for testing
FileSizeLarge = 1 * e2evolume.GiB
)
// TestVolType represents a volume type to be tested in a TestSuite
type TestVolType string
var (
// InlineVolume represents a volume type that is used inline in volumeSource
InlineVolume TestVolType = "InlineVolume"
// PreprovisionedPV represents a volume type for pre-provisioned Persistent Volume
PreprovisionedPV TestVolType = "PreprovisionedPV"
// DynamicPV represents a volume type for dynamic provisioned Persistent Volume
DynamicPV TestVolType = "DynamicPV"
// CSIInlineVolume represents a volume type that is defined inline and provided by a CSI driver.
CSIInlineVolume TestVolType = "CSIInlineVolume"
// GenericEphemeralVolume represents a volume type that is defined inline and provisioned through a PVC.
GenericEphemeralVolume TestVolType = "GenericEphemeralVolume"
)
// TestSnapshotType represents a snapshot type to be tested in a TestSuite
type TestSnapshotType string
var (
// DynamicCreatedSnapshot represents a snapshot type for dynamic created snapshot
DynamicCreatedSnapshot TestSnapshotType = "DynamicSnapshot"
// PreprovisionedCreatedSnapshot represents a snapshot type for pre-provisioned snapshot
PreprovisionedCreatedSnapshot TestSnapshotType = "PreprovisionedSnapshot"
)
// TestSnapshotDeletionPolicy represents the deletion policy of the snapshot class
type TestSnapshotDeletionPolicy string
var (
// DeleteSnapshot represents delete policy
DeleteSnapshot TestSnapshotDeletionPolicy = "Delete"
// RetainSnapshot represents retain policy
RetainSnapshot TestSnapshotDeletionPolicy = "Retain"
)
func (t TestSnapshotDeletionPolicy) String() string {
return string(t)
}
// TestPattern represents a combination of parameters to be tested in a TestSuite
type TestPattern struct {
Name string // Name of TestPattern
FeatureTag string // featureTag for the TestSuite
VolType TestVolType // Volume type of the volume
FsType string // Fstype of the volume
VolMode v1.PersistentVolumeMode // PersistentVolumeMode of the volume
SnapshotType TestSnapshotType // Snapshot type of the snapshot
SnapshotDeletionPolicy TestSnapshotDeletionPolicy // Deletion policy of the snapshot class
BindingMode storagev1.VolumeBindingMode // VolumeBindingMode of the volume
AllowExpansion bool // AllowVolumeExpansion flag of the StorageClass
}
var (
// Definitions for default fsType
// DefaultFsInlineVolume is TestPattern for "Inline-volume (default fs)"
DefaultFsInlineVolume = TestPattern{
Name: "Inline-volume (default fs)",
VolType: InlineVolume,
}
// DefaultFsCSIEphemeralVolume is TestPattern for "CSI Ephemeral-volume (default fs)"
DefaultFsCSIEphemeralVolume = TestPattern{
Name: "CSI Ephemeral-volume (default fs)",
VolType: CSIInlineVolume,
}
// DefaultFsGenericEphemeralVolume is TestPattern for "Generic Ephemeral-volume (default fs)"
DefaultFsGenericEphemeralVolume = TestPattern{
Name: "Generic Ephemeral-volume (default fs)",
VolType: GenericEphemeralVolume,
AllowExpansion: true,
}
// DefaultFsPreprovisionedPV is TestPattern for "Pre-provisioned PV (default fs)"
DefaultFsPreprovisionedPV = TestPattern{
Name: "Pre-provisioned PV (default fs)",
VolType: PreprovisionedPV,
}
// DefaultFsDynamicPV is TestPattern for "Dynamic PV (default fs)"
DefaultFsDynamicPV = TestPattern{
Name: "Dynamic PV (default fs)",
VolType: DynamicPV,
SnapshotType: DynamicCreatedSnapshot,
SnapshotDeletionPolicy: DeleteSnapshot,
}
// Definitions for ext3
// Ext3InlineVolume is TestPattern for "Inline-volume (ext3)"
Ext3InlineVolume = TestPattern{
Name: "Inline-volume (ext3)",
VolType: InlineVolume,
FsType: "ext3",
}
// Ext3CSIEphemeralVolume is TestPattern for "CSI Ephemeral-volume (ext3)"
Ext3CSIEphemeralVolume = TestPattern{
Name: "CSI Ephemeral-volume (ext3)",
VolType: CSIInlineVolume,
FsType: "ext3",
}
// Ext3GenericEphemeralVolume is TestPattern for "Generic Ephemeral-volume (ext3)"
Ext3GenericEphemeralVolume = TestPattern{
Name: "Generic Ephemeral-volume (ext3)",
VolType: GenericEphemeralVolume,
FsType: "ext3",
}
// Ext3PreprovisionedPV is TestPattern for "Pre-provisioned PV (ext3)"
Ext3PreprovisionedPV = TestPattern{
Name: "Pre-provisioned PV (ext3)",
VolType: PreprovisionedPV,
FsType: "ext3",
}
// Ext3DynamicPV is TestPattern for "Dynamic PV (ext3)"
Ext3DynamicPV = TestPattern{
Name: "Dynamic PV (ext3)",
VolType: DynamicPV,
FsType: "ext3",
}
// Definitions for ext4
// Ext4InlineVolume is TestPattern for "Inline-volume (ext4)"
Ext4InlineVolume = TestPattern{
Name: "Inline-volume (ext4)",
VolType: InlineVolume,
FsType: "ext4",
}
// Ext4CSIEphemeralVolume is TestPattern for "CSI Ephemeral-volume (ext4)"
Ext4CSIEphemeralVolume = TestPattern{
Name: "CSI Ephemeral-volume (ext4)",
VolType: CSIInlineVolume,
FsType: "ext4",
}
// Ext4GenericEphemeralVolume is TestPattern for "Generic Ephemeral-volume (ext4)"
Ext4GenericEphemeralVolume = TestPattern{
Name: "Generic Ephemeral-volume (ext4)",
VolType: GenericEphemeralVolume,
FsType: "ext4",
}
// Ext4PreprovisionedPV is TestPattern for "Pre-provisioned PV (ext4)"
Ext4PreprovisionedPV = TestPattern{
Name: "Pre-provisioned PV (ext4)",
VolType: PreprovisionedPV,
FsType: "ext4",
}
// Ext4DynamicPV is TestPattern for "Dynamic PV (ext4)"
Ext4DynamicPV = TestPattern{
Name: "Dynamic PV (ext4)",
VolType: DynamicPV,
FsType: "ext4",
SnapshotType: DynamicCreatedSnapshot,
SnapshotDeletionPolicy: DeleteSnapshot,
}
// Definitions for xfs
// XfsInlineVolume is TestPattern for "Inline-volume (xfs)"
XfsInlineVolume = TestPattern{
Name: "Inline-volume (xfs)",
VolType: InlineVolume,
FsType: "xfs",
FeatureTag: "[Slow]",
}
// XfsCSIEphemeralVolume is TestPattern for "CSI Ephemeral-volume (xfs)"
XfsCSIEphemeralVolume = TestPattern{
Name: "CSI Ephemeral-volume (xfs)",
VolType: CSIInlineVolume,
FsType: "xfs",
FeatureTag: "[Slow]",
}
// XfsGenericEphemeralVolume is TestPattern for "Generic Ephemeral-volume (xfs)"
XfsGenericEphemeralVolume = TestPattern{
Name: "Generic Ephemeral-volume (xfs)",
VolType: GenericEphemeralVolume,
FsType: "xfs",
FeatureTag: "[Slow]",
}
// XfsPreprovisionedPV is TestPattern for "Pre-provisioned PV (xfs)"
XfsPreprovisionedPV = TestPattern{
Name: "Pre-provisioned PV (xfs)",
VolType: PreprovisionedPV,
FsType: "xfs",
FeatureTag: "[Slow]",
}
// XfsDynamicPV is TestPattern for "Dynamic PV (xfs)"
XfsDynamicPV = TestPattern{
Name: "Dynamic PV (xfs)",
VolType: DynamicPV,
FsType: "xfs",
FeatureTag: "[Slow]",
SnapshotType: DynamicCreatedSnapshot,
SnapshotDeletionPolicy: DeleteSnapshot,
}
// Definitions for ntfs
// NtfsInlineVolume is TestPattern for "Inline-volume (ntfs)"
NtfsInlineVolume = TestPattern{
Name: "Inline-volume (ntfs)",
VolType: InlineVolume,
FsType: "ntfs",
FeatureTag: "[Feature:Windows]",
}
// NtfsCSIEphemeralVolume is TestPattern for "CSI Ephemeral-volume (ntfs)"
NtfsCSIEphemeralVolume = TestPattern{
Name: "CSI Ephemeral-volume (ntfs) [alpha]",
VolType: CSIInlineVolume,
FsType: "ntfs",
FeatureTag: "[Feature:Windows]",
}
// NtfsGenericEphemeralVolume is TestPattern for "Generic Ephemeral-volume (ntfs)"
NtfsGenericEphemeralVolume = TestPattern{
Name: "Generic Ephemeral-volume (ntfs)",
VolType: GenericEphemeralVolume,
FsType: "ntfs",
FeatureTag: "[Feature:Windows]",
}
// NtfsPreprovisionedPV is TestPattern for "Pre-provisioned PV (ntfs)"
NtfsPreprovisionedPV = TestPattern{
Name: "Pre-provisioned PV (ntfs)",
VolType: PreprovisionedPV,
FsType: "ntfs",
FeatureTag: "[Feature:Windows]",
}
// NtfsDynamicPV is TestPattern for "Dynamic PV (ntfs)"
NtfsDynamicPV = TestPattern{
Name: "Dynamic PV (ntfs)",
VolType: DynamicPV,
FsType: "ntfs",
FeatureTag: "[Feature:Windows]",
SnapshotDeletionPolicy: DeleteSnapshot,
SnapshotType: DynamicCreatedSnapshot,
}
// Definitions for Filesystem volume mode
// FsVolModePreprovisionedPV is TestPattern for "Pre-provisioned PV (filesystem)"
FsVolModePreprovisionedPV = TestPattern{
Name: "Pre-provisioned PV (filesystem volmode)",
VolType: PreprovisionedPV,
VolMode: v1.PersistentVolumeFilesystem,
}
// FsVolModeDynamicPV is TestPattern for "Dynamic PV (filesystem)"
FsVolModeDynamicPV = TestPattern{
Name: "Dynamic PV (filesystem volmode)",
VolType: DynamicPV,
VolMode: v1.PersistentVolumeFilesystem,
}
// Definitions for block volume mode
// BlockVolModePreprovisionedPV is TestPattern for "Pre-provisioned PV (block)"
BlockVolModePreprovisionedPV = TestPattern{
Name: "Pre-provisioned PV (block volmode)",
VolType: PreprovisionedPV,
VolMode: v1.PersistentVolumeBlock,
}
// BlockVolModeDynamicPV is TestPattern for "Dynamic PV (block)"
BlockVolModeDynamicPV = TestPattern{
Name: "Dynamic PV (block volmode)",
VolType: DynamicPV,
VolMode: v1.PersistentVolumeBlock,
SnapshotType: DynamicCreatedSnapshot,
SnapshotDeletionPolicy: DeleteSnapshot,
}
// BlockVolModeGenericEphemeralVolume is for generic ephemeral inline volumes in raw block mode.
BlockVolModeGenericEphemeralVolume = TestPattern{
Name: "Generic Ephemeral-volume (block volmode) (late-binding)",
VolType: GenericEphemeralVolume,
VolMode: v1.PersistentVolumeBlock,
BindingMode: storagev1.VolumeBindingWaitForFirstConsumer,
AllowExpansion: true,
}
// Definitions for snapshot case
// DynamicSnapshotDelete is TestPattern for "Dynamic snapshot"
DynamicSnapshotDelete = TestPattern{
Name: "Dynamic Snapshot (delete policy)",
SnapshotType: DynamicCreatedSnapshot,
SnapshotDeletionPolicy: DeleteSnapshot,
VolType: DynamicPV,
}
// PreprovisionedSnapshotDelete is TestPattern for "Pre-provisioned snapshot"
PreprovisionedSnapshotDelete = TestPattern{
Name: "Pre-provisioned Snapshot (delete policy)",
SnapshotType: PreprovisionedCreatedSnapshot,
SnapshotDeletionPolicy: DeleteSnapshot,
VolType: DynamicPV,
}
// EphemeralSnapshotDelete is TestPattern for snapshotting of a generic ephemeral volume
// where snapshots are deleted.
EphemeralSnapshotDelete = TestPattern{
Name: "Ephemeral Snapshot (delete policy)",
SnapshotType: DynamicCreatedSnapshot,
SnapshotDeletionPolicy: DeleteSnapshot,
VolType: GenericEphemeralVolume,
}
// DynamicSnapshotRetain is TestPattern for "Dynamic snapshot"
DynamicSnapshotRetain = TestPattern{
Name: "Dynamic Snapshot (retain policy)",
SnapshotType: DynamicCreatedSnapshot,
SnapshotDeletionPolicy: RetainSnapshot,
VolType: DynamicPV,
}
// PreprovisionedSnapshotRetain is TestPattern for "Pre-provisioned snapshot"
PreprovisionedSnapshotRetain = TestPattern{
Name: "Pre-provisioned Snapshot (retain policy)",
SnapshotType: PreprovisionedCreatedSnapshot,
SnapshotDeletionPolicy: RetainSnapshot,
VolType: DynamicPV,
}
// EphemeralSnapshotDelete is TestPattern for snapshotting of a generic ephemeral volume
// where snapshots are preserved.
EphemeralSnapshotRetain = TestPattern{
Name: "Ephemeral Snapshot (retain policy)",
SnapshotType: DynamicCreatedSnapshot,
SnapshotDeletionPolicy: RetainSnapshot,
VolType: GenericEphemeralVolume,
}
// Definitions for volume expansion case
// DefaultFsDynamicPVAllowExpansion is TestPattern for "Dynamic PV (default fs)(allowExpansion)"
DefaultFsDynamicPVAllowExpansion = TestPattern{
Name: "Dynamic PV (default fs)(allowExpansion)",
VolType: DynamicPV,
AllowExpansion: true,
}
// NtfsDynamicPVAllowExpansion is TestPattern for "Dynamic PV (default fs)(allowExpansion)"
NtfsDynamicPVAllowExpansion = TestPattern{
Name: "Dynamic PV (ntfs)(allowExpansion)",
VolType: DynamicPV,
AllowExpansion: true,
FsType: "ntfs",
FeatureTag: "[Feature:Windows]",
}
// BlockVolModeDynamicPVAllowExpansion is TestPattern for "Dynamic PV (block volmode)(allowExpansion)"
BlockVolModeDynamicPVAllowExpansion = TestPattern{
Name: "Dynamic PV (block volmode)(allowExpansion)",
VolType: DynamicPV,
VolMode: v1.PersistentVolumeBlock,
AllowExpansion: true,
}
// Definitions for topology tests
// TopologyImmediate is TestPattern for immediate binding
TopologyImmediate = TestPattern{
Name: "Dynamic PV (immediate binding)",
VolType: DynamicPV,
BindingMode: storagev1.VolumeBindingImmediate,
}
// TopologyDelayed is TestPattern for delayed binding
TopologyDelayed = TestPattern{
Name: "Dynamic PV (delayed binding)",
VolType: DynamicPV,
BindingMode: storagev1.VolumeBindingWaitForFirstConsumer,
}
)
// NewVolTypeMap creates a map with the given TestVolTypes enabled
func NewVolTypeMap(types ...TestVolType) map[TestVolType]bool {
m := map[TestVolType]bool{}
for _, t := range types {
m[t] = true
}
return m
}