Skip to content

Commit 6596e20

Browse files
committed
Make stress test parameters configurable
Change-Id: Ia062f3433b6043825a51a54c7c07eb4cdf809631
1 parent e132b77 commit 6596e20

File tree

3 files changed

+40
-21
lines changed

3 files changed

+40
-21
lines changed

test/e2e/storage/drivers/csi.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -426,6 +426,10 @@ func InitGcePDCSIDriver() testsuites.TestDriver {
426426
},
427427
RequiredAccessModes: []v1.PersistentVolumeAccessMode{v1.ReadWriteOnce},
428428
TopologyKeys: []string{GCEPDCSIZoneTopologyKey},
429+
StressTestOptions: &testsuites.StressTestOptions{
430+
NumPods: 10,
431+
NumRestarts: 10,
432+
},
429433
},
430434
}
431435
}

test/e2e/storage/testsuites/stress.go

Lines changed: 25 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ type stressTest struct {
5151
// stop and wait for any async routines
5252
wg sync.WaitGroup
5353
stopChs []chan struct{}
54+
55+
testOptions StressTestOptions
5456
}
5557

5658
var _ TestSuite = &stressTestSuite{}
@@ -59,8 +61,7 @@ var _ TestSuite = &stressTestSuite{}
5961
func InitStressTestSuite() TestSuite {
6062
return &stressTestSuite{
6163
tsInfo: TestSuiteInfo{
62-
Name: "stress",
63-
FeatureTag: "[Feature: VolumeStress]",
64+
Name: "stress",
6465
TestPatterns: []testpatterns.TestPattern{
6566
testpatterns.DefaultFsDynamicPV,
6667
testpatterns.BlockVolModeDynamicPV,
@@ -84,14 +85,16 @@ func (t *stressTestSuite) DefineTests(driver TestDriver, pattern testpatterns.Te
8485

8586
ginkgo.BeforeEach(func() {
8687
// 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)
9194
}
9295

9396
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)
9598
}
9699
})
97100

@@ -111,6 +114,7 @@ func (t *stressTestSuite) DefineTests(driver TestDriver, pattern testpatterns.Te
111114
l.resources = []*VolumeResource{}
112115
l.pods = []*v1.Pod{}
113116
l.stopChs = []chan struct{}{}
117+
l.testOptions = *dInfo.StressTestOptions
114118

115119
return l
116120
}
@@ -140,43 +144,43 @@ func (t *stressTestSuite) DefineTests(driver TestDriver, pattern testpatterns.Te
140144
}
141145

142146
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-
149147
var err error
150148

151149
l := init()
152150
defer func() {
153151
cleanup(l)
154152
}()
155153

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)
158156
r := CreateVolumeResource(driver, l.config, pattern, t.GetTestSuiteInfo().SupportedSizeRange)
159157
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)
163167
l.stopChs = append(l.stopChs, make(chan struct{}))
164168
}
165169

166170
// Restart pod repeatedly
167-
for i := 0; i < numPods; i++ {
171+
for i := 0; i < l.testOptions.NumPods; i++ {
168172
podIndex := i
169173
l.wg.Add(1)
170174
go func() {
171175
defer ginkgo.GinkgoRecover()
172176
defer l.wg.Done()
173-
for j := 0; j < numPodStarts; j++ {
177+
for j := 0; j < l.testOptions.NumRestarts; j++ {
174178
select {
175179
case <-l.stopChs[podIndex]:
176180
return
177181
default:
178182
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)
180184
_, err = cs.CoreV1().Pods(pod.Namespace).Create(context.TODO(), pod, metav1.CreateOptions{})
181185
framework.ExpectNoError(err)
182186

test/e2e/storage/testsuites/testdriver.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,17 @@ type DriverInfo struct {
188188
// Only relevant if TopologyKeys is set. Defaults to 1.
189189
// Example: multi-zonal disk requires at least 2 allowed topologies.
190190
NumAllowedTopologies int
191+
// [Optional] Scale parameters for stress tests.
192+
StressTestOptions *StressTestOptions
193+
}
194+
195+
// StressTestOptions contains parameters used for stress tests.
196+
type StressTestOptions struct {
197+
// Number of pods to create in the test. This may also create
198+
// up to 1 volume per pod.
199+
NumPods int
200+
// Number of times to restart each Pod.
201+
NumRestarts int
191202
}
192203

193204
// PerTestConfig represents parameters that control test execution.

0 commit comments

Comments
 (0)