e2e: use Ginkgo context
All code must use the context from Ginkgo when doing API calls or polling for a change, otherwise the code would not return immediately when the test gets aborted.
This commit is contained in:
@@ -45,13 +45,13 @@ var _ = SIGDescribe("ContainerLogRotation [Slow] [Serial] [Disruptive]", func()
|
||||
f := framework.NewDefaultFramework("container-log-rotation-test")
|
||||
f.NamespacePodSecurityEnforceLevel = admissionapi.LevelPrivileged
|
||||
ginkgo.Context("when a container generates a lot of log", func() {
|
||||
tempSetCurrentKubeletConfig(f, func(initialConfig *kubeletconfig.KubeletConfiguration) {
|
||||
tempSetCurrentKubeletConfig(f, func(ctx context.Context, initialConfig *kubeletconfig.KubeletConfiguration) {
|
||||
initialConfig.ContainerLogMaxFiles = testContainerLogMaxFiles
|
||||
initialConfig.ContainerLogMaxSize = testContainerLogMaxSize
|
||||
})
|
||||
|
||||
var logRotationPod *v1.Pod
|
||||
ginkgo.BeforeEach(func() {
|
||||
ginkgo.BeforeEach(func(ctx context.Context) {
|
||||
ginkgo.By("create log container")
|
||||
pod := &v1.Pod{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
@@ -73,7 +73,7 @@ var _ = SIGDescribe("ContainerLogRotation [Slow] [Serial] [Disruptive]", func()
|
||||
},
|
||||
},
|
||||
}
|
||||
logRotationPod = e2epod.NewPodClient(f).CreateSync(pod)
|
||||
logRotationPod = e2epod.NewPodClient(f).CreateSync(ctx, pod)
|
||||
ginkgo.DeferCleanup(e2epod.NewPodClient(f).DeleteSync, logRotationPod.Name, metav1.DeleteOptions{}, time.Minute)
|
||||
})
|
||||
|
||||
@@ -88,7 +88,7 @@ var _ = SIGDescribe("ContainerLogRotation [Slow] [Serial] [Disruptive]", func()
|
||||
framework.ExpectNoError(err)
|
||||
logPath := resp.GetStatus().GetLogPath()
|
||||
ginkgo.By("wait for container log being rotated to max file limit")
|
||||
gomega.Eventually(func() (int, error) {
|
||||
gomega.Eventually(ctx, func() (int, error) {
|
||||
logs, err := kubelogs.GetAllLogs(logPath)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
@@ -96,7 +96,7 @@ var _ = SIGDescribe("ContainerLogRotation [Slow] [Serial] [Disruptive]", func()
|
||||
return len(logs), nil
|
||||
}, rotationEventuallyTimeout, rotationPollInterval).Should(gomega.Equal(testContainerLogMaxFiles), "should eventually rotate to max file limit")
|
||||
ginkgo.By("make sure container log number won't exceed max file limit")
|
||||
gomega.Consistently(func() (int, error) {
|
||||
gomega.Consistently(ctx, func() (int, error) {
|
||||
logs, err := kubelogs.GetAllLogs(logPath)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
|
Reference in New Issue
Block a user