@@ -1302,6 +1302,111 @@ func TestResourceDatabaseAutonomousDatabaseResource_longtermBackup(t *testing.T)
13021302 })
13031303}
13041304
1305+ func TestDatabaseAutonomousDatabaseResource_schedule_upgrade (t * testing.T ) {
1306+ httpreplay .SetScenario ("TestDatabaseAutonomousDatabaseResource_schedule_upgrade" )
1307+ defer httpreplay .SaveScenario ()
1308+
1309+ config := acctest .ProviderTestConfig ()
1310+
1311+ compartmentId := utils .GetEnvSettingWithBlankDefault ("compartment_ocid" )
1312+ compartmentIdVariableStr := fmt .Sprintf ("variable \" compartment_id\" { default = \" %s\" }\n " , compartmentId )
1313+
1314+ resourceName := "oci_database_autonomous_database.test_autonomous_database"
1315+
1316+ acctest .SaveConfigContent (config + compartmentIdVariableStr + DatabaseAutonomousDatabaseResourceDependenciesLockBckRetention +
1317+ acctest .GenerateResourceFromRepresentationMap ("oci_database_autonomous_database" , "test_autonomous_database" , acctest .Optional , acctest .Create , DatabaseAutonomousDatabaseRepresentationLockBckRetention ), "database" , "autonomousDatabase" , t )
1318+
1319+ acctest .ResourceTest (t , testAccCheckDatabaseAutonomousDatabaseDestroy , []resource.TestStep {
1320+ //0. Verify Create
1321+ {
1322+ Config : config + compartmentIdVariableStr + DatabaseAutonomousDatabaseResourceDependencies +
1323+ acctest .GenerateResourceFromRepresentationMap ("oci_database_autonomous_database" , "test_autonomous_database" , acctest .Optional , acctest .Create , DatabaseAutonomousDatabaseRepresentationLockBckRetention ),
1324+ Check : acctest .ComposeAggregateTestCheckFuncWrapper (
1325+ resource .TestCheckResourceAttr (resourceName , "compute_model" , "ECPU" ),
1326+ resource .TestCheckResourceAttr (resourceName , "compartment_id" , compartmentId ),
1327+ resource .TestCheckResourceAttr (resourceName , "db_name" , adbName ),
1328+ ),
1329+ },
1330+ //1. schedule to earliest available time
1331+ {
1332+ Config : config + compartmentIdVariableStr + DatabaseAutonomousDatabaseResourceDependencies +
1333+ acctest .GenerateResourceFromRepresentationMap ("oci_database_autonomous_database" , "test_autonomous_database" , acctest .Optional , acctest .Update ,
1334+ acctest .RepresentationCopyWithRemovedProperties (acctest .RepresentationCopyWithNewProperties (DatabaseAutonomousDatabaseRepresentationLockBckRetention , map [string ]interface {}{
1335+ "is_schedule_db_version_upgrade_to_earliest" : acctest.Representation {RepType : acctest .Optional , Create : nil , Update : `true` },
1336+ "db_version" : acctest.Representation {RepType : acctest .Optional , Create : nil , Update : `23ai` },
1337+ }), []string {"admin_password" , "customer_contacts" , "freeform_tags" , "display_name" })),
1338+ ExpectNonEmptyPlan : true ,
1339+ Check : acctest .ComposeAggregateTestCheckFuncWrapper (
1340+ resource .TestCheckResourceAttr (resourceName , "compute_model" , "ECPU" ),
1341+ resource .TestCheckResourceAttr (resourceName , "compartment_id" , compartmentId ),
1342+ resource .TestCheckResourceAttr (resourceName , "db_name" , adbName ),
1343+ ),
1344+ },
1345+ //2. update schedule time for db upgrade
1346+ {
1347+ Config : config + compartmentIdVariableStr + DatabaseAutonomousDatabaseResourceDependencies +
1348+ acctest .GenerateResourceFromRepresentationMap ("oci_database_autonomous_database" , "test_autonomous_database" , acctest .Optional , acctest .Update ,
1349+ acctest .RepresentationCopyWithRemovedProperties (acctest .RepresentationCopyWithNewProperties (DatabaseAutonomousDatabaseRepresentationLockBckRetention , map [string ]interface {}{
1350+ "time_scheduled_db_version_upgrade" : acctest.Representation {RepType : acctest .Optional , Create : nil , Update : timeOfAutoRefreshCreate .Truncate (10 * time .Minute ).Add (10 * time .Minute ).Format (time .RFC3339 )},
1351+ "db_version" : acctest.Representation {RepType : acctest .Optional , Create : nil , Update : `23ai` },
1352+ }), []string {"admin_password" , "customer_contacts" , "freeform_tags" , "display_name" })),
1353+ ExpectNonEmptyPlan : true ,
1354+ Check : acctest .ComposeAggregateTestCheckFuncWrapper (
1355+ resource .TestCheckResourceAttr (resourceName , "compute_model" , "ECPU" ),
1356+ resource .TestCheckResourceAttr (resourceName , "compartment_id" , compartmentId ),
1357+ resource .TestCheckResourceAttr (resourceName , "db_name" , adbName ),
1358+ resource .TestCheckResourceAttrSet (resourceName , "time_scheduled_db_version_upgrade" ),
1359+ ),
1360+ },
1361+ //3. re-schedule time for db upgrade
1362+ {
1363+ Config : config + compartmentIdVariableStr + DatabaseAutonomousDatabaseResourceDependencies +
1364+ acctest .GenerateResourceFromRepresentationMap ("oci_database_autonomous_database" , "test_autonomous_database" , acctest .Optional , acctest .Update ,
1365+ acctest .RepresentationCopyWithRemovedProperties (acctest .RepresentationCopyWithNewProperties (DatabaseAutonomousDatabaseRepresentationLockBckRetention , map [string ]interface {}{
1366+ "time_scheduled_db_version_upgrade" : acctest.Representation {RepType : acctest .Optional , Create : nil , Update : timeOfAutoRefreshUpdate .Truncate (10 * time .Minute ).Add (10 * time .Minute ).Format (time .RFC3339 )},
1367+ "db_version" : acctest.Representation {RepType : acctest .Optional , Create : nil , Update : `23ai` },
1368+ }), []string {"admin_password" , "customer_contacts" , "freeform_tags" , "display_name" })),
1369+ ExpectNonEmptyPlan : true ,
1370+ Check : acctest .ComposeAggregateTestCheckFuncWrapper (
1371+ resource .TestCheckResourceAttr (resourceName , "compute_model" , "ECPU" ),
1372+ resource .TestCheckResourceAttr (resourceName , "compartment_id" , compartmentId ),
1373+ resource .TestCheckResourceAttr (resourceName , "db_name" , adbName ),
1374+ resource .TestCheckResourceAttrSet (resourceName , "time_scheduled_db_version_upgrade" ),
1375+ ),
1376+ },
1377+ //4. cancel time for db upgrade
1378+ {
1379+ Config : config + compartmentIdVariableStr + DatabaseAutonomousDatabaseResourceDependencies +
1380+ acctest .GenerateResourceFromRepresentationMap ("oci_database_autonomous_database" , "test_autonomous_database" , acctest .Optional , acctest .Update ,
1381+ acctest .RepresentationCopyWithRemovedProperties (acctest .RepresentationCopyWithNewProperties (DatabaseAutonomousDatabaseRepresentationLockBckRetention , map [string ]interface {}{
1382+ "is_disable_db_version_upgrade_schedule" : acctest.Representation {RepType : acctest .Optional , Create : nil , Update : `true` },
1383+ }), []string {"admin_password" , "customer_contacts" , "freeform_tags" , "display_name" })),
1384+ Check : acctest .ComposeAggregateTestCheckFuncWrapper (
1385+ resource .TestCheckResourceAttr (resourceName , "compute_model" , "ECPU" ),
1386+ resource .TestCheckResourceAttr (resourceName , "compartment_id" , compartmentId ),
1387+ resource .TestCheckResourceAttr (resourceName , "db_name" , adbName ),
1388+ ),
1389+ },
1390+ //5. scheduled db upgrade time again
1391+ {
1392+ Config : config + compartmentIdVariableStr + DatabaseAutonomousDatabaseResourceDependencies +
1393+ acctest .GenerateResourceFromRepresentationMap ("oci_database_autonomous_database" , "test_autonomous_database" , acctest .Optional , acctest .Update ,
1394+ acctest .RepresentationCopyWithRemovedProperties (acctest .RepresentationCopyWithNewProperties (DatabaseAutonomousDatabaseRepresentationLockBckRetention , map [string ]interface {}{
1395+ "time_scheduled_db_version_upgrade" : acctest.Representation {RepType : acctest .Optional , Create : nil , Update : timeOfAutoRefreshCreate .Truncate (10 * time .Minute ).Add (10 * time .Minute ).Format (time .RFC3339 )},
1396+ "is_disable_db_version_upgrade_schedule" : acctest.Representation {RepType : acctest .Optional , Create : nil , Update : `false` },
1397+ "db_version" : acctest.Representation {RepType : acctest .Optional , Create : nil , Update : `23ai` },
1398+ }), []string {"admin_password" , "customer_contacts" , "freeform_tags" , "display_name" })),
1399+ ExpectNonEmptyPlan : true ,
1400+ Check : acctest .ComposeAggregateTestCheckFuncWrapper (
1401+ resource .TestCheckResourceAttr (resourceName , "compute_model" , "ECPU" ),
1402+ resource .TestCheckResourceAttr (resourceName , "compartment_id" , compartmentId ),
1403+ resource .TestCheckResourceAttr (resourceName , "db_name" , adbName ),
1404+ resource .TestCheckResourceAttrSet (resourceName , "time_scheduled_db_version_upgrade" ),
1405+ ),
1406+ },
1407+ })
1408+ }
1409+
13051410// issue-routing-tag: database/dbaas-adb
13061411func TestResourceDatabaseAutonomousDatabaseResource_dataSafeStatus (t * testing.T ) {
13071412 shouldSkipADBStest := os .Getenv ("TF_VAR_should_skip_adbs_test" )
0 commit comments