Skip to content

Commit 769f621

Browse files
Terraform Team Automationravinitp
authored andcommitted
Added - Support for Oracle Home Version Control - Phase 3 (Patch ACD using GoldImage) | ADB-D & ADB-C@C
1 parent c0b9cad commit 769f621

17 files changed

+159
-12
lines changed

examples/database/atp-d/main.tf

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,14 @@ provider "oci" {
77
fingerprint = var.fingerprint
88
private_key_path = var.private_key_path
99
region = var.region
10-
version = "5.25.0"
1110
}
1211

1312
resource "oci_database_autonomous_container_database" "test_autonomous_container_database" {
1413
#Required
1514
cloud_autonomous_vm_cluster_id = oci_database_cloud_autonomous_vm_cluster.test_cloud_autonomous_vm_cluster.id
1615
display_name = "example-container-database"
1716
patch_model = "RELEASE_UPDATES"
18-
db_version = "19.22.0.1.0"
17+
db_version = "19.23.0.1.0"
1918
db_name = "ACDNAME"
2019

2120
#Optional
@@ -89,7 +88,6 @@ resource "oci_database_autonomous_container_database" "autonomous_container_data
8988
recovery_window_in_days = "7"
9089
}
9190
compartment_id = var.compartment_ocid
92-
db_unique_name = random_string.db_unique_name_adsi_acd.result
9391
display_name = "ACD-TFTest"
9492
freeform_tags = {
9593
"Department" = "Finance"

examples/database/exadata_cc/adbd/acd.tf

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
resource "random_string" "db_unique_name" {
22
length = 8
33
special = false
4+
numeric = false
45
}
56

67
resource "oci_database_autonomous_container_database" "autonomous_container_database" {
78
autonomous_vm_cluster_id = oci_database_autonomous_vm_cluster.test_autonomous_vm_cluster.id
8-
db_version = "19.20.0.1.0"
9+
db_version = "19.23.0.1.0"
910
backup_config {
1011
backup_destination_details {
1112
type = "LOCAL"

examples/database/exadata_cc/adbd/acd_from_adsi.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
resource "random_string" "db_unique_name_adsi_acd" {
22
length = 8
33
special = false
4-
number = false
4+
numeric = false
55
}
66

77
resource "oci_database_autonomous_container_database" "autonomous_container_database_from_adsi" {

internal/acctest/oci_dependency_graph.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ func InitDependencyGraph() {
1313
DependencyGraph["application"] = append(DependencyGraph["application"], "FunctionsFunction")
1414
DependencyGraph["asset"] = append(DependencyGraph["asset"], "CoreVolumeBackupPolicyAssignment")
1515
DependencyGraph["autonomousContainerDatabase"] = append(DependencyGraph["autonomousContainerDatabase"], "DatabaseAutonomousDatabase")
16+
DependencyGraph["autonomousDatabaseSoftwareImage"] = append(DependencyGraph["autonomousDatabaseSoftwareImage"], "DatabaseAutonomousContainerDatabase")
1617
DependencyGraph["autonomousDatabase"] = append(DependencyGraph["autonomousDatabase"], "DatabaseAutonomousDatabaseBackup")
1718
DependencyGraph["autonomousDatabase"] = append(DependencyGraph["autonomousDatabase"], "DatabaseAutonomousDatabaseInstanceWalletManagement")
1819
DependencyGraph["autonomousDatabase"] = append(DependencyGraph["autonomousDatabase"], "DatabaseAutonomousDatabaseWallet")

internal/integrationtest/database_autonomous_container_database_resource_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ var (
5757
"maintenance_window_details": acctest.RepresentationGroup{RepType: acctest.Optional, Group: DatabaseAutonomousContainerDatabaseMaintenanceWindowDetailsRepresentation},
5858
"service_level_agreement_type": acctest.Representation{RepType: acctest.Optional, Create: `STANDARD`},
5959
"db_name": acctest.Representation{RepType: acctest.Optional, Create: `DBNAME`},
60-
"db_version": acctest.Representation{RepType: acctest.Required, Create: `19.22.0.1.0`},
60+
"db_version": acctest.Representation{RepType: acctest.Required, Create: `19.23.0.1.0`},
6161
"is_dst_file_update_enabled": acctest.Representation{RepType: acctest.Optional, Create: `false`, Update: `true`},
6262
}
6363

internal/integrationtest/database_autonomous_container_database_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ var (
5959
"version_preference": acctest.Representation{RepType: acctest.Optional, Create: `LATEST_RELEASE_UPDATE`, Update: `NEXT_RELEASE_UPDATE`},
6060
"display_name": acctest.Representation{RepType: acctest.Required, Create: `containerDatabase2`, Update: `displayName2`},
6161
"patch_model": acctest.Representation{RepType: acctest.Required, Create: `RELEASE_UPDATES`, Update: `RELEASE_UPDATE_REVISIONS`},
62-
"db_version": acctest.Representation{RepType: acctest.Required, Create: `19.22.0.1.0`},
62+
"db_version": acctest.Representation{RepType: acctest.Required, Create: utils.GetEnvSettingWithDefault("acd_db_version", "19.22.0.1.0")},
6363
"cloud_autonomous_vm_cluster_id": acctest.Representation{RepType: acctest.Required, Create: `${oci_database_cloud_autonomous_vm_cluster.test_cloud_autonomous_vm_cluster.id}`},
6464
"backup_config": acctest.RepresentationGroup{RepType: acctest.Optional, Group: ACDatabaseBackupConfigRepresentation},
6565
"compartment_id": acctest.Representation{RepType: acctest.Optional, Create: `${var.compartment_id}`},

internal/integrationtest/database_maintenance_run_test.go

Lines changed: 109 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,12 +76,12 @@ var (
7676
"backup_config": acctest.RepresentationGroup{RepType: acctest.Required, Group: DatabaseAutonomousContainerDatabaseBackupConfigRepresentation},
7777
"key_store_id": acctest.Representation{RepType: acctest.Optional, Create: `${oci_database_key_store.test_key_store.id}`},
7878
"compartment_id": acctest.Representation{RepType: acctest.Optional, Create: `${var.compartment_id}`},
79-
"db_unique_name": acctest.Representation{RepType: acctest.Optional, Create: acbDBName},
79+
"db_unique_name": acctest.Representation{RepType: acctest.Optional, Create: acbDBName2},
8080
"defined_tags": acctest.Representation{RepType: acctest.Optional, Create: `${map("${oci_identity_tag_namespace.tag-namespace1.name}.${oci_identity_tag.tag1.name}", "value")}`, Update: `${map("${oci_identity_tag_namespace.tag-namespace1.name}.${oci_identity_tag.tag1.name}", "updatedValue")}`},
8181
"freeform_tags": acctest.Representation{RepType: acctest.Optional, Create: map[string]string{"Department": "Finance"}, Update: map[string]string{"Department": "Accounting"}},
8282
"maintenance_window_details": acctest.RepresentationGroup{RepType: acctest.Optional, Group: DatabaseAutonomousContainerDatabaseMaintenanceWindowDetailsRepresentation},
8383
"service_level_agreement_type": acctest.Representation{RepType: acctest.Optional, Create: `STANDARD`},
84-
"db_name": acctest.Representation{RepType: acctest.Optional, Create: `DBNAME`},
84+
"db_name": acctest.Representation{RepType: acctest.Optional, Create: `DBNAME2`},
8585
"db_version": acctest.Representation{RepType: acctest.Required, Create: `19.22.0.1.0`},
8686
"is_dst_file_update_enabled": acctest.Representation{RepType: acctest.Optional, Create: `false`, Update: `true`},
8787
}
@@ -92,12 +92,23 @@ var (
9292
ExaccDatabaseMaintenanceRunRepresentation = map[string]interface{}{
9393
"patch_type": acctest.Representation{RepType: acctest.Required, Create: `QUARTERLY`},
9494
"target_resource_id": acctest.Representation{RepType: acctest.Required, Create: `${oci_database_autonomous_container_database.test_autonomous_container_database.id}`},
95-
"compartment_id": acctest.Representation{RepType: acctest.Required, Create: `${var.compartment_id}`},
95+
"compartment_id": acctest.Representation{RepType: acctest.Optional, Create: `${var.compartment_id}`},
9696
"is_dst_file_update_enabled": acctest.Representation{RepType: acctest.Optional, Create: `false`},
9797
"patching_mode": acctest.Representation{RepType: acctest.Optional, Create: `ROLLING`, Update: `NONROLLING`},
9898
"time_scheduled": acctest.Representation{RepType: acctest.Required, Create: mrTimeScheduledCreate.Format(time.RFC3339Nano)},
9999
}
100100

101+
ExaccDatabaseMaintenanceRunFromAdsiRepresentation = map[string]interface{}{
102+
"patch_type": acctest.Representation{RepType: acctest.Required, Create: `CUSTOM_DATABASE_SOFTWARE_IMAGE`},
103+
"target_resource_id": acctest.Representation{RepType: acctest.Required, Create: `${oci_database_autonomous_container_database.test_autonomous_container_database_2.id}`},
104+
"compartment_id": acctest.Representation{RepType: acctest.Optional, Create: `${var.compartment_id}`},
105+
"database_software_image_id": acctest.Representation{RepType: acctest.Optional, Create: `${oci_database_autonomous_database_software_image.test_autonomous_database_software_image.id}`},
106+
"patching_mode": acctest.Representation{RepType: acctest.Optional, Create: `NONROLLING`},
107+
"time_scheduled": acctest.Representation{RepType: acctest.Required, Create: mrTimeScheduledCreate.Format(time.RFC3339Nano)},
108+
}
109+
110+
AdbdDatabaseMaintenanceRunFromAdsiRepresentation = ExaccDatabaseMaintenanceRunFromAdsiRepresentation
111+
101112
ExaccDatabaseMaintenanceRunResourceDependencies = ExaccMRACDResourceConfig
102113

103114
ExaccDatabaseMaintenanceRunSingularDataSourceRepresentation = map[string]interface{}{
@@ -119,7 +130,7 @@ var (
119130
"version_preference": acctest.Representation{RepType: acctest.Optional, Create: `LATEST_RELEASE_UPDATE`, Update: `NEXT_RELEASE_UPDATE`},
120131
"display_name": acctest.Representation{RepType: acctest.Required, Create: `containerDatabase2`, Update: `displayName2`},
121132
"patch_model": acctest.Representation{RepType: acctest.Required, Create: `RELEASE_UPDATES`, Update: `RELEASE_UPDATE_REVISIONS`},
122-
"db_version": acctest.Representation{RepType: acctest.Required, Create: `19.19.0.1.0`},
133+
"db_version": acctest.Representation{RepType: acctest.Required, Create: utils.GetEnvSettingWithDefault("mr_acd_db_version", "19.21.0.1.0")},
123134
"cloud_autonomous_vm_cluster_id": acctest.Representation{RepType: acctest.Required, Create: `${oci_database_cloud_autonomous_vm_cluster.test_cloud_autonomous_vm_cluster.id}`},
124135
"backup_config": acctest.RepresentationGroup{RepType: acctest.Optional, Group: ACDatabaseBackupConfigRepresentation},
125136
"compartment_id": acctest.Representation{RepType: acctest.Optional, Create: `${var.compartment_id}`},
@@ -133,6 +144,19 @@ var (
133144
"db_name": acctest.Representation{RepType: acctest.Optional, Create: `DBNAME`},
134145
"is_dst_file_update_enabled": acctest.Representation{RepType: acctest.Optional, Create: `false`, Update: `true`},
135146
}
147+
148+
AdbdMRACDatabaseRepresentation = acctest.RepresentationCopyWithNewProperties(DatabaseMRAutonomousContainerDatabaseRepresentation, map[string]interface{}{
149+
"db_name": acctest.Representation{RepType: acctest.Optional, Create: `DBNAME2`},
150+
})
151+
152+
ExaccDatabaseMaintenanceRunResourceFromAdsiDependencies = ExaccDatabaseAutonomousDatabaseSoftwareImageResourceConfig +
153+
acctest.GenerateResourceFromRepresentationMap("oci_database_autonomous_container_database", "test_autonomous_container_database_2", acctest.Optional, acctest.Update, ExaccMRACDatabaseRepresentation)
154+
155+
ExaccDatabaseMaintenanceRunFromAdsiResourceConfig = ExaccDatabaseMaintenanceRunResourceFromAdsiDependencies +
156+
acctest.GenerateResourceFromRepresentationMap("oci_database_maintenance_run", "test_maintenance_run", acctest.Optional, acctest.Update, ExaccDatabaseMaintenanceRunFromAdsiRepresentation)
157+
158+
AdbdDatabaseMaintenanceRunResourceFromAdsiDependencies = DatabaseAutonomousDatabaseSoftwareImageResourceConfig +
159+
acctest.GenerateResourceFromRepresentationMap("oci_database_autonomous_container_database", "test_autonomous_container_database_2", acctest.Optional, acctest.Update, AdbdMRACDatabaseRepresentation)
136160
)
137161

138162
// issue-routing-tag: database/dbaas-atp-d
@@ -369,6 +393,87 @@ func TestDatabaseMaintenanceRunResource_basic(t *testing.T) {
369393
})
370394
}
371395

396+
func TestExaccDatabaseMaintenanceRunFromAdsiResource(t *testing.T) {
397+
httpreplay.SetScenario("TestExaccDatabaseMaintenanceRunFromAdsiResource")
398+
defer httpreplay.SaveScenario()
399+
config := acctest.ProviderTestConfig()
400+
compartmentId := utils.GetEnvSettingWithBlankDefault("compartment_ocid")
401+
compartmentIdVariableStr := fmt.Sprintf("variable \"compartment_id\" { default = \"%s\" }\n", compartmentId)
402+
resourceName := "oci_database_maintenance_run.test_maintenance_run"
403+
singularDatasourceName := "data.oci_database_maintenance_run.test_maintenance_run"
404+
405+
acctest.ResourceTest(t, nil, []resource.TestStep{
406+
// create maintenance run
407+
{
408+
Config: config + compartmentIdVariableStr + ExaccDatabaseMaintenanceRunResourceFromAdsiDependencies +
409+
acctest.GenerateResourceFromRepresentationMap("oci_database_maintenance_run", "test_maintenance_run",
410+
acctest.Optional, acctest.Create, ExaccDatabaseMaintenanceRunFromAdsiRepresentation),
411+
Check: acctest.ComposeAggregateTestCheckFuncWrapper(
412+
resource.TestCheckResourceAttr(resourceName, "maintenance_subtype", "CUSTOM_DATABASE_SOFTWARE_IMAGE"),
413+
resource.TestCheckResourceAttrSet(resourceName, "target_resource_id"),
414+
resource.TestCheckResourceAttrSet(resourceName, "database_software_image_id"),
415+
resource.TestCheckResourceAttr(resourceName, "time_scheduled", mrTimeScheduledCreate.Format(time.RFC3339Nano)),
416+
resource.TestCheckResourceAttr(resourceName, "patching_mode", `NONROLLING`),
417+
func(s *terraform.State) (err error) {
418+
_, err = acctest.FromInstanceState(s, resourceName, "id")
419+
return err
420+
},
421+
),
422+
},
423+
// verify singular datasource
424+
{
425+
Config: config +
426+
acctest.GenerateDataSourceFromRepresentationMap("oci_database_maintenance_run", "test_maintenance_run", acctest.Required, acctest.Create, ExaccDatabaseMaintenanceRunSingularDataSourceRepresentation) +
427+
compartmentIdVariableStr + ExaccDatabaseMaintenanceRunFromAdsiResourceConfig,
428+
Check: acctest.ComposeAggregateTestCheckFuncWrapper(
429+
resource.TestCheckResourceAttrSet(singularDatasourceName, "maintenance_run_id"),
430+
resource.TestCheckResourceAttr(singularDatasourceName, "compartment_id", compartmentId),
431+
resource.TestCheckResourceAttr(singularDatasourceName, "maintenance_subtype", "CUSTOM_DATABASE_SOFTWARE_IMAGE"),
432+
resource.TestCheckResourceAttrSet(singularDatasourceName, "target_resource_id"),
433+
resource.TestCheckResourceAttrSet(singularDatasourceName, "id"),
434+
resource.TestCheckResourceAttr(singularDatasourceName, "patching_mode", "NONROLLING"),
435+
resource.TestCheckResourceAttrSet(singularDatasourceName, "state"),
436+
resource.TestCheckResourceAttrSet(singularDatasourceName, "time_scheduled"),
437+
),
438+
},
439+
{
440+
Config: config + compartmentIdVariableStr + ExaccDatabaseAutonomousDatabaseSoftwareImageResourceConfig,
441+
},
442+
})
443+
}
444+
445+
func TestAdbdDatabaseMaintenanceRunFromAdsiResource(t *testing.T) {
446+
httpreplay.SetScenario("TestAdbdDatabaseMaintenanceRunFromAdsiResource")
447+
defer httpreplay.SaveScenario()
448+
config := acctest.ProviderTestConfig()
449+
compartmentId := utils.GetEnvSettingWithBlankDefault("compartment_ocid")
450+
compartmentIdVariableStr := fmt.Sprintf("variable \"compartment_id\" { default = \"%s\" }\n", compartmentId)
451+
resourceName := "oci_database_maintenance_run.test_maintenance_run"
452+
453+
acctest.ResourceTest(t, nil, []resource.TestStep{
454+
// create maintenance run
455+
{
456+
Config: config + compartmentIdVariableStr + AdbdDatabaseMaintenanceRunResourceFromAdsiDependencies +
457+
acctest.GenerateResourceFromRepresentationMap("oci_database_maintenance_run", "test_maintenance_run",
458+
acctest.Optional, acctest.Create, AdbdDatabaseMaintenanceRunFromAdsiRepresentation),
459+
Check: acctest.ComposeAggregateTestCheckFuncWrapper(
460+
resource.TestCheckResourceAttr(resourceName, "maintenance_subtype", "CUSTOM_DATABASE_SOFTWARE_IMAGE"),
461+
resource.TestCheckResourceAttrSet(resourceName, "target_resource_id"),
462+
resource.TestCheckResourceAttrSet(resourceName, "database_software_image_id"),
463+
resource.TestCheckResourceAttr(resourceName, "time_scheduled", mrTimeScheduledCreate.Format(time.RFC3339Nano)),
464+
resource.TestCheckResourceAttr(resourceName, "patching_mode", `NONROLLING`),
465+
func(s *terraform.State) (err error) {
466+
_, err = acctest.FromInstanceState(s, resourceName, "id")
467+
return err
468+
},
469+
),
470+
},
471+
{
472+
Config: config + compartmentIdVariableStr + DatabaseAutonomousDatabaseSoftwareImageResourceConfig,
473+
},
474+
})
475+
}
476+
372477
func TestExaccDatabaseMaintenanceRunResource(t *testing.T) {
373478
httpreplay.SetScenario("TestDatabaseMaintenanceRunResource")
374479
defer httpreplay.SaveScenario()

internal/service/database/database_maintenance_run_data_source.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,10 @@ func (s *DatabaseMaintenanceRunDataSourceCrud) SetData() error {
8383
s.D.Set("custom_action_timeout_in_mins", *s.Res.CustomActionTimeoutInMins)
8484
}
8585

86+
if s.Res.DatabaseSoftwareImageId != nil {
87+
s.D.Set("database_software_image_id", *s.Res.DatabaseSoftwareImageId)
88+
}
89+
8690
if s.Res.Description != nil {
8791
s.D.Set("description", *s.Res.Description)
8892
}

internal/service/database/database_maintenance_run_histories_data_source.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,10 @@ func DatabaseMaintenanceRunHistoriesDataSource() *schema.Resource {
132132
Type: schema.TypeInt,
133133
Computed: true,
134134
},
135+
"database_software_image_id": {
136+
Type: schema.TypeString,
137+
Computed: true,
138+
},
135139
"description": {
136140
Type: schema.TypeString,
137141
Computed: true,
@@ -458,6 +462,10 @@ func MaintenanceRunSummaryToMap(obj *oci_database.MaintenanceRunSummary) map[str
458462
result["custom_action_timeout_in_mins"] = int(*obj.CustomActionTimeoutInMins)
459463
}
460464

465+
if obj.DatabaseSoftwareImageId != nil {
466+
result["database_software_image_id"] = string(*obj.DatabaseSoftwareImageId)
467+
}
468+
461469
if obj.Description != nil {
462470
result["description"] = string(*obj.Description)
463471
}

internal/service/database/database_maintenance_run_history_data_source.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,10 @@ func DatabaseMaintenanceRunHistoryDataSource() *schema.Resource {
9898
Type: schema.TypeInt,
9999
Computed: true,
100100
},
101+
"database_software_image_id": {
102+
Type: schema.TypeString,
103+
Computed: true,
104+
},
101105
"description": {
102106
Type: schema.TypeString,
103107
Computed: true,

0 commit comments

Comments
 (0)