@@ -17,6 +17,7 @@ limitations under the License.
1717package updaterun
1818
1919import (
20+ "context"
2021 "fmt"
2122 "time"
2223
@@ -219,14 +220,6 @@ var _ = Describe("UpdateRun stop tests", func() {
219220 validateUpdateRunMetricsEmitted (wantMetrics ... )
220221 })
221222
222- It ("Should not continue 1st stage when stopped" , func () {
223- By ("Validating update run is stopped" )
224- validateClusterStagedUpdateRunStatusConsistently (ctx , updateRun , wantStatus , "" )
225-
226- By ("Checking update run status metrics are emitted" )
227- validateUpdateRunMetricsEmitted (wantMetrics ... )
228- })
229-
230223 It ("Should accept the approval request and not rollout 1st stage while in Stop state" , func () {
231224 By ("Approving the approvalRequest" )
232225 approveClusterApprovalRequest (ctx , wantApprovalRequest .Name )
@@ -244,9 +237,13 @@ var _ = Describe("UpdateRun stop tests", func() {
244237 // Update the test's want status to match the new generation.
245238 updateAllStatusConditionsGeneration (wantStatus , updateRun .Generation )
246239
240+ By ("Validating the approvalRequest has ApprovalAccepted status" )
241+ validateApprovalRequestAccepted (ctx , wantApprovalRequest .Name )
242+ // Approval task has been approved.
243+ wantStatus .StagesStatus [0 ].BeforeStageTaskStatus [0 ].Conditions = append (wantStatus .StagesStatus [0 ].BeforeStageTaskStatus [0 ].Conditions ,
244+ generateTrueCondition (updateRun , placementv1beta1 .StageTaskConditionApprovalRequestApproved ))
245+
247246 By ("Validating update run is running" )
248- // Approval request approved for BeforeStageTask.
249- meta .SetStatusCondition (& wantStatus .StagesStatus [0 ].BeforeStageTaskStatus [0 ].Conditions , generateTrueCondition (updateRun , placementv1beta1 .StageTaskConditionApprovalRequestApproved ))
250247 // Mark 1st cluster started.
251248 meta .SetStatusCondition (& wantStatus .StagesStatus [0 ].Clusters [0 ].Conditions , generateTrueCondition (updateRun , placementv1beta1 .ClusterUpdatingConditionStarted ))
252249 // Mark stage progressing condition as true with progressing reason.
@@ -456,13 +453,7 @@ var _ = Describe("UpdateRun stop tests", func() {
456453 updateAllStatusConditionsGeneration (wantStatus , updateRun .Generation )
457454
458455 By ("Validating the approvalRequest has ApprovalAccepted status" )
459- Eventually (func () (bool , error ) {
460- var approvalRequest placementv1beta1.ClusterApprovalRequest
461- if err := k8sClient .Get (ctx , types.NamespacedName {Name : wantApprovalRequest .Name }, & approvalRequest ); err != nil {
462- return false , err
463- }
464- return condition .IsConditionStatusTrue (meta .FindStatusCondition (approvalRequest .Status .Conditions , string (placementv1beta1 .ApprovalRequestConditionApprovalAccepted )), approvalRequest .Generation ), nil
465- }, timeout , interval ).Should (BeTrue (), "failed to validate the approvalRequest approval accepted" )
456+ validateApprovalRequestAccepted (ctx , wantApprovalRequest .Name )
466457
467458 By ("Validating both after stage tasks have completed and 2nd stage has started" )
468459 // Approval AfterStageTask completed.
@@ -525,7 +516,7 @@ var _ = Describe("UpdateRun stop tests", func() {
525516 validateUpdateRunMetricsEmitted (wantMetrics ... )
526517 })
527518
528- It ("Should not complete deletion stage when stopped" , func () {
519+ It ("Should not complete deletion stage when in progress clusters still deleting while stopped" , func () {
529520 By ("Validating the first unscheduled cluster resource binding has started deleting but is NOT deleted" )
530521 Consistently (func () error {
531522 binding := & placementv1beta1.ClusterResourceBinding {}
@@ -648,3 +639,13 @@ func updateClusterStagedUpdateRunState(updateRunName string, state placementv1be
648639 }, timeout , interval ).Should (Succeed (), "Failed to update ClusterStagedUpdateRun %s state to %s" , updateRunName , state )
649640 return updateRun
650641}
642+
643+ func validateApprovalRequestAccepted (ctx context.Context , approvalRequestName string ) {
644+ Eventually (func () (bool , error ) {
645+ var approvalRequest placementv1beta1.ClusterApprovalRequest
646+ if err := k8sClient .Get (ctx , types.NamespacedName {Name : approvalRequestName }, & approvalRequest ); err != nil {
647+ return false , err
648+ }
649+ return condition .IsConditionStatusTrue (meta .FindStatusCondition (approvalRequest .Status .Conditions , string (placementv1beta1 .ApprovalRequestConditionApprovalAccepted )), approvalRequest .Generation ), nil
650+ }, timeout , interval ).Should (BeTrue (), "failed to validate the approvalRequest %s is accepted" , approvalRequestName )
651+ }
0 commit comments