Skip to content

Commit 2140a02

Browse files
Terraform Team AutomationjiaqchenO
authored andcommitted
Added - Support for High Performance Mount Targets (HPMT)
1 parent e209de3 commit 2140a02

File tree

6 files changed

+309
-5
lines changed

6 files changed

+309
-5
lines changed

examples/storage/fss/mount_target.tf

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ resource "oci_file_storage_mount_target" "my_mount_target_1" {
1616
freeform_tags = {
1717
"Department" = "Finance"
1818
}
19+
requested_throughput = "1"
1920

2021
nsg_ids = [oci_core_network_security_group.test_network_security_group.id]
2122
}
@@ -31,6 +32,7 @@ resource "oci_file_storage_mount_target" "my_mount_target_2" {
3132
# defined_tags = {
3233
# "example-tag-namespace-all.example-tag" = "value"
3334
# }
35+
requested_throughput = "1"
3436

3537
freeform_tags = {
3638
"Department" = "Accounting"

internal/integrationtest/file_storage_mount_target_test.go

Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ var (
4343
}
4444

4545
FileStorageMountTargetRepresentation = map[string]interface{}{
46+
4647
"availability_domain": acctest.Representation{RepType: acctest.Required, Create: `${data.oci_identity_availability_domains.test_availability_domains.availability_domains.0.name}`},
4748
"compartment_id": acctest.Representation{RepType: acctest.Required, Create: `${var.compartment_id}`},
4849
"subnet_id": acctest.Representation{RepType: acctest.Required, Create: `${oci_core_subnet.test_subnet.id}`},
@@ -57,6 +58,17 @@ var (
5758
"nsg_ids": acctest.Representation{RepType: acctest.Optional, Create: []string{`${oci_core_network_security_group.test_network_security_group.id}`}, Update: []string{}},
5859
"lifecycle": acctest.RepresentationGroup{RepType: acctest.Required, Group: ignoreDefinedTagsDifferencesRepresentation},
5960
}
61+
FileStorageHPMTMountTargetRepresentation = map[string]interface{}{
62+
"availability_domain": acctest.Representation{RepType: acctest.Required, Create: `${data.oci_identity_availability_domains.test_availability_domains.availability_domains.0.name}`},
63+
"compartment_id": acctest.Representation{RepType: acctest.Required, Create: `${var.compartment_id}`},
64+
"subnet_id": acctest.Representation{RepType: acctest.Required, Create: `${oci_core_subnet.test_subnet.id}`},
65+
"defined_tags": acctest.Representation{RepType: acctest.Optional, Create: `${map("${oci_identity_tag_namespace.tag-namespace1.name}.${oci_identity_tag.tag1.name}", "value")}`, Update: `${map("${oci_identity_tag_namespace.tag-namespace1.name}.${oci_identity_tag.tag1.name}", "updatedValue")}`},
66+
"display_name": acctest.Representation{RepType: acctest.Optional, Create: `mount-target-6`},
67+
"hostname_label": acctest.Representation{RepType: acctest.Optional, Create: `hostnamelabel`},
68+
"ip_address": acctest.Representation{RepType: acctest.Optional, Create: `10.0.0.5`},
69+
"requested_throughput": acctest.Representation{RepType: acctest.Optional, Create: `1`},
70+
"lifecycle": acctest.RepresentationGroup{RepType: acctest.Required, Group: ignoreDefinedTagsDifferencesRepresentation},
71+
}
6072
FileStorageMountTargetKerberosRepresentation = map[string]interface{}{
6173
"kerberos_realm": acctest.Representation{RepType: acctest.Required, Create: `kerberosRealm`, Update: `kerberosRealm2`},
6274
"backup_key_tab_secret_version": acctest.Representation{RepType: acctest.Optional, Create: `0`, Update: `0`},
@@ -193,6 +205,7 @@ func TestFileStorageMountTargetResource_basic(t *testing.T) {
193205
resource.TestCheckResourceAttr(resourceName, "ldap_idmap.0.negative_cache_lifetime_seconds", "300"),
194206
resource.TestCheckResourceAttrSet(resourceName, "ldap_idmap.0.outbound_connector1id"),
195207
resource.TestCheckResourceAttr(resourceName, "ldap_idmap.0.schema_type", "RFC2307"),
208+
resource.TestCheckResourceAttr(resourceName, "requested_throughput", "1"),
196209

197210
func(s *terraform.State) (err error) {
198211
resId, err = acctest.FromInstanceState(s, resourceName, "id")
@@ -241,6 +254,8 @@ func TestFileStorageMountTargetResource_basic(t *testing.T) {
241254
resource.TestCheckResourceAttr(resourceName, "ldap_idmap.0.negative_cache_lifetime_seconds", "300"),
242255
resource.TestCheckResourceAttrSet(resourceName, "ldap_idmap.0.outbound_connector1id"),
243256
resource.TestCheckResourceAttr(resourceName, "ldap_idmap.0.schema_type", "RFC2307"),
257+
resource.TestCheckResourceAttr(resourceName, "ldap_idmap.0.user_search_base", "userSearchBase"),
258+
resource.TestCheckResourceAttr(resourceName, "requested_throughput", "1"),
244259

245260
func(s *terraform.State) (err error) {
246261
resId2, err = acctest.FromInstanceState(s, resourceName, "id")
@@ -286,6 +301,7 @@ func TestFileStorageMountTargetResource_basic(t *testing.T) {
286301
resource.TestCheckResourceAttrSet(resourceName, "ldap_idmap.0.outbound_connector1id"),
287302
resource.TestCheckResourceAttrSet(resourceName, "ldap_idmap.0.outbound_connector2id"),
288303
resource.TestCheckResourceAttr(resourceName, "ldap_idmap.0.schema_type", "RFC2307"),
304+
resource.TestCheckResourceAttr(resourceName, "requested_throughput", "1"),
289305

290306
func(s *terraform.State) (err error) {
291307
resId2, err = acctest.FromInstanceState(s, resourceName, "id")
@@ -311,6 +327,9 @@ func TestFileStorageMountTargetResource_basic(t *testing.T) {
311327
resource.TestCheckResourceAttrSet(datasourceName, "mount_targets.0.export_set_id"),
312328
resource.TestCheckResourceAttr(datasourceName, "mount_targets.0.freeform_tags.%", "1"),
313329
resource.TestCheckResourceAttrSet(datasourceName, "mount_targets.0.id"),
330+
resource.TestCheckResourceAttrSet(datasourceName, "mount_targets.0.observed_throughput"),
331+
resource.TestCheckResourceAttr(datasourceName, "mount_targets.0.requested_throughput", "1"),
332+
resource.TestCheckResourceAttrSet(datasourceName, "mount_targets.0.reserved_storage_capacity"),
314333
resource.TestCheckResourceAttr(datasourceName, "mount_targets.nsg_ids.#", "0"),
315334
resource.TestCheckResourceAttrSet(datasourceName, "mount_targets.0.private_ip_ids.#"),
316335
resource.TestCheckResourceAttr(datasourceName, "mount_targets.0.state", string(oci_file_storage.MountTargetLifecycleStateActive)),
@@ -384,6 +403,103 @@ func TestFileStorageMountTargetResource_failedWorkRequest(t *testing.T) {
384403
})
385404
}
386405

406+
func TestFileStorageMountTargetResource_hpmtTest(t *testing.T) {
407+
httpreplay.SetScenario("TestFileStorageMountTargetResource_hpmtTest")
408+
defer httpreplay.SaveScenario()
409+
config := acctest.ProviderTestConfig()
410+
411+
compartmentId := utils.GetEnvSettingWithBlankDefault("compartment_ocid")
412+
compartmentIdVariableStr := fmt.Sprintf("variable \"compartment_id\" { default = \"%s\" }\n", compartmentId)
413+
414+
resourceName := "oci_file_storage_mount_target.test_mount_target3"
415+
416+
// Save TF content to Create resource with optional properties. This has to be exactly the same as the config part in the "Create with optionals" step in the test.
417+
acctest.SaveConfigContent(config+compartmentIdVariableStr+FileStorageMountTargetResourceDependencies+
418+
acctest.GenerateResourceFromRepresentationMap("oci_file_storage_mount_target",
419+
"test_mount_target3", acctest.Optional, acctest.Create, FileStorageHPMTMountTargetRepresentation), "filestorage", "mountTarget", t)
420+
421+
var resId, resId2 string
422+
423+
acctest.ResourceTest(t, testAccCheckFileStorageMountTargetDestroy, []resource.TestStep{
424+
// verify Create
425+
{
426+
Config: config + compartmentIdVariableStr + FileStorageMountTargetResourceDependencies +
427+
acctest.GenerateResourceFromRepresentationMap("oci_file_storage_mount_target", "test_mount_target3", acctest.Optional, acctest.Create, FileStorageHPMTMountTargetRepresentation),
428+
Check: acctest.ComposeAggregateTestCheckFuncWrapper(
429+
resource.TestCheckResourceAttr(resourceName, "requested_throughput", "1"),
430+
resource.TestCheckResourceAttrSet(resourceName, "observed_throughput"),
431+
resource.TestCheckResourceAttr(resourceName, "reserved_storage_capacity", "0"),
432+
resource.TestCheckNoResourceAttr(resourceName, "time_billing_cycle_end"),
433+
func(s *terraform.State) (err error) {
434+
resId, err = acctest.FromInstanceState(s, resourceName, "id")
435+
return err
436+
},
437+
),
438+
},
439+
440+
// verify Upgrade
441+
{
442+
Config: config + compartmentIdVariableStr + FileStorageMountTargetResourceDependencies +
443+
acctest.GenerateResourceFromRepresentationMap("oci_file_storage_mount_target", "test_mount_target3", acctest.Optional, acctest.Update,
444+
acctest.RepresentationCopyWithNewProperties(FileStorageHPMTMountTargetRepresentation, map[string]interface{}{
445+
"requested_throughput": acctest.Representation{RepType: acctest.Optional, Update: `20`},
446+
})),
447+
Check: acctest.ComposeAggregateTestCheckFuncWrapper(
448+
resource.TestCheckResourceAttr(resourceName, "requested_throughput", "20"),
449+
resource.TestCheckResourceAttr(resourceName, "observed_throughput", "20"),
450+
resource.TestCheckResourceAttr(resourceName, "reserved_storage_capacity", "20000"),
451+
resource.TestCheckResourceAttrSet(resourceName, "time_billing_cycle_end"),
452+
453+
func(s *terraform.State) (err error) {
454+
resId2, err = acctest.FromInstanceState(s, resourceName, "id")
455+
if resId != resId2 {
456+
return fmt.Errorf("resource recreated when it was supposed to be updated")
457+
}
458+
return err
459+
},
460+
),
461+
},
462+
// verify downgrade hpmt related parameters
463+
{
464+
Config: config + compartmentIdVariableStr + FileStorageMountTargetResourceDependencies +
465+
acctest.GenerateResourceFromRepresentationMap("oci_file_storage_mount_target", "test_mount_target3", acctest.Optional, acctest.Update,
466+
acctest.RepresentationCopyWithNewProperties(FileStorageHPMTMountTargetRepresentation, map[string]interface{}{
467+
"requested_throughput": acctest.Representation{RepType: acctest.Optional, Update: `1`},
468+
})),
469+
Check: acctest.ComposeAggregateTestCheckFuncWrapper(
470+
func(s *terraform.State) (err error) {
471+
time.Sleep(3 * time.Minute)
472+
resId2, err = acctest.FromInstanceState(s, resourceName, "id")
473+
if resId != resId2 {
474+
return fmt.Errorf("resource recreated when it was supposed to be updated")
475+
}
476+
return err
477+
},
478+
),
479+
},
480+
{
481+
Config: config + compartmentIdVariableStr + FileStorageMountTargetResourceDependencies +
482+
acctest.GenerateResourceFromRepresentationMap("oci_file_storage_mount_target", "test_mount_target3", acctest.Optional, acctest.Update,
483+
acctest.RepresentationCopyWithNewProperties(FileStorageHPMTMountTargetRepresentation, map[string]interface{}{
484+
"display_name": acctest.Representation{RepType: acctest.Optional, Update: `hpmt_mt`},
485+
})),
486+
Check: acctest.ComposeAggregateTestCheckFuncWrapper(
487+
resource.TestCheckResourceAttr(resourceName, "requested_throughput", "1"),
488+
resource.TestCheckResourceAttrSet(resourceName, "observed_throughput"),
489+
resource.TestCheckResourceAttr(resourceName, "reserved_storage_capacity", "0"),
490+
491+
func(s *terraform.State) (err error) {
492+
resId2, err = acctest.FromInstanceState(s, resourceName, "id")
493+
if resId != resId2 {
494+
return fmt.Errorf("resource recreated when it was supposed to be updated")
495+
}
496+
return err
497+
},
498+
),
499+
},
500+
})
501+
}
502+
387503
func testAccCheckFileStorageMountTargetDestroy(s *terraform.State) error {
388504
noResourceFound := true
389505
client := acctest.TestAccProvider.Meta().(*tf_client.OracleClients).FileStorageClient()

0 commit comments

Comments
 (0)