mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-25 12:43:23 +00:00
Make stress test parameters configurable
Change-Id: Ia062f3433b6043825a51a54c7c07eb4cdf809631
This commit is contained in:
parent
e132b77ae4
commit
6596e20b18
@ -426,6 +426,10 @@ func InitGcePDCSIDriver() testsuites.TestDriver {
|
|||||||
},
|
},
|
||||||
RequiredAccessModes: []v1.PersistentVolumeAccessMode{v1.ReadWriteOnce},
|
RequiredAccessModes: []v1.PersistentVolumeAccessMode{v1.ReadWriteOnce},
|
||||||
TopologyKeys: []string{GCEPDCSIZoneTopologyKey},
|
TopologyKeys: []string{GCEPDCSIZoneTopologyKey},
|
||||||
|
StressTestOptions: &testsuites.StressTestOptions{
|
||||||
|
NumPods: 10,
|
||||||
|
NumRestarts: 10,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -51,6 +51,8 @@ type stressTest struct {
|
|||||||
// stop and wait for any async routines
|
// stop and wait for any async routines
|
||||||
wg sync.WaitGroup
|
wg sync.WaitGroup
|
||||||
stopChs []chan struct{}
|
stopChs []chan struct{}
|
||||||
|
|
||||||
|
testOptions StressTestOptions
|
||||||
}
|
}
|
||||||
|
|
||||||
var _ TestSuite = &stressTestSuite{}
|
var _ TestSuite = &stressTestSuite{}
|
||||||
@ -60,7 +62,6 @@ func InitStressTestSuite() TestSuite {
|
|||||||
return &stressTestSuite{
|
return &stressTestSuite{
|
||||||
tsInfo: TestSuiteInfo{
|
tsInfo: TestSuiteInfo{
|
||||||
Name: "stress",
|
Name: "stress",
|
||||||
FeatureTag: "[Feature: VolumeStress]",
|
|
||||||
TestPatterns: []testpatterns.TestPattern{
|
TestPatterns: []testpatterns.TestPattern{
|
||||||
testpatterns.DefaultFsDynamicPV,
|
testpatterns.DefaultFsDynamicPV,
|
||||||
testpatterns.BlockVolModeDynamicPV,
|
testpatterns.BlockVolModeDynamicPV,
|
||||||
@ -84,14 +85,16 @@ func (t *stressTestSuite) DefineTests(driver TestDriver, pattern testpatterns.Te
|
|||||||
|
|
||||||
ginkgo.BeforeEach(func() {
|
ginkgo.BeforeEach(func() {
|
||||||
// Check preconditions.
|
// Check preconditions.
|
||||||
ok := false
|
if dInfo.StressTestOptions == nil {
|
||||||
_, ok = driver.(DynamicPVTestDriver)
|
e2eskipper.Skipf("Driver %s doesn't specify stress test options -- skipping", dInfo.Name)
|
||||||
if !ok {
|
}
|
||||||
e2eskipper.Skipf("Driver %s doesn't support %v -- skipping", dInfo.Name, pattern.VolType)
|
|
||||||
|
if _, ok := driver.(DynamicPVTestDriver); !ok {
|
||||||
|
e2eskipper.Skipf("Driver %s doesn't implement DynamicPVTestDriver -- skipping", dInfo.Name)
|
||||||
}
|
}
|
||||||
|
|
||||||
if !driver.GetDriverInfo().Capabilities[CapBlock] && pattern.VolMode == v1.PersistentVolumeBlock {
|
if !driver.GetDriverInfo().Capabilities[CapBlock] && pattern.VolMode == v1.PersistentVolumeBlock {
|
||||||
e2eskipper.Skipf("Driver %q does not support block volume mode - skipping", driver.GetDriverInfo().Name)
|
e2eskipper.Skipf("Driver %q does not support block volume mode - skipping", dInfo.Name)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -111,6 +114,7 @@ func (t *stressTestSuite) DefineTests(driver TestDriver, pattern testpatterns.Te
|
|||||||
l.resources = []*VolumeResource{}
|
l.resources = []*VolumeResource{}
|
||||||
l.pods = []*v1.Pod{}
|
l.pods = []*v1.Pod{}
|
||||||
l.stopChs = []chan struct{}{}
|
l.stopChs = []chan struct{}{}
|
||||||
|
l.testOptions = *dInfo.StressTestOptions
|
||||||
|
|
||||||
return l
|
return l
|
||||||
}
|
}
|
||||||
@ -140,12 +144,6 @@ func (t *stressTestSuite) DefineTests(driver TestDriver, pattern testpatterns.Te
|
|||||||
}
|
}
|
||||||
|
|
||||||
ginkgo.It("multiple pods should access different volumes repeatedly [Slow] [Serial]", func() {
|
ginkgo.It("multiple pods should access different volumes repeatedly [Slow] [Serial]", func() {
|
||||||
const (
|
|
||||||
numPods = 10
|
|
||||||
// number of times each Pod should start
|
|
||||||
numPodStarts = 10
|
|
||||||
)
|
|
||||||
|
|
||||||
var err error
|
var err error
|
||||||
|
|
||||||
l := init()
|
l := init()
|
||||||
@ -153,30 +151,36 @@ func (t *stressTestSuite) DefineTests(driver TestDriver, pattern testpatterns.Te
|
|||||||
cleanup(l)
|
cleanup(l)
|
||||||
}()
|
}()
|
||||||
|
|
||||||
for i := 0; i < numPods; i++ {
|
for i := 0; i < l.testOptions.NumPods; i++ {
|
||||||
framework.Logf("Creating resources for pod %v/%v", i, numPods)
|
framework.Logf("Creating resources for pod %v/%v", i, l.testOptions.NumPods-1)
|
||||||
r := CreateVolumeResource(driver, l.config, pattern, t.GetTestSuiteInfo().SupportedSizeRange)
|
r := CreateVolumeResource(driver, l.config, pattern, t.GetTestSuiteInfo().SupportedSizeRange)
|
||||||
l.resources = append(l.resources, r)
|
l.resources = append(l.resources, r)
|
||||||
l.pods = append(l.pods, e2epod.MakeSecPod(f.Namespace.Name,
|
podConfig := e2epod.Config{
|
||||||
[]*v1.PersistentVolumeClaim{r.Pvc},
|
NS: f.Namespace.Name,
|
||||||
nil, false, "", false, false, e2epv.SELinuxLabel, nil))
|
PVCs: []*v1.PersistentVolumeClaim{r.Pvc},
|
||||||
|
SeLinuxLabel: e2epv.SELinuxLabel,
|
||||||
|
}
|
||||||
|
pod, err := e2epod.MakeSecPod(&podConfig)
|
||||||
|
framework.ExpectNoError(err)
|
||||||
|
|
||||||
|
l.pods = append(l.pods, pod)
|
||||||
l.stopChs = append(l.stopChs, make(chan struct{}))
|
l.stopChs = append(l.stopChs, make(chan struct{}))
|
||||||
}
|
}
|
||||||
|
|
||||||
// Restart pod repeatedly
|
// Restart pod repeatedly
|
||||||
for i := 0; i < numPods; i++ {
|
for i := 0; i < l.testOptions.NumPods; i++ {
|
||||||
podIndex := i
|
podIndex := i
|
||||||
l.wg.Add(1)
|
l.wg.Add(1)
|
||||||
go func() {
|
go func() {
|
||||||
defer ginkgo.GinkgoRecover()
|
defer ginkgo.GinkgoRecover()
|
||||||
defer l.wg.Done()
|
defer l.wg.Done()
|
||||||
for j := 0; j < numPodStarts; j++ {
|
for j := 0; j < l.testOptions.NumRestarts; j++ {
|
||||||
select {
|
select {
|
||||||
case <-l.stopChs[podIndex]:
|
case <-l.stopChs[podIndex]:
|
||||||
return
|
return
|
||||||
default:
|
default:
|
||||||
pod := l.pods[podIndex]
|
pod := l.pods[podIndex]
|
||||||
framework.Logf("Pod %v, Iteration %v/%v", podIndex, j, numPodStarts)
|
framework.Logf("Pod %v, Iteration %v/%v", podIndex, j, l.testOptions.NumRestarts-1)
|
||||||
_, err = cs.CoreV1().Pods(pod.Namespace).Create(context.TODO(), pod, metav1.CreateOptions{})
|
_, err = cs.CoreV1().Pods(pod.Namespace).Create(context.TODO(), pod, metav1.CreateOptions{})
|
||||||
framework.ExpectNoError(err)
|
framework.ExpectNoError(err)
|
||||||
|
|
||||||
|
@ -188,6 +188,17 @@ type DriverInfo struct {
|
|||||||
// Only relevant if TopologyKeys is set. Defaults to 1.
|
// Only relevant if TopologyKeys is set. Defaults to 1.
|
||||||
// Example: multi-zonal disk requires at least 2 allowed topologies.
|
// Example: multi-zonal disk requires at least 2 allowed topologies.
|
||||||
NumAllowedTopologies int
|
NumAllowedTopologies int
|
||||||
|
// [Optional] Scale parameters for stress tests.
|
||||||
|
StressTestOptions *StressTestOptions
|
||||||
|
}
|
||||||
|
|
||||||
|
// StressTestOptions contains parameters used for stress tests.
|
||||||
|
type StressTestOptions struct {
|
||||||
|
// Number of pods to create in the test. This may also create
|
||||||
|
// up to 1 volume per pod.
|
||||||
|
NumPods int
|
||||||
|
// Number of times to restart each Pod.
|
||||||
|
NumRestarts int
|
||||||
}
|
}
|
||||||
|
|
||||||
// PerTestConfig represents parameters that control test execution.
|
// PerTestConfig represents parameters that control test execution.
|
||||||
|
Loading…
Reference in New Issue
Block a user