Skip to content

Commit 39c0db2

Browse files
ecabrerMaxrovr
authored andcommitted
Bug fix - Corrected Cloud Database Management Integration Test and added Example Test
1 parent 95a2b07 commit 39c0db2

24 files changed

+638
-243
lines changed
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# Copyright (c) 2025, Oracle and/or its affiliates. All rights reserved.
2+
# NAME
3+
# data.tf - Data Source file
4+
#
5+
# USAGE
6+
# Use the following path for Example and Backward-Compatibility Tests: database/db_systems/db_vm/db_management
7+
# NOTES
8+
# Associated Integration Test: TestDatabaseCloudDatabaseManagementResource_basic
9+
# FILES
10+
#
11+
# DESCRIPTION
12+
#
13+
# MODIFIED MM/DD/YY
14+
# escabrer 06/23/2025 - Created
15+
16+
17+
data "oci_identity_availability_domains" "test_availability_domains" {
18+
compartment_id = var.compartment_id
19+
}
20+
21+
22+
data "oci_database_db_systems" "test_db_systems" {
23+
compartment_id = var.compartment_id
24+
filter {
25+
name = "id"
26+
values = [oci_database_db_system.test_db_system.id]
27+
}
28+
}
29+
30+
data "oci_database_db_homes" "test_db_homes" {
31+
compartment_id = var.compartment_id
32+
db_system_id = oci_database_db_system.test_db_system.id
33+
}
34+
35+
data "oci_database_databases" "test_databases" {
36+
compartment_id = var.compartment_id
37+
db_home_id = data.oci_database_db_homes.test_db_homes.db_homes.0.db_home_id
38+
}
39+
40+
data "oci_database_database" "test_database" {
41+
database_id = data.oci_database_databases.test_databases.databases.0.id
42+
}
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
# Copyright (c) 2025, Oracle and/or its affiliates. All rights reserved.
2+
# NAME
3+
# main.tf - Main file
4+
#
5+
# USAGE
6+
# Use the following path for Example and Backward-Compatibility Tests: database/db_systems/db_vm/db_management
7+
# NOTES
8+
# Associated Integration Test: TestDatabaseCloudDatabaseManagementResource_basic
9+
# FILES
10+
#
11+
# DESCRIPTION
12+
#
13+
# MODIFIED MM/DD/YY
14+
# escabrer 06/23/2025 - Created
15+
16+
17+
resource "oci_database_db_system" "test_db_system" {
18+
availability_domain = data.oci_identity_availability_domains.test_availability_domains.availability_domains.0.name
19+
compartment_id = var.compartment_id
20+
cpu_core_count = "4"
21+
data_storage_size_in_gb = "256"
22+
database_edition = "ENTERPRISE_EDITION"
23+
db_home {
24+
database {
25+
admin_password = var.admin_password
26+
character_set = "AL32UTF8"
27+
db_name = "tfDb"
28+
db_workload = "OLTP"
29+
kms_key_id = var.kms_key_id
30+
kms_key_version_id = var.kms_key_version_id
31+
ncharacter_set = "AL16UTF16"
32+
pdb_name = "tfPdb"
33+
vault_id = var.vault_id
34+
}
35+
db_version = "19.0.0.0"
36+
display_name = "tfDbHome"
37+
}
38+
disk_redundancy = "NORMAL"
39+
display_name = "tfDbSystem"
40+
domain = oci_core_subnet.test_subnet.subnet_domain_name
41+
fault_domains = ["FAULT-DOMAIN-1"]
42+
hostname = "tfDbHost"
43+
license_model = "LICENSE_INCLUDED"
44+
node_count = "1"
45+
shape = "VM.Standard.E4.Flex"
46+
ssh_public_keys = [var.ssh_public_key]
47+
subnet_id = oci_core_subnet.test_subnet.id
48+
49+
lifecycle {
50+
ignore_changes = [defined_tags["Oracle-Tags.CreatedBy"], defined_tags["Oracle-Tags.CreatedOn"]]
51+
}
52+
}
53+
54+
resource "oci_database_management_db_management_private_endpoint" "test_db_management_private_endpoint" {
55+
compartment_id = var.compartment_id
56+
name = "tfPrivateEndpoint"
57+
subnet_id = oci_core_subnet.test_subnet.id
58+
}
59+
60+
resource "oci_database_cloud_database_management" "test_database_cloud_database_management" {
61+
credentialdetails {
62+
password_secret_id = var.ssl_secret_id
63+
user_name = "sys"
64+
}
65+
database_id = data.oci_database_databases.test_databases.databases.0.id
66+
enable_management = "true"
67+
management_type = "BASIC"
68+
private_end_point_id = oci_database_management_db_management_private_endpoint.test_db_management_private_endpoint.id
69+
service_name = "${data.oci_database_databases.test_databases.databases.0.db_unique_name}.${oci_core_subnet.test_subnet.subnet_domain_name}"
70+
}
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
# Copyright (c) 2025, Oracle and/or its affiliates. All rights reserved.
2+
# NAME
3+
# network.tf - Network Infra file
4+
#
5+
# USAGE
6+
# Use the following path for Example and Backward-Compatibility Tests: database/db_systems/db_vm/db_management
7+
# NOTES
8+
# Associated Integration Test: TestDatabaseCloudDatabaseManagementResource_basic
9+
# FILES
10+
#
11+
# DESCRIPTION
12+
#
13+
# MODIFIED MM/DD/YY
14+
# escabrer 06/23/2025 - Created
15+
16+
17+
# Copyright (c) 2025, Oracle and/or its affiliates. All rights reserved.
18+
# NAME
19+
# network.tf - Network Infra file
20+
#
21+
# USAGE
22+
# Use the following path for Example and Backward-Compatibility Tests: database/db_systems/db_vm/db_management
23+
# NOTES
24+
# Associated Integration Test: TestDatabaseCloudDatabaseManagementResource_basic
25+
# FILES
26+
#
27+
# DESCRIPTION
28+
#
29+
# MODIFIED MM/DD/YY
30+
# escabrer 06/23/2025 - Created
31+
32+
33+
resource "oci_core_vcn" "test_vcn" {
34+
cidr_block = "10.1.0.0/16"
35+
compartment_id = var.compartment_id
36+
display_name = "tfVcn"
37+
dns_label = "tfvcn"
38+
}
39+
40+
resource "oci_core_subnet" "test_subnet" {
41+
cidr_block = "10.1.20.0/24"
42+
compartment_id = var.compartment_id
43+
dhcp_options_id = oci_core_vcn.test_vcn.default_dhcp_options_id
44+
display_name = "tfSubnet"
45+
dns_label = "tfsubnet"
46+
route_table_id = oci_core_route_table.test_route_table.id
47+
security_list_ids = [oci_core_security_list.test_security_list.id]
48+
vcn_id = oci_core_vcn.test_vcn.id
49+
}
50+
51+
resource "oci_core_internet_gateway" "test_internet_gateway" {
52+
compartment_id = var.compartment_id
53+
display_name = "tfInternetGateway"
54+
vcn_id = oci_core_vcn.test_vcn.id
55+
}
56+
57+
resource "oci_core_route_table" "test_route_table" {
58+
compartment_id = var.compartment_id
59+
display_name = "tfRouteTable"
60+
route_rules {
61+
description = "Internal traffic for OCI Services"
62+
destination = "0.0.0.0/0"
63+
destination_type = "CIDR_BLOCK"
64+
network_entity_id = oci_core_internet_gateway.test_internet_gateway.id
65+
}
66+
vcn_id = oci_core_vcn.test_vcn.id
67+
}
68+
69+
resource "oci_core_security_list" "test_security_list" {
70+
compartment_id = var.compartment_id
71+
display_name = "tfSecurityList"
72+
egress_security_rules {
73+
destination = "0.0.0.0/0"
74+
protocol = "6"
75+
}
76+
ingress_security_rules {
77+
protocol = "6"
78+
source = "0.0.0.0/0"
79+
}
80+
vcn_id = oci_core_vcn.test_vcn.id
81+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Copyright (c) 2025, Oracle and/or its affiliates. All rights reserved.
2+
# NAME
3+
# provider.tf - provider file
4+
#
5+
# USAGE
6+
# Use the following path for Example and Backward-Compatibility Tests: database/db_systems/db_vm/db_management
7+
# NOTES
8+
# Associated Integration Test: TestDatabaseCloudDatabaseManagementResource_basic
9+
# FILES
10+
#
11+
# DESCRIPTION
12+
#
13+
# MODIFIED MM/DD/YY
14+
# escabrer 06/23/2025 - Created
15+
16+
17+
18+
provider "oci" {
19+
auth = "SecurityToken"
20+
config_file_profile = "terraform-federation-test"
21+
region = var.region
22+
tenancy_ocid = var.compartment_id
23+
}
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# Copyright (c) 2025, Oracle and/or its affiliates. All rights reserved.
2+
# NAME
3+
# variables.tf - Variables file
4+
#
5+
# USAGE
6+
# Use the following path for Example and Backward-Compatibility Tests: database/db_systems/db_vm/db_management
7+
# NOTES
8+
# Associated Integration Test: TestDatabaseCloudDatabaseManagementResource_basic
9+
# FILES
10+
#
11+
# DESCRIPTION
12+
#
13+
# MODIFIED MM/DD/YY
14+
# escabrer 06/23/2025 - Created
15+
16+
17+
18+
variable "tenancy_ocid" {
19+
}
20+
21+
variable "compartment_id" {
22+
}
23+
24+
variable "region" {
25+
}
26+
27+
variable "ssh_public_key" {
28+
}
29+
30+
variable "admin_password" {
31+
}
32+
33+
variable "kms_key_id" {
34+
}
35+
36+
variable "kms_key_version_id" {
37+
}
38+
39+
variable "vault_id" {
40+
}
41+
42+
variable "ssl_secret_id" {
43+
default = "test_secret_id"
44+
}

internal/acctest/test_helpers.go

Lines changed: 50 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -725,40 +725,62 @@ func CommonTestVariables() string {
725725
}
726726

727727
func BaseDBCommonTestVariables() string {
728-
return `
729-
variable "tenancy_ocid" {
730-
default = "` + getEnvSettingWithBlankDefaultVar("tenancy_ocid") + `"
731-
}
728+
return fmt.Sprintf(`
729+
variable "tenancy_ocid" {
730+
default = "%s"
731+
}
732732
733-
variable "ssh_public_key" {
734-
default = "ssh-rsa KKKLK3NzaC1yc2EAAAADAQABAAABAQC+UC9MFNA55NIVtKPIBCNw7++ACXhD0hx+Zyj25JfHykjz/QU3Q5FAU3DxDbVXyubgXfb/GJnrKRY8O4QDdvnZZRvQFFEOaApThAmCAM5MuFUIHdFvlqP+0W+ZQnmtDhwVe2NCfcmOrMuaPEgOKO3DOW6I/qOOdO691Xe2S9NgT9HhN0ZfFtEODVgvYulgXuCCXsJs+NUqcHAOxxFUmwkbPvYi0P0e2DT8JKeiOOC8VKUEgvVx+GKmqasm+Y6zHFW7vv3g2GstE1aRs3mttHRoC/JPM86PRyIxeWXEMzyG5wHqUu4XZpDbnWNxi6ugxnAGiL3CrIFdCgRNgHz5qS1l MustWin"
735-
}
733+
variable "compartment_ocid" {
734+
default = "%s"
735+
}
736736
737-
variable "region" {
738-
default = "` + getEnvSettingWithBlankDefaultVar("region") + `"
739-
}
740-
741-
variable "compartment_ocid" {
742-
default = "` + getEnvSettingWithBlankDefaultVar("compartment_ocid") + `"
743-
}
737+
variable "compartment_id" {
738+
default = "%s"
739+
}
744740
745-
variable "compartment_id" {
746-
default = "` + getEnvSettingWithBlankDefaultVar("compartment_ocid") + `"
747-
}
741+
variable "region" {
742+
default = "%s"
743+
}
748744
749-
variable "kms_key_id" {
750-
default = "` + getEnvSettingWithBlankDefaultVar("kms_key_id") + `"
751-
}
752-
753-
variable "kms_key_version_id" {
754-
default = "` + getEnvSettingWithBlankDefaultVar("kms_key_version_id") + `"
755-
}
745+
variable "ssh_public_key" {
746+
default = "%s"
747+
}
756748
757-
variable "vault_id" {
758-
default = "` + getEnvSettingWithBlankDefaultVar("vault_id") + `"
759-
}
749+
variable "kms_key_id" {
750+
default = "%s"
751+
}
760752
761-
`
753+
variable "kms_key_version_id" {
754+
default = "%s"
755+
}
756+
757+
variable "vault_id" {
758+
default = "%s"
759+
}
760+
761+
variable "ssl_secret_id" {
762+
default = "%s"
763+
}
764+
765+
variable "admin_password" {
766+
default = "%s"
767+
}
768+
769+
variable "tag_namespace_name" {
770+
default = "%s"
771+
}`,
772+
getEnvSettingWithBlankDefaultVar("tenancy_ocid"),
773+
getEnvSettingWithBlankDefaultVar("compartment_ocid"),
774+
getEnvSettingWithBlankDefaultVar("compartment_ocid"),
775+
getEnvSettingWithBlankDefaultVar("region"),
776+
getEnvSettingWithBlankDefaultVar("ssh_public_key"),
777+
getEnvSettingWithBlankDefaultVar("kms_key_id"),
778+
getEnvSettingWithBlankDefaultVar("kms_key_version_id"),
779+
getEnvSettingWithBlankDefaultVar("vault_id"),
780+
getEnvSettingWithDefaultVar("ssl_secret_id", "test_secret_id"),
781+
getEnvSettingWithBlankDefaultVar("admin_password"),
782+
getEnvSettingWithDefaultVar("tag_namespace_name", "tfTagNamespace"),
783+
)
762784
}
763785

764786
func BaseDBProviderTestConfig() string {
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
package basedb
2+
3+
import (
4+
"github.com/oracle/terraform-provider-oci/internal/integrationtest/basedb/dbsystems"
5+
"github.com/oracle/terraform-provider-oci/internal/integrationtest/basedb/network"
6+
"github.com/oracle/terraform-provider-oci/internal/integrationtest/basedb/tags"
7+
)
8+
9+
var (
10+
BaseConfig = tags.BaseConfig + network.BaseConfig + dbsystems.BaseConfig
11+
)
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
package dbsystems
2+
3+
var (
4+
DatasourceBaseConfig = DbSystemDatasourceConfig + DbHomesDatasourceConfig + DatabasesDatasourceConfig + DatabaseDatasourceConfig
5+
ResourceBaseConfig = DbSystemResourceConfig
6+
BaseConfig = DatasourceBaseConfig + ResourceBaseConfig
7+
)

0 commit comments

Comments
 (0)