Skip to content

Commit

Permalink
add a single simpe e2e case
Browse files Browse the repository at this point in the history
  • Loading branch information
AxeZhan committed Jul 2, 2023
1 parent 32345f4 commit 4ca87e8
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions test/e2e/common/node/lifecycle_hook.go
Original file line number Diff line number Diff line change
Expand Up @@ -269,3 +269,32 @@ func getPodWithHook(name string, image string, lifecycle *v1.Lifecycle) *v1.Pod
},
}
}

var _ = SIGDescribe("PodLifecycleSleepAction", func() {
f := framework.NewDefaultFramework("pod-lifecycle-sleep-action")
f.NamespacePodSecurityEnforceLevel = admissionapi.LevelBaseline
var podClient *e2epod.PodClient
ginkgo.Context("when create a pod with lifecycle hook using sleep action", func() {
ginkgo.BeforeEach(func(ctx context.Context) {
podClient = e2epod.NewPodClient(f)
})
ginkgo.It("valid prestop hook using sleep action", func(ctx context.Context) {
lifecycle := &v1.Lifecycle{
PreStop: &v1.LifecycleHandler{
Sleep: &v1.SleepAction{Seconds: 5},
},
}
podWithHook := getPodWithHook("pod-with-prestop-sleep-hook", imageutils.GetPauseImageName(), lifecycle)
ginkgo.By("create the pod with lifecycle hook using sleep action")
podClient.CreateSync(ctx, podWithHook)
ginkgo.By("delete the pod with lifecycle hook using sleep action")
start := time.Now()
podClient.DeleteSync(ctx, podWithHook.Name, metav1.DeleteOptions{}, e2epod.DefaultPodDeletionTimeout)
cost := time.Since(start)
// verify that deletion was delayed by sleep seconds
if cost < time.Second*5 || cost > time.Second*30 {
framework.Failf("unexpected delay duration before killing the pod")
}
})
})
})

0 comments on commit 4ca87e8

Please sign in to comment.