Skip to content

Commit

Permalink
Merge branch 'GoogleCloudPlatform:main' into add-networksecurity-urlL…
Browse files Browse the repository at this point in the history
…ists
  • Loading branch information
diogoEsteves42 authored Apr 4, 2023
2 parents 9eb6374 + 50d115d commit 77302a9
Show file tree
Hide file tree
Showing 14 changed files with 182 additions and 7 deletions.
6 changes: 2 additions & 4 deletions .ci/containers/membership-checker/membership.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,8 @@ var (
"NickElliot",
}

// This is for reviewers who are "on vacation" will not receive new review assignments but will still receive re-requests for assigned PRs.
onVacationReviewers = []string{
"zli82016",
}
// This is for reviewers who are "on vacation": will not receive new review assignments but will still receive re-requests for assigned PRs.
onVacationReviewers = []string{}
)

// Check if a user is team member to not request a random reviewer
Expand Down
5 changes: 5 additions & 0 deletions .ci/containers/membership-checker/utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@ func TestRemovesList(t *testing.T) {
Removal: []string{"a", "A", "d"},
Expected: []string{"b", "c", "B"},
},
"Remove none": {
Original: []string{"a", "b", "c", "A", "B"},
Removal: []string{},
Expected: []string{"a", "b", "c", "A", "B"},
},
"Remove all": {
Original: []string{"a", "b", "c", "A", "B"},
Removal: []string{"a", "b", "c", "A", "B"},
Expand Down
2 changes: 0 additions & 2 deletions mmv1/products/alloydb/Cluster.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,6 @@
The database engine major version. This is an output-only field and it's populated at the Cluster creation time. This field cannot be changed after cluster creation.
- !ruby/object:Api::Type::NestedObject
name: "initialUser"
immutable: true
description: |
Initial user to setup during cluster creation.
custom_flatten: "templates/terraform/custom_flatten/alloydb_cluster_input_user_flatten.go.erb"
Expand Down Expand Up @@ -145,7 +144,6 @@
description: "Labels to apply to backups created using this configuration."
- !ruby/object:Api::Type::NestedObject
name: "weeklySchedule"
immutable: true
required: true
description: "Weekly schedule for the Backup."
default_from_api: true
Expand Down
2 changes: 2 additions & 0 deletions mmv1/products/firebase/WebApp.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ autogen_async: true
skip_sweeper: true
examples:
- !ruby/object:Provider::Terraform::Examples
# TODO: https://github.com/hashicorp/terraform-provider-google/issues/14158
skip_vcr: true
name: "firebase_web_app_basic"
min_version: "beta"
primary_resource_id: "basic"
Expand Down
2 changes: 1 addition & 1 deletion mmv1/products/pubsub/Subscription.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ properties:
description: |
Specifies the "time-to-live" duration for an associated resource. The
resource expires if it is not active for a period of ttl.
If ttl is not set, the associated resource never expires.
If ttl is set to "", the associated resource never expires.
A duration in seconds with up to nine fractional digits, terminated by 's'.
Example - "3.5s".
diff_suppress_func: 'comparePubsubSubscriptionExpirationPolicy'
Expand Down
2 changes: 2 additions & 0 deletions mmv1/provider/terraform_validator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,8 @@ def copy_common_files(output_folder, generate_code, _generate_docs)
'third_party/terraform/utils/common_operation.go'],
['converters/google/resources/convert.go',
'third_party/terraform/utils/convert.go'],
['converters/google/resources/extract.go',
'third_party/terraform/utils/extract.go'],
['converters/google/resources/service_scope.go',
'third_party/terraform/utils/service_scope.go'],
['converters/google/resources/kms_utils.go',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ func GetFwTestProvider(t *testing.T) *frameworkTestProvider {
}

func TestAccFrameworkProviderMeta_setModuleName(t *testing.T) {
// TODO: https://github.com/hashicorp/terraform-provider-google/issues/14158
SkipIfVcr(t)
t.Parallel()

moduleName := "my-module"
Expand Down Expand Up @@ -128,6 +130,8 @@ func TestAccFrameworkProviderBasePath_setInvalidBasePath(t *testing.T) {
}

func TestAccFrameworkProviderBasePath_setBasePath(t *testing.T) {
// TODO: https://github.com/hashicorp/terraform-provider-google/issues/14158
SkipIfVcr(t)
t.Parallel()

VcrTest(t, resource.TestCase{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import (
)

func TestAccDataSourceDNSKeys_basic(t *testing.T) {
// TODO: https://github.com/hashicorp/terraform-provider-google/issues/14158
SkipIfVcr(t)
t.Parallel()

dnsZoneName := fmt.Sprintf("tf-test-dnskey-test-%s", RandString(t, 10))
Expand Down Expand Up @@ -59,6 +61,8 @@ func TestAccDataSourceDNSKeys_basic(t *testing.T) {
}

func TestAccDataSourceDNSKeys_noDnsSec(t *testing.T) {
// TODO: https://github.com/hashicorp/terraform-provider-google/issues/14158
SkipIfVcr(t)
t.Parallel()

dnsZoneName := fmt.Sprintf("tf-test-dnskey-test-%s", RandString(t, 10))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import (
)

func TestAccDataSourceDnsManagedZone_basic(t *testing.T) {
// TODO: https://github.com/hashicorp/terraform-provider-google/issues/14158
SkipIfVcr(t)
t.Parallel()

VcrTest(t, resource.TestCase{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import (
)

func TestAccDataSourceDnsRecordSet_basic(t *testing.T) {
// TODO: https://github.com/hashicorp/terraform-provider-google/issues/14158
SkipIfVcr(t)
t.Parallel()

var ttl1, ttl2 string // ttl is a computed string-type attribute that is easy to compare in the test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import (
)

func TestAccDataSourceGoogleFirebaseAppleAppConfig(t *testing.T) {
// TODO: https://github.com/hashicorp/terraform-provider-google/issues/14158
SkipIfVcr(t)
t.Parallel()

context := map[string]interface{}{
Expand Down
150 changes: 150 additions & 0 deletions mmv1/third_party/terraform/tests/resource_alloydb_cluster_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,3 +67,153 @@ resource "google_compute_network" "default" {
}
`, context)
}

// Test if adding automatedBackupPolicy AND initialUser re-creates the cluster.
// Ideally, cluster shouldn't be re-created. This test will only pass if the cluster
// isn't re-created but updated in-place.
func TestAccAlloydbCluster_addAutomatedBackupPolicyAndInitialUser(t *testing.T) {
t.Parallel()

context := map[string]interface{}{
"random_suffix": RandString(t, 10),
}

VcrTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
ProtoV5ProviderFactories: ProtoV5ProviderFactories(t),
CheckDestroy: testAccCheckAlloydbClusterDestroyProducer(t),
Steps: []resource.TestStep{
{
Config: testAccAlloydbCluster_withoutInitialUserAndAutomatedBackupPolicy(context),
},
{
ResourceName: "google_alloydb_cluster.default",
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{"initial_user", "cluster_id", "location"},
},
{
Config: testAccAlloydbCluster_withInitialUserAndAutomatedBackupPolicy(context),
},
{
ResourceName: "google_alloydb_cluster.default",
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{"initial_user", "cluster_id", "location"},
},
{
Config: testAccAlloydbCluster_alloydbClusterBasicExample(context),
},
},
})
}

// Test if deleting automatedBackupPolicy AND initialUser re-creates the cluster.
// Ideally, cluster shouldn't be re-created. This test will only pass if the cluster
// isn't re-created but updated in-place.
func TestAccAlloydbCluster_deleteAutomatedBackupPolicyAndInitialUser(t *testing.T) {
t.Parallel()

context := map[string]interface{}{
"random_suffix": RandString(t, 10),
}

VcrTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
ProtoV5ProviderFactories: ProtoV5ProviderFactories(t),
CheckDestroy: testAccCheckAlloydbClusterDestroyProducer(t),
Steps: []resource.TestStep{
{
Config: testAccAlloydbCluster_withInitialUserAndAutomatedBackupPolicy(context),
},
{
ResourceName: "google_alloydb_cluster.default",
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{"initial_user", "cluster_id", "location"},
},
{
Config: testAccAlloydbCluster_withoutInitialUserAndAutomatedBackupPolicy(context),
},
{
ResourceName: "google_alloydb_cluster.default",
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{"initial_user", "cluster_id", "location"},
},
{
Config: testAccAlloydbCluster_alloydbClusterBasicExample(context),
},
},
})
}

func testAccAlloydbCluster_withInitialUserAndAutomatedBackupPolicy(context map[string]interface{}) string {
return Nprintf(`
resource "google_alloydb_cluster" "default" {
cluster_id = "tf-test-alloydb-cluster%{random_suffix}"
location = "us-central1"
network = "projects/${data.google_project.project.number}/global/networks/${google_compute_network.default.name}"
initial_user {
user = "tf-test-alloydb-cluster%{random_suffix}"
password = "tf-test-alloydb-cluster%{random_suffix}"
}
automated_backup_policy {
location = "us-central1"
backup_window = "1800s"
enabled = true
weekly_schedule {
days_of_week = ["MONDAY"]
start_times {
hours = 23
minutes = 0
seconds = 0
nanos = 0
}
}
quantity_based_retention {
count = 1
}
labels = {
test = "tf-test-alloydb-cluster%{random_suffix}"
}
}
lifecycle {
prevent_destroy = true
}
}
data "google_project" "project" {
}
resource "google_compute_network" "default" {
name = "tf-test-alloydb-cluster%{random_suffix}"
}
`, context)
}

func testAccAlloydbCluster_withoutInitialUserAndAutomatedBackupPolicy(context map[string]interface{}) string {
return Nprintf(`
resource "google_alloydb_cluster" "default" {
cluster_id = "tf-test-alloydb-cluster%{random_suffix}"
location = "us-central1"
network = "projects/${data.google_project.project.number}/global/networks/${google_compute_network.default.name}"
lifecycle {
prevent_destroy = true
}
}
data "google_project" "project" {
}
resource "google_compute_network" "default" {
name = "tf-test-alloydb-cluster%{random_suffix}"
}
`, context)
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ import (
)

func TestAccFirebaseWebApp_firebaseWebAppFull(t *testing.T) {
// TODO: https://github.com/hashicorp/terraform-provider-google/issues/14158
SkipIfVcr(t)
t.Parallel()

context := map[string]interface{}{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@ func testSweepSQLDatabaseInstance(region string) error {
}

for _, d := range found.Items {
if !IsSweepableTestResource(d.Name) {
continue
}

// don't delete replicas, we'll take care of that
// when deleting the database they replicate
if d.ReplicaConfiguration != nil {
Expand Down

0 comments on commit 77302a9

Please sign in to comment.