Skip to content

Commit

Permalink
fix TestAccDataprocVirtualCluster_basic (#9362)
Browse files Browse the repository at this point in the history
  • Loading branch information
shuyama1 authored Oct 26, 2023
1 parent 84a4be7 commit db87c12
Showing 1 changed file with 7 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -105,25 +105,23 @@ func TestAccDataprocCluster_basic(t *testing.T) {
})
}

<% if version == "ga" -%>
func TestAccDataprocVirtualCluster_basic(t *testing.T) {
t.Parallel()

var cluster dataproc.Cluster
rnd := acctest.RandString(t, 10)
pid := envvar.GetTestProjectFromEnv()
version := "3.1-dataproc-7"
networkName := acctest.BootstrapSharedTestNetwork(t, "dataproc-cluster")
subnetworkName := acctest.BootstrapSubnet(t, "dataproc-cluster", networkName)
acctest.BootstrapFirewallForDataprocSharedNetwork(t, "dataproc-cluster", networkName)
networkName := acctest.BootstrapSharedTestNetwork(t, "gke-cluster")
subnetworkName := acctest.BootstrapSubnet(t, "gke-cluster", networkName)

acctest.VcrTest(t, resource.TestCase{
PreCheck: func() { acctest.AccTestPreCheck(t) },
ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories(t),
CheckDestroy: testAccCheckDataprocClusterDestroy(t),
Steps: []resource.TestStep{
{
Config: testAccDataprocVirtualCluster_basic(pid, rnd, subnetworkName),
Config: testAccDataprocVirtualCluster_basic(pid, rnd, networkName, subnetworkName),
Check: resource.ComposeTestCheckFunc(
testAccCheckDataprocClusterExists(t, "google_dataproc_cluster.virtual_cluster", &cluster),

Expand All @@ -145,7 +143,6 @@ func TestAccDataprocVirtualCluster_basic(t *testing.T) {
},
})
}
<% end -%>

func TestAccDataprocCluster_withAccelerators(t *testing.T) {
t.Parallel()
Expand Down Expand Up @@ -1257,8 +1254,7 @@ resource "google_dataproc_cluster" "basic" {
`, rnd)
}

<% if version == "ga" -%>
func testAccDataprocVirtualCluster_basic(projectID, rnd, subnetworkName string) string {
func testAccDataprocVirtualCluster_basic(projectID, rnd, networkName, subnetworkName string) string {
return fmt.Sprintf(`
data "google_project" "project" {
project_id = "%s"
Expand All @@ -1267,11 +1263,8 @@ data "google_project" "project" {
resource "google_container_cluster" "primary" {
name = "tf-test-gke-%s"
location = "us-central1-a"
cluster_config {
gce_cluster_config {
subnetwork = "%s"
}
}
network = "%s"
subnetwork = "%s"

initial_node_count = 1

Expand Down Expand Up @@ -1320,9 +1313,8 @@ resource "google_dataproc_cluster" "virtual_cluster" {
}
}
}
`, projectID, rnd, subnetworkName, projectID, rnd, rnd, rnd, rnd, rnd, rnd)
`, projectID, rnd, networkName, subnetworkName, projectID, rnd, rnd, rnd, rnd, rnd, rnd)
}
<% end -%>

func testAccCheckDataprocGkeClusterNodePoolsHaveRoles(cluster *dataproc.Cluster, roles ...string) func(s *terraform.State) error {
return func(s *terraform.State) error {
Expand Down

0 comments on commit db87c12

Please sign in to comment.