-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Chris Archibald
authored and
Chris Archibald
committed
Oct 14, 2024
1 parent
eb188d4
commit 962b55d
Showing
16 changed files
with
458 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
69 changes: 69 additions & 0 deletions
69
internal/provider/cluster/cluster_licensing_license_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,69 @@ | ||
package cluster_test | ||
|
||
import ( | ||
"fmt" | ||
"os" | ||
"regexp" | ||
"testing" | ||
|
||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" | ||
ntest "github.com/netapp/terraform-provider-netapp-ontap/internal/provider" | ||
) | ||
|
||
func TestLicensingLicenseResouceAlias(t *testing.T) { | ||
testLicense := os.Getenv("TF_ACC_NETAPP_LICENSE") | ||
name := "FCP" | ||
credName := "cluster4" | ||
resource.Test(t, resource.TestCase{ | ||
PreCheck: func() { ntest.TestAccPreCheck(t) }, | ||
ProtoV6ProviderFactories: ntest.TestAccProtoV6ProviderFactories, | ||
Steps: []resource.TestStep{ | ||
{ | ||
Config: testAccLicensingLicenseResourceConfigAlias("testme"), | ||
ExpectError: regexp.MustCompile("1115159"), | ||
}, | ||
{ | ||
Config: testAccLicensingLicenseResourceConfigAlias(testLicense), | ||
Check: resource.ComposeTestCheckFunc( | ||
resource.TestCheckResourceAttr("netapp-ontap_cluster_licensing_license.cluster_licensing_license", "name", "insight_balance")), | ||
}, | ||
// Test importing a resource | ||
{ | ||
ResourceName: "netapp-ontap_cluster_licensing_license.cluster_licensing_license", | ||
ImportState: true, | ||
ImportStateId: fmt.Sprintf("%s,%s", name, credName), | ||
Check: resource.ComposeTestCheckFunc( | ||
resource.TestCheckResourceAttr("netapp-ontap_cluster_licensing_license.cluster_licensing_license", "name", "insight_balance")), | ||
}, | ||
}, | ||
}) | ||
} | ||
|
||
func testAccLicensingLicenseResourceConfigAlias(key string) string { | ||
host := os.Getenv("TF_ACC_NETAPP_HOST") | ||
admin := os.Getenv("TF_ACC_NETAPP_USER") | ||
password := os.Getenv("TF_ACC_NETAPP_PASS") | ||
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 = "cluster4" | ||
hostname = "%s" | ||
username = "%s" | ||
password = "%s" | ||
validate_certs = false | ||
}, | ||
] | ||
} | ||
resource "netapp-ontap_cluster_licensing_license_resource" "cluster_licensing_license" { | ||
# required to know which system to interface with | ||
cx_profile_name = "cluster4" | ||
keys = ["%s"] | ||
} | ||
`, host, admin, password, key) | ||
} |
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
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
86 changes: 86 additions & 0 deletions
86
internal/provider/cluster/cluster_peer_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,86 @@ | ||
package cluster_test | ||
|
||
import ( | ||
"fmt" | ||
"os" | ||
"testing" | ||
|
||
ntest "github.com/netapp/terraform-provider-netapp-ontap/internal/provider" | ||
|
||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" | ||
) | ||
|
||
func TestAccClusterPeerResourceAlias(t *testing.T) { | ||
resource.Test(t, resource.TestCase{ | ||
PreCheck: func() { ntest.TestAccPreCheck(t) }, | ||
ProtoV6ProviderFactories: ntest.TestAccProtoV6ProviderFactories, | ||
Steps: []resource.TestStep{ | ||
// Create svm peer and read | ||
{ | ||
Config: testAccClusterPeerResourceConfigAlias("10.193.180.110", "10.193.176.189"), | ||
Check: resource.ComposeTestCheckFunc( | ||
resource.TestCheckResourceAttr("netapp-ontap_cluster_peer.example", "remote.ip_addresses.0", "10.193.180.110"), | ||
), | ||
}, | ||
// Update applications | ||
{ | ||
Config: testAccClusterPeerResourceConfigAlias("10.193.180.109", "10.193.176.189"), | ||
Check: resource.ComposeTestCheckFunc( | ||
resource.TestCheckResourceAttr("netapp-ontap_cluster_peer.example", "remote.ip_addresses.0", "10.193.180.109"), | ||
), | ||
}, | ||
// Import and read | ||
{ | ||
ResourceName: "netapp-ontap_cluster_peer.example", | ||
ImportState: true, | ||
ImportStateId: fmt.Sprintf("%s,%s", "acc_test_cluster2", "cluster4"), | ||
Check: resource.ComposeTestCheckFunc( | ||
resource.TestCheckResourceAttr("netapp-ontap_cluster_peer.example", "name", "acc_test_cluster2"), | ||
), | ||
}, | ||
}, | ||
}) | ||
} | ||
func testAccClusterPeerResourceConfigAlias(remotIP, sourceIP string) string { | ||
host := os.Getenv("TF_ACC_NETAPP_HOST2") | ||
admin := os.Getenv("TF_ACC_NETAPP_USER") | ||
password := os.Getenv("TF_ACC_NETAPP_PASS") | ||
password2 := os.Getenv("TF_ACC_NETAPP_PASS2") | ||
host2 := os.Getenv("TF_ACC_NETAPP_HOST") | ||
if host == "" || admin == "" || password == "" { | ||
fmt.Println("TF_ACC_NETAPP_HOST2, TF_ACC_NETAPP_HOST, TF_ACC_NETAPP_USER, TF_ACC_NETAPP_PASS 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 | ||
}, | ||
{ | ||
name = "cluster3" | ||
hostname = "%s" | ||
username = "%s" | ||
password = "%s" | ||
validate_certs = false | ||
}, | ||
] | ||
} | ||
resource "netapp-ontap_cluster_peers_resource" "example" { | ||
cx_profile_name = "cluster4" | ||
remote = { | ||
ip_addresses = ["%s"] | ||
} | ||
source_details = { | ||
ip_addresses = ["%s"] | ||
} | ||
peer_cx_profile_name = "cluster3" | ||
passphrase = "12345678" | ||
peer_applications = ["snapmirror"] | ||
}`, host, admin, password2, host2, admin, password, remotIP, sourceIP) | ||
} |
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
Oops, something went wrong.