Skip to content

Commit ccdf29f

Browse files
Shrey Kapoorravinitp
authored andcommitted
Added Support for BDS - Automated Patching for OS/Kernel, Node Maintenance, Add Master/Utility
1 parent 1934246 commit ccdf29f

19 files changed

+1033
-22
lines changed
Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
2+
# Need to have this block even though it's empty; for import testing
3+
provider "oci" {
4+
}
5+
6+
variable "tenancy_ocid" {
7+
}
8+
9+
variable "ssh_public_key" {
10+
}
11+
12+
variable "region" {
13+
default = "us-ashburn-1"
14+
}
15+
16+
17+
data "oci_bds_bds_instance_get_os_patch" "test_bds_instance_get_os_patch" {
18+
bds_instance_id = "${oci_bds_bds_instance.test_bds_instance.id}"
19+
os_patch_version = "${var.os_patch_version}"
20+
}
21+
variable "compartment_id" {}
22+
variable "subnet_id" { }
23+
variable "os_patch_version" { default = "ol7.9-x86_64-1.24.0.100-0.0" }
24+
25+
resource "oci_bds_bds_instance" "test_bds_instance" {
26+
cluster_admin_password = "T3JhY2xlVGVhbVVTQSExMjM="
27+
cluster_public_key = "${var.ssh_public_key}"
28+
cluster_version = "ODH1"
29+
compartment_id = "${var.compartment_id}"
30+
compute_only_worker_node {
31+
block_volume_size_in_gbs = "150"
32+
number_of_nodes = "2"
33+
shape = "VM.Standard.E4.Flex"
34+
shape_config {
35+
memory_in_gbs = "32"
36+
ocpus = "3"
37+
}
38+
subnet_id = "${var.subnet_id}"
39+
}
40+
display_name = "displayName"
41+
edge_node {
42+
block_volume_size_in_gbs = "150"
43+
number_of_nodes = "2"
44+
shape = "VM.Standard.E4.Flex"
45+
shape_config {
46+
memory_in_gbs = "32"
47+
ocpus = "3"
48+
}
49+
subnet_id = "${var.subnet_id}"
50+
}
51+
is_high_availability = "true"
52+
is_secure = "true"
53+
master_node {
54+
block_volume_size_in_gbs = "150"
55+
number_of_nodes = "2"
56+
shape = "VM.Standard.E4.Flex"
57+
shape_config {
58+
memory_in_gbs = "32"
59+
ocpus = "3"
60+
}
61+
subnet_id = "${var.subnet_id}"
62+
}
63+
util_node {
64+
block_volume_size_in_gbs = "150"
65+
number_of_nodes = "2"
66+
shape = "VM.Standard.E4.Flex"
67+
shape_config {
68+
memory_in_gbs = "32"
69+
ocpus = "3"
70+
}
71+
subnet_id = "${var.subnet_id}"
72+
}
73+
worker_node {
74+
block_volume_size_in_gbs = "150"
75+
number_of_nodes = "3"
76+
shape = "VM.Standard2.4"
77+
subnet_id = "${var.subnet_id}"
78+
}
79+
}
80+
81+
resource "oci_core_subnet" "test_subnet" {
82+
cidr_block = "10.0.0.0/24"
83+
compartment_id = "${var.compartment_id}"
84+
lifecycle {
85+
ignore_changes = ["defined_tags"]
86+
}
87+
vcn_id = "${oci_core_vcn.test_vcn.id}"
88+
}
89+
90+
resource "oci_core_vcn" "test_vcn" {
91+
cidr_block = "10.0.0.0/16"
92+
compartment_id = "${var.compartment_id}"
93+
lifecycle {
94+
ignore_changes = ["defined_tags"]
95+
}
96+
}
Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
2+
# Need to have this block even though it's empty; for import testing
3+
provider "oci" {
4+
}
5+
6+
variable "tenancy_ocid" {
7+
}
8+
9+
variable "ssh_public_key" {
10+
}
11+
12+
variable "region" {
13+
default = "us-ashburn-1"
14+
}
15+
16+
17+
data "oci_bds_bds_instance_list_os_patches" "test_bds_instance_list_os_patches" {
18+
bds_instance_id = "${oci_bds_bds_instance.test_bds_instance.id}"
19+
}
20+
variable "compartment_id" { }
21+
variable "subnet_id" { }
22+
23+
resource "oci_bds_bds_instance" "test_bds_instance" {
24+
cluster_admin_password = "T3JhY2xlVGVhbVVTQSExMjM="
25+
cluster_public_key = "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDpUa4zUZKyU3AkW9yoJTBDO550wpWZOXdHswfRq75gbJ2ZYlMtifvwiO3qUL/RIZSC6e1wA5OL2LQ97UaHrLLPXgjvKGVIDRHqPkzTOayjJ4ZA7NPNhcu6f/OxhKkCYF3TAQObhMJmUSMrWSUeufaRIujDz1HHqazxOgFk09fj4i2dcGnfPcm32t8a9MzlsHSmgexYCUwxGisuuWTsnMgxbqsj6DaY51l+SEPi5tf10iFmUWqziF0eKDDQ/jHkwLJ8wgBJef9FSOmwJReHcBY+NviwFTatGj7Cwtnks6CVomsFD+rAMJ9uzM8SCv5agYunx07hnEXbR9r/TXqgXGfN bdsclusterkey@oracleoci.com"
26+
cluster_version = "ODH1"
27+
compartment_id = "${var.compartment_id}"
28+
compute_only_worker_node {
29+
block_volume_size_in_gbs = "150"
30+
number_of_nodes = "2"
31+
shape = "VM.Standard.E4.Flex"
32+
shape_config {
33+
memory_in_gbs = "32"
34+
ocpus = "3"
35+
}
36+
subnet_id = "${var.subnet_id}"
37+
}
38+
display_name = "displayName"
39+
edge_node {
40+
block_volume_size_in_gbs = "150"
41+
number_of_nodes = "2"
42+
shape = "VM.Standard.E4.Flex"
43+
shape_config {
44+
memory_in_gbs = "32"
45+
ocpus = "3"
46+
}
47+
subnet_id = "${var.subnet_id}"
48+
}
49+
is_high_availability = "true"
50+
is_secure = "true"
51+
master_node {
52+
block_volume_size_in_gbs = "150"
53+
number_of_nodes = "2"
54+
shape = "VM.Standard.E4.Flex"
55+
shape_config {
56+
memory_in_gbs = "32"
57+
ocpus = "3"
58+
}
59+
subnet_id = "${var.subnet_id}"
60+
}
61+
util_node {
62+
block_volume_size_in_gbs = "150"
63+
number_of_nodes = "2"
64+
shape = "VM.Standard.E4.Flex"
65+
shape_config {
66+
memory_in_gbs = "32"
67+
ocpus = "3"
68+
}
69+
subnet_id = "${var.subnet_id}"
70+
}
71+
worker_node {
72+
block_volume_size_in_gbs = "150"
73+
number_of_nodes = "3"
74+
shape = "VM.Standard2.4"
75+
subnet_id = "${var.subnet_id}"
76+
}
77+
}
78+
79+
resource "oci_core_subnet" "test_subnet" {
80+
cidr_block = "10.0.0.0/24"
81+
compartment_id = "${var.compartment_id}"
82+
lifecycle {
83+
ignore_changes = ["defined_tags"]
84+
}
85+
vcn_id = "${oci_core_vcn.test_vcn.id}"
86+
}
87+
88+
resource "oci_core_vcn" "test_vcn" {
89+
cidr_block = "10.0.0.0/16"
90+
compartment_id = "${var.compartment_id}"
91+
lifecycle {
92+
ignore_changes = ["defined_tags"]
93+
}
94+
}
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
// Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved.
2+
// Licensed under the Mozilla Public License v2.0
3+
4+
package integrationtest
5+
6+
import (
7+
"fmt"
8+
"testing"
9+
10+
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
11+
12+
"github.com/oracle/terraform-provider-oci/httpreplay"
13+
"github.com/oracle/terraform-provider-oci/internal/acctest"
14+
15+
"github.com/oracle/terraform-provider-oci/internal/utils"
16+
)
17+
18+
var (
19+
BdsBdsInstanceGetOsPatchDataSourceRepresentation = map[string]interface{}{
20+
"bds_instance_id": acctest.Representation{RepType: acctest.Required, Create: `${oci_bds_bds_instance.test_bds_instance.id}`},
21+
"os_patch_version": acctest.Representation{RepType: acctest.Required, Create: `${var.os_patch_version}`},
22+
}
23+
24+
BdsBdsInstanceGetOsPatchResourceConfig = acctest.GenerateResourceFromRepresentationMap("oci_bds_bds_instance", "test_bds_instance", acctest.Required, acctest.Create, bdsInstanceOdhRepresentation) +
25+
acctest.GenerateResourceFromRepresentationMap("oci_core_subnet", "test_subnet", acctest.Required, acctest.Create, CoreSubnetRepresentation) +
26+
acctest.GenerateResourceFromRepresentationMap("oci_core_vcn", "test_vcn", acctest.Required, acctest.Create, CoreVcnRepresentation)
27+
)
28+
29+
// issue-routing-tag: bds/default
30+
func TestBdsBdsInstanceGetOsPatchResource_basic(t *testing.T) {
31+
httpreplay.SetScenario("TestBdsBdsInstanceGetOsPatchResource_basic")
32+
defer httpreplay.SaveScenario()
33+
34+
config := acctest.ProviderTestConfig()
35+
36+
compartmentId := utils.GetEnvSettingWithBlankDefault("compartment_ocid")
37+
compartmentIdVariableStr := fmt.Sprintf("variable \"compartment_id\" { default = \"%s\" }\n", compartmentId)
38+
39+
osPatchVersion := utils.GetEnvSettingWithBlankDefault("os_patch_version")
40+
osPatchVersionVariableStr := fmt.Sprintf("variable \"os_patch_version\" { default = \"%s\" }\n", osPatchVersion)
41+
42+
subnetId := utils.GetEnvSettingWithBlankDefault("subnet_ocid")
43+
subnetIdVariableStr := fmt.Sprintf("variable \"subnet_id\" { default = \"%s\" }\n", subnetId)
44+
45+
datasourceName := "data.oci_bds_bds_instance_get_os_patch.test_bds_instance_get_os_patch"
46+
47+
acctest.SaveConfigContent("", "", "", t)
48+
49+
acctest.ResourceTest(t, nil, []resource.TestStep{
50+
// verify datasource
51+
{
52+
Config: config +
53+
acctest.GenerateDataSourceFromRepresentationMap("oci_bds_bds_instance_get_os_patch", "test_bds_instance_get_os_patch", acctest.Required, acctest.Create, BdsBdsInstanceGetOsPatchDataSourceRepresentation) +
54+
compartmentIdVariableStr + subnetIdVariableStr + osPatchVersionVariableStr + BdsBdsInstanceGetOsPatchResourceConfig,
55+
Check: acctest.ComposeAggregateTestCheckFuncWrapper(
56+
resource.TestCheckResourceAttrSet(datasourceName, "bds_instance_id"),
57+
resource.TestCheckResourceAttr(datasourceName, "os_patch_version", "ol7.9-x86_64-1.24.0.100-0.0"),
58+
resource.TestCheckResourceAttrSet(datasourceName, "min_bds_version"),
59+
resource.TestCheckResourceAttrSet(datasourceName, "patch_type"),
60+
resource.TestCheckResourceAttrSet(datasourceName, "release_date"),
61+
),
62+
},
63+
})
64+
}
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
// Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved.
2+
// Licensed under the Mozilla Public License v2.0
3+
4+
package integrationtest
5+
6+
import (
7+
"fmt"
8+
"testing"
9+
10+
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
11+
12+
"github.com/oracle/terraform-provider-oci/httpreplay"
13+
"github.com/oracle/terraform-provider-oci/internal/acctest"
14+
15+
"github.com/oracle/terraform-provider-oci/internal/utils"
16+
)
17+
18+
var (
19+
BdsBdsInstanceListOsPatchDataSourceRepresentation = map[string]interface{}{
20+
"bds_instance_id": acctest.Representation{RepType: acctest.Required, Create: `${oci_bds_bds_instance.test_bds_instance.id}`},
21+
}
22+
23+
BdsBdsInstanceListOsPatchResourceConfig = acctest.GenerateResourceFromRepresentationMap("oci_bds_bds_instance", "test_bds_instance", acctest.Required, acctest.Create, bdsInstanceOdhRepresentation) +
24+
acctest.GenerateResourceFromRepresentationMap("oci_core_subnet", "test_subnet", acctest.Required, acctest.Create, CoreSubnetRepresentation) +
25+
acctest.GenerateResourceFromRepresentationMap("oci_core_vcn", "test_vcn", acctest.Required, acctest.Create, CoreVcnRepresentation)
26+
)
27+
28+
// issue-routing-tag: bds/default
29+
func TestBdsBdsInstanceListOsPatchResource_basic(t *testing.T) {
30+
httpreplay.SetScenario("TestBdsBdsInstanceListOsPatchResource_basic")
31+
defer httpreplay.SaveScenario()
32+
33+
config := acctest.ProviderTestConfig()
34+
35+
compartmentId := utils.GetEnvSettingWithBlankDefault("compartment_ocid")
36+
compartmentIdVariableStr := fmt.Sprintf("variable \"compartment_id\" { default = \"%s\" }\n", compartmentId)
37+
subnetId := utils.GetEnvSettingWithBlankDefault("subnet_ocid")
38+
subnetIdVariableStr := fmt.Sprintf("variable \"subnet_id\" { default = \"%s\" }\n", subnetId)
39+
40+
datasourceName := "data.oci_bds_bds_instance_list_os_patches.test_bds_instance_list_os_patches"
41+
acctest.SaveConfigContent("", "", "", t)
42+
// acctest.SaveConfigContent(config+compartmentIdVariableStr+BdsBdsInstanceListOsPatchResourceConfig+
43+
// acctest.GenerateResourceFromRepresentationMap("oci_bds_bds_instance", "test_bds_instance", acctest.Required, acctest.Create, BdsBdsInstanceListOsPatchDataSourceRepresentation), "bds", "bdsInstanceListOsPatch", t)
44+
45+
acctest.ResourceTest(t, nil, []resource.TestStep{
46+
// verify datasource
47+
{
48+
Config: config +
49+
acctest.GenerateDataSourceFromRepresentationMap("oci_bds_bds_instance_list_os_patches", "test_bds_instance_list_os_patches", acctest.Required, acctest.Create, BdsBdsInstanceListOsPatchDataSourceRepresentation) +
50+
compartmentIdVariableStr + subnetIdVariableStr + BdsBdsInstanceListOsPatchResourceConfig,
51+
Check: acctest.ComposeAggregateTestCheckFuncWrapper(
52+
resource.TestCheckResourceAttrSet(datasourceName, "bds_instance_id"),
53+
54+
resource.TestCheckResourceAttrSet(datasourceName, "os_patches.#"),
55+
resource.TestCheckResourceAttrSet(datasourceName, "os_patches.0.os_patch_version"),
56+
resource.TestCheckResourceAttrSet(datasourceName, "os_patches.0.release_date"),
57+
),
58+
},
59+
})
60+
}

internal/integrationtest/bds_bds_instance_patch_history_test.go

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import (
1818
var (
1919
BdsBdsInstancePatchHistoryDataSourceRepresentation = map[string]interface{}{
2020
"bds_instance_id": acctest.Representation{RepType: acctest.Required, Create: `${oci_bds_bds_instance.test_bds_instance.id}`},
21+
"patch_type": acctest.Representation{RepType: acctest.Optional, Create: `ODH`},
2122
"patch_version": acctest.Representation{RepType: acctest.Optional, Create: `patchVersion`},
2223
"state": acctest.Representation{RepType: acctest.Optional, Create: `INSTALLED`},
2324
}
@@ -38,6 +39,9 @@ func TestBdsBdsInstancePatchHistoryResource_basic(t *testing.T) {
3839
compartmentId := utils.GetEnvSettingWithBlankDefault("compartment_ocid")
3940
compartmentIdVariableStr := fmt.Sprintf("variable \"compartment_id\" { default = \"%s\" }\n", compartmentId)
4041

42+
subnetId := utils.GetEnvSettingWithBlankDefault("subnet_ocid")
43+
subnetIdVariableStr := fmt.Sprintf("variable \"subnet_id\" { default = \"%s\" }\n", subnetId)
44+
4145
datasourceName := "data.oci_bds_bds_instance_patch_histories.test_bds_instance_patch_histories"
4246

4347
acctest.SaveConfigContent("", "", "", t)
@@ -47,11 +51,14 @@ func TestBdsBdsInstancePatchHistoryResource_basic(t *testing.T) {
4751
{
4852
Config: config +
4953
acctest.GenerateDataSourceFromRepresentationMap("oci_bds_bds_instance_patch_histories", "test_bds_instance_patch_histories", acctest.Required, acctest.Create, BdsBdsInstancePatchHistoryDataSourceRepresentation) +
50-
compartmentIdVariableStr + BdsBdsInstancePatchHistoryResourceConfig,
54+
compartmentIdVariableStr + subnetIdVariableStr + BdsBdsInstancePatchHistoryResourceConfig,
5155
Check: acctest.ComposeAggregateTestCheckFuncWrapper(
5256
resource.TestCheckResourceAttrSet(datasourceName, "bds_instance_id"),
53-
57+
resource.TestCheckResourceAttr(datasourceName, "patch_type", "ODH"),
58+
resource.TestCheckResourceAttr(datasourceName, "patch_version", "patchVersion"),
59+
resource.TestCheckResourceAttr(datasourceName, "state", "AVAILABLE"),
5460
resource.TestCheckResourceAttrSet(datasourceName, "patch_histories.#"),
61+
resource.TestCheckResourceAttrSet(datasourceName, "patch_histories.0.patch_type"),
5562
resource.TestCheckResourceAttrSet(datasourceName, "patch_histories.0.state"),
5663
resource.TestCheckResourceAttrSet(datasourceName, "patch_histories.0.time_updated"),
5764
resource.TestCheckResourceAttrSet(datasourceName, "patch_histories.0.version"),

0 commit comments

Comments
 (0)