@@ -144,6 +144,21 @@ func TestGoldenGateDeploymentResource_basic(t *testing.T) {
144144 "maintenance_window" : acctest.RepresentationGroup {RepType : acctest .Required , Group : deploymentMaintenanceWindowRepresentation },
145145 }
146146
147+ deploymentLocksRepresentation = map [string ]interface {}{
148+ "type" : acctest.Representation {RepType : acctest .Required , Create : `FULL` },
149+ "message" : acctest.Representation {RepType : acctest .Optional , Create : `message` },
150+ }
151+
152+ ignoreDefinedTagsAndLocks = map [string ]interface {}{
153+ "ignore_changes" : acctest.Representation {RepType : acctest .Required , Create : []string {`locks` , `defined_tags` , `is_lock_override` }},
154+ }
155+
156+ lockedDeploymentRepresentation = acctest .RepresentationCopyWithNewProperties (goldenGateDeploymentRepresentation , map [string ]interface {}{
157+ "locks" : acctest.RepresentationGroup {RepType : acctest .Optional , Group : deploymentLocksRepresentation },
158+ "is_lock_override" : acctest.Representation {RepType : acctest .Required , Create : `true` , Update : `true` },
159+ "lifecycle" : acctest.RepresentationGroup {RepType : acctest .Required , Group : ignoreDefinedTagsAndLocks },
160+ })
161+
147162 goldenGateDeploymentSingularDataSourceRepresentation = map [string ]interface {}{
148163 "deployment_id" : acctest.Representation {RepType : acctest .Required , Create : `${oci_golden_gate_deployment.depl_test_ggs_deployment.id}` },
149164 }
@@ -558,36 +573,43 @@ func TestGoldenGateDeploymentResource_basic(t *testing.T) {
558573 Config : config ,
559574 },
560575 /* Start/stop/upgrade test*/
561- // 0. create a new deployment and stop it right after the creation
576+ // 0. create a new and locked deployment and stop it right after the creation
562577 {
563578 Config : config +
564579 acctest .GenerateResourceFromRepresentationMap ("oci_golden_gate_deployment" , "depl_test_ggs_deployment" , acctest .Optional , acctest .Create ,
565- acctest .RepresentationCopyWithNewProperties (goldenGateDeploymentRepresentation , map [string ]interface {}{
580+ acctest .RepresentationCopyWithNewProperties (lockedDeploymentRepresentation , map [string ]interface {}{
566581 "state" : acctest.Representation {RepType : acctest .Optional , Create : string (oci_golden_gate .LifecycleStateInactive )},
567582 "ogg_data" : acctest.RepresentationGroup {RepType : acctest .Required , Group : oggDataForUpgradeRepresentation },
568583 })),
569584 Check : acctest .ComposeAggregateTestCheckFuncWrapper (
570585 resource .TestCheckResourceAttr (resourceName , "compartment_id" , compartmentId ),
571586 resource .TestCheckResourceAttr (resourceName , "state" , string (oci_golden_gate .LifecycleStateInactive )),
572587 resource .TestCheckResourceAttr (resourceName , "ogg_data.0.ogg_version" , baseOggVersion ),
588+ resource .TestCheckResourceAttr (resourceName , "locks.0.type" , "FULL" ),
589+ resource .TestCheckResourceAttr (resourceName , "locks.0.message" , "message" ),
590+ resource .TestCheckResourceAttrSet (resourceName , "locks.0.time_created" ),
591+
573592 func (s * terraform.State ) (err error ) {
574593 resId , err = acctest .FromInstanceState (s , resourceName , "id" )
575594 return err
576595 },
577596 ),
578597 },
579- // 1. start the deployment and upgrade it at the same time
598+ // 1. start the locked deployment and upgrade it at the same time
580599 {
581600 Config : config +
582601 acctest .GenerateResourceFromRepresentationMap ("oci_golden_gate_deployment" , "depl_test_ggs_deployment" , acctest .Optional , acctest .Update ,
583- acctest .RepresentationCopyWithNewProperties (goldenGateDeploymentRepresentation , map [string ]interface {}{
602+ acctest .RepresentationCopyWithNewProperties (lockedDeploymentRepresentation , map [string ]interface {}{
584603 "state" : acctest.Representation {RepType : acctest .Optional , Create : string (oci_golden_gate .LifecycleStateActive )},
585604 "ogg_data" : acctest.RepresentationGroup {RepType : acctest .Required , Group : oggDataForUpgradeRepresentation },
586605 })),
587606 Check : acctest .ComposeAggregateTestCheckFuncWrapper (
588607 resource .TestCheckResourceAttr (resourceName , "compartment_id" , compartmentId ),
589608 resource .TestCheckResourceAttr (resourceName , "state" , string (oci_golden_gate .LifecycleStateActive )),
590609 resource .TestCheckResourceAttr (resourceName , "ogg_data.0.ogg_version" , upgradedOggVersion ),
610+ resource .TestCheckResourceAttr (resourceName , "locks.0.type" , "FULL" ),
611+ resource .TestCheckResourceAttr (resourceName , "locks.0.message" , "message" ),
612+ resource .TestCheckResourceAttrSet (resourceName , "locks.0.time_created" ),
591613 func (s * terraform.State ) (err error ) {
592614 resId2 , err = acctest .FromInstanceState (s , resourceName , "id" )
593615 if resId != resId2 {
@@ -731,6 +753,9 @@ func sweepGoldenGateDeploymentResource(compartment string) error {
731753
732754 deleteDeploymentRequest .DeploymentId = & deploymentId
733755
756+ var overrideLock = true
757+ deleteDeploymentRequest .IsLockOverride = & overrideLock
758+
734759 deleteDeploymentRequest .RequestMetadata .RetryPolicy = tfresource .GetRetryPolicy (true , "golden_gate" )
735760 _ , error := goldenGateClient .DeleteDeployment (context .Background (), deleteDeploymentRequest )
736761 if error != nil {
0 commit comments