Skip to content

Commit

Permalink
feat: add acceptance tests for ip_interface resource service_policy
Browse files Browse the repository at this point in the history
… parameter

Signed-off-by: Achim Christ <[email protected]>
  • Loading branch information
acch committed Nov 4, 2024
1 parent c45d88a commit 2552062
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,28 +18,30 @@ func TestAccNetworkIpInterfaceResourceAlias(t *testing.T) {
Steps: []resource.TestStep{
// non-existant SVM return code 2621462. Must happen before create/read
{
Config: testAccNetworkIPInterfaceResourceConfigAlias("non-existant", "10.10.10.10", "ontap_cluster_1-01"),
Config: testAccNetworkIPInterfaceResourceConfigAlias("non-existant", "10.10.10.10", "ontap_cluster_1-01", "default-data-files"),
ExpectError: regexp.MustCompile("2621462"),
},
// non-existant home node
{
Config: testAccNetworkIPInterfaceResourceConfigAlias("svm0", "10.10.10.10", "non-existant_home_node"),
ExpectError: regexp.MustCompile("393271"),
Config: testAccNetworkIPInterfaceResourceConfigAlias("svm0", "10.10.10.10", "non-existant_home_node", "default-data-files"),
ExpectError: regexp.MustCompile("53281680"),
},
// Create and Read
{
Config: testAccNetworkIPInterfaceResourceConfigAlias("svm0", "10.10.10.10", "ontap_cluster_1-01"),
Config: testAccNetworkIPInterfaceResourceConfigAlias("svm0", "10.10.10.10", "ontap_cluster_1-01", "default-data-files"),
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttr("netapp-ontap_networking_ip_interface_resource.example", "name", "test-interface"),
resource.TestCheckResourceAttr("netapp-ontap_networking_ip_interface_resource.example", "svm_name", "svm0"),
resource.TestCheckResourceAttr("netapp-ontap_networking_ip_interface_resource.example", "service_policy", "default-data-files"),
),
},
// Update and Read
{
Config: testAccNetworkIPInterfaceResourceConfigAlias("svm0", "10.10.10.20", "ontap_cluster_1-01"),
Config: testAccNetworkIPInterfaceResourceConfigAlias("svm0", "10.10.10.20", "ontap_cluster_1-01", "default-data-iscsi"),
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttr("netapp-ontap_networking_ip_interface_resource.example", "name", "test-interface"),
resource.TestCheckResourceAttr("netapp-ontap_networking_ip_interface_resource.example", "ip.address", "10.10.10.20"),
resource.TestCheckResourceAttr("netapp-ontap_networking_ip_interface_resource.example", "service_policy", "default-data-iscsi"),
),
},
// Test importing a resource
Expand All @@ -56,7 +58,7 @@ func TestAccNetworkIpInterfaceResourceAlias(t *testing.T) {
})
}

func testAccNetworkIPInterfaceResourceConfigAlias(svmName, address, homeNode string) string {
func testAccNetworkIPInterfaceResourceConfigAlias(svmName, address, homeNode, servicePolicy string) string {
host := os.Getenv("TF_ACC_NETAPP_HOST")
admin := os.Getenv("TF_ACC_NETAPP_USER")
password := os.Getenv("TF_ACC_NETAPP_PASS")
Expand Down Expand Up @@ -89,6 +91,7 @@ resource "netapp-ontap_networking_ip_interface_resource" "example" {
home_port = "e0d"
home_node = "%s"
}
service_policy = "%s"
}
`, host, admin, password, svmName, address, homeNode)
`, host, admin, password, svmName, address, homeNode, servicePolicy)
}
17 changes: 10 additions & 7 deletions internal/provider/networking/network_ip_interface_resource_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,28 +18,30 @@ func TestAccNetworkIpInterfaceResource(t *testing.T) {
Steps: []resource.TestStep{
// non-existant SVM return code 2621462. Must happen before create/read
{
Config: testAccNetworkIPInterfaceResourceConfig("non-existant", "10.10.10.10", "ontap_cluster_1-01"),
Config: testAccNetworkIPInterfaceResourceConfig("non-existant", "10.10.10.10", "ontap_cluster_1-01", "default-data-files"),
ExpectError: regexp.MustCompile("2621462"),
},
// non-existant home node
{
Config: testAccNetworkIPInterfaceResourceConfig("svm0", "10.10.10.10", "non-existant_home_node"),
ExpectError: regexp.MustCompile("393271"),
Config: testAccNetworkIPInterfaceResourceConfig("svm0", "10.10.10.10", "non-existant_home_node", "default-data-files"),
ExpectError: regexp.MustCompile("53281680"),
},
// Create and Read
{
Config: testAccNetworkIPInterfaceResourceConfig("svm0", "10.10.10.10", "ontap_cluster_1-01"),
Config: testAccNetworkIPInterfaceResourceConfig("svm0", "10.10.10.10", "ontap_cluster_1-01", "default-data-files"),
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttr("netapp-ontap_network_ip_interface.example", "name", "test-interface"),
resource.TestCheckResourceAttr("netapp-ontap_network_ip_interface.example", "svm_name", "svm0"),
resource.TestCheckResourceAttr("netapp-ontap_network_ip_interface.example", "service_policy", "default-data-files"),
),
},
// Update and Read
{
Config: testAccNetworkIPInterfaceResourceConfig("svm0", "10.10.10.20", "ontap_cluster_1-01"),
Config: testAccNetworkIPInterfaceResourceConfig("svm0", "10.10.10.20", "ontap_cluster_1-01", "default-data-iscsi"),
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttr("netapp-ontap_network_ip_interface.example", "name", "test-interface"),
resource.TestCheckResourceAttr("netapp-ontap_network_ip_interface.example", "ip.address", "10.10.10.20"),
resource.TestCheckResourceAttr("netapp-ontap_network_ip_interface.example", "service_policy", "default-data-iscsi"),
),
},
// Test importing a resource
Expand All @@ -56,7 +58,7 @@ func TestAccNetworkIpInterfaceResource(t *testing.T) {
})
}

func testAccNetworkIPInterfaceResourceConfig(svmName, address, homeNode string) string {
func testAccNetworkIPInterfaceResourceConfig(svmName, address, homeNode, servicePolicy string) string {
host := os.Getenv("TF_ACC_NETAPP_HOST")
admin := os.Getenv("TF_ACC_NETAPP_USER")
password := os.Getenv("TF_ACC_NETAPP_PASS")
Expand Down Expand Up @@ -89,6 +91,7 @@ resource "netapp-ontap_network_ip_interface" "example" {
home_port = "e0d"
home_node = "%s"
}
service_policy = "%s"
}
`, host, admin, password, svmName, address, homeNode)
`, host, admin, password, svmName, address, homeNode, servicePolicy)
}

0 comments on commit 2552062

Please sign in to comment.