-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #326 from NetApp/old-name-storage
add support for old name for storage
- Loading branch information
Showing
25 changed files
with
931 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
70 changes: 70 additions & 0 deletions
70
internal/provider/storage/storage_aggregate_resource_alias_test.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
package storage_test | ||
|
||
import ( | ||
"fmt" | ||
"os" | ||
"regexp" | ||
"testing" | ||
|
||
ntest "github.com/netapp/terraform-provider-netapp-ontap/internal/provider" | ||
|
||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" | ||
) | ||
|
||
func TestAccStorageAggregateResourceAlias(t *testing.T) { | ||
resource.Test(t, resource.TestCase{ | ||
PreCheck: func() { ntest.TestAccPreCheck(t) }, | ||
ProtoV6ProviderFactories: ntest.TestAccProtoV6ProviderFactories, | ||
Steps: []resource.TestStep{ | ||
{ | ||
Config: testAccStorageAggregateResourceConfigAlias("non-existant"), | ||
ExpectError: regexp.MustCompile("is an invalid value"), | ||
}, | ||
{ | ||
Config: testAccStorageAggregateResourceConfigAlias("swenjun-vsim2"), | ||
Check: resource.ComposeTestCheckFunc( | ||
resource.TestCheckResourceAttr("netapp-ontap_storage_aggregate_resource.example", "name", "acc_test_aggr"), | ||
resource.TestCheckNoResourceAttr("netapp-ontap_storage_aggregate_resource.example", "vol"), | ||
), | ||
}, | ||
// Test importing a resource | ||
{ | ||
ResourceName: "netapp-ontap_storage_aggregate_resource.example", | ||
ImportState: true, | ||
ImportStateId: fmt.Sprintf("%s,%s", "acc_test_aggr", "cluster4"), | ||
Check: resource.ComposeTestCheckFunc( | ||
resource.TestCheckResourceAttr("netapp-ontap_storage_aggregate_resource.example", "name", "acc_test_aggr"), | ||
), | ||
}, | ||
}, | ||
}) | ||
} | ||
|
||
func testAccStorageAggregateResourceConfigAlias(node string) string { | ||
host := os.Getenv("TF_ACC_NETAPP_HOST2") | ||
admin := os.Getenv("TF_ACC_NETAPP_USER") | ||
password := os.Getenv("TF_ACC_NETAPP_PASS2") | ||
if host == "" || admin == "" || password == "" { | ||
fmt.Println("TF_ACC_NETAPP_HOST2, TF_ACC_NETAPP_USER, and TF_ACC_NETAPP_PASS2 must be set for acceptance tests") | ||
os.Exit(1) | ||
} | ||
return fmt.Sprintf(` | ||
provider "netapp-ontap" { | ||
connection_profiles = [ | ||
{ | ||
name = "cluster4" | ||
hostname = "%s" | ||
username = "%s" | ||
password = "%s" | ||
validate_certs = false | ||
}, | ||
] | ||
} | ||
resource "netapp-ontap_storage_aggregate_resource" "example" { | ||
cx_profile_name = "cluster4" | ||
node = "%s" | ||
name = "acc_test_aggr" | ||
disk_count = 5 | ||
}`, host, admin, password, node) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
159 changes: 159 additions & 0 deletions
159
internal/provider/storage/storage_flexcache_resource_alias_test.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,159 @@ | ||
package storage_test | ||
|
||
import ( | ||
"fmt" | ||
"os" | ||
"regexp" | ||
"testing" | ||
|
||
ntest "github.com/netapp/terraform-provider-netapp-ontap/internal/provider" | ||
|
||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" | ||
) | ||
|
||
func TestAccStorageFlexcacheResourceAlias(t *testing.T) { | ||
resource.Test(t, resource.TestCase{ | ||
PreCheck: func() { ntest.TestAccPreCheck(t) }, | ||
ProtoV6ProviderFactories: ntest.TestAccProtoV6ProviderFactories, | ||
Steps: []resource.TestStep{ | ||
// Test non existant SVM | ||
{ | ||
Config: testAccStorageFlexcacheResourceConfigAlias("non-existant", "terraformTest4"), | ||
ExpectError: regexp.MustCompile("2621462"), | ||
}, | ||
// test bad volume name | ||
{ | ||
Config: testAccStorageFlexcacheResourceConfigAlias("non-existant", "name-cant-have-dashes"), | ||
ExpectError: regexp.MustCompile("917888"), | ||
}, | ||
// Test create the resource | ||
{ | ||
Config: testAccStorageFlexcacheResourceConfigAlias("acc_test", "accFlexcache"), | ||
Check: resource.ComposeTestCheckFunc( | ||
resource.TestCheckResourceAttr("netapp-ontap_storage_flexcache_resource.example", "name", "accFlexcache"), | ||
resource.TestCheckNoResourceAttr("netapp-ontap_storage_flexcache_resource.example", "volname"), | ||
), | ||
}, | ||
// Test create the resource with junction path | ||
{ | ||
Config: testAccStorageFlexcacheResourcePathConfigAlias("acc_test", "accFlexcacheJP", "/accFlexcachejp"), | ||
Check: resource.ComposeTestCheckFunc( | ||
resource.TestCheckResourceAttr("netapp-ontap_storage_flexcache_resource.jpexample", "name", "accFlexcacheJP"), | ||
resource.TestCheckResourceAttr("netapp-ontap_storage_flexcache_resource.jpexample", "junction_path", "/accFlexcachejp"), | ||
), | ||
}, | ||
// Test importing a resource | ||
{ | ||
ResourceName: "netapp-ontap_storage_flexcache_resource.jpexample", | ||
ImportState: true, | ||
ImportStateId: fmt.Sprintf("%s,%s,%s", "accFlexcacheJP", "acc_test", "cluster5"), | ||
Check: resource.ComposeTestCheckFunc( | ||
resource.TestCheckResourceAttr("netapp-ontap_storage_flexcache_resource.jpexample", "name", "accFlexcache"), | ||
), | ||
}, | ||
}, | ||
}) | ||
} | ||
|
||
func testAccStorageFlexcacheResourceConfigAlias(svm, volName string) string { | ||
host := os.Getenv("TF_ACC_NETAPP_HOST2") | ||
admin := os.Getenv("TF_ACC_NETAPP_USER") | ||
password := os.Getenv("TF_ACC_NETAPP_PASS2") | ||
|
||
if host == "" || admin == "" || password == "" { | ||
fmt.Println("TF_ACC_NETAPP_HOST, TF_ACC_NETAPP_USER, and TF_ACC_NETAPP_PASS must be set for acceptance tests") | ||
os.Exit(1) | ||
} | ||
return fmt.Sprintf(` | ||
provider "netapp-ontap" { | ||
connection_profiles = [ | ||
{ | ||
name = "cluster5" | ||
hostname = "%s" | ||
username = "%s" | ||
password = "%s" | ||
validate_certs = false | ||
}, | ||
] | ||
} | ||
resource "netapp-ontap_storage_flexcache_resource" "example" { | ||
cx_profile_name = "cluster5" | ||
name = "%s" | ||
svm_name = "%s" | ||
origins = [ | ||
{ | ||
volume = { | ||
name = "acc_test_storage_flexcache_origin_volume" | ||
}, | ||
svm = { | ||
name = "acc_test" | ||
} | ||
} | ||
] | ||
size = 200 | ||
size_unit = "mb" | ||
guarantee = { | ||
type = "none" | ||
} | ||
dr_cache = false | ||
global_file_locking_enabled = false | ||
aggregates = [ | ||
{ | ||
name = "acc_test" | ||
} | ||
] | ||
}`, host, admin, password, volName, svm) | ||
} | ||
|
||
func testAccStorageFlexcacheResourcePathConfigAlias(svm, volName string, junctionPath string) string { | ||
host := os.Getenv("TF_ACC_NETAPP_HOST2") | ||
admin := os.Getenv("TF_ACC_NETAPP_USER") | ||
password := os.Getenv("TF_ACC_NETAPP_PASS2") | ||
|
||
if host == "" || admin == "" || password == "" { | ||
fmt.Println("TF_ACC_NETAPP_HOST, TF_ACC_NETAPP_USER, and TF_ACC_NETAPP_PASS must be set for acceptance tests") | ||
os.Exit(1) | ||
} | ||
return fmt.Sprintf(` | ||
provider "netapp-ontap" { | ||
connection_profiles = [ | ||
{ | ||
name = "cluster5" | ||
hostname = "%s" | ||
username = "%s" | ||
password = "%s" | ||
validate_certs = false | ||
}, | ||
] | ||
} | ||
resource "netapp-ontap_storage_flexcache_resource" "jpexample" { | ||
cx_profile_name = "cluster5" | ||
name = "%s" | ||
svm_name = "%s" | ||
origins = [ | ||
{ | ||
volume = { | ||
name = "acc_test_storage_flexcache_origin_volume" | ||
}, | ||
svm = { | ||
name = "acc_test" | ||
} | ||
} | ||
] | ||
size = 200 | ||
size_unit = "mb" | ||
guarantee = { | ||
type = "none" | ||
} | ||
dr_cache = false | ||
junction_path = "%s" | ||
global_file_locking_enabled = false | ||
aggregates = [ | ||
{ | ||
name = "acc_test" | ||
} | ||
] | ||
}`, host, admin, password, volName, svm, junctionPath) | ||
} |
Oops, something went wrong.