diff --git a/module-controller/api/v1alpha1/moduledeployment_types.go b/module-controller/api/v1alpha1/moduledeployment_types.go index 5ef511b70..afe5e91e4 100644 --- a/module-controller/api/v1alpha1/moduledeployment_types.go +++ b/module-controller/api/v1alpha1/moduledeployment_types.go @@ -163,6 +163,7 @@ type ModuleDeploymentSpec struct { ProgressDeadlineSeconds int32 `json:"progressDeadlineSeconds,omitempty"` + // +kubebuilder:default:=0 // +kubebuilder:validation:Minimum=0 ConfirmBatchNum int32 `json:"confirmBatchNum,omitempty"` diff --git a/module-controller/config/crd/bases/serverless.alipay.com_moduledeployments.yaml b/module-controller/config/crd/bases/serverless.alipay.com_moduledeployments.yaml index baa2324af..78f4e4af9 100644 --- a/module-controller/config/crd/bases/serverless.alipay.com_moduledeployments.yaml +++ b/module-controller/config/crd/bases/serverless.alipay.com_moduledeployments.yaml @@ -42,6 +42,7 @@ spec: minLength: 1 type: string confirmBatchNum: + default: 0 format: int32 minimum: 0 type: integer diff --git a/module-controller/internal/controller/moduledeployment_controller_operation_strategy_suit_test.go b/module-controller/internal/controller/moduledeployment_controller_operation_strategy_suit_test.go index 2f2aad225..e9171b3f1 100644 --- a/module-controller/internal/controller/moduledeployment_controller_operation_strategy_suit_test.go +++ b/module-controller/internal/controller/moduledeployment_controller_operation_strategy_suit_test.go @@ -578,7 +578,7 @@ var _ = Describe("ModuleDeployment Controller OperationStrategy Test", func() { return err } - if !moduleDeployment.Spec.Pause { + if moduleDeployment.Spec.ConfirmBatchNum > 0 { return fmt.Errorf("the deployment is not paused") } @@ -593,18 +593,22 @@ var _ = Describe("ModuleDeployment Controller OperationStrategy Test", func() { Eventually(func() bool { Expect(k8sClient.Get(context.TODO(), nn, &moduleDeployment)).Should(Succeed()) - moduleDeployment.Spec.Pause = false + moduleDeployment.Spec.ConfirmBatchNum = 1 return Expect(k8sClient.Update(context.TODO(), &moduleDeployment)).Should(Succeed()) }, timeout, interval).Should(BeTrue()) }) + It("wait moduleDeployment Completed", func() { + waitModuleDeploymentCompleted(moduleDeploymentName, namespace) + }) + It("4. check if the moduleDeployment status is completed", func() { Eventually(func() bool { if k8sClient.Get(context.TODO(), nn, &moduleDeployment) != nil { return false } - if moduleDeployment.Spec.Pause != false { + if moduleDeployment.Spec.ConfirmBatchNum != 0 { return false } @@ -627,7 +631,7 @@ var _ = Describe("ModuleDeployment Controller OperationStrategy Test", func() { return err } - if !moduleDeployment.Spec.Pause { + if moduleDeployment.Spec.ConfirmBatchNum > 0 { return fmt.Errorf("the deployment is not paused") } @@ -642,7 +646,7 @@ var _ = Describe("ModuleDeployment Controller OperationStrategy Test", func() { Eventually(func() bool { Expect(k8sClient.Get(context.TODO(), nn, &moduleDeployment)).Should(Succeed()) - moduleDeployment.Spec.Pause = false + moduleDeployment.Spec.ConfirmBatchNum = 1 return Expect(k8sClient.Update(context.TODO(), &moduleDeployment)).Should(Succeed()) }, timeout, interval).Should(BeTrue()) }) @@ -653,7 +657,7 @@ var _ = Describe("ModuleDeployment Controller OperationStrategy Test", func() { return err } - if moduleDeployment.Spec.Pause != false { + if moduleDeployment.Spec.ConfirmBatchNum != 1 { return fmt.Errorf("the module-deployment is paused") }