diff --git a/test/e2e/clusterpropagationpolicy_test.go b/test/e2e/clusterpropagationpolicy_test.go index 3aa0266b9c1f..3ef24c6664d3 100644 --- a/test/e2e/clusterpropagationpolicy_test.go +++ b/test/e2e/clusterpropagationpolicy_test.go @@ -19,6 +19,9 @@ package e2e import ( "context" "fmt" + "github.com/karmada-io/karmada/pkg/controllers/binding" + "github.com/karmada-io/karmada/pkg/events" + corev1 "k8s.io/api/core/v1" "time" "github.com/onsi/ginkgo/v2" @@ -1150,4 +1153,37 @@ var _ = ginkgo.Describe("[Suspension] ClusterPropagationPolicy testing", func() }, pollTimeout, pollInterval).Should(gomega.Equal(true)) }) }) + + ginkgo.It("suspend the CPP scheduling", func() { + ginkgo.By("update the cpp suspension scheduling to true", func() { + policy.Spec.Suspension = &policyv1alpha1.Suspension{ + Scheduling: ptr.To(true), + } + framework.UpdateClusterPropagationPolicyWithSpec(karmadaClient, policy.Name, policy.Spec) + }) + + ginkgo.By("check CRB suspension spec", func() { + framework.WaitClusterResourceBindingFitWith(karmadaClient, resourceBindingName, func(binding *workv1alpha2.ClusterResourceBinding) bool { + return binding.Spec.Suspension != nil && ptr.Deref(binding.Spec.Suspension.Scheduling, false) + }) + }) + + ginkgo.By("check Work Scheduling status condition", func() { + gomega.Eventually(func() bool { + crb, err := karmadaClient.WorkV1alpha2().ClusterResourceBindings().Get(context.TODO(), resourceBindingName, metav1.GetOptions{}) + if err != nil { + return false + } + return crb != nil && meta.IsStatusConditionPresentAndEqual(crb.Status.Conditions, workv1alpha2.Suspended, metav1.ConditionTrue) + }, pollTimeout, pollInterval).Should(gomega.Equal(true)) + }) + + ginkgo.By("check scheduling event", func() { + framework.WaitEventFitWith(kubeClient, "", resourceBindingName, + func(event corev1.Event) bool { + return event.Reason == events.EventReasonBindingScheduling && + event.Message == binding.SuspendedSchedulingConditionMessage + }) + }) + }) }) diff --git a/test/e2e/propagationpolicy_test.go b/test/e2e/propagationpolicy_test.go index 3440d8949ac7..fc6ce6deb5f3 100644 --- a/test/e2e/propagationpolicy_test.go +++ b/test/e2e/propagationpolicy_test.go @@ -20,6 +20,7 @@ import ( "context" "encoding/json" "fmt" + "github.com/karmada-io/karmada/pkg/controllers/binding" "time" "github.com/onsi/ginkgo/v2" @@ -1246,6 +1247,42 @@ var _ = ginkgo.Describe("[Suspension] PropagationPolicy testing", func() { }) }) + ginkgo.It("suspend the PP scheduling", func() { + ginkgo.By("update the pp suspension scheduling to true", func() { + policy.Spec.Suspension = &policyv1alpha1.Suspension{ + Scheduling: ptr.To(true), + } + framework.UpdatePropagationPolicyWithSpec(karmadaClient, policy.Namespace, policy.Name, policy.Spec) + }) + + ginkgo.By("check RB suspension spec", func() { + framework.WaitResourceBindingFitWith(karmadaClient, deployment.Namespace, names.GenerateBindingName(deployment.Kind, deployment.Name), + func(binding *workv1alpha2.ResourceBinding) bool { + return binding.Spec.Suspension != nil && ptr.Deref(binding.Spec.Suspension.Scheduling, false) + }) + }) + + ginkgo.By("check RB Scheduling status condition", func() { + rbName := names.GenerateBindingName(deployment.Kind, deployment.Name) + gomega.Eventually(func() bool { + rb, err := karmadaClient.WorkV1alpha2().ResourceBindings(rbName).Get(context.TODO(), rbName, metav1.GetOptions{}) + if err != nil { + return false + } + return rb != nil && meta.IsStatusConditionPresentAndEqual(rb.Status.Conditions, workv1alpha2.Suspended, metav1.ConditionTrue) + }, pollTimeout, pollInterval).Should(gomega.Equal(true)) + }) + + ginkgo.By("check scheduling event", func() { + rbName := names.GenerateBindingName(deployment.Kind, deployment.Name) + framework.WaitEventFitWith(kubeClient, testNamespace, rbName, + func(event corev1.Event) bool { + return event.Reason == events.EventReasonBindingScheduling && + event.Message == binding.SuspendedSchedulingConditionMessage + }) + }) + }) + ginkgo.It("suspension resume", func() { ginkgo.By("update deployment replicas", func() { framework.UpdateDeploymentReplicas(kubeClient, deployment, updateDeploymentReplicas)