Skip to content

Commit 9202df6

Browse files
lm-oraclesrinioci
authored andcommitted
Added - Support for GoldenGate new deployment creation page and extended connectivity test results
1 parent d890f69 commit 9202df6

15 files changed

+662
-96
lines changed

examples/goldengate/Deployment/main.tf

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ variable "objectstorage_bucket_name" {}
99
variable "objectstorage_namespace" {}
1010
variable password_secret_id {}
1111
variable identity_domain_id {}
12+
variable group_id {}
1213

1314
variable "deployment_cpu_core_count" {
1415
default = 1
@@ -106,6 +107,9 @@ resource "oci_golden_gate_deployment" "test_deployment" {
106107
admin_password = var.deployment_ogg_data_admin_password
107108
admin_username = var.deployment_ogg_data_admin_username
108109
deployment_name = var.deployment_ogg_data_deployment_name
110+
group_to_roles_mapping {
111+
security_group_id = var.group_id
112+
}
109113
}
110114
locks {}
111115
}
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
// Copyright (c) 2017, 2024, 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+
GoldenGateDeploymentEnvironmentDataSourceRepresentation = map[string]interface{}{
20+
"compartment_id": acctest.Representation{RepType: acctest.Required, Create: `${var.compartment_id}`},
21+
}
22+
23+
GoldenGateDeploymentEnvironmentResourceConfig = ""
24+
)
25+
26+
// issue-routing-tag: golden_gate/default
27+
func TestGoldenGateDeploymentEnvironmentResource_basic(t *testing.T) {
28+
httpreplay.SetScenario("TestGoldenGateDeploymentEnvironmentResource_basic")
29+
defer httpreplay.SaveScenario()
30+
31+
config := acctest.ProviderTestConfig()
32+
33+
compartmentId := utils.GetEnvSettingWithBlankDefault("compartment_ocid")
34+
compartmentIdVariableStr := fmt.Sprintf("variable \"compartment_id\" { default = \"%s\" }\n", compartmentId)
35+
36+
datasourceName := "data.oci_golden_gate_deployment_environments.test_deployment_environments"
37+
38+
acctest.SaveConfigContent("", "", "", t)
39+
40+
acctest.ResourceTest(t, nil, []resource.TestStep{
41+
// verify datasource
42+
{
43+
Config: config +
44+
acctest.GenerateDataSourceFromRepresentationMap("oci_golden_gate_deployment_environments", "test_deployment_environments", acctest.Required, acctest.Create, GoldenGateDeploymentEnvironmentDataSourceRepresentation) +
45+
compartmentIdVariableStr + GoldenGateDeploymentEnvironmentResourceConfig,
46+
Check: acctest.ComposeAggregateTestCheckFuncWrapper(
47+
resource.TestCheckResourceAttr(datasourceName, "compartment_id", compartmentId),
48+
49+
resource.TestCheckResourceAttrSet(datasourceName, "deployment_environment_collection.#"),
50+
resource.TestCheckResourceAttr(datasourceName, "deployment_environment_collection.0.items.#", "6"),
51+
),
52+
},
53+
})
54+
}

internal/integrationtest/golden_gate_deployment_test.go

Lines changed: 53 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ func TestGoldenGateDeploymentResource_basic(t *testing.T) {
4343
IDENTITY_DOMAIN_ID = "identity_domain_id"
4444
PASSWORD_SECRET_ID = "password_secret_id"
4545
PASSWORD_SECRET_ID_2 = "password_secret_id_2"
46+
GROUP_ID = "group_id"
4647
)
4748

4849
var (
@@ -73,6 +74,7 @@ func TestGoldenGateDeploymentResource_basic(t *testing.T) {
7374
passwordSecretId2 = utils.GetEnvSettingWithBlankDefault(PASSWORD_SECRET_ID_2)
7475
baseOggVersion = utils.GetEnvSettingWithBlankDefault(BASE_OGG_VERSION)
7576
upgradedOggVersion = utils.GetEnvSettingWithBlankDefault(UPGRADED_OGG_VERSION)
77+
groupId = utils.GetEnvSettingWithBlankDefault(GROUP_ID)
7678

7779
resId string
7880
resId2 string
@@ -93,6 +95,20 @@ func TestGoldenGateDeploymentResource_basic(t *testing.T) {
9395
"key": acctest.Representation{RepType: acctest.Optional, Update: `${var.key}`},
9496
}
9597

98+
groupToRolesMappingRepresentation = map[string]interface{}{
99+
"security_group_id": acctest.Representation{RepType: acctest.Required, Create: `${var.group_id}`},
100+
"administrator_group_id": acctest.Representation{RepType: acctest.Optional, Update: `${var.group_id}`},
101+
"operator_group_id": acctest.Representation{RepType: acctest.Optional, Update: `${var.group_id}`},
102+
"user_group_id": acctest.Representation{RepType: acctest.Optional, Update: `${var.group_id}`},
103+
}
104+
105+
goldenGateDeploymentOggDataWithGroupRoleMappingRepresentation = map[string]interface{}{
106+
"admin_password": acctest.Representation{RepType: acctest.Required, Create: `${var.password}`},
107+
"admin_username": acctest.Representation{RepType: acctest.Required, Create: `adminUsername`},
108+
"deployment_name": acctest.Representation{RepType: acctest.Required, Create: `depl_test_ggs_deployment_name`},
109+
"group_to_roles_mapping": acctest.RepresentationGroup{RepType: acctest.Required, Group: groupToRolesMappingRepresentation},
110+
}
111+
96112
deploymentMaintenanceConfigurationRepresentation = map[string]interface{}{
97113
"bundle_release_upgrade_period_in_days": acctest.Representation{RepType: acctest.Optional, Create: `10`, Update: `11`},
98114
"interim_release_upgrade_period_in_days": acctest.Representation{RepType: acctest.Optional, Create: `5`, Update: `6`},
@@ -182,6 +198,7 @@ func TestGoldenGateDeploymentResource_basic(t *testing.T) {
182198
makeVariableStr(NEW_PASSWORD, t) +
183199
makeVariableStr(PASSWORD_SECRET_ID, t) +
184200
makeVariableStr(PASSWORD_SECRET_ID_2, t) +
201+
makeVariableStr(GROUP_ID, t) +
185202
GoldenGateDeploymentResourceDependencies
186203

187204
if identityDomainId != "" {
@@ -192,7 +209,7 @@ func TestGoldenGateDeploymentResource_basic(t *testing.T) {
192209
acctest.SaveConfigContent(config+testDeploymentIdVariableStr+
193210
acctest.GenerateResourceFromRepresentationMap("oci_golden_gate_deployment", "depl_test_ggs_deployment", acctest.Optional, acctest.Create, goldenGateDeploymentRepresentation), "goldengate", "deployment", t)
194211

195-
acctest.ResourceTest(t, testAccCheckGoldenGateDeploymentDestroy, []resource.TestStep{
212+
var steps = []resource.TestStep{
196213
// verify Create
197214
{
198215
Config: config + testDeploymentIdVariableStr +
@@ -220,6 +237,39 @@ func TestGoldenGateDeploymentResource_basic(t *testing.T) {
220237
),
221238
},
222239

240+
// delete before next Create
241+
{
242+
Config: config,
243+
},
244+
// check groupToRolesMapping attribute set
245+
{
246+
Config: config + testDeploymentIdVariableStr + acctest.GenerateResourceFromRepresentationMap("oci_golden_gate_deployment", "depl_test_ggs_deployment", acctest.Required, acctest.Create,
247+
acctest.RepresentationCopyWithNewProperties(goldenGateDeploymentRepresentation, map[string]interface{}{
248+
"deployment_type": acctest.Representation{RepType: acctest.Required, Create: `OGG`},
249+
"ogg_data": acctest.RepresentationGroup{RepType: acctest.Required, Group: goldenGateDeploymentOggDataWithGroupRoleMappingRepresentation},
250+
})),
251+
252+
Check: acctest.ComposeAggregateTestCheckFuncWrapper(
253+
resource.TestCheckResourceAttr(resourceName, "compartment_id", compartmentId),
254+
resource.TestCheckResourceAttr(resourceName, "cpu_core_count", "1"),
255+
resource.TestCheckResourceAttr(resourceName, "deployment_type", "OGG"),
256+
resource.TestCheckResourceAttr(resourceName, "display_name", "Terraform_integration_test"),
257+
resource.TestCheckResourceAttr(resourceName, "is_auto_scaling_enabled", "false"),
258+
resource.TestCheckResourceAttrSet(resourceName, "subnet_id"),
259+
resource.TestCheckResourceAttr(resourceName, "license_model", "LICENSE_INCLUDED"),
260+
resource.TestCheckResourceAttr(resourceName, "ogg_data.#", "1"),
261+
resource.TestCheckResourceAttr(resourceName, "ogg_data.0.admin_username", "adminUsername"),
262+
resource.TestCheckResourceAttrSet(resourceName, "ogg_data.0.deployment_name"),
263+
resource.TestCheckResourceAttrSet(resourceName, "ogg_data.0.ogg_version"),
264+
resource.TestCheckResourceAttr(resourceName, "ogg_data.0.group_to_roles_mapping.#", "1"),
265+
resource.TestCheckResourceAttr(resourceName, "ogg_data.0.group_to_roles_mapping.0.security_group_id", groupId),
266+
267+
func(s *terraform.State) (err error) {
268+
resId, err = acctest.FromInstanceState(s, resourceName, "id")
269+
return err
270+
},
271+
),
272+
},
223273
// delete before next Create
224274
{
225275
Config: config,
@@ -685,7 +735,8 @@ func TestGoldenGateDeploymentResource_basic(t *testing.T) {
685735
{
686736
Config: config,
687737
},
688-
})
738+
}
739+
acctest.ResourceTest(t, testAccCheckGoldenGateDeploymentDestroy, steps)
689740
}
690741

691742
func testAccCheckGoldenGateDeploymentDestroy(s *terraform.State) error {

internal/service/golden_gate/golden_gate_deployment_backup_resource.go

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -310,22 +310,10 @@ func (s *GoldenGateDeploymentBackupResourceCrud) Create() error {
310310
}
311311

312312
workId := response.OpcWorkRequestId
313-
workRequestResponse := oci_golden_gate.GetWorkRequestResponse{}
314-
workRequestResponse, err = s.Client.GetWorkRequest(context.Background(),
315-
oci_golden_gate.GetWorkRequestRequest{
316-
WorkRequestId: workId,
317-
RequestMetadata: oci_common.RequestMetadata{
318-
RetryPolicy: tfresource.GetRetryPolicy(s.DisableNotFoundRetries, "golden_gate"),
319-
},
320-
})
321-
if err == nil {
322-
// The work request response contains an array of objects
323-
for _, res := range workRequestResponse.Resources {
324-
if res.EntityType != nil && strings.Contains(strings.ToLower(*res.EntityType), "deploymentbackup") && res.Identifier != nil {
325-
s.D.SetId(*res.Identifier)
326-
break
327-
}
328-
}
313+
var identifier *string
314+
identifier = response.Id
315+
if identifier != nil {
316+
s.D.SetId(*identifier)
329317
}
330318
return s.getDeploymentBackupFromWorkRequest(workId, tfresource.GetRetryPolicy(s.DisableNotFoundRetries, "golden_gate"), oci_golden_gate.ActionTypeCreated, s.D.Timeout(schema.TimeoutCreate))
331319
}

internal/service/golden_gate/golden_gate_deployment_data_source.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,8 @@ func (s *GoldenGateDeploymentDataSourceCrud) SetData() error {
6767

6868
s.D.SetId(*s.Res.Id)
6969

70+
s.D.Set("category", s.Res.Category)
71+
7072
if s.Res.CompartmentId != nil {
7173
s.D.Set("compartment_id", *s.Res.CompartmentId)
7274
}
@@ -103,6 +105,8 @@ func (s *GoldenGateDeploymentDataSourceCrud) SetData() error {
103105
s.D.Set("display_name", *s.Res.DisplayName)
104106
}
105107

108+
s.D.Set("environment_type", s.Res.EnvironmentType)
109+
106110
if s.Res.Fqdn != nil {
107111
s.D.Set("fqdn", *s.Res.Fqdn)
108112
}

0 commit comments

Comments
 (0)