|
62 | 62 | "license_model": Representation{repType: Optional, create: `LICENSE_INCLUDED`}, |
63 | 63 | "whitelisted_ips": Representation{repType: Optional, create: []string{`1.1.1.1/28`}}, |
64 | 64 | "timeouts": RepresentationGroup{Required, autonomousDatabaseTimeoutsRepresentation}, |
| 65 | + "state": Representation{repType: Optional, create: `AVAILABLE`}, |
65 | 66 | } |
66 | 67 |
|
67 | 68 | autonomousDatabaseTimeoutsRepresentation = map[string]interface{}{ |
@@ -157,7 +158,7 @@ func TestDatabaseAutonomousDatabaseResource_basic(t *testing.T) { |
157 | 158 | resource.TestCheckResourceAttr(resourceName, "is_dedicated", "false"), |
158 | 159 | resource.TestCheckResourceAttr(resourceName, "is_preview_version_with_service_terms_accepted", "false"), |
159 | 160 | resource.TestCheckResourceAttr(resourceName, "license_model", "LICENSE_INCLUDED"), |
160 | | - resource.TestCheckResourceAttrSet(resourceName, "state"), |
| 161 | + resource.TestCheckResourceAttr(resourceName, "state", "AVAILABLE"), |
161 | 162 | resource.TestCheckResourceAttr(resourceName, "whitelisted_ips.#", "1"), |
162 | 163 |
|
163 | 164 | func(s *terraform.State) (err error) { |
@@ -196,7 +197,7 @@ func TestDatabaseAutonomousDatabaseResource_basic(t *testing.T) { |
196 | 197 | resource.TestCheckResourceAttr(resourceName, "is_dedicated", "false"), |
197 | 198 | resource.TestCheckResourceAttr(resourceName, "is_preview_version_with_service_terms_accepted", "false"), |
198 | 199 | resource.TestCheckResourceAttr(resourceName, "license_model", "LICENSE_INCLUDED"), |
199 | | - resource.TestCheckResourceAttrSet(resourceName, "state"), |
| 200 | + resource.TestCheckResourceAttr(resourceName, "state", "AVAILABLE"), |
200 | 201 | resource.TestCheckResourceAttr(resourceName, "whitelisted_ips.#", "1"), |
201 | 202 |
|
202 | 203 | func(s *terraform.State) (err error) { |
@@ -230,7 +231,73 @@ func TestDatabaseAutonomousDatabaseResource_basic(t *testing.T) { |
230 | 231 | resource.TestCheckResourceAttr(resourceName, "is_dedicated", "false"), |
231 | 232 | resource.TestCheckResourceAttr(resourceName, "is_preview_version_with_service_terms_accepted", "false"), |
232 | 233 | resource.TestCheckResourceAttr(resourceName, "license_model", "LICENSE_INCLUDED"), |
233 | | - resource.TestCheckResourceAttrSet(resourceName, "state"), |
| 234 | + resource.TestCheckResourceAttr(resourceName, "state", "AVAILABLE"), |
| 235 | + |
| 236 | + func(s *terraform.State) (err error) { |
| 237 | + resId2, err = fromInstanceState(s, resourceName, "id") |
| 238 | + if resId != resId2 { |
| 239 | + return fmt.Errorf("Resource recreated when it was supposed to be updated.") |
| 240 | + } |
| 241 | + return err |
| 242 | + }, |
| 243 | + ), |
| 244 | + }, |
| 245 | + // verify stop the autonomous database |
| 246 | + { |
| 247 | + Config: config + compartmentIdVariableStr + AutonomousDatabaseResourceDependencies + |
| 248 | + generateResourceFromRepresentationMap("oci_database_autonomous_database", "test_autonomous_database", Optional, Update, |
| 249 | + getUpdatedRepresentationCopy("state", Representation{repType: Optional, create: "STOPPED"}, autonomousDatabaseRepresentation)), |
| 250 | + Check: resource.ComposeAggregateTestCheckFunc( |
| 251 | + resource.TestCheckResourceAttr(resourceName, "admin_password", "BEstrO0ng_#12"), |
| 252 | + resource.TestCheckResourceAttr(resourceName, "compartment_id", compartmentId), |
| 253 | + resource.TestCheckResourceAttr(resourceName, "cpu_core_count", "1"), |
| 254 | + resource.TestCheckResourceAttr(resourceName, "data_safe_status", "NOT_REGISTERED"), |
| 255 | + resource.TestCheckResourceAttr(resourceName, "data_storage_size_in_tbs", "1"), |
| 256 | + resource.TestCheckResourceAttrSet(resourceName, "db_version"), |
| 257 | + resource.TestCheckResourceAttr(resourceName, "db_name", adbName), |
| 258 | + resource.TestCheckResourceAttr(resourceName, "db_workload", "OLTP"), |
| 259 | + resource.TestCheckResourceAttr(resourceName, "defined_tags.%", "1"), |
| 260 | + resource.TestCheckResourceAttr(resourceName, "display_name", "displayName2"), |
| 261 | + resource.TestCheckResourceAttr(resourceName, "freeform_tags.%", "1"), |
| 262 | + resource.TestCheckResourceAttrSet(resourceName, "id"), |
| 263 | + resource.TestCheckResourceAttr(resourceName, "is_auto_scaling_enabled", "false"), |
| 264 | + resource.TestCheckResourceAttr(resourceName, "is_dedicated", "false"), |
| 265 | + resource.TestCheckResourceAttr(resourceName, "is_preview_version_with_service_terms_accepted", "false"), |
| 266 | + resource.TestCheckResourceAttr(resourceName, "license_model", "LICENSE_INCLUDED"), |
| 267 | + resource.TestCheckResourceAttr(resourceName, "state", "STOPPED"), |
| 268 | + |
| 269 | + func(s *terraform.State) (err error) { |
| 270 | + resId2, err = fromInstanceState(s, resourceName, "id") |
| 271 | + if resId != resId2 { |
| 272 | + return fmt.Errorf("Resource recreated when it was supposed to be updated.") |
| 273 | + } |
| 274 | + return err |
| 275 | + }, |
| 276 | + ), |
| 277 | + }, |
| 278 | + // verify start the autonomous database |
| 279 | + { |
| 280 | + Config: config + compartmentIdVariableStr + AutonomousDatabaseResourceDependencies + |
| 281 | + generateResourceFromRepresentationMap("oci_database_autonomous_database", "test_autonomous_database", Optional, Update, |
| 282 | + getUpdatedRepresentationCopy("state", Representation{repType: Optional, create: "AVAILABLE"}, autonomousDatabaseRepresentation)), |
| 283 | + Check: resource.ComposeAggregateTestCheckFunc( |
| 284 | + resource.TestCheckResourceAttr(resourceName, "admin_password", "BEstrO0ng_#12"), |
| 285 | + resource.TestCheckResourceAttr(resourceName, "compartment_id", compartmentId), |
| 286 | + resource.TestCheckResourceAttr(resourceName, "cpu_core_count", "1"), |
| 287 | + resource.TestCheckResourceAttr(resourceName, "data_safe_status", "NOT_REGISTERED"), |
| 288 | + resource.TestCheckResourceAttr(resourceName, "data_storage_size_in_tbs", "1"), |
| 289 | + resource.TestCheckResourceAttrSet(resourceName, "db_version"), |
| 290 | + resource.TestCheckResourceAttr(resourceName, "db_name", adbName), |
| 291 | + resource.TestCheckResourceAttr(resourceName, "db_workload", "OLTP"), |
| 292 | + resource.TestCheckResourceAttr(resourceName, "defined_tags.%", "1"), |
| 293 | + resource.TestCheckResourceAttr(resourceName, "display_name", "displayName2"), |
| 294 | + resource.TestCheckResourceAttr(resourceName, "freeform_tags.%", "1"), |
| 295 | + resource.TestCheckResourceAttrSet(resourceName, "id"), |
| 296 | + resource.TestCheckResourceAttr(resourceName, "is_auto_scaling_enabled", "false"), |
| 297 | + resource.TestCheckResourceAttr(resourceName, "is_dedicated", "false"), |
| 298 | + resource.TestCheckResourceAttr(resourceName, "is_preview_version_with_service_terms_accepted", "false"), |
| 299 | + resource.TestCheckResourceAttr(resourceName, "license_model", "LICENSE_INCLUDED"), |
| 300 | + resource.TestCheckResourceAttr(resourceName, "state", "AVAILABLE"), |
234 | 301 |
|
235 | 302 | func(s *terraform.State) (err error) { |
236 | 303 | resId2, err = fromInstanceState(s, resourceName, "id") |
|
0 commit comments