Skip to content
This repository has been archived by the owner on Feb 18, 2024. It is now read-only.

Commit

Permalink
修改单测,添加ConfirmBatchNum默认值为0的注释,使其为0时也在yaml中展示
Browse files Browse the repository at this point in the history
  • Loading branch information
liu-657667 committed Jan 17, 2024
1 parent b4d326e commit 8537718
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
1 change: 1 addition & 0 deletions module-controller/api/v1alpha1/moduledeployment_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ type ModuleDeploymentSpec struct {

ProgressDeadlineSeconds int32 `json:"progressDeadlineSeconds,omitempty"`

// +kubebuilder:default:=0
// +kubebuilder:validation:Minimum=0
ConfirmBatchNum int32 `json:"confirmBatchNum,omitempty"`

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ spec:
minLength: 1
type: string
confirmBatchNum:
default: 0
format: int32
minimum: 0
type: integer
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}

Expand All @@ -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
}

Expand All @@ -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")
}

Expand All @@ -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())
})
Expand All @@ -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")
}

Expand Down

0 comments on commit 8537718

Please sign in to comment.