@@ -19,11 +19,13 @@ package base
1919import (
2020 "github.com/onsi/ginkgo/v2"
2121 appsv1 "k8s.io/api/apps/v1"
22+ corev1 "k8s.io/api/core/v1"
2223 "k8s.io/apimachinery/pkg/types"
2324 "k8s.io/apimachinery/pkg/util/rand"
2425 "k8s.io/utils/ptr"
2526
2627 policyv1alpha1 "github.com/karmada-io/karmada/pkg/apis/policy/v1alpha1"
28+ "github.com/karmada-io/karmada/pkg/events"
2729 "github.com/karmada-io/karmada/test/e2e/framework"
2830 testhelper "github.com/karmada-io/karmada/test/helper"
2931)
@@ -87,6 +89,12 @@ var _ = ginkgo.Describe("[Preemption] propagation policy preemption testing", fu
8789 framework .CreatePropagationPolicy (karmadaClient , highPriorityPolicy )
8890 framework .WaitDeploymentPresentOnClusterFitWith (preemptingClusterName , deployment .Namespace , deployment .Name , func (* appsv1.Deployment ) bool { return true })
8991 })
92+ ginkgo .By ("checking PreemptPolicySucceed event on deployment" , func () {
93+ framework .WaitEventFitWith (kubeClient , deployment .Namespace , deployment .Name ,
94+ func (event corev1.Event ) bool {
95+ return event .Reason == events .EventReasonPreemptPolicySucceed
96+ })
97+ })
9098
9199 ginkgo .By ("Delete the high-priority PropagationPolicy to let the low-priority PropagationPolicy preempt the deployment" , func () {
92100 framework .RemovePropagationPolicy (karmadaClient , highPriorityPolicy .Namespace , highPriorityPolicy .Name )
@@ -139,6 +147,7 @@ var _ = ginkgo.Describe("[Preemption] propagation policy preemption testing", fu
139147
140148 ginkgo .It ("Propagate the deployment with the ClusterPropagationPolicy and then create the PropagationPolicy to preempt it" , func () {
141149 ginkgo .By ("Wait for propagating deployment by the ClusterPropagationPolicy" , func () {
150+
142151 framework .WaitDeploymentPresentOnClusterFitWith (preemptedClusterName , deployment .Namespace , deployment .Name , func (* appsv1.Deployment ) bool { return true })
143152 })
144153
@@ -147,6 +156,13 @@ var _ = ginkgo.Describe("[Preemption] propagation policy preemption testing", fu
147156 framework .WaitDeploymentPresentOnClusterFitWith (preemptingClusterName , deployment .Namespace , deployment .Name , func (* appsv1.Deployment ) bool { return true })
148157 })
149158
159+ ginkgo .By ("checking PreemptPolicySucceed event on deployment" , func () {
160+ framework .WaitEventFitWith (kubeClient , deployment .Namespace , deployment .Name ,
161+ func (event corev1.Event ) bool {
162+ return event .Reason == events .EventReasonPreemptPolicySucceed
163+ })
164+ })
165+
150166 ginkgo .By ("Delete the PropagationPolicy to let the ClusterPropagationPolicy preempt the deployment" , func () {
151167 framework .RemovePropagationPolicy (karmadaClient , propagationPolicy .Namespace , propagationPolicy .Name )
152168 framework .WaitDeploymentPresentOnClusterFitWith (preemptedClusterName , deployment .Namespace , deployment .Name , func (* appsv1.Deployment ) bool { return true })
@@ -216,6 +232,13 @@ var _ = ginkgo.Describe("[Preemption] propagation policy preemption testing", fu
216232 framework .PatchPropagationPolicy (karmadaClient , highPriorityPolicy .Namespace , highPriorityPolicy .Name , patch , types .JSONPatchType )
217233 framework .WaitDeploymentPresentOnClusterFitWith (preemptingClusterName , deployment .Namespace , deployment .Name , func (* appsv1.Deployment ) bool { return true })
218234 })
235+
236+ ginkgo .By ("checking PreemptPolicySucceed event on deployment" , func () {
237+ framework .WaitEventFitWith (kubeClient , deployment .Namespace , deployment .Name ,
238+ func (event corev1.Event ) bool {
239+ return event .Reason == events .EventReasonPreemptPolicySucceed
240+ })
241+ })
219242 })
220243 })
221244 })
@@ -272,6 +295,13 @@ var _ = ginkgo.Describe("[Preemption] propagation policy preemption testing", fu
272295 framework .WaitDeploymentPresentOnClusterFitWith (preemptingClusterName , deployment .Namespace , deployment .Name , func (* appsv1.Deployment ) bool { return true })
273296 })
274297
298+ ginkgo .By ("checking PreemptPolicySucceed event on deployment" , func () {
299+ framework .WaitEventFitWith (kubeClient , deployment .Namespace , deployment .Name ,
300+ func (event corev1.Event ) bool {
301+ return event .Reason == events .EventReasonPreemptPolicySucceed
302+ })
303+ })
304+
275305 ginkgo .By ("Delete the high-priority ClusterPropagationPolicy to let the low-priority ClusterPropagationPolicy preempt the deployment" , func () {
276306 framework .RemoveClusterPropagationPolicy (karmadaClient , highPriorityPolicy .Name )
277307 framework .WaitDeploymentPresentOnClusterFitWith (preemptedClusterName , deployment .Namespace , deployment .Name , func (* appsv1.Deployment ) bool { return true })
@@ -341,6 +371,13 @@ var _ = ginkgo.Describe("[Preemption] propagation policy preemption testing", fu
341371 framework .PatchClusterPropagationPolicy (karmadaClient , highPriorityPolicy .Name , patch , types .JSONPatchType )
342372 framework .WaitDeploymentPresentOnClusterFitWith (preemptingClusterName , deployment .Namespace , deployment .Name , func (* appsv1.Deployment ) bool { return true })
343373 })
374+
375+ ginkgo .By ("checking PreemptPolicySucceed event on deployment" , func () {
376+ framework .WaitEventFitWith (kubeClient , deployment .Namespace , deployment .Name ,
377+ func (event corev1.Event ) bool {
378+ return event .Reason == events .EventReasonPreemptPolicySucceed
379+ })
380+ })
344381 })
345382 })
346383 })
0 commit comments