@@ -110,6 +110,9 @@ func TestAutoScalingAutoScalingConfigurationResource_basic(t *testing.T) {
110110 compartmentId := getEnvSettingWithBlankDefault ("compartment_ocid" )
111111 compartmentIdVariableStr := fmt .Sprintf ("variable \" compartment_id\" { default = \" %s\" }\n " , compartmentId )
112112
113+ compartmentIdU := getEnvSettingWithDefault ("compartment_id_for_update" , compartmentId )
114+ compartmentIdUVariableStr := fmt .Sprintf ("variable \" compartment_id_for_update\" { default = \" %s\" }\n " , compartmentIdU )
115+
113116 resourceName := "oci_autoscaling_auto_scaling_configuration.test_auto_scaling_configuration"
114117 datasourceName := "data.oci_autoscaling_auto_scaling_configurations.test_auto_scaling_configurations"
115118 singularDatasourceName := "data.oci_autoscaling_auto_scaling_configuration.test_auto_scaling_configuration"
@@ -231,6 +234,67 @@ func TestAutoScalingAutoScalingConfigurationResource_basic(t *testing.T) {
231234 ),
232235 },
233236
237+ // verify update to the compartment (the compartment will be switched back in the next step)
238+ {
239+ Config : config + compartmentIdVariableStr + compartmentIdUVariableStr + AutoScalingConfigurationResourceDependencies +
240+ generateResourceFromRepresentationMap ("oci_autoscaling_auto_scaling_configuration" , "test_auto_scaling_configuration" , Optional , Create ,
241+ representationCopyWithNewProperties (autoScalingConfigurationRepresentation , map [string ]interface {}{
242+ "compartment_id" : Representation {repType : Required , create : `${var.compartment_id_for_update}` },
243+ })),
244+ Check : resource .ComposeAggregateTestCheckFunc (
245+ resource .TestCheckResourceAttr (resourceName , "auto_scaling_resources.#" , "1" ),
246+ resource .TestCheckResourceAttrSet (resourceName , "auto_scaling_resources.0.id" ),
247+ resource .TestCheckResourceAttr (resourceName , "auto_scaling_resources.0.type" , "instancePool" ),
248+ resource .TestCheckResourceAttr (resourceName , "compartment_id" , compartmentIdU ),
249+ resource .TestCheckResourceAttr (resourceName , "cool_down_in_seconds" , "300" ),
250+ resource .TestCheckResourceAttr (resourceName , "defined_tags.%" , "1" ),
251+ resource .TestCheckResourceAttr (resourceName , "display_name" , "example_autoscaling_configuration" ),
252+ resource .TestCheckResourceAttr (resourceName , "freeform_tags.%" , "1" ),
253+ resource .TestCheckResourceAttrSet (resourceName , "id" ),
254+ resource .TestCheckResourceAttr (resourceName , "is_enabled" , "false" ),
255+ resource .TestCheckResourceAttr (resourceName , "policies.#" , "1" ),
256+ resource .TestCheckResourceAttrSet (resourceName , "policies.0.id" ),
257+ resource .TestCheckResourceAttr (resourceName , "policies.0.capacity.#" , "1" ),
258+ resource .TestCheckResourceAttr (resourceName , "policies.0.capacity.0.initial" , "2" ),
259+ resource .TestCheckResourceAttr (resourceName , "policies.0.capacity.0.max" , "3" ),
260+ resource .TestCheckResourceAttr (resourceName , "policies.0.capacity.0.min" , "2" ),
261+ resource .TestCheckResourceAttr (resourceName , "policies.0.display_name" , "example_autoscaling_configuration" ),
262+ resource .TestCheckResourceAttr (resourceName , "policies.0.policy_type" , "threshold" ),
263+ resource .TestCheckResourceAttr (resourceName , "policies.0.rules.#" , "2" ),
264+ CheckResourceSetContainsElementWithProperties (resourceName , "policies.0.rules" , map [string ]string {
265+ "action.#" : "1" ,
266+ "action.0.type" : "CHANGE_COUNT_BY" ,
267+ "action.0.value" : "1" ,
268+ "display_name" : "scale out rule" ,
269+ "metric.#" : "1" ,
270+ "metric.0.metric_type" : "CPU_UTILIZATION" ,
271+ "metric.0.threshold.#" : "1" ,
272+ "metric.0.threshold.0.operator" : "GT" ,
273+ "metric.0.threshold.0.value" : "1" ,
274+ },
275+ []string {}),
276+ CheckResourceSetContainsElementWithProperties (resourceName , "policies.0.rules" , map [string ]string {
277+ "action.#" : "1" ,
278+ "action.0.type" : "CHANGE_COUNT_BY" ,
279+ "action.0.value" : "-1" ,
280+ "display_name" : "scale in rule" ,
281+ "metric.#" : "1" ,
282+ "metric.0.metric_type" : "CPU_UTILIZATION" ,
283+ "metric.0.threshold.#" : "1" ,
284+ "metric.0.threshold.0.operator" : "LT" ,
285+ "metric.0.threshold.0.value" : "1" ,
286+ },
287+ []string {}),
288+ resource .TestCheckResourceAttrSet (resourceName , "policies.0.time_created" ),
289+ resource .TestCheckResourceAttrSet (resourceName , "time_created" ),
290+
291+ func (s * terraform.State ) (err error ) {
292+ resId , err = fromInstanceState (s , resourceName , "id" )
293+ return err
294+ },
295+ ),
296+ },
297+
234298 // verify updates to updatable parameters
235299 {
236300 Config : config + compartmentIdVariableStr + AutoScalingConfigurationResourceDependencies +
0 commit comments