Skip to content

Commit f969478

Browse files
Yue DengNagaRajuPasunuri
authored andcommitted
Added - Support for Oracle Database @ Azure in ExaDB-XS service
1 parent 56a7478 commit f969478

17 files changed

+179
-9
lines changed

examples/database/db_systems/db_exadbxs/exadb_vm_cluster.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ resource "oci_database_exadb_vm_cluster" "test_exadb_vm_cluster" {
1414
shape = "EXADBXS"
1515
ssh_public_keys = [var.ssh_public_key]
1616
subnet_id = oci_core_subnet.exadbxs_client_subnet.id
17+
subscription_id = var.subscription_id
1718
backup_subnet_id = oci_core_subnet.exadbxs_backup_subnet.id
1819

1920
node_config {

examples/database/db_systems/db_exadbxs/exascale_db_storage_vault.tf

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ resource "oci_database_exascale_db_storage_vault" "test_exascale_db_storage_vaul
1010
total_size_in_gbs = 800
1111
}
1212
additional_flash_cache_in_percent = 20
13+
cluster_placement_group_id = var.cpg_id
14+
subscription_id = var.subscription_id
1315
}
1416

1517
data "oci_database_exascale_db_storage_vaults" "test_exascale_db_storage_vaults" {

examples/database/db_systems/db_exadbxs/variables.tf

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,12 @@ variable "db_name" {
1919

2020
variable "test_db_password" {
2121
default = "BEstrO0ng_#11"
22+
}
23+
24+
variable "cpg_id" {
25+
default = null
26+
}
27+
28+
variable "subscription_id" {
29+
default = null
2230
}

internal/integrationtest/database_exadb_vm_cluster_test.go

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,11 @@ import (
2424
"github.com/oracle/terraform-provider-oci/internal/utils"
2525
)
2626

27+
/*
28+
Pre-requisite to run the tests:
29+
1. create a cluster placement group and set its ocid to env variable TF_VAR_cpg_id
30+
2. set env variable TF_VAR_grid_image_id to the ocid of a valid gridImage
31+
*/
2732
var (
2833
DatabaseExadbVmClusterRequiredOnlyResource = DatabaseExadbVmClusterResourceDependencies +
2934
acctest.GenerateResourceFromRepresentationMap("oci_database_exadb_vm_cluster", "test_exadb_vm_cluster", acctest.Required, acctest.Create, DatabaseExadbVmClusterRepresentation)
@@ -37,6 +42,7 @@ var (
3742

3843
DatabaseExadbVmClusterDataSourceRepresentation = map[string]interface{}{
3944
"compartment_id": acctest.Representation{RepType: acctest.Required, Create: `${var.compartment_id}`},
45+
"cluster_placement_group_id": acctest.Representation{RepType: acctest.Optional, Create: `${var.cpg_id}`},
4046
"display_name": acctest.Representation{RepType: acctest.Optional, Create: `TFExadbVmCluster`, Update: `TFExadbVmClusterUpdatedName`},
4147
"exascale_db_storage_vault_id": acctest.Representation{RepType: acctest.Optional, Create: `${oci_database_exascale_db_storage_vault.test_exascale_db_storage_vault.id}`},
4248
"state": acctest.Representation{RepType: acctest.Optional, Create: `AVAILABLE`},
@@ -194,10 +200,16 @@ var (
194200
}
195201
`
196202

197-
// Note: set env variable TF_VAR_grid_image_id before running this test
198-
GridImageIdDependency = `variable "grid_image_id" {}`
199-
DatabaseExadbVmClusterResourceDependencies = AvailabilityDomainConfig + ExadbVmClusterNetwork + GridImageIdDependency +
200-
acctest.GenerateResourceFromRepresentationMap("oci_database_exascale_db_storage_vault", "test_exascale_db_storage_vault", acctest.Required, acctest.Create, DatabaseExascaleDbStorageVaultRepresentation)
203+
ExadbVmClusterVariables = `
204+
variable "grid_image_id" {}
205+
variable "cpg_id" {}
206+
`
207+
208+
DatabaseExadbVmClusterResourceDependencies = AvailabilityDomainConfig + ExadbVmClusterNetwork + ExadbVmClusterVariables +
209+
acctest.GenerateResourceFromRepresentationMap("oci_database_exascale_db_storage_vault", "test_exascale_db_storage_vault", acctest.Required, acctest.Create,
210+
acctest.RepresentationCopyWithNewProperties(DatabaseExascaleDbStorageVaultRepresentation, map[string]interface{}{
211+
"cluster_placement_group_id": acctest.Representation{RepType: acctest.Required, Create: `${var.cpg_id}`},
212+
}))
201213
)
202214

203215
// issue-routing-tag: database/ExaCS
@@ -207,6 +219,7 @@ func TestDatabaseExadbVmClusterResource_basic(t *testing.T) {
207219

208220
config := acctest.ProviderTestConfig()
209221

222+
cpgId := utils.GetRequiredEnvSetting("cpg_id")
210223
compartmentId := utils.GetEnvSettingWithBlankDefault("compartment_ocid")
211224
compartmentIdVariableStr := fmt.Sprintf("variable \"compartment_id\" { default = \"%s\" }\n", compartmentId)
212225

@@ -230,6 +243,7 @@ func TestDatabaseExadbVmClusterResource_basic(t *testing.T) {
230243
Check: acctest.ComposeAggregateTestCheckFuncWrapper(
231244
resource.TestCheckResourceAttrSet(resourceName, "availability_domain"),
232245
resource.TestCheckResourceAttr(resourceName, "compartment_id", compartmentId),
246+
resource.TestCheckResourceAttr(resourceName, "cluster_placement_group_id", cpgId),
233247
resource.TestCheckResourceAttr(resourceName, "display_name", "TFExadbVmCluster"),
234248
resource.TestCheckResourceAttrSet(resourceName, "exascale_db_storage_vault_id"),
235249
resource.TestCheckResourceAttrSet(resourceName, "gi_version"),
@@ -264,6 +278,7 @@ func TestDatabaseExadbVmClusterResource_basic(t *testing.T) {
264278
acctest.GenerateResourceFromRepresentationMap("oci_database_exadb_vm_cluster", "test_exadb_vm_cluster", acctest.Optional, acctest.Create, DatabaseExadbVmClusterRepresentation),
265279
Check: acctest.ComposeAggregateTestCheckFuncWrapper(
266280
resource.TestCheckResourceAttrSet(resourceName, "availability_domain"),
281+
resource.TestCheckResourceAttr(resourceName, "cluster_placement_group_id", cpgId),
267282
resource.TestCheckResourceAttr(resourceName, "compartment_id", compartmentId),
268283
resource.TestCheckResourceAttr(resourceName, "display_name", "TFExadbVmCluster"),
269284
resource.TestCheckResourceAttrSet(resourceName, "exascale_db_storage_vault_id"),
@@ -324,6 +339,7 @@ func TestDatabaseExadbVmClusterResource_basic(t *testing.T) {
324339
})),
325340
Check: acctest.ComposeAggregateTestCheckFuncWrapper(
326341
resource.TestCheckResourceAttrSet(resourceName, "availability_domain"),
342+
resource.TestCheckResourceAttr(resourceName, "cluster_placement_group_id", cpgId),
327343
resource.TestCheckResourceAttr(resourceName, "compartment_id", compartmentIdU),
328344
resource.TestCheckResourceAttr(resourceName, "display_name", "TFExadbVmCluster"),
329345
resource.TestCheckResourceAttrSet(resourceName, "exascale_db_storage_vault_id"),
@@ -379,6 +395,7 @@ func TestDatabaseExadbVmClusterResource_basic(t *testing.T) {
379395
acctest.GenerateResourceFromRepresentationMap("oci_database_exadb_vm_cluster", "test_exadb_vm_cluster", acctest.Optional, acctest.Update, DatabaseExadbVmClusterRepresentation),
380396
Check: acctest.ComposeAggregateTestCheckFuncWrapper(
381397
resource.TestCheckResourceAttrSet(resourceName, "availability_domain"),
398+
resource.TestCheckResourceAttr(resourceName, "cluster_placement_group_id", cpgId),
382399
resource.TestCheckResourceAttr(resourceName, "compartment_id", compartmentId),
383400
resource.TestCheckResourceAttr(resourceName, "display_name", "TFExadbVmClusterUpdatedName"),
384401
resource.TestCheckResourceAttrSet(resourceName, "exascale_db_storage_vault_id"),
@@ -434,6 +451,7 @@ func TestDatabaseExadbVmClusterResource_basic(t *testing.T) {
434451
compartmentIdVariableStr + DatabaseExadbVmClusterResourceDependencies +
435452
acctest.GenerateResourceFromRepresentationMap("oci_database_exadb_vm_cluster", "test_exadb_vm_cluster", acctest.Optional, acctest.Update, DatabaseExadbVmClusterRepresentation),
436453
Check: acctest.ComposeAggregateTestCheckFuncWrapper(
454+
resource.TestCheckResourceAttr(datasourceName, "cluster_placement_group_id", cpgId),
437455
resource.TestCheckResourceAttr(datasourceName, "compartment_id", compartmentId),
438456
resource.TestCheckResourceAttr(datasourceName, "display_name", "TFExadbVmClusterUpdatedName"),
439457
resource.TestCheckResourceAttrSet(datasourceName, "exascale_db_storage_vault_id"),
@@ -475,6 +493,7 @@ func TestDatabaseExadbVmClusterResource_basic(t *testing.T) {
475493
resource.TestCheckResourceAttr(datasourceName, "exadb_vm_clusters.0.freeform_tags.Department", "Accounting"),
476494
resource.TestCheckResourceAttr(datasourceName, "exadb_vm_clusters.0.system_tags.%", "0"),
477495
// computed fields
496+
resource.TestCheckResourceAttr(datasourceName, "exadb_vm_clusters.0.cluster_placement_group_id", cpgId),
478497
resource.TestCheckResourceAttrSet(datasourceName, "exadb_vm_clusters.0.listener_port"),
479498
resource.TestCheckResourceAttrSet(datasourceName, "exadb_vm_clusters.0.scan_dns_name"),
480499
resource.TestCheckResourceAttrSet(datasourceName, "exadb_vm_clusters.0.scan_dns_record_id"),
@@ -530,6 +549,7 @@ func TestDatabaseExadbVmClusterResource_basic(t *testing.T) {
530549
resource.TestCheckResourceAttr(singularDatasourceName, "freeform_tags.Department", "Accounting"),
531550
resource.TestCheckResourceAttr(singularDatasourceName, "system_tags.%", "0"),
532551
// computed fields
552+
resource.TestCheckResourceAttr(singularDatasourceName, "cluster_placement_group_id", cpgId),
533553
resource.TestCheckResourceAttrSet(singularDatasourceName, "listener_port"),
534554
resource.TestCheckResourceAttrSet(singularDatasourceName, "scan_dns_name"),
535555
resource.TestCheckResourceAttrSet(singularDatasourceName, "scan_dns_record_id"),

internal/integrationtest/database_exascale_db_storage_vault_test.go

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,10 @@ import (
2424
"github.com/oracle/terraform-provider-oci/internal/utils"
2525
)
2626

27+
/*
28+
Pre-requisite to run the tests:
29+
1. create a cluster placement group and set its ocid to env variable TF_VAR_cpg_id
30+
*/
2731
var (
2832
DatabaseExascaleDbStorageVaultRequiredOnlyResource = DatabaseExascaleDbStorageVaultResourceDependencies +
2933
acctest.GenerateResourceFromRepresentationMap("oci_database_exascale_db_storage_vault", "test_exascale_db_storage_vault", acctest.Required, acctest.Create, DatabaseExascaleDbStorageVaultRepresentation)
@@ -36,10 +40,11 @@ var (
3640
}
3741

3842
DatabaseExascaleDbStorageVaultDataSourceRepresentation = map[string]interface{}{
39-
"compartment_id": acctest.Representation{RepType: acctest.Required, Create: `${var.compartment_id}`},
40-
"display_name": acctest.Representation{RepType: acctest.Optional, Create: `TFExascaleDbStorageVault`, Update: `TFExascaleDbStorageVaultUpdatedName`},
41-
"state": acctest.Representation{RepType: acctest.Optional, Create: `AVAILABLE`},
42-
"filter": acctest.RepresentationGroup{RepType: acctest.Required, Group: DatabaseExascaleDbStorageVaultDataSourceFilterRepresentation}}
43+
"compartment_id": acctest.Representation{RepType: acctest.Required, Create: `${var.compartment_id}`},
44+
"cluster_placement_group_id": acctest.Representation{RepType: acctest.Optional, Create: `${var.cpg_id}`},
45+
"display_name": acctest.Representation{RepType: acctest.Optional, Create: `TFExascaleDbStorageVault`, Update: `TFExascaleDbStorageVaultUpdatedName`},
46+
"state": acctest.Representation{RepType: acctest.Optional, Create: `AVAILABLE`},
47+
"filter": acctest.RepresentationGroup{RepType: acctest.Required, Group: DatabaseExascaleDbStorageVaultDataSourceFilterRepresentation}}
4348

4449
DatabaseExascaleDbStorageVaultDataSourceFilterRepresentation = map[string]interface{}{
4550
"name": acctest.Representation{RepType: acctest.Required, Create: `id`},
@@ -51,6 +56,7 @@ var (
5156
"compartment_id": acctest.Representation{RepType: acctest.Required, Create: `${var.compartment_id}`},
5257
"display_name": acctest.Representation{RepType: acctest.Required, Create: `TFExascaleDbStorageVault`, Update: `TFExascaleDbStorageVaultUpdatedName`},
5358
"high_capacity_database_storage": acctest.RepresentationGroup{RepType: acctest.Required, Group: DatabaseExascaleDbStorageVaultHighCapacityDatabaseStorageRepresentation},
59+
"cluster_placement_group_id": acctest.Representation{RepType: acctest.Optional, Create: `${var.cpg_id}`},
5460
"additional_flash_cache_in_percent": acctest.Representation{RepType: acctest.Optional, Create: `20`, Update: `25`},
5561
"description": acctest.Representation{RepType: acctest.Optional, Create: `ExaScale DB Storage Vault - description`, Update: `ExaScale DB Storage Vault - updated description`},
5662
"time_zone": acctest.Representation{RepType: acctest.Optional, Create: `US/Pacific`},
@@ -67,7 +73,8 @@ var (
6773
"ignore_changes": acctest.Representation{RepType: acctest.Required, Create: []string{`defined_tags`}},
6874
}
6975

70-
DatabaseExascaleDbStorageVaultResourceDependencies = AvailabilityDomainConfig
76+
ClusterPlacementGroupIdDependency = `variable "cpg_id" {}`
77+
DatabaseExascaleDbStorageVaultResourceDependencies = AvailabilityDomainConfig + ClusterPlacementGroupIdDependency
7178
)
7279

7380
// issue-routing-tag: database/ExaCS
@@ -77,6 +84,7 @@ func TestDatabaseExascaleDbStorageVaultResource_basic(t *testing.T) {
7784

7885
config := acctest.ProviderTestConfig()
7986

87+
cpgId := utils.GetRequiredEnvSetting("cpg_id")
8088
compartmentId := utils.GetEnvSettingWithBlankDefault("compartment_ocid")
8189
compartmentIdVariableStr := fmt.Sprintf("variable \"compartment_id\" { default = \"%s\" }\n", compartmentId)
8290

@@ -123,6 +131,7 @@ func TestDatabaseExascaleDbStorageVaultResource_basic(t *testing.T) {
123131
resource.TestCheckResourceAttrSet(resourceName, "id"),
124132
resource.TestCheckResourceAttrSet(resourceName, "state"),
125133
resource.TestCheckResourceAttrSet(resourceName, "availability_domain"),
134+
resource.TestCheckResourceAttr(resourceName, "cluster_placement_group_id", cpgId),
126135
resource.TestCheckResourceAttr(resourceName, "compartment_id", compartmentId),
127136
resource.TestCheckResourceAttr(resourceName, "display_name", "TFExascaleDbStorageVault"),
128137
//resource.TestCheckResourceAttr(resourceName, "vm_cluster_count", "0"),
@@ -158,6 +167,7 @@ func TestDatabaseExascaleDbStorageVaultResource_basic(t *testing.T) {
158167
resource.TestCheckResourceAttrSet(resourceName, "id"),
159168
resource.TestCheckResourceAttrSet(resourceName, "state"),
160169
resource.TestCheckResourceAttrSet(resourceName, "availability_domain"),
170+
resource.TestCheckResourceAttr(resourceName, "cluster_placement_group_id", cpgId),
161171
resource.TestCheckResourceAttr(resourceName, "compartment_id", compartmentIdU),
162172
resource.TestCheckResourceAttr(resourceName, "display_name", "TFExascaleDbStorageVault"),
163173
//resource.TestCheckResourceAttr(resourceName, "vm_cluster_count", "0"),
@@ -188,6 +198,7 @@ func TestDatabaseExascaleDbStorageVaultResource_basic(t *testing.T) {
188198
resource.TestCheckResourceAttrSet(resourceName, "id"),
189199
resource.TestCheckResourceAttrSet(resourceName, "state"),
190200
resource.TestCheckResourceAttrSet(resourceName, "availability_domain"),
201+
resource.TestCheckResourceAttr(resourceName, "cluster_placement_group_id", cpgId),
191202
resource.TestCheckResourceAttr(resourceName, "compartment_id", compartmentId),
192203
resource.TestCheckResourceAttr(resourceName, "display_name", "TFExascaleDbStorageVaultUpdatedName"),
193204
//resource.TestCheckResourceAttr(resourceName, "vm_cluster_count", "0"),
@@ -216,6 +227,7 @@ func TestDatabaseExascaleDbStorageVaultResource_basic(t *testing.T) {
216227
compartmentIdVariableStr + DatabaseExascaleDbStorageVaultResourceDependencies +
217228
acctest.GenerateResourceFromRepresentationMap("oci_database_exascale_db_storage_vault", "test_exascale_db_storage_vault", acctest.Optional, acctest.Update, DatabaseExascaleDbStorageVaultRepresentation),
218229
Check: acctest.ComposeAggregateTestCheckFuncWrapper(
230+
resource.TestCheckResourceAttr(datasourceName, "cluster_placement_group_id", cpgId),
219231
resource.TestCheckResourceAttr(datasourceName, "compartment_id", compartmentId),
220232
resource.TestCheckResourceAttr(datasourceName, "display_name", "TFExascaleDbStorageVaultUpdatedName"),
221233
resource.TestCheckResourceAttr(datasourceName, "state", "AVAILABLE"),
@@ -225,6 +237,7 @@ func TestDatabaseExascaleDbStorageVaultResource_basic(t *testing.T) {
225237
resource.TestCheckResourceAttrSet(datasourceName, "exascale_db_storage_vaults.0.state"),
226238
resource.TestCheckResourceAttrSet(datasourceName, "exascale_db_storage_vaults.0.time_created"),
227239
resource.TestCheckResourceAttrSet(datasourceName, "exascale_db_storage_vaults.0.availability_domain"),
240+
resource.TestCheckResourceAttr(datasourceName, "exascale_db_storage_vaults.0.cluster_placement_group_id", cpgId),
228241
resource.TestCheckResourceAttr(datasourceName, "exascale_db_storage_vaults.0.compartment_id", compartmentId),
229242
resource.TestCheckResourceAttr(datasourceName, "exascale_db_storage_vaults.0.display_name", "TFExascaleDbStorageVaultUpdatedName"),
230243
//resource.TestCheckResourceAttr(datasourceName, "exascale_db_storage_vaults.0.vm_cluster_count", "0"),
@@ -251,6 +264,7 @@ func TestDatabaseExascaleDbStorageVaultResource_basic(t *testing.T) {
251264
resource.TestCheckResourceAttrSet(singularDatasourceName, "state"),
252265
resource.TestCheckResourceAttrSet(singularDatasourceName, "time_created"),
253266
resource.TestCheckResourceAttrSet(singularDatasourceName, "availability_domain"),
267+
resource.TestCheckResourceAttr(singularDatasourceName, "cluster_placement_group_id", cpgId),
254268
resource.TestCheckResourceAttr(singularDatasourceName, "compartment_id", compartmentId),
255269
resource.TestCheckResourceAttr(singularDatasourceName, "display_name", "TFExascaleDbStorageVaultUpdatedName"),
256270
//resource.TestCheckResourceAttr(singularDatasourceName, "vm_cluster_count", "0"),

internal/service/database/database_exadb_vm_cluster_data_source.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,10 @@ func (s *DatabaseExadbVmClusterDataSourceCrud) SetData() error {
8181
s.D.Set("cluster_name", *s.Res.ClusterName)
8282
}
8383

84+
if s.Res.ClusterPlacementGroupId != nil {
85+
s.D.Set("cluster_placement_group_id", *s.Res.ClusterPlacementGroupId)
86+
}
87+
8488
if s.Res.CompartmentId != nil {
8589
s.D.Set("compartment_id", *s.Res.CompartmentId)
8690
}
@@ -185,6 +189,10 @@ func (s *DatabaseExadbVmClusterDataSourceCrud) SetData() error {
185189
s.D.Set("subnet_id", *s.Res.SubnetId)
186190
}
187191

192+
if s.Res.SubscriptionId != nil {
193+
s.D.Set("subscription_id", *s.Res.SubscriptionId)
194+
}
195+
188196
if s.Res.SystemTags != nil {
189197
s.D.Set("system_tags", tfresource.SystemTagsToMap(s.Res.SystemTags))
190198
}

internal/service/database/database_exadb_vm_cluster_resource.go

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,12 @@ func DatabaseExadbVmClusterResource() *schema.Resource {
260260
Computed: true,
261261
Elem: schema.TypeString,
262262
},
263+
"subscription_id": {
264+
Type: schema.TypeString,
265+
Optional: true,
266+
Computed: true,
267+
ForceNew: true,
268+
},
263269
"system_version": {
264270
Type: schema.TypeString,
265271
Optional: true,
@@ -273,6 +279,10 @@ func DatabaseExadbVmClusterResource() *schema.Resource {
273279
},
274280

275281
// Computed
282+
"cluster_placement_group_id": {
283+
Type: schema.TypeString,
284+
Computed: true,
285+
},
276286
"gi_version": {
277287
Type: schema.TypeString,
278288
Computed: true,
@@ -620,6 +630,11 @@ func (s *DatabaseExadbVmClusterResourceCrud) Create() error {
620630
request.SubnetId = &tmp
621631
}
622632

633+
if subscriptionId, ok := s.D.GetOkExists("subscription_id"); ok {
634+
tmp := subscriptionId.(string)
635+
request.SubscriptionId = &tmp
636+
}
637+
623638
if systemVersion, ok := s.D.GetOkExists("system_version"); ok {
624639
tmp := systemVersion.(string)
625640
request.SystemVersion = &tmp
@@ -919,6 +934,10 @@ func (s *DatabaseExadbVmClusterResourceCrud) SetData() error {
919934
s.D.Set("cluster_name", *s.Res.ClusterName)
920935
}
921936

937+
if s.Res.ClusterPlacementGroupId != nil {
938+
s.D.Set("cluster_placement_group_id", *s.Res.ClusterPlacementGroupId)
939+
}
940+
922941
if s.Res.CompartmentId != nil {
923942
s.D.Set("compartment_id", *s.Res.CompartmentId)
924943
}
@@ -1093,6 +1112,10 @@ func (s *DatabaseExadbVmClusterResourceCrud) SetData() error {
10931112
s.D.Set("subnet_id", *s.Res.SubnetId)
10941113
}
10951114

1115+
if s.Res.SubscriptionId != nil {
1116+
s.D.Set("subscription_id", *s.Res.SubscriptionId)
1117+
}
1118+
10961119
if s.Res.SystemTags != nil {
10971120
s.D.Set("system_tags", tfresource.SystemTagsToMap(s.Res.SystemTags))
10981121
}

0 commit comments

Comments
 (0)