-
Notifications
You must be signed in to change notification settings - Fork 1.7k
/
resource_dataproc_metastore_service_test.go
104 lines (90 loc) · 2.63 KB
/
resource_dataproc_metastore_service_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
package google
import (
"fmt"
"testing"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
)
func TestAccDataprocMetastoreService_updateAndImport(t *testing.T) {
t.Parallel()
name := "tf-metastore-" + randString(t, 10)
tier := [2]string{"DEVELOPER", "ENTERPRISE"}
vcrTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testAccCheckBigqueryReservationReservationDestroyProducer(t),
Steps: []resource.TestStep{
{
Config: testAccDataprocMetastoreService_updateAndImport(name, tier[0]),
},
{
ResourceName: "google_dataproc_metastore_service.my_metastore",
ImportState: true,
ImportStateVerify: true,
},
{
Config: testAccDataprocMetastoreService_updateAndImport(name, tier[1]),
},
{
ResourceName: "google_dataproc_metastore_service.my_metastore",
ImportState: true,
ImportStateVerify: true,
},
},
})
}
func testAccDataprocMetastoreService_updateAndImport(name, tier string) string {
return fmt.Sprintf(`
resource "google_dataproc_metastore_service" "my_metastore" {
service_id = "%s"
location = "us-central1"
tier = "%s"
hive_metastore_config {
version = "2.3.6"
}
}
`, name, tier)
}
func TestAccDataprocMetastoreService_PrivateServiceConnect(t *testing.T) {
t.Parallel()
context := map[string]interface{}{
"random_suffix": randString(t, 10),
}
vcrTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testAccCheckDataprocMetastoreServiceDestroyProducer(t),
Steps: []resource.TestStep{
{
Config: testAccDataprocMetastoreService_PrivateServiceConnect(context),
},
{
ResourceName: "google_dataproc_metastore_service.default",
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{"service_id", "location"},
},
},
})
}
func testAccDataprocMetastoreService_PrivateServiceConnect(context map[string]interface{}) string {
return Nprintf(`
// Use data source instead of creating a subnetwork due to a bug on API side.
// With the bug, the new created subnetwork cannot be deleted when deleting the dataproc metastore service.
data "google_compute_subnetwork" "subnet" {
name = "default"
region = "us-central1"
}
resource "google_dataproc_metastore_service" "default" {
service_id = "tf-test-metastore-srv%{random_suffix}"
location = "us-central1"
hive_metastore_config {
version = "3.1.2"
}
network_config {
consumers {
subnetwork = data.google_compute_subnetwork.subnet.id
}
}
}
`, context)
}