Skip to content

Commit

Permalink
Merge pull request #22798 from neil-yechenwei/storagetargetupdate
Browse files Browse the repository at this point in the history
`azurerm_hpc_cache_nfs_target/azurerm_hpc_cache_blob_nfs_target` - update the validation of `usage_model`
  • Loading branch information
tombuildsstuff authored Aug 3, 2023
2 parents f378e2a + 5a9a206 commit aa1513e
Show file tree
Hide file tree
Showing 6 changed files with 61 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ func resourceHPCCacheBlobNFSTarget() *pluginsdk.Resource {
ValidateFunc: validation.StringInSlice([]string{
"READ_HEAVY_INFREQ",
"READ_HEAVY_CHECK_180",
"READ_ONLY",
"READ_WRITE",
"WRITE_WORKLOAD_15",
"WRITE_AROUND",
"WRITE_WORKLOAD_CHECK_30",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,28 @@ func TestAccHPCCacheBlobNFSTarget_requiresImport(t *testing.T) {
})
}

func TestAccHPCCacheBlobNFSTarget_usageModel(t *testing.T) {
data := acceptance.BuildTestData(t, "azurerm_hpc_cache_blob_nfs_target", "test")
r := HPCCacheBlobNFSTargetResource{}

data.ResourceTest(t, r, []acceptance.TestStep{
{
Config: r.usageModel(data, "READ_WRITE"),
Check: acceptance.ComposeTestCheckFunc(
check.That(data.ResourceName).ExistsInAzure(r),
),
},
data.ImportStep(),
{
Config: r.usageModel(data, "READ_ONLY"),
Check: acceptance.ComposeTestCheckFunc(
check.That(data.ResourceName).ExistsInAzure(r),
),
},
data.ImportStep(),
})
}

func (HPCCacheBlobNFSTargetResource) Exists(ctx context.Context, clients *clients.Client, state *pluginsdk.InstanceState) (*bool, error) {
id, err := storagetargets.ParseStorageTargetID(state.ID)
if err != nil {
Expand Down Expand Up @@ -353,3 +375,18 @@ resource "azurerm_hpc_cache" "test" {
}
`, data.RandomInteger, data.Locations.Primary, data.RandomString)
}

func (r HPCCacheBlobNFSTargetResource) usageModel(data acceptance.TestData, modelName string) string {
return fmt.Sprintf(`
%s
resource "azurerm_hpc_cache_blob_nfs_target" "test" {
name = "acctest-HPCCTGT-%s"
resource_group_name = azurerm_resource_group.test.name
cache_name = azurerm_hpc_cache.test.name
storage_container_id = jsondecode(azurerm_resource_group_template_deployment.storage-containers.output_content).id.value
namespace_path = "/p1"
usage_model = "%s"
}
`, r.template(data), data.RandomString, modelName)
}
2 changes: 2 additions & 0 deletions internal/services/hpccache/hpc_cache_nfs_target_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,8 @@ func resourceHPCCacheNFSTarget() *pluginsdk.Resource {
ValidateFunc: validation.StringInSlice([]string{
"READ_HEAVY_INFREQ",
"READ_HEAVY_CHECK_180",
"READ_ONLY",
"READ_WRITE",
"WRITE_WORKLOAD_15",
"WRITE_AROUND",
"WRITE_WORKLOAD_CHECK_30",
Expand Down
22 changes: 18 additions & 4 deletions internal/services/hpccache/hpc_cache_nfs_target_resource_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,21 @@ func TestAccHPCCacheNFSTarget_usageModel(t *testing.T) {
},
data.ImportStep(),
{
Config: r.usageModel(data),
Config: r.usageModel(data, "READ_HEAVY_CHECK_180"),
Check: acceptance.ComposeTestCheckFunc(
check.That(data.ResourceName).ExistsInAzure(r),
),
},
data.ImportStep(),
{
Config: r.usageModel(data, "READ_WRITE"),
Check: acceptance.ComposeTestCheckFunc(
check.That(data.ResourceName).ExistsInAzure(r),
),
},
data.ImportStep(),
{
Config: r.usageModel(data, "READ_ONLY"),
Check: acceptance.ComposeTestCheckFunc(
check.That(data.ResourceName).ExistsInAzure(r),
),
Expand Down Expand Up @@ -179,7 +193,7 @@ resource "azurerm_hpc_cache_nfs_target" "test" {
`, r.cacheTemplate(data), data.RandomString)
}

func (r HPCCacheNFSTargetResource) usageModel(data acceptance.TestData) string {
func (r HPCCacheNFSTargetResource) usageModel(data acceptance.TestData, modelName string) string {
return fmt.Sprintf(`
%s
Expand All @@ -188,7 +202,7 @@ resource "azurerm_hpc_cache_nfs_target" "test" {
resource_group_name = azurerm_resource_group.test.name
cache_name = azurerm_hpc_cache.test.name
target_host_name = azurerm_linux_virtual_machine.test.private_ip_address
usage_model = "READ_HEAVY_CHECK_180"
usage_model = "%s"
namespace_junction {
namespace_path = "/nfs/a1"
nfs_export = "/export/a"
Expand All @@ -199,7 +213,7 @@ resource "azurerm_hpc_cache_nfs_target" "test" {
nfs_export = "/export/b"
}
}
`, r.cacheTemplate(data), data.RandomString)
`, r.cacheTemplate(data), data.RandomString, modelName)
}

func (r HPCCacheNFSTargetResource) namespaceJunction(data acceptance.TestData) string {
Expand Down
2 changes: 1 addition & 1 deletion website/docs/r/hpc_cache_blob_nfs_target.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ The following arguments are supported:

-> **Note:** This is the Resource Manager ID of the Storage Container, rather than the regular ID - and can be accessed on the `azurerm_storage_container` Data Source/Resource as `resource_manager_id`.

* `usage_model` - (Required) The type of usage of the HPC Cache Blob NFS Target. Possible values are: `READ_HEAVY_INFREQ`, `READ_HEAVY_CHECK_180`, `WRITE_WORKLOAD_15`, `WRITE_AROUND`, `WRITE_WORKLOAD_CHECK_30`, `WRITE_WORKLOAD_CHECK_60` and `WRITE_WORKLOAD_CLOUDWS`.
* `usage_model` - (Required) The type of usage of the HPC Cache Blob NFS Target. Possible values are: `READ_HEAVY_INFREQ`, `READ_HEAVY_CHECK_180`, `READ_ONLY`, `READ_WRITE`, `WRITE_WORKLOAD_15`, `WRITE_AROUND`, `WRITE_WORKLOAD_CHECK_30`, `WRITE_WORKLOAD_CHECK_60` and `WRITE_WORKLOAD_CLOUDWS`.

---

Expand Down
2 changes: 1 addition & 1 deletion website/docs/r/hpc_cache_nfs_target.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ The following arguments are supported:

* `target_host_name` - (Required) The IP address or fully qualified domain name (FQDN) of the HPC Cache NFS target. Changing this forces a new resource to be created.

* `usage_model` - (Required) The type of usage of the HPC Cache NFS Target. Possible values are: `READ_HEAVY_INFREQ`, `READ_HEAVY_CHECK_180`, `WRITE_WORKLOAD_15`, `WRITE_AROUND`, `WRITE_WORKLOAD_CHECK_30`, `WRITE_WORKLOAD_CHECK_60` and `WRITE_WORKLOAD_CLOUDWS`.
* `usage_model` - (Required) The type of usage of the HPC Cache NFS Target. Possible values are: `READ_HEAVY_INFREQ`, `READ_HEAVY_CHECK_180`, `READ_ONLY`, `READ_WRITE`, `WRITE_WORKLOAD_15`, `WRITE_AROUND`, `WRITE_WORKLOAD_CHECK_30`, `WRITE_WORKLOAD_CHECK_60` and `WRITE_WORKLOAD_CLOUDWS`.

* `namespace_junction` - (Required) Can be specified multiple times to define multiple `namespace_junction`. Each `namespace_juntion` block supports fields documented below.

Expand Down

0 comments on commit aa1513e

Please sign in to comment.