Skip to content

Commit

Permalink
Merge pull request #345 from NetApp/335-docs-typo-on-the-documents
Browse files Browse the repository at this point in the history
fix acc tests
  • Loading branch information
suhasbshekar authored Dec 6, 2024
2 parents 1335e25 + dd5728a commit 6f16570
Show file tree
Hide file tree
Showing 22 changed files with 696 additions and 695 deletions.
22 changes: 11 additions & 11 deletions internal/provider/cluster/cluster_schedule_resource_alias_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ func TestAccClusterScheduleResourceAlias(t *testing.T) {
},
// Create interval and read
{
Config: testAccClusterScheduleResourceIntervalConfigAlias("tf-interval-schedule-test", "PT8M30S"),
Config: testAccClusterScheduleResourceIntervalConfigAlias("tf-interval-schedule-test2", "PT8M30S"),
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttr("netapp-ontap_cluster_schedule_resource.example", "name", "tf-interval-schedule-test"),
resource.TestCheckResourceAttr("netapp-ontap_cluster_schedule_resource.example", "name", "tf-interval-schedule-test2"),
resource.TestCheckResourceAttr("netapp-ontap_cluster_schedule_resource.example", "interval", "PT8M30S"),
),
},
Expand Down Expand Up @@ -77,11 +77,11 @@ func TestAccClusterScheduleResourceAlias(t *testing.T) {
}

func testAccClusterScheduleResourceIntervalConfigAlias(name string, interval string) string {
host := os.Getenv("TF_ACC_NETAPP_HOST")
host := os.Getenv("TF_ACC_NETAPP_HOST5")
admin := os.Getenv("TF_ACC_NETAPP_USER")
password := os.Getenv("TF_ACC_NETAPP_PASS")
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")
fmt.Println("TF_ACC_NETAPP_HOST5, TF_ACC_NETAPP_USER, and TF_ACC_NETAPP_PASS2 must be set for acceptance tests")
os.Exit(1)
}
return fmt.Sprintf(`
Expand All @@ -106,11 +106,11 @@ resource "netapp-ontap_cluster_schedule_resource" "example" {
}

func testAccClusterScheduleCreateResourceCronConfigAlias(name string) string {
host := os.Getenv("TF_ACC_NETAPP_HOST")
host := os.Getenv("TF_ACC_NETAPP_HOST5")
admin := os.Getenv("TF_ACC_NETAPP_USER")
password := os.Getenv("TF_ACC_NETAPP_PASS")
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")
fmt.Println("TF_ACC_NETAPP_HOST5, TF_ACC_NETAPP_USER, and TF_ACC_NETAPP_PASS2 must be set for acceptance tests")
os.Exit(1)
}
return fmt.Sprintf(`
Expand Down Expand Up @@ -141,11 +141,11 @@ resource "netapp-ontap_cluster_schedule_resource" "cron-example" {
}

func testAccClusterScheduleUpdateResourceCronConfigAlias(name string) string {
host := os.Getenv("TF_ACC_NETAPP_HOST")
host := os.Getenv("TF_ACC_NETAPP_HOST5")
admin := os.Getenv("TF_ACC_NETAPP_USER")
password := os.Getenv("TF_ACC_NETAPP_PASS")
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")
fmt.Println("TF_ACC_NETAPP_HOST5, TF_ACC_NETAPP_USER, and TF_ACC_NETAPP_PASS2 must be set for acceptance tests")
os.Exit(1)
}
return fmt.Sprintf(`
Expand Down
25 changes: 13 additions & 12 deletions internal/provider/cluster/cluster_schedule_resource_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@ package cluster_test

import (
"fmt"
ntest "github.com/netapp/terraform-provider-netapp-ontap/internal/provider"
"os"
"regexp"
"testing"

ntest "github.com/netapp/terraform-provider-netapp-ontap/internal/provider"

"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
)

Expand All @@ -22,9 +23,9 @@ func TestAccClusterScheduleResource(t *testing.T) {
},
// Create interval and read
{
Config: testAccClusterScheduleResourceIntervalConfig("tf-interval-schedule-test", "PT8M30S"),
Config: testAccClusterScheduleResourceIntervalConfig("tf-interval-schedule-test2", "PT8M30S"),
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttr("netapp-ontap_cluster_schedule.example", "name", "tf-interval-schedule-test"),
resource.TestCheckResourceAttr("netapp-ontap_cluster_schedule.example", "name", "tf-interval-schedule-test2"),
resource.TestCheckResourceAttr("netapp-ontap_cluster_schedule.example", "interval", "PT8M30S"),
),
},
Expand Down Expand Up @@ -76,11 +77,11 @@ func TestAccClusterScheduleResource(t *testing.T) {
}

func testAccClusterScheduleResourceIntervalConfig(name string, interval string) string {
host := os.Getenv("TF_ACC_NETAPP_HOST")
host := os.Getenv("TF_ACC_NETAPP_HOST5")
admin := os.Getenv("TF_ACC_NETAPP_USER")
password := os.Getenv("TF_ACC_NETAPP_PASS")
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")
fmt.Println("TF_ACC_NETAPP_HOST5, TF_ACC_NETAPP_USER, and TF_ACC_NETAPP_PASS2 must be set for acceptance tests")
os.Exit(1)
}
return fmt.Sprintf(`
Expand All @@ -105,11 +106,11 @@ resource "netapp-ontap_cluster_schedule" "example" {
}

func testAccClusterScheduleCreateResourceCronConfig(name string) string {
host := os.Getenv("TF_ACC_NETAPP_HOST")
host := os.Getenv("TF_ACC_NETAPP_HOST5")
admin := os.Getenv("TF_ACC_NETAPP_USER")
password := os.Getenv("TF_ACC_NETAPP_PASS")
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")
fmt.Println("TF_ACC_NETAPP_HOST5, TF_ACC_NETAPP_USER, and TF_ACC_NETAPP_PASS2 must be set for acceptance tests")
os.Exit(1)
}
return fmt.Sprintf(`
Expand Down Expand Up @@ -140,11 +141,11 @@ resource "netapp-ontap_cluster_schedule" "cron-example" {
}

func testAccClusterScheduleUpdateResourceCronConfig(name string) string {
host := os.Getenv("TF_ACC_NETAPP_HOST")
host := os.Getenv("TF_ACC_NETAPP_HOST5")
admin := os.Getenv("TF_ACC_NETAPP_USER")
password := os.Getenv("TF_ACC_NETAPP_PASS")
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")
fmt.Println("TF_ACC_NETAPP_HOST5, TF_ACC_NETAPP_USER, and TF_ACC_NETAPP_PASS2 must be set for acceptance tests")
os.Exit(1)
}
return fmt.Sprintf(`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
)

func TestAccNameServicesDNSResourceAlias(t *testing.T) {
svmName := "ansibleSVM"
svmName := "terraform"
credName := "cluster4"
resource.Test(t, resource.TestCase{
PreCheck: func() { ntest.TestAccPreCheck(t) },
Expand All @@ -23,9 +23,9 @@ func TestAccNameServicesDNSResourceAlias(t *testing.T) {
ExpectError: regexp.MustCompile("2621462"),
},
{
Config: testAccNameServicesDNSResourceConfigAlias("svm5"),
Config: testAccNameServicesDNSResourceConfigAlias("terraform"),
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttr("netapp-ontap_name_services_dns_resource.dns", "svm_name", "svm5"),
resource.TestCheckResourceAttr("netapp-ontap_name_services_dns_resource.dns", "svm_name", "terraform"),
),
},
// Test importing a resource
Expand All @@ -34,7 +34,7 @@ func TestAccNameServicesDNSResourceAlias(t *testing.T) {
ImportState: true,
ImportStateId: fmt.Sprintf("%s,%s", svmName, credName),
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttr("netapp-ontap_name_services_dns_resource.dns", "svm_name", "ansibleSVM"),
resource.TestCheckResourceAttr("netapp-ontap_name_services_dns_resource.dns", "svm_name", "terraform"),
resource.TestCheckResourceAttr("netapp-ontap_name_services_dns_resource.dns", "name_servers.0", "netappad.com"),
),
},
Expand All @@ -43,11 +43,11 @@ func TestAccNameServicesDNSResourceAlias(t *testing.T) {
}

func testAccNameServicesDNSResourceConfigAlias(svmName string) string {
host := os.Getenv("TF_ACC_NETAPP_HOST")
host := os.Getenv("TF_ACC_NETAPP_HOST5")
admin := os.Getenv("TF_ACC_NETAPP_USER")
password := os.Getenv("TF_ACC_NETAPP_PASS")
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")
fmt.Println("TF_ACC_NETAPP_HOST5, TF_ACC_NETAPP_USER, and TF_ACC_NETAPP_PASS2 must be set for acceptance tests")
os.Exit(1)
}
return fmt.Sprintf(`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
)

func TestAccNameServicesDNSResource(t *testing.T) {
svmName := "ansibleSVM"
svmName := "terraform"
credName := "cluster4"
resource.Test(t, resource.TestCase{
PreCheck: func() { ntest.TestAccPreCheck(t) },
Expand All @@ -23,9 +23,9 @@ func TestAccNameServicesDNSResource(t *testing.T) {
ExpectError: regexp.MustCompile("2621462"),
},
{
Config: testAccNameServicesDNSResourceConfig("svm5"),
Config: testAccNameServicesDNSResourceConfig("terraform"),
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttr("netapp-ontap_dns.dns", "svm_name", "svm5"),
resource.TestCheckResourceAttr("netapp-ontap_dns.dns", "svm_name", "terraform"),
),
},
// Test importing a resource
Expand All @@ -34,7 +34,7 @@ func TestAccNameServicesDNSResource(t *testing.T) {
ImportState: true,
ImportStateId: fmt.Sprintf("%s,%s", svmName, credName),
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttr("netapp-ontap_dns.dns", "svm_name", "ansibleSVM"),
resource.TestCheckResourceAttr("netapp-ontap_dns.dns", "svm_name", "terraform"),
resource.TestCheckResourceAttr("netapp-ontap_dns.dns", "name_servers.0", "netappad.com"),
),
},
Expand All @@ -43,11 +43,11 @@ func TestAccNameServicesDNSResource(t *testing.T) {
}

func testAccNameServicesDNSResourceConfig(svmName string) string {
host := os.Getenv("TF_ACC_NETAPP_HOST")
host := os.Getenv("TF_ACC_NETAPP_HOST5")
admin := os.Getenv("TF_ACC_NETAPP_USER")
password := os.Getenv("TF_ACC_NETAPP_PASS")
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")
fmt.Println("TF_ACC_NETAPP_HOST5, TF_ACC_NETAPP_USER, and TF_ACC_NETAPP_PASS2 must be set for acceptance tests")
os.Exit(1)
}
return fmt.Sprintf(`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
)

func TestAccNameServicesLDAPResourceAlias(t *testing.T) {
svmName := "accsvm"
svmName := "terraform"
credName := "cluster4"
resource.Test(t, resource.TestCase{
PreCheck: func() { ntest.TestAccPreCheck(t) },
Expand All @@ -25,17 +25,17 @@ func TestAccNameServicesLDAPResourceAlias(t *testing.T) {
},
// Test create
{
Config: testAccNameServicesLDAPResourceConfigAlias("svm1", "subtree"),
Config: testAccNameServicesLDAPResourceConfigAlias("terraform", "subtree"),
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttr("netapp-ontap_name_services_ldap_resource.name_services_ldap", "svm_name", "svm1"),
resource.TestCheckResourceAttr("netapp-ontap_name_services_ldap_resource.name_services_ldap", "svm_name", "terraform"),
resource.TestCheckResourceAttr("netapp-ontap_name_services_ldap_resource.name_services_ldap", "servers.0", "1.1.1.1"),
),
},
// Test update
{
Config: testAccNameServicesLDAPResourceConfigAlias("svm1", "base"),
Config: testAccNameServicesLDAPResourceConfigAlias("terraform", "base"),
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttr("netapp-ontap_name_services_ldap_resource.name_services_ldap", "svm_name", "svm1"),
resource.TestCheckResourceAttr("netapp-ontap_name_services_ldap_resource.name_services_ldap", "svm_name", "terraform"),
resource.TestCheckResourceAttr("netapp-ontap_name_services_ldap_resource.name_services_ldap", "base_scope", "base"),
),
},
Expand All @@ -54,11 +54,11 @@ func TestAccNameServicesLDAPResourceAlias(t *testing.T) {
}

func testAccNameServicesLDAPResourceConfigAlias(svmName string, baseScope string) string {
host := os.Getenv("TF_ACC_NETAPP_HOST")
host := os.Getenv("TF_ACC_NETAPP_HOST5")
admin := os.Getenv("TF_ACC_NETAPP_USER")
password := os.Getenv("TF_ACC_NETAPP_PASS")
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")
fmt.Println("TF_ACC_NETAPP_HOST5, TF_ACC_NETAPP_USER, and TF_ACC_NETAPP_PASS2 must be set for acceptance tests")
os.Exit(1)
}
return fmt.Sprintf(`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
)

func TestAccNameServicesLDAPResource(t *testing.T) {
svmName := "accsvm"
svmName := "terraform"
credName := "cluster4"
resource.Test(t, resource.TestCase{
PreCheck: func() { ntest.TestAccPreCheck(t) },
Expand All @@ -25,17 +25,17 @@ func TestAccNameServicesLDAPResource(t *testing.T) {
},
// Test create
{
Config: testAccNameServicesLDAPResourceConfig("svm1", "subtree"),
Config: testAccNameServicesLDAPResourceConfig("terraform", "subtree"),
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttr("netapp-ontap_name_services_ldap.name_services_ldap", "svm_name", "svm1"),
resource.TestCheckResourceAttr("netapp-ontap_name_services_ldap.name_services_ldap", "svm_name", "terraform"),
resource.TestCheckResourceAttr("netapp-ontap_name_services_ldap.name_services_ldap", "servers.0", "1.1.1.1"),
),
},
// Test update
{
Config: testAccNameServicesLDAPResourceConfig("svm1", "base"),
Config: testAccNameServicesLDAPResourceConfig("terraform", "base"),
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttr("netapp-ontap_name_services_ldap.name_services_ldap", "svm_name", "svm1"),
resource.TestCheckResourceAttr("netapp-ontap_name_services_ldap.name_services_ldap", "svm_name", "terraform"),
resource.TestCheckResourceAttr("netapp-ontap_name_services_ldap.name_services_ldap", "base_scope", "base"),
),
},
Expand All @@ -54,11 +54,11 @@ func TestAccNameServicesLDAPResource(t *testing.T) {
}

func testAccNameServicesLDAPResourceConfig(svmName string, baseScope string) string {
host := os.Getenv("TF_ACC_NETAPP_HOST")
host := os.Getenv("TF_ACC_NETAPP_HOST5")
admin := os.Getenv("TF_ACC_NETAPP_USER")
password := os.Getenv("TF_ACC_NETAPP_PASS")
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")
fmt.Println("TF_ACC_NETAPP_HOST5, TF_ACC_NETAPP_USER, and TF_ACC_NETAPP_PASS2 must be set for acceptance tests")
os.Exit(1)
}
return fmt.Sprintf(`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,45 +23,45 @@ func TestAccNetworkIpInterfaceResourceAlias(t *testing.T) {
},
// non-existant home node
{
Config: testAccNetworkIPInterfaceResourceConfigAlias("svm0", "10.10.10.10", "non-existant_home_node"),
Config: testAccNetworkIPInterfaceResourceConfigAlias("terraform", "10.10.10.10", "non-existant_home_node"),
ExpectError: regexp.MustCompile("393271"),
},
// Create and Read
{
Config: testAccNetworkIPInterfaceResourceConfigAlias("svm0", "10.10.10.10", "ontap_cluster_1-01"),
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"),
),
},
// Update and Read
{
Config: testAccNetworkIPInterfaceResourceConfigAlias("svm0", "10.10.10.20", "ontap_cluster_1-01"),
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"),
),
},
// {
// Config: testAccNetworkIPInterfaceResourceConfigAlias("terraform", "10.10.10.10", "ontap_cluster_1-01"),
// 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", "terraform"),
// ),
// },
// // Update and Read
// {
// Config: testAccNetworkIPInterfaceResourceConfigAlias("terraform", "10.10.10.20", "ontap_cluster_1-01"),
// 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"),
// ),
// },
// Test importing a resource
{
ResourceName: "netapp-ontap_networking_ip_interface_resource.example",
ImportState: true,
ImportStateId: fmt.Sprintf("%s,%s,%s", "test-interface", "svm0", "cluster4"),
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"),
),
},
// {
// ResourceName: "netapp-ontap_networking_ip_interface_resource.example",
// ImportState: true,
// ImportStateId: fmt.Sprintf("%s,%s,%s", "acc_test", "terraform", "cluster4"),
// Check: resource.ComposeTestCheckFunc(
// resource.TestCheckResourceAttr("netapp-ontap_networking_ip_interface_resource.example", "name", "acc_test"),
// resource.TestCheckResourceAttr("netapp-ontap_networking_ip_interface_resource.example", "ip.address", "10.193.180.56"),
// ),
// },
},
})
}

func testAccNetworkIPInterfaceResourceConfigAlias(svmName, address, homeNode string) string {
host := os.Getenv("TF_ACC_NETAPP_HOST")
host := os.Getenv("TF_ACC_NETAPP_HOST5")
admin := os.Getenv("TF_ACC_NETAPP_USER")
password := os.Getenv("TF_ACC_NETAPP_PASS")
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")
fmt.Println("TF_ACC_NETAPP_HOST5, TF_ACC_NETAPP_USER, and TF_ACC_NETAPP_PASS2 must be set for acceptance tests")
os.Exit(1)
}
return fmt.Sprintf(`
Expand Down
Loading

0 comments on commit 6f16570

Please sign in to comment.