@@ -51,6 +51,8 @@ type stressTest struct {
51
51
// stop and wait for any async routines
52
52
wg sync.WaitGroup
53
53
stopChs []chan struct {}
54
+
55
+ testOptions StressTestOptions
54
56
}
55
57
56
58
var _ TestSuite = & stressTestSuite {}
@@ -59,8 +61,7 @@ var _ TestSuite = &stressTestSuite{}
59
61
func InitStressTestSuite () TestSuite {
60
62
return & stressTestSuite {
61
63
tsInfo : TestSuiteInfo {
62
- Name : "stress" ,
63
- FeatureTag : "[Feature: VolumeStress]" ,
64
+ Name : "stress" ,
64
65
TestPatterns : []testpatterns.TestPattern {
65
66
testpatterns .DefaultFsDynamicPV ,
66
67
testpatterns .BlockVolModeDynamicPV ,
@@ -84,14 +85,16 @@ func (t *stressTestSuite) DefineTests(driver TestDriver, pattern testpatterns.Te
84
85
85
86
ginkgo .BeforeEach (func () {
86
87
// Check preconditions.
87
- ok := false
88
- _ , ok = driver .(DynamicPVTestDriver )
89
- if ! ok {
90
- e2eskipper .Skipf ("Driver %s doesn't support %v -- skipping" , dInfo .Name , pattern .VolType )
88
+ if dInfo .StressTestOptions == nil {
89
+ e2eskipper .Skipf ("Driver %s doesn't specify stress test options -- skipping" , dInfo .Name )
90
+ }
91
+
92
+ if _ , ok := driver .(DynamicPVTestDriver ); ! ok {
93
+ e2eskipper .Skipf ("Driver %s doesn't implement DynamicPVTestDriver -- skipping" , dInfo .Name )
91
94
}
92
95
93
96
if ! driver .GetDriverInfo ().Capabilities [CapBlock ] && pattern .VolMode == v1 .PersistentVolumeBlock {
94
- e2eskipper .Skipf ("Driver %q does not support block volume mode - skipping" , driver . GetDriverInfo () .Name )
97
+ e2eskipper .Skipf ("Driver %q does not support block volume mode - skipping" , dInfo .Name )
95
98
}
96
99
})
97
100
@@ -111,6 +114,7 @@ func (t *stressTestSuite) DefineTests(driver TestDriver, pattern testpatterns.Te
111
114
l .resources = []* VolumeResource {}
112
115
l .pods = []* v1.Pod {}
113
116
l .stopChs = []chan struct {}{}
117
+ l .testOptions = * dInfo .StressTestOptions
114
118
115
119
return l
116
120
}
@@ -140,43 +144,43 @@ func (t *stressTestSuite) DefineTests(driver TestDriver, pattern testpatterns.Te
140
144
}
141
145
142
146
ginkgo .It ("multiple pods should access different volumes repeatedly [Slow] [Serial]" , func () {
143
- const (
144
- numPods = 10
145
- // number of times each Pod should start
146
- numPodStarts = 10
147
- )
148
-
149
147
var err error
150
148
151
149
l := init ()
152
150
defer func () {
153
151
cleanup (l )
154
152
}()
155
153
156
- for i := 0 ; i < numPods ; i ++ {
157
- framework .Logf ("Creating resources for pod %v/%v" , i , numPods )
154
+ for i := 0 ; i < l . testOptions . NumPods ; i ++ {
155
+ framework .Logf ("Creating resources for pod %v/%v" , i , l . testOptions . NumPods - 1 )
158
156
r := CreateVolumeResource (driver , l .config , pattern , t .GetTestSuiteInfo ().SupportedSizeRange )
159
157
l .resources = append (l .resources , r )
160
- l .pods = append (l .pods , e2epod .MakeSecPod (f .Namespace .Name ,
161
- []* v1.PersistentVolumeClaim {r .Pvc },
162
- nil , false , "" , false , false , e2epv .SELinuxLabel , nil ))
158
+ podConfig := e2epod.Config {
159
+ NS : f .Namespace .Name ,
160
+ PVCs : []* v1.PersistentVolumeClaim {r .Pvc },
161
+ SeLinuxLabel : e2epv .SELinuxLabel ,
162
+ }
163
+ pod , err := e2epod .MakeSecPod (& podConfig )
164
+ framework .ExpectNoError (err )
165
+
166
+ l .pods = append (l .pods , pod )
163
167
l .stopChs = append (l .stopChs , make (chan struct {}))
164
168
}
165
169
166
170
// Restart pod repeatedly
167
- for i := 0 ; i < numPods ; i ++ {
171
+ for i := 0 ; i < l . testOptions . NumPods ; i ++ {
168
172
podIndex := i
169
173
l .wg .Add (1 )
170
174
go func () {
171
175
defer ginkgo .GinkgoRecover ()
172
176
defer l .wg .Done ()
173
- for j := 0 ; j < numPodStarts ; j ++ {
177
+ for j := 0 ; j < l . testOptions . NumRestarts ; j ++ {
174
178
select {
175
179
case <- l .stopChs [podIndex ]:
176
180
return
177
181
default :
178
182
pod := l .pods [podIndex ]
179
- framework .Logf ("Pod %v, Iteration %v/%v" , podIndex , j , numPodStarts )
183
+ framework .Logf ("Pod %v, Iteration %v/%v" , podIndex , j , l . testOptions . NumRestarts - 1 )
180
184
_ , err = cs .CoreV1 ().Pods (pod .Namespace ).Create (context .TODO (), pod , metav1.CreateOptions {})
181
185
framework .ExpectNoError (err )
182
186
0 commit comments