Skip to content

Commit

Permalink
change the name of test case's from TestAccNutanix.. to TestAccV2Nuta…
Browse files Browse the repository at this point in the history
…nix..
  • Loading branch information
Haroon-Dweikat-Ntx committed Dec 10, 2024
1 parent 0239b1c commit 9ca7566
Show file tree
Hide file tree
Showing 53 changed files with 149 additions and 147 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (

const dataSourceNameClusters = "data.nutanix_clusters_v2.test"

func TestAccNutanixClustersV2DataSource_basic(t *testing.T) {
func TestAccV2NutanixClustersDataSource_basic(t *testing.T) {
resource.Test(t, resource.TestCase{
PreCheck: func() { acc.TestAccPreCheck(t) },
Providers: acc.TestAccProviders,
Expand All @@ -24,7 +24,7 @@ func TestAccNutanixClustersV2DataSource_basic(t *testing.T) {
})
}

func TestAccNutanixClustersV2DataSource_filter(t *testing.T) {
func TestAccV2NutanixClustersDataSource_filter(t *testing.T) {
resource.Test(t, resource.TestCase{
PreCheck: func() { acc.TestAccPreCheck(t) },
Providers: acc.TestAccProviders,
Expand All @@ -40,7 +40,7 @@ func TestAccNutanixClustersV2DataSource_filter(t *testing.T) {
})
}

func TestAccNutanixClustersV2DataSource_limit(t *testing.T) {
func TestAccV2NutanixClustersDataSource_limit(t *testing.T) {
resource.Test(t, resource.TestCase{
PreCheck: func() { acc.TestAccPreCheck(t) },
Providers: acc.TestAccProviders,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (

const dataSourceNameCluster = "data.nutanix_cluster_v2.test"

func TestAccNutanixClusterV2DataSource_basic(t *testing.T) {
func TestAccV2NutanixClusterDataSource_basic(t *testing.T) {
resource.Test(t, resource.TestCase{
PreCheck: func() { acc.TestAccPreCheck(t) },
Providers: acc.TestAccProviders,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (

const datasourceNameHostEntities = "data.nutanix_hosts_v2.test"

func TestAccNutanixHostEntitiesV2Datasource_Basic(t *testing.T) {
func TestAccV2NutanixHostEntitiesDatasource_Basic(t *testing.T) {
resource.Test(t, resource.TestCase{
PreCheck: func() { acc.TestAccPreCheck(t) },
Providers: acc.TestAccProviders,
Expand All @@ -25,7 +25,7 @@ func TestAccNutanixHostEntitiesV2Datasource_Basic(t *testing.T) {
})
}

func TestAccNutanixHostEntitiesV2Datasource_WithLimit(t *testing.T) {
func TestAccV2NutanixHostEntitiesDatasource_WithLimit(t *testing.T) {
resource.Test(t, resource.TestCase{
PreCheck: func() { acc.TestAccPreCheck(t) },
Providers: acc.TestAccProviders,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ package clustersv2

import (
"context"
"fmt"

"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
import1 "github.com/nutanix/ntnx-api-golang-clients/clustermgmt-go-client/v4/models/clustermgmt/v4/config"
Expand Down Expand Up @@ -356,7 +354,6 @@ func DatasourceNutanixHostEntityV2Read(ctx context.Context, d *schema.ResourceDa
if err != nil {
return diag.Errorf("error while fetching host entity : %v", err)
}
fmt.Println(resp)

getResp := resp.Data.GetValue().(import1.Host)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (

const datasourceNameHostEntity = "data.nutanix_host_v2.test"

func TestAccNutanixHostEntityV2Datasource_Basic(t *testing.T) {
func TestAccV2NutanixHostEntityDatasource_Basic(t *testing.T) {
resource.Test(t, resource.TestCase{
PreCheck: func() { acc.TestAccPreCheck(t) },
Providers: acc.TestAccProviders,
Expand All @@ -27,7 +27,7 @@ func TestAccNutanixHostEntityV2Datasource_Basic(t *testing.T) {
})
}

func TestAccNutanixHostEntityV2Datasource_WithNoClsExtId(t *testing.T) {
func TestAccV2NutanixHostEntityDatasource_WithNoClsExtId(t *testing.T) {
resource.Test(t, resource.TestCase{
PreCheck: func() { acc.TestAccPreCheck(t) },
Providers: acc.TestAccProviders,
Expand All @@ -40,7 +40,7 @@ func TestAccNutanixHostEntityV2Datasource_WithNoClsExtId(t *testing.T) {
})
}

func TestAccNutanixHostEntityV2Datasource_WithNoHostExtId(t *testing.T) {
func TestAccV2NutanixHostEntityDatasource_WithNoHostExtId(t *testing.T) {
resource.Test(t, resource.TestCase{
PreCheck: func() { acc.TestAccPreCheck(t) },
Providers: acc.TestAccProviders,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (

const resourceNameDiscoverUnconfiguredNodes = "nutanix_clusters_discover_unconfigured_nodes_v2.test"

func TestAccNutanixClusterDiscoverUnconfiguredNodesV2Resource_basic(t *testing.T) {
func TestAccV2NutanixClusterDiscoverUnconfiguredNodesResource_basic(t *testing.T) {
resource.Test(t, resource.TestCase{
PreCheck: func() { acc.TestAccPreCheck(t) },
Providers: acc.TestAccProviders,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const (
resourceNameClusterRegistration = "nutanix_pc_registration_v2.node-registration"
)

func TestAccNutanixClusterV2Resource_CreateClusterWithMinimumConfig(t *testing.T) {
func TestAccV2NutanixClusterResource_CreateClusterWithMinimumConfig(t *testing.T) {
r := acctest.RandInt()
name := fmt.Sprintf("tf-test-cluster-%d", r)

Expand All @@ -37,7 +37,7 @@ func TestAccNutanixClusterV2Resource_CreateClusterWithMinimumConfig(t *testing.T
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttr(resourceNameCluster, "name", name),
resource.TestCheckResourceAttr(resourceNameCluster, "dryrun", "false"),
resource.TestCheckResourceAttr(resourceNameCluster, "nodes.0.node_list.0.controller_vm_ip.0.ipv4.0.value", testVars.Clusters.CvmIP),
resource.TestCheckResourceAttr(resourceNameCluster, "nodes.0.node_list.0.controller_vm_ip.0.ipv4.0.value", testVars.Clusters.Nodes[0].CvmIp),
resource.TestCheckResourceAttr(resourceNameCluster, "nodes.0.number_of_nodes", "1"),
resource.TestCheckResourceAttr(resourceNameCluster, "config.0.cluster_arch", testVars.Clusters.Config.ClusterArch),
resource.TestCheckResourceAttr(resourceNameCluster, "config.0.fault_tolerance_state.0.domain_awareness_level", testVars.Clusters.Config.FaultToleranceState.DomainAwarenessLevel),
Expand All @@ -47,7 +47,7 @@ func TestAccNutanixClusterV2Resource_CreateClusterWithMinimumConfig(t *testing.T
})
}

func TestAccNutanixClusterV2Resource_CreateClusterWithAllConfig(t *testing.T) {
func TestAccV2NutanixClusterResource_CreateClusterWithAllConfig(t *testing.T) {
r := acctest.RandInt()
name := fmt.Sprintf("tf-test-cluster-%d", r)

Expand All @@ -67,16 +67,16 @@ func TestAccNutanixClusterV2Resource_CreateClusterWithAllConfig(t *testing.T) {
Check: resource.ComposeTestCheckFunc(
// check the unconfigured node is discovered or not
resource.TestCheckResourceAttr(resourceNameDiscoverUnConfigNode, "address_type", "IPV4"),
resource.TestCheckResourceAttr(resourceNameDiscoverUnConfigNode, "ip_filter_list.0.ipv4.0.value", testVars.Clusters.CvmIP),
resource.TestCheckResourceAttr(resourceNameDiscoverUnConfigNode, "ip_filter_list.0.ipv4.0.value", testVars.Clusters.Nodes[0].CvmIp),
resource.TestCheckResourceAttr(resourceNameDiscoverUnConfigNode, "unconfigured_nodes.#", "1"),
resource.TestCheckResourceAttr(resourceNameDiscoverUnConfigNode, "unconfigured_nodes.0.cvm_ip.0.ipv4.0.value", testVars.Clusters.CvmIP),
resource.TestCheckResourceAttr(resourceNameDiscoverUnConfigNode, "unconfigured_nodes.0.cvm_ip.0.ipv4.0.value", testVars.Clusters.Nodes[0].CvmIp),
resource.TestCheckResourceAttrSet(resourceNameDiscoverUnConfigNode, "unconfigured_nodes.0.nos_version"),
resource.TestCheckResourceAttrSet(resourceNameDiscoverUnConfigNode, "unconfigured_nodes.0.hypervisor_type"),

// check the cluster is created with minimum config
resource.TestCheckResourceAttr(resourceNameCluster, "name", name),
resource.TestCheckResourceAttr(resourceNameCluster, "dryrun", "false"),
resource.TestCheckResourceAttr(resourceNameCluster, "nodes.0.node_list.0.controller_vm_ip.0.ipv4.0.value", testVars.Clusters.CvmIP),
resource.TestCheckResourceAttr(resourceNameCluster, "nodes.0.node_list.0.controller_vm_ip.0.ipv4.0.value", testVars.Clusters.Nodes[0].CvmIp),
resource.TestCheckResourceAttr(resourceNameCluster, "nodes.0.number_of_nodes", "1"),
resource.TestCheckResourceAttr(resourceNameCluster, "config.0.cluster_arch", testVars.Clusters.Config.ClusterArch),
resource.TestCheckResourceAttr(resourceNameCluster, "config.0.fault_tolerance_state.0.domain_awareness_level", testVars.Clusters.Config.FaultToleranceState.DomainAwarenessLevel),
Expand All @@ -87,7 +87,7 @@ func TestAccNutanixClusterV2Resource_CreateClusterWithAllConfig(t *testing.T) {
resource.TestCheckResourceAttr(resourceNameCluster, "network.0.ntp_server_ip_list.3.fqdn.0.value", testVars.Clusters.Network.NTPServers[3]),

resource.TestCheckResourceAttrSet(resourceNameClusterRegistration, "pc_ext_id"),
resource.TestCheckResourceAttr(resourceNameClusterRegistration, "remote_cluster.0.aos_remote_cluster_spec.0.remote_cluster.0.address.0.ipv4.0.value", testVars.Clusters.CvmIP),
resource.TestCheckResourceAttr(resourceNameClusterRegistration, "remote_cluster.0.aos_remote_cluster_spec.0.remote_cluster.0.address.0.ipv4.0.value", testVars.Clusters.Nodes[0].CvmIp),
resource.TestCheckResourceAttr(resourceNameClusterRegistration, "remote_cluster.0.aos_remote_cluster_spec.0.remote_cluster.0.credentials.0.authentication.0.username", testVars.Clusters.Nodes[0].Username),
),
},
Expand All @@ -99,7 +99,7 @@ func TestAccNutanixClusterV2Resource_CreateClusterWithAllConfig(t *testing.T) {
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttr(resourceNameCluster, "name", name+"-updated"),
resource.TestCheckResourceAttr(resourceNameCluster, "dryrun", "false"),
resource.TestCheckResourceAttr(resourceNameCluster, "nodes.0.node_list.0.controller_vm_ip.0.ipv4.0.value", testVars.Clusters.CvmIP),
resource.TestCheckResourceAttr(resourceNameCluster, "nodes.0.node_list.0.controller_vm_ip.0.ipv4.0.value", testVars.Clusters.Nodes[0].CvmIp),
resource.TestCheckResourceAttr(resourceNameCluster, "nodes.0.number_of_nodes", "1"),
resource.TestCheckResourceAttr(resourceNameCluster, "config.0.cluster_arch", testVars.Clusters.Config.ClusterArch),
resource.TestCheckResourceAttr(resourceNameCluster, "config.0.fault_tolerance_state.0.domain_awareness_level", testVars.Clusters.Config.FaultToleranceState.DomainAwarenessLevel),
Expand Down Expand Up @@ -143,7 +143,7 @@ func testAccClusterResourceMinimumConfig(name string) string {
address_type = "IPV4"
ip_filter_list {
ipv4 {
value = local.clusters.cvm_ip
value = local.clusters.nodes[0].cvm_ip
}
}
depends_on = [data.nutanix_clusters_v2.clusters]
Expand All @@ -152,7 +152,7 @@ func testAccClusterResourceMinimumConfig(name string) string {
lifecycle {
postcondition {
condition = length(self.unconfigured_nodes) == 1
error_message = "The node ${local.clusters.cvm_ip} are not unconfigured"
error_message = "The node ${local.clusters.nodes[0].cvm_ip} are not unconfigured"
}
}
}
Expand All @@ -165,7 +165,7 @@ func testAccClusterResourceMinimumConfig(name string) string {
node_list {
controller_vm_ip {
ipv4 {
value = local.clusters.cvm_ip
value = local.clusters.nodes[0].cvm_ip
}
}
}
Expand All @@ -179,7 +179,7 @@ func testAccClusterResourceMinimumConfig(name string) string {
}
provisioner "local-exec" {
command = " sshpass -p '${local.clusters.pe_password}' ssh -o StrictHostKeyChecking=no ${local.clusters.pe_username}@${local.clusters.cvm_ip} '/home/nutanix/prism/cli/ncli user reset-password user-name=${local.clusters.nodes[0].username} password=${local.clusters.nodes[0].password}' "
command = " sshpass -p '${local.clusters.pe_password}' ssh -o StrictHostKeyChecking=no ${local.clusters.pe_username}@${local.clusters.nodes[0].cvm_ip} '/home/nutanix/prism/cli/ncli user reset-password user-name=${local.clusters.nodes[0].username} password=${local.clusters.nodes[0].password}' "
on_failure = continue
}
Expand All @@ -199,7 +199,7 @@ func testAccClusterResourceMinimumConfig(name string) string {
remote_cluster {
address {
ipv4 {
value = local.clusters.cvm_ip
value = local.clusters.nodes[0].cvm_ip
}
}
credentials {
Expand Down Expand Up @@ -227,7 +227,7 @@ func testAccClusterResourceAllConfig(name string) string {
address_type = "IPV4"
ip_filter_list {
ipv4 {
value = local.clusters.cvm_ip
value = local.clusters.nodes[0].cvm_ip
}
}
depends_on = [data.nutanix_clusters_v2.clusters]
Expand All @@ -236,7 +236,7 @@ func testAccClusterResourceAllConfig(name string) string {
lifecycle {
postcondition {
condition = length(self.unconfigured_nodes) == 1
error_message = "The node ${local.clusters.cvm_ip} are not unconfigured"
error_message = "The node ${local.clusters.nodes[0].cvm_ip} are not unconfigured"
}
}
}
Expand All @@ -249,7 +249,7 @@ func testAccClusterResourceAllConfig(name string) string {
node_list {
controller_vm_ip {
ipv4 {
value = local.clusters.cvm_ip
value = local.clusters.nodes[0].cvm_ip
}
}
}
Expand Down Expand Up @@ -294,7 +294,7 @@ func testAccClusterResourceAllConfig(name string) string {
}
provisioner "local-exec" {
command = " sshpass -p '${local.clusters.pe_password}' ssh -o StrictHostKeyChecking=no ${local.clusters.pe_username}@${local.clusters.cvm_ip} '/home/nutanix/prism/cli/ncli user reset-password user-name=${local.clusters.nodes[0].username} password=${local.clusters.nodes[0].password}' "
command = " sshpass -p '${local.clusters.pe_password}' ssh -o StrictHostKeyChecking=no ${local.clusters.pe_username}@${local.clusters.nodes[0].cvm_ip} '/home/nutanix/prism/cli/ncli user reset-password user-name=${local.clusters.nodes[0].username} password=${local.clusters.nodes[0].password}' "
on_failure = continue
}
Expand All @@ -309,7 +309,7 @@ func testAccClusterResourceAllConfig(name string) string {
remote_cluster {
address {
ipv4 {
value = local.clusters.cvm_ip
value = local.clusters.nodes[0].cvm_ip
}
}
credentials {
Expand Down Expand Up @@ -337,7 +337,7 @@ func testAccClusterResourceUpdateConfig(updatedName string) string {
address_type = "IPV4"
ip_filter_list {
ipv4 {
value = local.clusters.cvm_ip
value = local.clusters.nodes[0].cvm_ip
}
}
depends_on = [data.nutanix_clusters_v2.clusters]
Expand All @@ -346,7 +346,7 @@ func testAccClusterResourceUpdateConfig(updatedName string) string {
lifecycle {
postcondition {
condition = length(self.unconfigured_nodes) == 1
error_message = "The node ${local.clusters.cvm_ip} are not unconfigured"
error_message = "The node ${local.clusters.nodes[0].cvm_ip} are not unconfigured"
}
}
}
Expand All @@ -359,7 +359,7 @@ func testAccClusterResourceUpdateConfig(updatedName string) string {
node_list {
controller_vm_ip {
ipv4 {
value = local.clusters.cvm_ip
value = local.clusters.nodes[0].cvm_ip
}
}
}
Expand Down Expand Up @@ -424,7 +424,7 @@ func testAccClusterResourceUpdateConfig(updatedName string) string {
}
provisioner "local-exec" {
command = " sshpass -p '${local.clusters.pe_password}' ssh -o StrictHostKeyChecking=no ${local.clusters.pe_username}@${local.clusters.cvm_ip} '/home/nutanix/prism/cli/ncli user reset-password user-name=${local.clusters.nodes[0].username} password=${local.clusters.nodes[0].password}' "
command = " sshpass -p '${local.clusters.pe_password}' ssh -o StrictHostKeyChecking=no ${local.clusters.pe_username}@${local.clusters.nodes[0].cvm_ip} '/home/nutanix/prism/cli/ncli user reset-password user-name=${local.clusters.nodes[0].username} password=${local.clusters.nodes[0].password}' "
on_failure = continue
}
Expand All @@ -439,7 +439,7 @@ func testAccClusterResourceUpdateConfig(updatedName string) string {
remote_cluster {
address {
ipv4 {
value = local.clusters.cvm_ip
value = local.clusters.nodes[0].cvm_ip
}
}
credentials {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,7 @@ func flattenVMRecoveryPoints(vmRecoveryPoints []config.VmRecoveryPoint) []map[st
return nil
}

func flattenApplicationConsistentProperties(vmRecoveryProperties *config.OneOfVmRecoveryPointApplicationConsistentProperties) map[string]interface{} {
func flattenApplicationConsistentProperties(vmRecoveryProperties *config.OneOfVmRecoveryPointApplicationConsistentProperties) []map[string]interface{} {
if vmRecoveryProperties != nil {
vmRecProps := make(map[string]interface{})
if *vmRecoveryProperties.ObjectType_ == ApplicationConsistentPropertiesVss1 ||
Expand All @@ -423,7 +423,7 @@ func flattenApplicationConsistentProperties(vmRecoveryProperties *config.OneOfVm
vmRecProps["should_store_vss_metadata"] = properties.ShouldStoreVssMetadata
vmRecProps["object_type"] = properties.ObjectType_
}
return vmRecProps
return []map[string]interface{}{vmRecProps}
}
return nil
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (

const datasourceNameRecoveryPoint = "data.nutanix_recovery_point_v2.test"

func TestAccNutanixRecoveryPointV2Datasource_VmRecoveryPoints(t *testing.T) {
func TestAccV2NutanixRecoveryPointDatasource_VmRecoveryPoints(t *testing.T) {
r := acctest.RandInt()
name := fmt.Sprintf("tf-test-recovery-point-%d", r)
vmName := fmt.Sprintf("tf-test-rp-vm-%d", r)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (

const datasourceNameRecoveryPoints = "data.nutanix_recovery_points_v2.test"

func TestAccNutanixRecoveryPointsV2Datasource_Basic(t *testing.T) {
func TestAccV2NutanixRecoveryPointsDatasource_Basic(t *testing.T) {
r := acctest.RandInt()
name := fmt.Sprintf("tf-test-recovery-point-%d", r)
vmName := fmt.Sprintf("tf-test-rp-vm-%d", r)
Expand All @@ -37,7 +37,7 @@ func TestAccNutanixRecoveryPointsV2Datasource_Basic(t *testing.T) {
})
}

func TestAccNutanixRecoveryPointsV2Datasource_WithFilter(t *testing.T) {
func TestAccV2NutanixRecoveryPointsDatasource_WithFilter(t *testing.T) {
r := acctest.RandInt()
name := fmt.Sprintf("tf-test-recovery-point-%d", r)
vmName := fmt.Sprintf("tf-test-rp-vm-%d", r)
Expand Down Expand Up @@ -67,7 +67,7 @@ func TestAccNutanixRecoveryPointsV2Datasource_WithFilter(t *testing.T) {
})
}

func TestAccNutanixRecoveryPointsV2Datasource_WithLimit(t *testing.T) {
func TestAccV2NutanixRecoveryPointsDatasource_WithLimit(t *testing.T) {
r := acctest.RandInt()
name := fmt.Sprintf("tf-test-recovery-point-%d", r)
vmName := fmt.Sprintf("tf-test-rp-vm-%d", r)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,9 @@ func DatasourceNutanixVMRecoveryPointInfoV2Read(ctx context.Context, d *schema.R
if err := d.Set("vm_categories", getResp.VmCategories); err != nil {
return diag.FromErr(err)
}
if err := d.Set("application_consistent_properties", flattenApplicationConsistentProperties(getResp.ApplicationConsistentProperties)); err != nil {
return diag.FromErr(err)
}

d.SetId(*getResp.ExtId)
return nil
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (

const resourceNameRecoveryPointReplicate = "nutanix_recovery_point_replicate_v2.test"

func TestAccNutanixRecoveryPointReplicateV2Resource_basic(t *testing.T) {
func TestAccV2NutanixRecoveryPointReplicateResource_basic(t *testing.T) {
r := acctest.RandInt()
name := fmt.Sprintf("tf-test-recovery-point-%d", r)
//clsName := fmt.Sprintf("tf-test-cluster-rp-%d", r)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (

const resourceNameRecoveryPointRestore = "nutanix_recovery_point_restore_v2.test"

func TestAccNutanixRecoveryPointRestoreV2Resource_basic(t *testing.T) {
func TestAccV2NutanixRecoveryPointRestoreResource_basic(t *testing.T) {
r := acctest.RandInt()
name := fmt.Sprintf("tf-test-recovery-point-%d", r)
vmName := fmt.Sprintf("tf-test-vm-%d", r)
Expand Down
Loading

0 comments on commit 9ca7566

Please sign in to comment.