Skip to content

Commit d93893b

Browse files
Yue DengMaxrovr
authored andcommitted
Added - Support for PDB Snapshots on ExaDB-XS
1 parent d0a989a commit d93893b

18 files changed

+1158
-30
lines changed

examples/database/db_systems/db_exadbxs/exadb_vm_cluster_database.tf

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,14 @@ resource "oci_database_database" "test_db1" {
1616
source = "NONE"
1717
}
1818

19-
resource "oci_database_database" "test_db2" {
20-
database {
21-
admin_password = var.test_db_password
22-
db_name = "TFDB2"
23-
}
24-
db_home_id = oci_database_db_home.test_db_home.id
25-
source = "NONE"
26-
}
19+
# resource "oci_database_database" "test_db2" {
20+
# database {
21+
# admin_password = var.test_db_password
22+
# db_name = "TFDB2"
23+
# }
24+
# db_home_id = oci_database_db_home.test_db_home.id
25+
# source = "NONE"
26+
# }
2727

2828
resource "oci_database_pluggable_database" "test_db1_pdb" {
2929
container_database_id = oci_database_database.test_db1.id
@@ -32,6 +32,11 @@ resource "oci_database_pluggable_database" "test_db1_pdb" {
3232
tde_wallet_password = var.test_db_password
3333
}
3434

35+
resource "oci_database_pluggable_database_snapshot" "test_db1_pdb_snapshot" {
36+
name = "DB1PdbSnapshot"
37+
pluggable_database_id = oci_database_pluggable_database.test_db1_pdb.id
38+
}
39+
3540
resource "oci_database_pluggable_database" "test_db1_local_cloned_pdb" {
3641
container_database_id = oci_database_database.test_db1.id
3742
pdb_name = "DB1LocalThinClonedPDB"
@@ -40,6 +45,7 @@ resource "oci_database_pluggable_database" "test_db1_local_cloned_pdb" {
4045
pdb_creation_type_details {
4146
creation_type = "LOCAL_CLONE_PDB"
4247
source_pluggable_database_id = oci_database_pluggable_database.test_db1_pdb.id
48+
source_pluggable_database_snapshot_id = oci_database_pluggable_database_snapshot.test_db1_pdb_snapshot.id
4349
is_thin_clone = true
4450
}
4551
}
@@ -53,10 +59,20 @@ resource "oci_database_pluggable_database" "test_db1_local_cloned_pdb" {
5359
# creation_type = "REMOTE_CLONE_PDB"
5460
# source_container_database_admin_password = var.test_db_password
5561
# source_pluggable_database_id = oci_database_pluggable_database.test_db1_pdb.id
62+
# source_pluggable_database_snapshot_id = oci_database_pluggable_database_snapshot.test_db1_pdb_snapshot.id
5663
# is_thin_clone = true
5764
# }
5865
# }
5966

67+
data "oci_database_pluggable_database_snapshots" "test_pdb_snapshots" {
68+
compartment_id = var.compartment_ocid
69+
cluster_id = oci_database_exadb_vm_cluster.test_exadb_vm_cluster.id
70+
}
71+
72+
data "oci_database_pluggable_database_snapshot" "test_db1_pdb_snapshot" {
73+
pluggable_database_snapshot_id = oci_database_pluggable_database_snapshot.test_db1_pdb_snapshot.id
74+
}
75+
6076
data "oci_database_pluggable_databases" "test_pdbs" {
6177
compartment_id = var.compartment_ocid
6278
state = "AVAILABLE"

examples/database/db_systems/db_exadbxs/exadb_vm_cluster_update_history_entries.tf

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ data "oci_database_exadb_vm_cluster_update_history_entries" "test_exadb_vm_clust
55
update_type = "OS_UPDATE"
66
}
77

8-
data "oci_database_exadb_vm_cluster_update_history_entry" "test_exadb_vm_cluster_update_history_entry" {
9-
#Required
10-
exadb_vm_cluster_id = oci_database_exadb_vm_cluster.test_exadb_vm_cluster.id
11-
#Optional
12-
update_history_entry_id = data.oci_database_exadb_vm_cluster_update_history_entries.test_exadb_vm_cluster_update_history_entries.exadb_vm_cluster_update_history_entries[0].id
13-
}
8+
# data "oci_database_exadb_vm_cluster_update_history_entry" "test_exadb_vm_cluster_update_history_entry" {
9+
# #Required
10+
# exadb_vm_cluster_id = oci_database_exadb_vm_cluster.test_exadb_vm_cluster.id
11+
# #Optional
12+
# update_history_entry_id = data.oci_database_exadb_vm_cluster_update_history_entries.test_exadb_vm_cluster_update_history_entries.exadb_vm_cluster_update_history_entries[0].id
13+
# }

examples/database/db_systems/db_exadbxs/exadb_vm_cluster_updates.tf

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ data "oci_database_exadb_vm_cluster_updates" "test_exadb_vm_cluster_updates" {
55
update_type = "GI_PATCH"
66
}
77

8-
data "oci_database_exadb_vm_cluster_update" "test_exadb_vm_cluster_update" {
9-
#Required
10-
exadb_vm_cluster_id = oci_database_exadb_vm_cluster.test_exadb_vm_cluster.id
11-
update_id = data.oci_database_exadb_vm_cluster_updates.test_exadb_vm_cluster_updates.exadb_vm_cluster_updates[0].id
12-
}
8+
# data "oci_database_exadb_vm_cluster_update" "test_exadb_vm_cluster_update" {
9+
# #Required
10+
# exadb_vm_cluster_id = oci_database_exadb_vm_cluster.test_exadb_vm_cluster.id
11+
# update_id = data.oci_database_exadb_vm_cluster_updates.test_exadb_vm_cluster_updates.exadb_vm_cluster_updates[0].id
12+
# }

internal/integrationtest/database_exadb_vm_cluster_pluggable_database_local_clone_test.go

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,20 +43,27 @@ var (
4343
}
4444

4545
ExaDbVmClusterLocalClonePdbCreationTypeDetailsRepresentation = map[string]interface{}{
46-
"creation_type": acctest.Representation{RepType: acctest.Required, Create: `LOCAL_CLONE_PDB`},
47-
"source_pluggable_database_id": acctest.Representation{RepType: acctest.Required, Create: `${var.source_pluggable_database_id}`},
48-
"is_thin_clone": acctest.Representation{RepType: acctest.Required, Create: `true`},
46+
"creation_type": acctest.Representation{RepType: acctest.Required, Create: `LOCAL_CLONE_PDB`},
47+
"source_pluggable_database_id": acctest.Representation{RepType: acctest.Required, Create: `${data.oci_database_pluggable_database_snapshot.source_pdb_snapshot.pluggable_database_id}`},
48+
"source_pluggable_database_snapshot_id": acctest.Representation{RepType: acctest.Required, Create: `${data.oci_database_pluggable_database_snapshot.source_pdb_snapshot.id}`},
49+
"is_thin_clone": acctest.Representation{RepType: acctest.Required, Create: `true`},
4950
}
5051

5152
ExaDbVmClusterLocalClonePdbIgnoreDefinedTagsRepresentation = map[string]interface{}{
5253
"ignore_changes": acctest.Representation{RepType: acctest.Required, Create: []string{`defined_tags`}},
5354
}
5455

55-
// Note: set env variable TF_VAR_source_pluggable_database_id before running this test
56+
// Note: set env variable TF_VAR_source_pdb_snapshot_id before running this test
57+
ExaDbVmClusterLocalCloneSourcePDBSnapshotSingularDataSourceRepresentation = map[string]interface{}{
58+
"pluggable_database_snapshot_id": acctest.Representation{RepType: acctest.Required, Create: `${var.source_pdb_snapshot_id}`},
59+
}
60+
5661
ExaDbVmClusterLocalCloneSourcePDBSingularDataSourceRepresentation = map[string]interface{}{
57-
"pluggable_database_id": acctest.Representation{RepType: acctest.Required, Create: `${var.source_pluggable_database_id}`},
62+
"pluggable_database_id": acctest.Representation{RepType: acctest.Required, Create: `${data.oci_database_pluggable_database_snapshot.source_pdb_snapshot.pluggable_database_id}`},
5863
}
59-
ExaDbVmClusterLocalClonePdbResourceDependencies = `variable "source_pluggable_database_id" {}` +
64+
65+
ExaDbVmClusterLocalClonePdbResourceDependencies = `variable "source_pdb_snapshot_id" {}` +
66+
acctest.GenerateDataSourceFromRepresentationMap("oci_database_pluggable_database_snapshot", "source_pdb_snapshot", acctest.Optional, acctest.Create, ExaDbVmClusterLocalCloneSourcePDBSnapshotSingularDataSourceRepresentation) +
6067
acctest.GenerateDataSourceFromRepresentationMap("oci_database_pluggable_database", "source_pdb", acctest.Optional, acctest.Create, ExaDbVmClusterLocalCloneSourcePDBSingularDataSourceRepresentation)
6168
)
6269

@@ -95,6 +102,7 @@ func TestDatabaseExaDbVmClusterPluggableDatabaseResource_localThinClone(t *testi
95102
resource.TestCheckResourceAttr(resourceName, "pdb_creation_type_details.0.creation_type", "LOCAL_CLONE_PDB"),
96103
resource.TestCheckResourceAttr(resourceName, "pdb_creation_type_details.0.is_thin_clone", "true"),
97104
resource.TestCheckResourceAttrSet(resourceName, "pdb_creation_type_details.0.source_pluggable_database_id"),
105+
resource.TestCheckResourceAttrSet(resourceName, "pdb_creation_type_details.0.source_pluggable_database_snapshot_id"),
98106
),
99107
},
100108
// verify datasource

internal/integrationtest/database_exadb_vm_cluster_pluggable_database_remote_clone_test.go

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,18 +45,29 @@ var (
4545
ExaDbVmClusterRemoteClonePdbCreationTypeDetailsRepresentation = map[string]interface{}{
4646
"creation_type": acctest.Representation{RepType: acctest.Required, Create: `REMOTE_CLONE_PDB`},
4747
"source_container_database_admin_password": acctest.Representation{RepType: acctest.Required, Create: `BEstrO0ng_#11`},
48-
"source_pluggable_database_id": acctest.Representation{RepType: acctest.Required, Create: `${var.source_pluggable_database_id}`},
48+
"source_pluggable_database_id": acctest.Representation{RepType: acctest.Required, Create: `${data.oci_database_pluggable_database_snapshot.source_pdb_snapshot.pluggable_database_id}`},
49+
"source_pluggable_database_snapshot_id": acctest.Representation{RepType: acctest.Required, Create: `${data.oci_database_pluggable_database_snapshot.source_pdb_snapshot.id}`},
4950
"is_thin_clone": acctest.Representation{RepType: acctest.Required, Create: `true`},
5051
}
5152

5253
ExaDbVmClusterRemoteClonePdbIgnoreDefinedTagsRepresentation = map[string]interface{}{
5354
"ignore_changes": acctest.Representation{RepType: acctest.Required, Create: []string{`defined_tags`}},
5455
}
5556

56-
// Note: set env variable TF_VAR_source_pluggable_database_id and TF_VAR_destination_database_id before running this test
57+
// Note: set env variable TF_VAR_source_pdb_snapshot_id and TF_VAR_destination_database_id before running this test
58+
ExaDbVmClusterRemoteCloneSourcePDBSnapshotSingularDataSourceRepresentation = map[string]interface{}{
59+
"pluggable_database_snapshot_id": acctest.Representation{RepType: acctest.Required, Create: `${var.source_pdb_snapshot_id}`},
60+
}
61+
62+
ExaDbVmClusterRemoteCloneSourcePDBSingularDataSourceRepresentation = map[string]interface{}{
63+
"pluggable_database_id": acctest.Representation{RepType: acctest.Required, Create: `${data.oci_database_pluggable_database_snapshot.source_pdb_snapshot.pluggable_database_id}`},
64+
}
65+
5766
ExaDbVmClusterRemoteClonePdbResourceDependencies = `
58-
variable "source_pluggable_database_id" {}
59-
variable "destination_database_id" {}`
67+
variable "source_pdb_snapshot_id" {}
68+
variable "destination_database_id" {}` +
69+
acctest.GenerateDataSourceFromRepresentationMap("oci_database_pluggable_database_snapshot", "source_pdb_snapshot", acctest.Optional, acctest.Create, ExaDbVmClusterRemoteCloneSourcePDBSnapshotSingularDataSourceRepresentation) +
70+
acctest.GenerateDataSourceFromRepresentationMap("oci_database_pluggable_database", "source_pdb", acctest.Optional, acctest.Create, ExaDbVmClusterRemoteCloneSourcePDBSingularDataSourceRepresentation)
6071
)
6172

6273
// issue-routing-tag: database/ExaCS
@@ -94,6 +105,7 @@ func TestDatabaseExaDbVmClusterPluggableDatabaseResource_remoteThinClone(t *test
94105
resource.TestCheckResourceAttr(resourceName, "pdb_creation_type_details.0.creation_type", "REMOTE_CLONE_PDB"),
95106
resource.TestCheckResourceAttr(resourceName, "pdb_creation_type_details.0.is_thin_clone", "true"),
96107
resource.TestCheckResourceAttrSet(resourceName, "pdb_creation_type_details.0.source_pluggable_database_id"),
108+
resource.TestCheckResourceAttrSet(resourceName, "pdb_creation_type_details.0.source_pluggable_database_snapshot_id"),
97109
resource.TestCheckResourceAttrSet(resourceName, "pdb_creation_type_details.0.source_container_database_admin_password"),
98110
),
99111
},

0 commit comments

Comments
 (0)