Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update documentation and add test case for data cache setting as it is available for postgres now #9241

Merged
merged 5 commits into from
Nov 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1573,6 +1573,38 @@ func TestAccSQLDatabaseInstance_sqlMysqlDataCacheConfig(t *testing.T) {
})
}

func TestAccSQLDatabaseInstance_sqlPostgresDataCacheConfig(t *testing.T) {
nityanavali1 marked this conversation as resolved.
Show resolved Hide resolved
t.Parallel()
enterprisePlusInstanceName := "tf-test-enterprise-plus" + acctest.RandString(t, 10)
enterprisePlusTier := "db-perf-optimized-N-2"
enterpriseInstanceName := "tf-test-enterprise-" + acctest.RandString(t, 10)
enterpriseTier := "db-custom-2-13312"
acctest.VcrTest(t, resource.TestCase{
PreCheck: func() { acctest.AccTestPreCheck(t) },
ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories(t),
CheckDestroy: testAccSqlDatabaseInstanceDestroyProducer(t),
Steps: []resource.TestStep{
{
Config: testGoogleSqlDatabaseInstance_sqlPostgresDataCacheConfig(enterprisePlusInstanceName, enterprisePlusTier, "ENTERPRISE_PLUS"),
Check: resource.ComposeAggregateTestCheckFunc(
resource.TestCheckResourceAttr("google_sql_database_instance.instance", "settings.0.data_cache_config.0.data_cache_enabled", "true"),
),
},
{
ResourceName: "google_sql_database_instance.instance",
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{"deletion_protection"},
},
{
Config: testGoogleSqlDatabaseInstance_sqlPostgresDataCacheConfig(enterpriseInstanceName, enterpriseTier, "ENTERPRISE"),
ExpectError: regexp.MustCompile(
fmt.Sprintf("Error, failed to create instance %s: googleapi: Error 400: Invalid request: Only ENTERPRISE PLUS edition supports data cache.., invalid", enterpriseInstanceName)),
},
},
})
}

func TestAccSqlDatabaseInstance_SqlServerAuditConfig(t *testing.T) {
// Service Networking
acctest.SkipIfVcr(t)
Expand Down Expand Up @@ -2363,6 +2395,24 @@ resource "google_sql_database_instance" "instance" {
}`, instanceName)
}

func testGoogleSqlDatabaseInstance_sqlPostgresDataCacheConfig(instanceName, tier, edition string) string {
return fmt.Sprintf(`

resource "google_sql_database_instance" "instance" {
name = "%s"
region = "us-east1"
database_version = "POSTGRES_14"
deletion_protection = false
settings {
tier = "%s"
edition = "%s"
data_cache_config {
data_cache_enabled = true
}
}
}`, instanceName, tier, edition)
}

func testGoogleSqlDatabaseInstance_SqlServerAuditConfig(databaseName, rootPassword, bucketName, uploadInterval, retentionInterval string) string {
return fmt.Sprintf(`
resource "google_storage_bucket" "gs-bucket" {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -317,8 +317,7 @@ The optional `settings.active_directory_config` subblock supports:

The optional `settings.data_cache_config` subblock supports:

* `data_cache_enabled` - (Optional) Whether data cache is enabled for the instance. Defaults to `false`
Can only be used with MYSQL.
* `data_cache_enabled` - (Optional) Whether data cache is enabled for the instance. Defaults to `false`. Can be used with MYSQL and PostgreSQL only.

The optional `settings.deny_maintenance_period` subblock supports:

Expand Down