@@ -5,21 +5,41 @@ package integrationtest
55
66import (
77 "fmt"
8+ "strconv"
89 "testing"
910
10- "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
11+ "github.com/hashicorp/terraform-plugin-sdk/v2/terraform"
12+ "github.com/oracle/terraform-provider-oci/internal/resourcediscovery"
1113
14+ "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
1215 "github.com/oracle/terraform-provider-oci/httpreplay"
1316 "github.com/oracle/terraform-provider-oci/internal/acctest"
1417
1518 "github.com/oracle/terraform-provider-oci/internal/utils"
1619)
1720
1821var (
22+ //BdsBdsInstancePatchActionRequiredOnlyResource = BdsBdsInstancePatchActionResourceDependencies +
23+ //acctest.GenerateResourceFromRepresentationMap("oci_bds_bds_instance_patch_action", "test_bds_instance_patch_action", acctest.Required, acctest.Create, BdsBdsInstancePatchActionRepresentation)
24+
1925 BdsBdsInstancePatchActionRepresentation = map [string ]interface {}{
2026 "bds_instance_id" : acctest.Representation {RepType : acctest .Required , Create : `${oci_bds_bds_instance.test_bds_instance.id}` },
21- "cluster_admin_password" : acctest.Representation {RepType : acctest .Required , Create : `V2VsY29tZTE=` },
22- "version" : acctest.Representation {RepType : acctest .Required , Create : "ODH-1.1.0.379" },
27+ "cluster_admin_password" : acctest.Representation {RepType : acctest .Required , Create : `clusterAdminPassword` },
28+ "version" : acctest.Representation {RepType : acctest .Required , Create : `version` },
29+ "patching_config" : acctest.RepresentationGroup {RepType : acctest .Required , Group : BdsBdsInstancePatchActionPatchingConfigRepresentation },
30+ "timeouts" : acctest.RepresentationGroup {RepType : acctest .Required , Group : PatchTimeoutsRepresentation },
31+ }
32+ BdsBdsInstancePatchActionPatchingConfigRepresentation = map [string ]interface {}{
33+ "patching_config_strategy" : acctest.Representation {RepType : acctest .Required , Create : `DOWNTIME_BASED` },
34+ "batch_size" : acctest.Representation {RepType : acctest .Required , Create : `3` },
35+ "wait_time_between_batch_in_seconds" : acctest.Representation {RepType : acctest .Required , Create : `600` },
36+ "wait_time_between_domain_in_seconds" : acctest.Representation {RepType : acctest .Required , Create : `600` },
37+ }
38+
39+ PatchTimeoutsRepresentation = map [string ]interface {}{
40+ "create" : acctest.Representation {RepType : acctest .Required , Create : `24h` },
41+ "update" : acctest.Representation {RepType : acctest .Required , Create : `24h` },
42+ "delete" : acctest.Representation {RepType : acctest .Required , Create : `24h` },
2343 }
2444
2545 BdsBdsInstancePatchActionResourceDependencies = acctest .GenerateResourceFromRepresentationMap ("oci_bds_bds_instance" , "test_bds_instance" , acctest .Required , acctest .Create , bdsInstanceOdhRepresentation ) +
2949
3050// issue-routing-tag: bds/default
3151func TestBdsBdsInstancePatchActionResource_basic (t * testing.T ) {
32- t .Skip ("Run manual with an older cluster with patch available" )
52+ // t.Skip("Run manual with an older cluster with patch available")
3353 httpreplay .SetScenario ("TestBdsBdsInstancePatchActionResource_basic" )
3454 defer httpreplay .SaveScenario ()
3555
@@ -40,18 +60,51 @@ func TestBdsBdsInstancePatchActionResource_basic(t *testing.T) {
4060
4161 resourceName := "oci_bds_bds_instance_patch_action.test_bds_instance_patch_action"
4262
63+ var resId string
64+ // Save TF content to Create resource with optional properties. This has to be exactly the same as the config part in the "create with optionals" step in the test.
4365 // Save TF content to Create resource with only required properties. This has to be exactly the same as the config part in the create step in the test.
44- acctest .SaveConfigContent (config + compartmentIdVariableStr + BdsBdsInstancePatchActionResourceDependencies +
45- acctest .GenerateResourceFromRepresentationMap ("oci_bds_bds_instance_patch_action" , "test_bds_instance_patch_action" , acctest .Required , acctest .Create , BdsBdsInstancePatchActionRepresentation ), "bds" , "bdsInstancePatchAction" , t )
66+
67+ acctest .SaveConfigContent (config + compartmentIdVariableStr +
68+ acctest .GenerateResourceFromRepresentationMap ("oci_bds_bds_instance_patch_action" , "test_bds_instance_patch_action" , acctest .Optional , acctest .Create , BdsBdsInstancePatchActionRepresentation ), "bds" , "bdsInstancePatchAction" , t )
4669
4770 acctest .ResourceTest (t , nil , []resource.TestStep {
4871 // verify Create
4972 {
50- Config : config + compartmentIdVariableStr + BdsBdsInstancePatchActionResourceDependencies +
73+ Config : config + compartmentIdVariableStr +
5174 acctest .GenerateResourceFromRepresentationMap ("oci_bds_bds_instance_patch_action" , "test_bds_instance_patch_action" , acctest .Required , acctest .Create , BdsBdsInstancePatchActionRepresentation ),
5275 Check : acctest .ComposeAggregateTestCheckFuncWrapper (
5376 resource .TestCheckResourceAttrSet (resourceName , "bds_instance_id" ),
5477 ),
5578 },
79+
80+ // delete before next Create
81+ {
82+ Config : config + compartmentIdVariableStr + BdsBdsInstancePatchActionResourceDependencies ,
83+ },
84+ // verify Create with optionals
85+ {
86+ Config : config + compartmentIdVariableStr + BdsBdsInstancePatchActionResourceDependencies +
87+ acctest .GenerateResourceFromRepresentationMap ("oci_bds_bds_instance_patch_action" , "test_bds_instance_patch_action" , acctest .Optional , acctest .Create , BdsBdsInstancePatchActionRepresentation ),
88+ Check : acctest .ComposeAggregateTestCheckFuncWrapper (
89+ resource .TestCheckResourceAttrSet (resourceName , "bds_instance_id" ),
90+ resource .TestCheckResourceAttr (resourceName , "cluster_admin_password" , "clusterAdminPassword" ),
91+ resource .TestCheckResourceAttr (resourceName , "patching_config.#" , "1" ),
92+ resource .TestCheckResourceAttr (resourceName , "patching_config.0.batch_size" , "3" ),
93+ resource .TestCheckResourceAttr (resourceName , "patching_config.0.patching_config_strategy" , "DOWNTIME_BASED" ),
94+ resource .TestCheckResourceAttr (resourceName , "patching_config.0.wait_time_between_batch_in_seconds" , "600" ),
95+ resource .TestCheckResourceAttr (resourceName , "patching_config.0.wait_time_between_domain_in_seconds" , "600" ),
96+ resource .TestCheckResourceAttr (resourceName , "version" , "version" ),
97+
98+ func (s * terraform.State ) (err error ) {
99+ resId , err = acctest .FromInstanceState (s , resourceName , "id" )
100+ if isEnableExportCompartment , _ := strconv .ParseBool (utils .GetEnvSettingWithDefault ("enable_export_compartment" , "true" )); isEnableExportCompartment {
101+ if errExport := resourcediscovery .TestExportCompartmentWithResourceName (& resId , & compartmentId , resourceName ); errExport != nil {
102+ return errExport
103+ }
104+ }
105+ return err
106+ },
107+ ),
108+ },
56109 })
57110}
0 commit comments