Skip to content

Commit dca5212

Browse files
Terraform Team AutomationMaxrovr
authored andcommitted
Added - Support for Datalake/Lakehouse Feature for MySQL HeatWave
1 parent 971d817 commit dca5212

10 files changed

+134
-23
lines changed

examples/mysql/heat_wave_cluster/main.tf

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,9 @@ resource "oci_mysql_heat_wave_cluster" "test_heat_wave_cluster" {
7676
db_system_id = oci_mysql_mysql_db_system.test_mysql_db_system.id
7777
cluster_size = "2"
7878
shape_name = "MySQL.HeatWave.VM.Standard.E3"
79+
80+
# Optional
81+
is_lakehouse_enabled = true
7982
}
8083

8184
data "oci_mysql_mysql_configurations" "test_mysql_configurations" {

internal/integrationtest/mysql_heat_wave_cluster_test.go

Lines changed: 92 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -25,25 +25,25 @@ import (
2525
)
2626

2727
var (
28-
MysqlHeatWaveClusterRequiredOnlyResource = MysqlHeatWaveClusterResourceDependencies +
29-
acctest.GenerateResourceFromRepresentationMap("oci_mysql_heat_wave_cluster", "test_heat_wave_cluster", acctest.Required, acctest.Create, MysqlHeatWaveClusterRepresentation)
28+
MysqlHeatWaveClusterRequiredOnlyResource = MysqlHeatWaveWarehouseClusterResourceDependencies +
29+
acctest.GenerateResourceFromRepresentationMap("oci_mysql_heat_wave_cluster", "test_heat_wave_cluster", acctest.Required, acctest.Create, MysqlHeatWaveLakehouseClusterRepresentation)
3030

31-
MysqlHeatWaveClusterResourceConfig = MysqlHeatWaveClusterResourceDependencies +
32-
acctest.GenerateResourceFromRepresentationMap("oci_mysql_heat_wave_cluster", "test_heat_wave_cluster", acctest.Optional, acctest.Update, MysqlHeatWaveClusterRepresentation)
31+
MysqlHeatWaveClusterResourceConfig = MysqlHeatWaveWarehouseClusterResourceDependencies +
32+
acctest.GenerateResourceFromRepresentationMap("oci_mysql_heat_wave_cluster", "test_heat_wave_cluster", acctest.Optional, acctest.Update, MysqlHeatWaveWarehouseClusterRepresentation)
3333

3434
MysqlMysqlHeatWaveClusterSingularDataSourceRepresentation = map[string]interface{}{
3535
"db_system_id": acctest.Representation{RepType: acctest.Required, Create: `${oci_mysql_mysql_db_system.test_mysql_db_system.id}`},
3636
}
3737

38-
mysqlDbSystemHeatWaveRepresentation = map[string]interface{}{
38+
MysqlDbSystemHeatWaveRepresentation = map[string]interface{}{
3939
"admin_password": acctest.Representation{RepType: acctest.Required, Create: `BEstrO0ng_#11`},
4040
"admin_username": acctest.Representation{RepType: acctest.Required, Create: `adminUser`},
4141
"availability_domain": acctest.Representation{RepType: acctest.Required, Create: `${data.oci_identity_availability_domains.test_availability_domains.availability_domains.0.name}`},
4242
"compartment_id": acctest.Representation{RepType: acctest.Required, Create: `${var.compartment_id}`},
4343
"configuration_id": acctest.Representation{RepType: acctest.Optional, Create: `${var.MysqlConfigurationOCID[var.region]}`},
4444
"shape_name": acctest.Representation{RepType: acctest.Required, Create: `MySQL.VM.Standard.E3.1.8GB`},
4545
"subnet_id": acctest.Representation{RepType: acctest.Required, Create: `${oci_core_subnet.test_subnet.id}`},
46-
"backup_policy": acctest.RepresentationGroup{RepType: acctest.Optional, Group: MysqlMysqlDbSystemBackupPolicyRepresentation},
46+
"backup_policy": acctest.RepresentationGroup{RepType: acctest.Required, Group: MysqlDbSystemHeatWaveBackupPolicyRepresentation},
4747
"data_storage_size_in_gb": acctest.Representation{RepType: acctest.Required, Create: `50`},
4848
"defined_tags": acctest.Representation{RepType: acctest.Optional, Create: `${map("${oci_identity_tag_namespace.tag-namespace1.name}.${oci_identity_tag.tag1.name}", "value")}`},
4949
"description": acctest.Representation{RepType: acctest.Optional, Create: `MySQL Database Service`},
@@ -57,19 +57,49 @@ var (
5757
"port_x": acctest.Representation{RepType: acctest.Optional, Create: `33306`},
5858
}
5959

60-
MysqlHeatWaveClusterRepresentation = map[string]interface{}{
61-
"db_system_id": acctest.Representation{RepType: acctest.Required, Create: `${oci_mysql_mysql_db_system.test_mysql_db_system.id}`},
62-
"cluster_size": acctest.Representation{RepType: acctest.Required, Create: `2`, Update: `3`},
63-
"shape_name": acctest.Representation{RepType: acctest.Required, Create: `MySQL.VM.Standard.E3.1.8GB`},
64-
"state": acctest.Representation{RepType: acctest.Optional, Create: `INACTIVE`, Update: `ACTIVE`}, // testing stop & start actions
60+
MysqlDbSystemHeatWaveBackupPolicyRepresentation = map[string]interface{}{
61+
"defined_tags": acctest.Representation{RepType: acctest.Optional, Create: `${map("${oci_identity_tag_namespace.tag-namespace1.name}.${oci_identity_tag.tag1.name}", "value")}`},
62+
"freeform_tags": acctest.Representation{RepType: acctest.Optional, Create: map[string]string{"Department": "Finance"}},
63+
"is_enabled": acctest.Representation{RepType: acctest.Optional, Create: `false`},
64+
"pitr_policy": acctest.RepresentationGroup{RepType: acctest.Required, Group: MysqlDbSystemHeatWavePitrPolicyRepresentation},
65+
"retention_in_days": acctest.Representation{RepType: acctest.Optional, Create: `10`},
66+
"window_start_time": acctest.Representation{RepType: acctest.Optional, Create: `01:00-00:00`},
67+
}
68+
69+
// Lakehouse tests: Create - Warehouse tests: Update
70+
MysqlDbSystemHeatWavePitrPolicyRepresentation = map[string]interface{}{
71+
"is_enabled": acctest.Representation{RepType: acctest.Required, Create: `false`, Update: `true`},
72+
}
73+
74+
MysqlHeatWaveLakehouseClusterRepresentation = map[string]interface{}{
75+
"db_system_id": acctest.Representation{RepType: acctest.Required, Create: `${oci_mysql_mysql_db_system.test_mysql_db_system.id}`},
76+
"cluster_size": acctest.Representation{RepType: acctest.Required, Create: `2`},
77+
"shape_name": acctest.Representation{RepType: acctest.Required, Create: `MySQL.VM.Standard.E3.1.8GB`},
78+
"state": acctest.Representation{RepType: acctest.Required, Create: `ACTIVE`},
79+
"is_lakehouse_enabled": acctest.Representation{RepType: acctest.Required, Create: `true`, Update: `false`},
6580
}
6681

67-
MysqlHeatWaveClusterResourceDependencies = MysqlMysqlConfigurationResourceConfig +
82+
MysqlHeatWaveWarehouseClusterRepresentation = map[string]interface{}{
83+
"db_system_id": acctest.Representation{RepType: acctest.Required, Create: `${oci_mysql_mysql_db_system.test_mysql_db_system.id}`},
84+
"cluster_size": acctest.Representation{RepType: acctest.Required, Create: `2`, Update: `3`},
85+
"shape_name": acctest.Representation{RepType: acctest.Required, Create: `MySQL.VM.Standard.E3.1.8GB`},
86+
"state": acctest.Representation{RepType: acctest.Required, Create: `INACTIVE`, Update: `ACTIVE`}, // testing stop & start actions
87+
"is_lakehouse_enabled": acctest.Representation{RepType: acctest.Required, Create: `false`, Update: `false`},
88+
}
89+
90+
MysqlHeatWaveClusterResourceDependenciesBase = MysqlMysqlConfigurationResourceConfig +
6891
acctest.GenerateResourceFromRepresentationMap("oci_core_subnet", "test_subnet", acctest.Required, acctest.Create, CoreSubnetRepresentation) +
6992
acctest.GenerateResourceFromRepresentationMap("oci_core_vcn", "test_vcn", acctest.Required, acctest.Create, CoreVcnRepresentation) +
7093
AvailabilityDomainConfig +
71-
acctest.GenerateDataSourceFromRepresentationMap("oci_mysql_shapes", "test_shapes", acctest.Required, acctest.Create, MysqlMysqlShapeDataSourceRepresentation) +
72-
acctest.GenerateResourceFromRepresentationMap("oci_mysql_mysql_db_system", "test_mysql_db_system", acctest.Required, acctest.Create, mysqlDbSystemHeatWaveRepresentation)
94+
acctest.GenerateDataSourceFromRepresentationMap("oci_mysql_shapes", "test_shapes", acctest.Required, acctest.Create, MysqlMysqlShapeDataSourceRepresentation)
95+
96+
// DbSystem with PITR disabled
97+
MysqlHeatWaveLakehouseClusterResourceDependencies = MysqlHeatWaveClusterResourceDependenciesBase +
98+
acctest.GenerateResourceFromRepresentationMap("oci_mysql_mysql_db_system", "test_mysql_db_system", acctest.Required, acctest.Create, MysqlDbSystemHeatWaveRepresentation)
99+
100+
// DbSystem with PITR enabled
101+
MysqlHeatWaveWarehouseClusterResourceDependencies = MysqlHeatWaveClusterResourceDependenciesBase +
102+
acctest.GenerateResourceFromRepresentationMap("oci_mysql_mysql_db_system", "test_mysql_db_system", acctest.Required, acctest.Update, MysqlDbSystemHeatWaveRepresentation)
73103
)
74104

75105
// issue-routing-tag: mysql/default
@@ -91,10 +121,18 @@ func TestMysqlHeatWaveClusterResource_basic(t *testing.T) {
91121
acctest.ResourceTest(t, testAccCheckMysqlHeatWaveClusterDestroy, []resource.TestStep{
92122
// verify Create
93123
{
94-
Config: config + compartmentIdVariableStr + MysqlHeatWaveClusterResourceDependencies +
95-
acctest.GenerateResourceFromRepresentationMap("oci_mysql_heat_wave_cluster", "test_heat_wave_cluster", acctest.Required, acctest.Create, MysqlHeatWaveClusterRepresentation),
124+
Config: config + compartmentIdVariableStr + MysqlHeatWaveLakehouseClusterResourceDependencies +
125+
acctest.GenerateResourceFromRepresentationMap("oci_mysql_heat_wave_cluster", "test_heat_wave_cluster", acctest.Required, acctest.Create, MysqlHeatWaveLakehouseClusterRepresentation),
96126
Check: acctest.ComposeAggregateTestCheckFuncWrapper(
127+
resource.TestCheckResourceAttr(resourceName, "cluster_nodes.#", "2"),
128+
resource.TestCheckResourceAttr(resourceName, "cluster_size", "2"),
129+
resource.TestCheckResourceAttr(resourceName, "shape_name", "MySQL.VM.Standard.E3.1.8GB"),
130+
resource.TestCheckResourceAttr(resourceName, "state", "ACTIVE"),
131+
resource.TestCheckResourceAttr(resourceName, "is_lakehouse_enabled", "true"),
132+
97133
resource.TestCheckResourceAttrSet(resourceName, "db_system_id"),
134+
resource.TestCheckResourceAttrSet(resourceName, "time_created"),
135+
resource.TestCheckResourceAttrSet(resourceName, "time_updated"),
98136

99137
func(s *terraform.State) (err error) {
100138
resId, err = acctest.FromInstanceState(s, resourceName, "id")
@@ -103,19 +141,49 @@ func TestMysqlHeatWaveClusterResource_basic(t *testing.T) {
103141
),
104142
},
105143

106-
// delete before next Create
144+
// Verify update enable Lakehouse
145+
{
146+
Config: config + compartmentIdVariableStr + MysqlHeatWaveLakehouseClusterResourceDependencies +
147+
acctest.GenerateResourceFromRepresentationMap("oci_mysql_heat_wave_cluster", "test_heat_wave_cluster", acctest.Required, acctest.Update, MysqlHeatWaveLakehouseClusterRepresentation),
148+
Check: acctest.ComposeAggregateTestCheckFuncWrapper(
149+
resource.TestCheckResourceAttr(resourceName, "cluster_nodes.#", "2"),
150+
resource.TestCheckResourceAttr(resourceName, "cluster_size", "2"),
151+
resource.TestCheckResourceAttr(resourceName, "shape_name", "MySQL.VM.Standard.E3.1.8GB"),
152+
resource.TestCheckResourceAttr(resourceName, "state", "ACTIVE"),
153+
resource.TestCheckResourceAttr(resourceName, "is_lakehouse_enabled", "false"),
154+
155+
resource.TestCheckResourceAttrSet(resourceName, "db_system_id"),
156+
resource.TestCheckResourceAttrSet(resourceName, "time_created"),
157+
resource.TestCheckResourceAttrSet(resourceName, "time_updated"),
158+
159+
func(s *terraform.State) (err error) {
160+
resId2, err = acctest.FromInstanceState(s, resourceName, "id")
161+
if resId != resId2 {
162+
return fmt.Errorf("Resource recreated when it was supposed to be updated.")
163+
}
164+
return err
165+
},
166+
),
167+
},
168+
169+
// deleting Lakehouse cluster before creating Warehouse cluster
170+
{
171+
Config: config + compartmentIdVariableStr + MysqlHeatWaveLakehouseClusterResourceDependencies,
172+
},
173+
// Update DbSystem to enable PITR policies
107174
{
108-
Config: config + compartmentIdVariableStr + MysqlHeatWaveClusterResourceDependencies,
175+
Config: config + compartmentIdVariableStr + MysqlHeatWaveWarehouseClusterResourceDependencies,
109176
},
110177
// verify Create & stop
111178
{
112-
Config: config + compartmentIdVariableStr + MysqlHeatWaveClusterResourceDependencies +
113-
acctest.GenerateResourceFromRepresentationMap("oci_mysql_heat_wave_cluster", "test_heat_wave_cluster", acctest.Optional, acctest.Create, MysqlHeatWaveClusterRepresentation),
179+
Config: config + compartmentIdVariableStr + MysqlHeatWaveWarehouseClusterResourceDependencies +
180+
acctest.GenerateResourceFromRepresentationMap("oci_mysql_heat_wave_cluster", "test_heat_wave_cluster", acctest.Optional, acctest.Create, MysqlHeatWaveWarehouseClusterRepresentation),
114181
Check: acctest.ComposeAggregateTestCheckFuncWrapper(
115182
resource.TestCheckResourceAttr(resourceName, "cluster_nodes.#", "2"),
116183
resource.TestCheckResourceAttr(resourceName, "cluster_size", "2"),
117184
resource.TestCheckResourceAttr(resourceName, "shape_name", "MySQL.VM.Standard.E3.1.8GB"),
118185
resource.TestCheckResourceAttr(resourceName, "state", "INACTIVE"),
186+
resource.TestCheckResourceAttr(resourceName, "is_lakehouse_enabled", "false"),
119187

120188
resource.TestCheckResourceAttrSet(resourceName, "db_system_id"),
121189
resource.TestCheckResourceAttrSet(resourceName, "time_created"),
@@ -135,13 +203,14 @@ func TestMysqlHeatWaveClusterResource_basic(t *testing.T) {
135203

136204
// verify start & updates to updatable parameters
137205
{
138-
Config: config + compartmentIdVariableStr + MysqlHeatWaveClusterResourceDependencies +
139-
acctest.GenerateResourceFromRepresentationMap("oci_mysql_heat_wave_cluster", "test_heat_wave_cluster", acctest.Optional, acctest.Update, MysqlHeatWaveClusterRepresentation),
206+
Config: config + compartmentIdVariableStr + MysqlHeatWaveWarehouseClusterResourceDependencies +
207+
acctest.GenerateResourceFromRepresentationMap("oci_mysql_heat_wave_cluster", "test_heat_wave_cluster", acctest.Optional, acctest.Update, MysqlHeatWaveWarehouseClusterRepresentation),
140208
Check: acctest.ComposeAggregateTestCheckFuncWrapper(
141209
resource.TestCheckResourceAttr(resourceName, "cluster_nodes.#", "3"),
142210
resource.TestCheckResourceAttr(resourceName, "cluster_size", "3"),
143211
resource.TestCheckResourceAttr(resourceName, "shape_name", "MySQL.VM.Standard.E3.1.8GB"),
144212
resource.TestCheckResourceAttr(resourceName, "state", "ACTIVE"),
213+
resource.TestCheckResourceAttr(resourceName, "is_lakehouse_enabled", "false"),
145214

146215
resource.TestCheckResourceAttrSet(resourceName, "db_system_id"),
147216
resource.TestCheckResourceAttrSet(resourceName, "time_created"),
@@ -167,6 +236,7 @@ func TestMysqlHeatWaveClusterResource_basic(t *testing.T) {
167236

168237
resource.TestCheckResourceAttr(singularDatasourceName, "cluster_nodes.#", "3"),
169238
resource.TestCheckResourceAttr(singularDatasourceName, "cluster_size", "3"),
239+
resource.TestCheckResourceAttr(singularDatasourceName, "is_lakehouse_enabled", "false"),
170240
resource.TestCheckResourceAttr(singularDatasourceName, "shape_name", "MySQL.VM.Standard.E3.1.8GB"),
171241
resource.TestCheckResourceAttr(singularDatasourceName, "state", "ACTIVE"),
172242
resource.TestCheckResourceAttrSet(singularDatasourceName, "time_created"),

internal/service/mysql/mysql_heat_wave_cluster_data_source.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,10 @@ func (s *MysqlHeatWaveClusterDataSourceCrud) SetData() error {
7676
s.D.Set("cluster_size", *s.Res.ClusterSize)
7777
}
7878

79+
if s.Res.IsLakehouseEnabled != nil {
80+
s.D.Set("is_lakehouse_enabled", *s.Res.IsLakehouseEnabled)
81+
}
82+
7983
if s.Res.LifecycleDetails != nil {
8084
s.D.Set("lifecycle_details", *s.Res.LifecycleDetails)
8185
}

internal/service/mysql/mysql_heat_wave_cluster_resource.go

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,11 @@ func MysqlHeatWaveClusterResource() *schema.Resource {
4545
Type: schema.TypeInt,
4646
Required: true,
4747
},
48+
"is_lakehouse_enabled": {
49+
Type: schema.TypeBool,
50+
Optional: true,
51+
Computed: true,
52+
},
4853
"shape_name": {
4954
Type: schema.TypeString,
5055
Required: true,
@@ -252,6 +257,11 @@ func (s *MysqlHeatWaveClusterResourceCrud) Create() error {
252257
request.DbSystemId = &tmp
253258
}
254259

260+
if isLakehouseEnabled, ok := s.D.GetOkExists("is_lakehouse_enabled"); ok {
261+
tmp := isLakehouseEnabled.(bool)
262+
request.IsLakehouseEnabled = &tmp
263+
}
264+
255265
if shapeName, ok := s.D.GetOkExists("shape_name"); ok {
256266
tmp := shapeName.(string)
257267
request.ShapeName = &tmp
@@ -307,6 +317,11 @@ func (s *MysqlHeatWaveClusterResourceCrud) Update() error {
307317
request.DbSystemId = &tmp
308318
}
309319

320+
if isLakehouseEnabled, ok := s.D.GetOkExists("is_lakehouse_enabled"); ok {
321+
tmp := isLakehouseEnabled.(bool)
322+
request.IsLakehouseEnabled = &tmp
323+
}
324+
310325
if shapeName, ok := s.D.GetOkExists("shape_name"); ok {
311326
tmp := shapeName.(string)
312327
request.ShapeName = &tmp
@@ -359,6 +374,10 @@ func (s *MysqlHeatWaveClusterResourceCrud) SetData() error {
359374
s.D.Set("db_system_id", *s.Res.DbSystemId)
360375
}
361376

377+
if s.Res.IsLakehouseEnabled != nil {
378+
s.D.Set("is_lakehouse_enabled", *s.Res.IsLakehouseEnabled)
379+
}
380+
362381
if s.Res.LifecycleDetails != nil {
363382
s.D.Set("lifecycle_details", *s.Res.LifecycleDetails)
364383
}

internal/service/mysql/mysql_mysql_db_system_resource.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -645,6 +645,10 @@ func MysqlMysqlDbSystemResource() *schema.Resource {
645645
Type: schema.TypeInt,
646646
Computed: true,
647647
},
648+
"is_lakehouse_enabled": {
649+
Type: schema.TypeBool,
650+
Computed: true,
651+
},
648652
"shape_name": {
649653
Type: schema.TypeString,
650654
Computed: true,
@@ -1806,6 +1810,10 @@ func HeatWaveClusterSummaryToMap(obj *oci_mysql.HeatWaveClusterSummary) map[stri
18061810
result["cluster_size"] = int(*obj.ClusterSize)
18071811
}
18081812

1813+
if obj.IsLakehouseEnabled != nil {
1814+
result["is_lakehouse_enabled"] = bool(*obj.IsLakehouseEnabled)
1815+
}
1816+
18091817
if obj.ShapeName != nil {
18101818
result["shape_name"] = string(*obj.ShapeName)
18111819
}

website/docs/d/mysql_heat_wave_cluster.html.markdown

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ The following attributes are exported:
3939
* `time_updated` - The date and time the MySQL HeatWave node was updated, as described by [RFC 3339](https://tools.ietf.org/rfc/rfc3339).
4040
* `cluster_size` - The number of analytics-processing compute instances, of the specified shape, in the HeatWave cluster.
4141
* `db_system_id` - The OCID of the parent DB System this HeatWave cluster is attached to.
42+
* `is_lakehouse_enabled` - Lakehouse enabled status for the HeatWave cluster.
4243
* `lifecycle_details` - Additional information about the current lifecycleState.
4344
* `shape_name` - The shape determines resources to allocate to the HeatWave nodes - CPU cores, memory.
4445
* `state` - The current state of the HeatWave cluster.

website/docs/d/mysql_mysql_db_system.html.markdown

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@ The following attributes are exported:
137137
* `freeform_tags` - Simple key-value pair that is applied without any predefined name, type or scope. Exists for cross-compatibility only. Example: `{"bar-key": "value"}`
138138
* `heat_wave_cluster` - A summary of a HeatWave cluster.
139139
* `cluster_size` - The number of analytics-processing compute instances, of the specified shape, in the HeatWave cluster.
140+
* `is_lakehouse_enabled` - Lakehouse enabled status for the HeatWave cluster.
140141
* `shape_name` - The shape determines resources to allocate to the HeatWave nodes - CPU cores, memory.
141142
* `state` - The current state of the MySQL HeatWave cluster.
142143
* `time_created` - The date and time the HeatWave cluster was created, as described by [RFC 3339](https://tools.ietf.org/rfc/rfc3339).

website/docs/d/mysql_mysql_db_systems.html.markdown

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,7 @@ The following attributes are exported:
161161
* `freeform_tags` - Simple key-value pair that is applied without any predefined name, type or scope. Exists for cross-compatibility only. Example: `{"bar-key": "value"}`
162162
* `heat_wave_cluster` - A summary of a HeatWave cluster.
163163
* `cluster_size` - The number of analytics-processing compute instances, of the specified shape, in the HeatWave cluster.
164+
* `is_lakehouse_enabled` - Lakehouse enabled status for the HeatWave cluster.
164165
* `shape_name` - The shape determines resources to allocate to the HeatWave nodes - CPU cores, memory.
165166
* `state` - The current state of the MySQL HeatWave cluster.
166167
* `time_created` - The date and time the HeatWave cluster was created, as described by [RFC 3339](https://tools.ietf.org/rfc/rfc3339).

0 commit comments

Comments
 (0)