forked from hashicorp/terraform-provider-google
-
Notifications
You must be signed in to change notification settings - Fork 0
/
resource_vertex_ai_featurestore_entitytype_generated_test.go
128 lines (113 loc) · 3.45 KB
/
resource_vertex_ai_featurestore_entitytype_generated_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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
// ----------------------------------------------------------------------------
//
// *** AUTO GENERATED CODE *** Type: MMv1 ***
//
// ----------------------------------------------------------------------------
//
// This file is automatically generated by Magic Modules and manual
// changes will be clobbered when the file is regenerated.
//
// Please read more about how to change this file in
// .github/CONTRIBUTING.md.
//
// ----------------------------------------------------------------------------
package google
import (
"fmt"
"strings"
"testing"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
"github.com/hashicorp/terraform-plugin-sdk/v2/terraform"
)
func TestAccVertexAIFeaturestoreEntitytype_vertexAiFeaturestoreEntitytypeExample(t *testing.T) {
t.Parallel()
context := map[string]interface{}{
"org_id": getTestOrgFromEnv(t),
"billing_account": getTestBillingAccountFromEnv(t),
"kms_key_name": BootstrapKMSKeyInLocation(t, "us-central1").CryptoKey.Name,
"random_suffix": randString(t, 10),
}
vcrTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testAccCheckVertexAIFeaturestoreEntitytypeDestroyProducer(t),
Steps: []resource.TestStep{
{
Config: testAccVertexAIFeaturestoreEntitytype_vertexAiFeaturestoreEntitytypeExample(context),
},
{
ResourceName: "google_vertex_ai_featurestore_entitytype.entity",
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{"name", "etag", "featurestore"},
},
},
})
}
func testAccVertexAIFeaturestoreEntitytype_vertexAiFeaturestoreEntitytypeExample(context map[string]interface{}) string {
return Nprintf(`
resource "google_vertex_ai_featurestore" "featurestore" {
name = "terraform%{random_suffix}"
labels = {
foo = "bar"
}
region = "us-central1"
online_serving_config {
fixed_node_count = 2
}
encryption_spec {
kms_key_name = "%{kms_key_name}"
}
}
resource "google_vertex_ai_featurestore_entitytype" "entity" {
name = "terraform%{random_suffix}"
labels = {
foo = "bar"
}
featurestore = google_vertex_ai_featurestore.featurestore.id
monitoring_config {
snapshot_analysis {
disabled = false
monitoring_interval_days = 1
staleness_days = 21
}
numerical_threshold_config {
value = 0.8
}
categorical_threshold_config {
value = 10.0
}
import_features_analysis {
state = "ENABLED"
anomaly_detection_baseline = "PREVIOUS_IMPORT_FEATURES_STATS"
}
}
}
`, context)
}
func testAccCheckVertexAIFeaturestoreEntitytypeDestroyProducer(t *testing.T) func(s *terraform.State) error {
return func(s *terraform.State) error {
for name, rs := range s.RootModule().Resources {
if rs.Type != "google_vertex_ai_featurestore_entitytype" {
continue
}
if strings.HasPrefix(name, "data.") {
continue
}
config := googleProviderConfig(t)
url, err := replaceVarsForTest(config, rs, "{{VertexAIBasePath}}{{featurestore}}/entityTypes/{{name}}")
if err != nil {
return err
}
billingProject := ""
if config.BillingProject != "" {
billingProject = config.BillingProject
}
_, err = sendRequest(config, "GET", billingProject, url, config.userAgent, nil)
if err == nil {
return fmt.Errorf("VertexAIFeaturestoreEntitytype still exists at %s", url)
}
}
return nil
}
}