Skip to content

Commit

Permalink
Add test for sql database secondary zone (#6296)
Browse files Browse the repository at this point in the history
  • Loading branch information
iyabchen authored Jul 19, 2022
1 parent dd3835d commit 32aa7cf
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 18 deletions.
29 changes: 15 additions & 14 deletions mmv1/third_party/validator/sql_database_instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,20 +97,20 @@ func expandSqlDatabaseInstanceSettings(configured []interface{}, secondGen bool)
_settings := configured[0].(map[string]interface{})
settings := &sqladmin.Settings{
// Version is unset in Create but is set during update
SettingsVersion: int64(_settings["version"].(int)),
Tier: _settings["tier"].(string),
ForceSendFields: []string{"StorageAutoResize"},
ActivationPolicy: _settings["activation_policy"].(string),
AvailabilityType: _settings["availability_type"].(string),
DataDiskSizeGb: int64(_settings["disk_size"].(int)),
DataDiskType: _settings["disk_type"].(string),
PricingPlan: _settings["pricing_plan"].(string),
UserLabels: convertStringMap(_settings["user_labels"].(map[string]interface{})),
BackupConfiguration: expandBackupConfiguration(_settings["backup_configuration"].([]interface{})),
DatabaseFlags: expandDatabaseFlags(_settings["database_flags"].([]interface{})),
IpConfiguration: expandIpConfiguration(_settings["ip_configuration"].([]interface{})),
LocationPreference: expandLocationPreference(_settings["location_preference"].([]interface{})),
MaintenanceWindow: expandMaintenanceWindow(_settings["maintenance_window"].([]interface{})),
SettingsVersion: int64(_settings["version"].(int)),
Tier: _settings["tier"].(string),
ForceSendFields: []string{"StorageAutoResize"},
ActivationPolicy: _settings["activation_policy"].(string),
AvailabilityType: _settings["availability_type"].(string),
DataDiskSizeGb: int64(_settings["disk_size"].(int)),
DataDiskType: _settings["disk_type"].(string),
PricingPlan: _settings["pricing_plan"].(string),
UserLabels: convertStringMap(_settings["user_labels"].(map[string]interface{})),
BackupConfiguration: expandBackupConfiguration(_settings["backup_configuration"].([]interface{})),
DatabaseFlags: expandDatabaseFlags(_settings["database_flags"].([]interface{})),
IpConfiguration: expandIpConfiguration(_settings["ip_configuration"].([]interface{})),
LocationPreference: expandLocationPreference(_settings["location_preference"].([]interface{})),
MaintenanceWindow: expandMaintenanceWindow(_settings["maintenance_window"].([]interface{})),
}

// 1st Generation instances don't support the disk_autoresize parameter
Expand Down Expand Up @@ -173,6 +173,7 @@ func expandLocationPreference(configured []interface{}) *sqladmin.LocationPrefer
return &sqladmin.LocationPreference{
FollowGaeApplication: _locationPreference["follow_gae_application"].(string),
Zone: _locationPreference["zone"].(string),
SecondaryZone: _locationPreference["secondary_zone"].(string),
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@
},
"locationPreference": {
"followGaeApplication": "test-follow_gae_application",
"zone": "us-central1-a"
"zone": "us-central1-a",
"secondaryZone": "us-central1-b"
},
"maintenanceWindow": {
"day": 42,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ resource "google_sql_database_instance" "main" {
location_preference {
follow_gae_application = "test-follow_gae_application"
zone = "us-central1-a"
secondary_zone = "us-central1-b"
}
maintenance_window {
day = 42
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,8 @@
"location_preference": [
{
"follow_gae_application": "test-follow_gae_application",
"zone": "us-central1-a"
"zone": "us-central1-a",
"secondary_zone": "us-central1-b"
}
],
"maintenance_window": [
Expand Down Expand Up @@ -309,7 +310,8 @@
"location_preference": [
{
"follow_gae_application": "test-follow_gae_application",
"zone": "us-central1-a"
"zone": "us-central1-a",
"secondary_zone": "us-central1-b"
}
],
"maintenance_window": [
Expand Down Expand Up @@ -603,6 +605,9 @@
},
"zone": {
"constant_value": "us-central1-a"
},
"secondary_zone": {
"constant_value": "us-central1-b"
}
}
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const (
defaultOrganizationDomain = "meep.test.com"
defaultOrganizationTarget = "13579"
defaultProject = "foobar"
defaultProviderVersion = "4.20.0"
defaultProviderVersion = "4.28.0"
defaultRegion = "us-central1"
defaultServiceAccount = "[email protected]"
)
Expand Down

0 comments on commit 32aa7cf

Please sign in to comment.