Skip to content

Commit 943f7c1

Browse files
committed
data source acc test.
1 parent 92e55e5 commit 943f7c1

File tree

2 files changed

+77
-9
lines changed

2 files changed

+77
-9
lines changed

internal/service/odb/cloud_vm_cluster_data_source_test.go

Lines changed: 45 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ func TestAccODBCloudVmClusterDataSource_basic(t *testing.T) {
4343
}
4444

4545
var cloudvmcluster odbtypes.CloudVmCluster
46+
odbNetRName := sdkacctest.RandomWithPrefix(vmClusterTestDS.odbNetDisplayNamePrefix)
47+
exaInfraRName := sdkacctest.RandomWithPrefix(vmClusterTestDS.exaInfraDisplayNamePrefix)
4648
vmcDisplayName := sdkacctest.RandomWithPrefix(vmClusterTestDS.vmClusterDisplayNamePrefix)
4749
dataSourceName := "data.aws_odb_cloud_vm_cluster.test"
4850
publicKey, _, err := sdkacctest.RandSSHKeyPair(acctest.DefaultEmailAddress)
@@ -53,14 +55,14 @@ func TestAccODBCloudVmClusterDataSource_basic(t *testing.T) {
5355
resource.ParallelTest(t, resource.TestCase{
5456
PreCheck: func() {
5557
acctest.PreCheck(ctx, t)
56-
// testAccPreCheck(ctx, t)
58+
vmClusterTestDS.testAccPreCheck(ctx, t)
5759
},
5860
ErrorCheck: acctest.ErrorCheck(t, names.ODBServiceID),
5961
ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories,
6062
CheckDestroy: vmClusterTestDS.testAccCheckCloudVmClusterDestroy(ctx),
6163
Steps: []resource.TestStep{
6264
{
63-
Config: vmClusterTestDS.cloudVmClusterWithHardcoded("odbnet_c91byo6y6m", "exa_ji5quxxzn9", vmcDisplayName, publicKey),
65+
Config: vmClusterTestDS.cloudVMClusterConfig(odbNetRName, exaInfraRName, vmcDisplayName, publicKey),
6466
Check: resource.ComposeAggregateTestCheckFunc(
6567
vmClusterTestDS.testAccCheckCloudVmClusterExists(ctx, dataSourceName, &cloudvmcluster),
6668
resource.TestCheckResourceAttr(dataSourceName, "display_name", vmcDisplayName),
@@ -133,21 +135,56 @@ func (cloudVmClusterDSTest) testAccPreCheck(ctx context.Context, t *testing.T) {
133135
}
134136
}
135137

136-
func (cloudVmClusterDSTest) cloudVmClusterWithHardcoded(odbNet, exaInfra, displayName, sshKey string) string {
138+
func (cloudVmClusterDSTest) cloudVMClusterConfig(odbNet, exaInfra, displayName, sshKey string) string {
137139
dsTfCodeVmCluster := fmt.Sprintf(`
140+
141+
resource "aws_odb_network" "test" {
142+
display_name = %[1]q
143+
availability_zone_id = "use1-az6"
144+
client_subnet_cidr = "10.2.0.0/24"
145+
backup_subnet_cidr = "10.2.1.0/24"
146+
s3_access = "DISABLED"
147+
zero_etl_access = "DISABLED"
148+
}
149+
150+
resource "aws_odb_cloud_exadata_infrastructure" "test" {
151+
display_name = %[2]q
152+
shape = "Exadata.X9M"
153+
storage_count = 3
154+
compute_count = 2
155+
availability_zone_id = "use1-az6"
156+
customer_contacts_to_send_to_oci = ["[email protected]"]
157+
maintenance_window = {
158+
custom_action_timeout_in_mins = 16
159+
days_of_week = []
160+
hours_of_day = []
161+
is_custom_action_timeout_enabled = true
162+
lead_time_in_weeks = 0
163+
months = []
164+
patching_mode = "ROLLING"
165+
preference = "NO_PREFERENCE"
166+
weeks_of_month =[]
167+
}
168+
169+
}
170+
171+
data "aws_odb_db_servers_list" "test" {
172+
cloud_exadata_infrastructure_id = aws_odb_cloud_exadata_infrastructure.test.id
173+
}
174+
138175
resource "aws_odb_cloud_vm_cluster" "test" {
139-
odb_network_id = %[1]q
140-
cloud_exadata_infrastructure_id = %[2]q
141-
display_name = %[3]q
142-
ssh_public_keys = [%[4]q]
176+
display_name = %[3]q
177+
cloud_exadata_infrastructure_id = aws_odb_cloud_exadata_infrastructure.test.id
143178
cpu_core_count = 6
144179
gi_version = "23.0.0.0"
145180
hostname_prefix = "apollo12"
181+
ssh_public_keys = [%[4]q]
182+
odb_network_id = aws_odb_network.test.id
146183
is_local_backup_enabled = true
147184
is_sparse_diskgroup_enabled = true
148185
license_model = "LICENSE_INCLUDED"
149186
data_storage_size_in_tbs = 20.0
150-
db_servers = [ "dbs_7ecm4wbjxy","dbs_uy5wmaqk6s"]
187+
db_servers = [ for db_server in data.aws_odb_db_servers_list.test.db_servers : db_server.id]
151188
db_node_storage_size_in_gbs = 120.0
152189
memory_size_in_gbs = 60
153190
tags = {
@@ -160,6 +197,5 @@ data "aws_odb_cloud_vm_cluster" "test" {
160197
id = aws_odb_cloud_vm_cluster.test.id
161198
}
162199
`, odbNet, exaInfra, displayName, sshKey)
163-
//fmt.Println(dsTfCodeVmCluster)
164200
return dsTfCodeVmCluster
165201
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
//Copyright © 2025, Oracle and/or its affiliates. All rights reserved.
2+
3+
package odb
4+
5+
import (
6+
"context"
7+
"github.com/aws/aws-sdk-go-v2/aws"
8+
"github.com/aws/aws-sdk-go-v2/service/odb"
9+
"github.com/hashicorp/terraform-plugin-log/tflog"
10+
"github.com/hashicorp/terraform-provider-aws/names"
11+
)
12+
13+
func (p *servicePackage) NewClient(ctx context.Context, config map[string]any) (*odb.Client, error) {
14+
cfg := *(config["aws_sdkv2_config"].(*aws.Config))
15+
16+
return odb.NewFromConfig(cfg,
17+
odb.WithEndpointResolverV2(newEndpointResolverV2()),
18+
withBaseEndpoint(config[names.AttrEndpoint].(string)),
19+
func(o *odb.Options) {
20+
//if config["partition"].(string) == names.StandardPartitionID {
21+
if cfg.Region != "\"us-east-1\"" {
22+
tflog.Info(ctx, "overriding region", map[string]any{
23+
"original_region": cfg.Region,
24+
"override_region": "us-east-1",
25+
})
26+
o.Region = "us-east-1"
27+
}
28+
//}
29+
o.BaseEndpoint = aws.String("https://gammaiad.capi.us-east-1.oracolo.alameda.aws.dev")
30+
},
31+
), nil
32+
}

0 commit comments

Comments
 (0)