Skip to content

Commit a4c1638

Browse files
Revert "TERSI-4090: BaseDB CP - TestDatabaseDatabaseUpgradeResource_basic &"
This reverts commit fafcb53.
1 parent 030c13c commit a4c1638

31 files changed

+1164
-869
lines changed
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
// Copyright (c) 2017, 2024, Oracle and/or its affiliates. All rights reserved.
2+
// Licensed under the Mozilla Public License v2.0
3+
data "oci_identity_availability_domain" "ad" {
4+
compartment_id = var.tenancy_ocid
5+
ad_number = 3
6+
}
7+
8+
# Get DB node list
9+
data "oci_database_db_nodes" "db_nodes" {
10+
compartment_id = var.compartment_ocid
11+
db_system_id = oci_database_db_system.test_db_system.id
12+
}
13+
14+
# Get DB node details
15+
data "oci_database_db_node" "db_node_details" {
16+
db_node_id = data.oci_database_db_nodes.db_nodes.db_nodes[0]["id"]
17+
}
18+
19+
# Gets the OCID of the first (default) vNIC
20+
#data "oci_core_vnic" "db_node_vnic" {
21+
# vnic_id = data.oci_database_db_node.db_node_details.vnic_id
22+
#}
23+
24+
data "oci_database_db_homes" "db_homes" {
25+
compartment_id = var.compartment_ocid
26+
db_system_id = oci_database_db_system.test_db_system.id
27+
}
28+
29+
data "oci_database_databases" "databases" {
30+
compartment_id = var.compartment_ocid
31+
db_home_id = data.oci_database_db_homes.db_homes.db_homes[0].db_home_id
32+
}
33+
34+
data "oci_database_db_versions" "test_db_versions_by_db_system_id" {
35+
compartment_id = var.compartment_ocid
36+
db_system_id = oci_database_db_system.test_db_system.id
37+
}
38+
39+
data "oci_database_db_system_shapes" "test_db_system_shapes" {
40+
availability_domain = data.oci_identity_availability_domain.ad.name
41+
compartment_id = var.compartment_ocid
42+
43+
filter {
44+
name = "shape"
45+
values = [var.db_system_shape]
46+
}
47+
}
48+
49+
data "oci_database_db_systems" "db_systems" {
50+
compartment_id = var.compartment_ocid
51+
52+
filter {
53+
name = "id"
54+
values = [oci_database_db_system.test_db_system.id]
55+
}
56+
}
57+
58+
data "oci_database_db_systems_upgrade_history_entries" "t" {
59+
db_system_id = data.oci_database_db_systems.db_systems.db_systems.0.id
60+
}
Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
// Copyright (c) 2017, 2024, Oracle and/or its affiliates. All rights reserved.
2+
// Licensed under the Mozilla Public License v2.0
3+
resource "oci_core_vcn" "vcn" {
4+
cidr_block = "10.1.0.0/16"
5+
compartment_id = var.compartment_ocid
6+
display_name = "TFExampleVCNDBSystem"
7+
dns_label = "tfexvcndbsys"
8+
}
9+
10+
resource "oci_core_subnet" "subnet" {
11+
availability_domain = data.oci_identity_availability_domain.ad.name
12+
cidr_block = "10.1.20.0/24"
13+
display_name = "TFExampleSubnetDBSystem"
14+
dns_label = "tfexsubdbsys"
15+
security_list_ids = [oci_core_security_list.ExampleSecurityList.id]
16+
compartment_id = var.compartment_ocid
17+
vcn_id = oci_core_vcn.vcn.id
18+
route_table_id = oci_core_route_table.route_table.id
19+
dhcp_options_id = oci_core_vcn.vcn.default_dhcp_options_id
20+
}
21+
22+
resource "oci_core_subnet" "subnet_backup" {
23+
availability_domain = data.oci_identity_availability_domain.ad.name
24+
cidr_block = "10.1.1.0/24"
25+
display_name = "TFExampleSubnetDBSystemBackup"
26+
dns_label = "tfexsubdbsysbp"
27+
security_list_ids = [oci_core_security_list.ExampleSecurityList.id]
28+
compartment_id = var.compartment_ocid
29+
vcn_id = oci_core_vcn.vcn.id
30+
route_table_id = oci_core_route_table.route_table_backup.id
31+
dhcp_options_id = oci_core_vcn.vcn.default_dhcp_options_id
32+
}
33+
34+
resource "oci_core_internet_gateway" "internet_gateway" {
35+
compartment_id = var.compartment_ocid
36+
display_name = "TFExampleIGDBSystem"
37+
vcn_id = oci_core_vcn.vcn.id
38+
}
39+
40+
resource "oci_core_route_table" "route_table" {
41+
compartment_id = var.compartment_ocid
42+
vcn_id = oci_core_vcn.vcn.id
43+
display_name = "TFExampleRouteTableDBSystem"
44+
45+
route_rules {
46+
destination = "0.0.0.0/0"
47+
destination_type = "CIDR_BLOCK"
48+
network_entity_id = oci_core_internet_gateway.internet_gateway.id
49+
}
50+
}
51+
52+
resource "oci_core_route_table" "route_table_backup" {
53+
compartment_id = var.compartment_ocid
54+
vcn_id = oci_core_vcn.vcn.id
55+
display_name = "TFExampleRouteTableDBSystemBackup"
56+
57+
route_rules {
58+
destination = "0.0.0.0/0"
59+
destination_type = "CIDR_BLOCK"
60+
network_entity_id = oci_core_internet_gateway.internet_gateway.id
61+
}
62+
}
63+
64+
resource "oci_core_security_list" "ExampleSecurityList" {
65+
compartment_id = var.compartment_ocid
66+
vcn_id = oci_core_vcn.vcn.id
67+
display_name = "TFExampleSecurityList"
68+
69+
// allow outbound tcp traffic on all ports
70+
egress_security_rules {
71+
destination = "0.0.0.0/0"
72+
protocol = "6"
73+
}
74+
75+
// allow outbound udp traffic on a port range
76+
egress_security_rules {
77+
destination = "0.0.0.0/0"
78+
protocol = "17" // udp
79+
stateless = true
80+
}
81+
82+
egress_security_rules {
83+
destination = "0.0.0.0/0"
84+
protocol = "1"
85+
stateless = true
86+
}
87+
88+
// allow inbound ssh traffic from a specific port
89+
ingress_security_rules {
90+
protocol = "6" // tcp
91+
source = "0.0.0.0/0"
92+
stateless = false
93+
}
94+
95+
// allow inbound icmp traffic of a specific type
96+
ingress_security_rules {
97+
protocol = 1
98+
source = "0.0.0.0/0"
99+
stateless = true
100+
}
101+
}
102+
103+
resource "oci_core_network_security_group" "test_network_security_group" {
104+
compartment_id = var.compartment_ocid
105+
vcn_id = oci_core_vcn.vcn.id
106+
display_name = "displayName"
107+
}
108+
109+
resource "oci_core_network_security_group" "test_network_security_group_backup" {
110+
compartment_id = var.compartment_ocid
111+
vcn_id = oci_core_vcn.vcn.id
112+
display_name = "displayName"
113+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// Copyright (c) 2017, 2024, Oracle and/or its affiliates. All rights reserved.
2+
// Licensed under the Mozilla Public License v2.0
3+
provider "oci" {
4+
tenancy_ocid = var.tenancy_ocid
5+
user_ocid = var.user_ocid
6+
fingerprint = var.fingerprint
7+
private_key_path = var.private_key_path
8+
region = var.region
9+
}
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
// Copyright (c) 2017, 2024, Oracle and/or its affiliates. All rights reserved.
2+
// Licensed under the Mozilla Public License v2.0
3+
resource "oci_database_db_system" "test_db_system" {
4+
availability_domain = data.oci_identity_availability_domain.ad.name
5+
compartment_id = var.compartment_ocid
6+
database_edition = var.db_edition
7+
8+
db_home {
9+
database {
10+
admin_password = var.db_admin_password
11+
db_name = "aTFdbVm"
12+
character_set = var.character_set
13+
ncharacter_set = var.n_character_set
14+
db_workload = var.db_workload
15+
pdb_name = var.pdb_name
16+
17+
db_backup_config {
18+
auto_backup_enabled = false
19+
}
20+
}
21+
22+
db_version = var.db_version
23+
display_name = "MyTFDBHomeVm"
24+
}
25+
26+
db_system_options {
27+
storage_management = "ASM"
28+
}
29+
30+
disk_redundancy = var.db_disk_redundancy
31+
shape = var.db_system_shape
32+
subnet_id = oci_core_subnet.subnet.id
33+
ssh_public_keys = [var.ssh_public_key]
34+
display_name = "MyTFDBSystemVM"
35+
hostname = var.hostname
36+
data_storage_size_in_gb = var.data_storage_size_in_gb
37+
license_model = var.license_model
38+
node_count = data.oci_database_db_system_shapes.test_db_system_shapes.db_system_shapes[0]["minimum_node_count"]
39+
nsg_ids = [oci_core_network_security_group.test_network_security_group_backup.id, oci_core_network_security_group.test_network_security_group.id]
40+
41+
#To use defined_tags, set the values below to an existing tag namespace, refer to the identity example on how to create tag namespaces
42+
#defined_tags = {"${oci_identity_tag_namespace.tag-namespace1.name}.${oci_identity_tag.tag1.name}" = "value"}
43+
44+
freeform_tags = {
45+
"Department" = "Finance"
46+
}
47+
//To ignore DbVersion after database upgrade
48+
lifecycle {
49+
ignore_changes = [
50+
db_home.0.db_version,
51+
]
52+
}
53+
}
54+
55+
resource "oci_database_db_systems_upgrade" "test_upgrade" {
56+
action = "UPGRADE"
57+
db_system_id = data.oci_database_db_systems.db_systems.db_systems.0.id
58+
new_gi_version = "19.12.0.0"
59+
}
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
// Copyright (c) 2017, 2024, Oracle and/or its affiliates. All rights reserved.
2+
// Licensed under the Mozilla Public License v2.0
3+
variable "tenancy_ocid" {
4+
}
5+
6+
variable "user_ocid" {
7+
}
8+
9+
variable "fingerprint" {
10+
}
11+
12+
variable "private_key_path" {
13+
}
14+
15+
variable "region" {
16+
}
17+
18+
variable "compartment_ocid" {
19+
}
20+
21+
variable "ssh_public_key" {
22+
}
23+
24+
variable "ssh_private_key" {
25+
}
26+
27+
# DBSystem specific
28+
variable "db_system_shape" {
29+
default = "VM.Standard2.1"
30+
}
31+
32+
variable "db_edition" {
33+
default = "ENTERPRISE_EDITION"
34+
}
35+
36+
variable "db_admin_password" {
37+
default = "BEstrO0ng_#12"
38+
}
39+
40+
variable "db_version" {
41+
default = "12.2.0.1"
42+
}
43+
44+
variable "db_disk_redundancy" {
45+
default = "NORMAL"
46+
}
47+
48+
variable "sparse_diskgroup" {
49+
default = true
50+
}
51+
52+
variable "hostname" {
53+
default = "myoracledb"
54+
}
55+
56+
variable "host_user_name" {
57+
default = "opc"
58+
}
59+
60+
variable "n_character_set" {
61+
default = "AL16UTF16"
62+
}
63+
64+
variable "character_set" {
65+
default = "AL32UTF8"
66+
}
67+
68+
variable "db_workload" {
69+
default = "OLTP"
70+
}
71+
72+
variable "pdb_name" {
73+
default = "pdbName"
74+
}
75+
76+
variable "data_storage_size_in_gb" {
77+
default = "256"
78+
}
79+
80+
variable "license_model" {
81+
default = "LICENSE_INCLUDED"
82+
}
83+
84+
variable "node_count" {
85+
default = "2"
86+
}

examples/database/db_systems/db_vm/db_upgrade/data.tf

Lines changed: 0 additions & 52 deletions
This file was deleted.

0 commit comments

Comments
 (0)