mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-26 05:03:09 +00:00
Merge pull request #96023 from chrishenzie/e2e-cleanup-non-namespaced-objects
Cleanup non-namespaced objects in e2e test during interrupts
This commit is contained in:
commit
3d62aad55e
@ -81,10 +81,11 @@ func (t *stressTestSuite) DefineTests(driver TestDriver, pattern testpatterns.Te
|
|||||||
var (
|
var (
|
||||||
dInfo = driver.GetDriverInfo()
|
dInfo = driver.GetDriverInfo()
|
||||||
cs clientset.Interface
|
cs clientset.Interface
|
||||||
|
l *stressTest
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// Check preconditions before setting up namespace via framework below.
|
||||||
ginkgo.BeforeEach(func() {
|
ginkgo.BeforeEach(func() {
|
||||||
// Check preconditions.
|
|
||||||
if dInfo.StressTestOptions == nil {
|
if dInfo.StressTestOptions == nil {
|
||||||
e2eskipper.Skipf("Driver %s doesn't specify stress test options -- skipping", dInfo.Name)
|
e2eskipper.Skipf("Driver %s doesn't specify stress test options -- skipping", dInfo.Name)
|
||||||
}
|
}
|
||||||
@ -104,9 +105,9 @@ func (t *stressTestSuite) DefineTests(driver TestDriver, pattern testpatterns.Te
|
|||||||
// f must run inside an It or Context callback.
|
// f must run inside an It or Context callback.
|
||||||
f := framework.NewDefaultFramework("stress")
|
f := framework.NewDefaultFramework("stress")
|
||||||
|
|
||||||
init := func() *stressTest {
|
init := func() {
|
||||||
cs = f.ClientSet
|
cs = f.ClientSet
|
||||||
l := &stressTest{}
|
l = &stressTest{}
|
||||||
|
|
||||||
// Now do the more expensive test initialization.
|
// Now do the more expensive test initialization.
|
||||||
l.config, l.driverCleanup = driver.PrepareTest(f)
|
l.config, l.driverCleanup = driver.PrepareTest(f)
|
||||||
@ -115,11 +116,26 @@ func (t *stressTestSuite) DefineTests(driver TestDriver, pattern testpatterns.Te
|
|||||||
l.pods = []*v1.Pod{}
|
l.pods = []*v1.Pod{}
|
||||||
l.testOptions = *dInfo.StressTestOptions
|
l.testOptions = *dInfo.StressTestOptions
|
||||||
l.ctx, l.cancel = context.WithCancel(context.Background())
|
l.ctx, l.cancel = context.WithCancel(context.Background())
|
||||||
|
|
||||||
return l
|
|
||||||
}
|
}
|
||||||
|
|
||||||
cleanup := func(l *stressTest) {
|
createPodsAndVolumes := func() {
|
||||||
|
for i := 0; i < l.testOptions.NumPods; i++ {
|
||||||
|
framework.Logf("Creating resources for pod %v/%v", i, l.testOptions.NumPods-1)
|
||||||
|
r := CreateVolumeResource(driver, l.config, pattern, t.GetTestSuiteInfo().SupportedSizeRange)
|
||||||
|
l.resources = append(l.resources, r)
|
||||||
|
podConfig := e2epod.Config{
|
||||||
|
NS: f.Namespace.Name,
|
||||||
|
PVCs: []*v1.PersistentVolumeClaim{r.Pvc},
|
||||||
|
SeLinuxLabel: e2epv.SELinuxLabel,
|
||||||
|
}
|
||||||
|
pod, err := e2epod.MakeSecPod(&podConfig)
|
||||||
|
framework.ExpectNoError(err)
|
||||||
|
|
||||||
|
l.pods = append(l.pods, pod)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
cleanup := func() {
|
||||||
var errs []error
|
var errs []error
|
||||||
|
|
||||||
framework.Logf("Stopping and waiting for all test routines to finish")
|
framework.Logf("Stopping and waiting for all test routines to finish")
|
||||||
@ -141,27 +157,16 @@ func (t *stressTestSuite) DefineTests(driver TestDriver, pattern testpatterns.Te
|
|||||||
l.migrationCheck.validateMigrationVolumeOpCounts()
|
l.migrationCheck.validateMigrationVolumeOpCounts()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ginkgo.BeforeEach(func() {
|
||||||
|
init()
|
||||||
|
createPodsAndVolumes()
|
||||||
|
})
|
||||||
|
|
||||||
|
f.AddAfterEach("cleanup", func(f *framework.Framework, failed bool) {
|
||||||
|
cleanup()
|
||||||
|
})
|
||||||
|
|
||||||
ginkgo.It("multiple pods should access different volumes repeatedly [Slow] [Serial]", func() {
|
ginkgo.It("multiple pods should access different volumes repeatedly [Slow] [Serial]", func() {
|
||||||
l := init()
|
|
||||||
defer func() {
|
|
||||||
cleanup(l)
|
|
||||||
}()
|
|
||||||
|
|
||||||
for i := 0; i < l.testOptions.NumPods; i++ {
|
|
||||||
framework.Logf("Creating resources for pod %v/%v", i, l.testOptions.NumPods-1)
|
|
||||||
r := CreateVolumeResource(driver, l.config, pattern, t.GetTestSuiteInfo().SupportedSizeRange)
|
|
||||||
l.resources = append(l.resources, r)
|
|
||||||
podConfig := e2epod.Config{
|
|
||||||
NS: f.Namespace.Name,
|
|
||||||
PVCs: []*v1.PersistentVolumeClaim{r.Pvc},
|
|
||||||
SeLinuxLabel: e2epv.SELinuxLabel,
|
|
||||||
}
|
|
||||||
pod, err := e2epod.MakeSecPod(&podConfig)
|
|
||||||
framework.ExpectNoError(err)
|
|
||||||
|
|
||||||
l.pods = append(l.pods, pod)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Restart pod repeatedly
|
// Restart pod repeatedly
|
||||||
for i := 0; i < l.testOptions.NumPods; i++ {
|
for i := 0; i < l.testOptions.NumPods; i++ {
|
||||||
podIndex := i
|
podIndex := i
|
||||||
|
Loading…
Reference in New Issue
Block a user