From ab3b1dfcf33a0341a6601612e860673d547acf1e Mon Sep 17 00:00:00 2001 From: ezilber-akamai Date: Thu, 15 May 2025 11:11:11 -0400 Subject: [PATCH 1/2] Updated type for changed fields --- postgres.go | 4 +- ...TestDatabasePostgres_EngineConfig_Get.yaml | 107 +++++++++--------- test/integration/postgres_db_config_test.go | 4 +- .../postgresql_database_config_get.json | 9 +- test/unit/postgres_test.go | 4 +- 5 files changed, 61 insertions(+), 67 deletions(-) diff --git a/postgres.go b/postgres.go index eba19cd70..dc19ccfc2 100644 --- a/postgres.go +++ b/postgres.go @@ -424,7 +424,7 @@ type PasswordEncryption struct { Enum []string `json:"enum"` Example string `json:"example"` RequiresRestart bool `json:"requires_restart"` - Type []string `json:"type"` + Type string `json:"type"` } type PGPartmanBGWInterval struct { @@ -465,7 +465,7 @@ type PGStatStatementsTrack struct { Description string `json:"description"` Enum []string `json:"enum"` RequiresRestart bool `json:"requires_restart"` - Type []string `json:"type"` + Type string `json:"type"` } type TempFileLimit struct { diff --git a/test/integration/fixtures/TestDatabasePostgres_EngineConfig_Get.yaml b/test/integration/fixtures/TestDatabasePostgres_EngineConfig_Get.yaml index 25abaf0ce..c5f2f1e20 100644 --- a/test/integration/fixtures/TestDatabasePostgres_EngineConfig_Get.yaml +++ b/test/integration/fixtures/TestDatabasePostgres_EngineConfig_Get.yaml @@ -104,59 +104,58 @@ interactions: "maximum": 96, "minimum": 8, "requires_restart": true, "type": "integer"}, "password_encryption": {"default": "md5", "description": "Chooses the algorithm for encrypting passwords.", "enum": ["md5", "scram-sha-256"], "example": "scram-sha-256", "requires_restart": - false, "type": ["string", "null"]}, "pg_partman_bgw.interval": {"description": - "Sets the time interval to run pg_partman''s scheduled tasks", "example": 3600, - "maximum": 604800, "minimum": 3600, "requires_restart": false, "type": "integer"}, - "pg_partman_bgw.role": {"description": "Controls which role to use for pg_partman''s - scheduled background tasks.", "example": "myrolename", "maxLength": 64, "pattern": - "^[_A-Za-z0-9][-._A-Za-z0-9]{0,63}$", "requires_restart": false, "type": "string"}, - "pg_stat_monitor.pgsm_enable_query_plan": {"description": "Enables or disables - query plan monitoring", "example": false, "requires_restart": false, "type": - "boolean"}, "pg_stat_monitor.pgsm_max_buckets": {"description": "Sets the maximum - number of buckets ", "example": 10, "maximum": 10, "minimum": 1, "requires_restart": - true, "type": "integer"}, "pg_stat_statements.track": {"description": "Controls - which statements are counted. Specify top to track top-level statements (those - issued directly by clients), all to also track nested statements (such as statements - invoked within functions), or none to disable statement statistics collection. - The default value is top.", "enum": ["all", "top", "none"], "requires_restart": - false, "type": ["string"]}, "temp_file_limit": {"description": "PostgreSQL temporary - file limit in KiB, -1 for unlimited", "example": 5000000, "maximum": 2147483647, - "minimum": -1, "requires_restart": false, "type": "integer"}, "timezone": {"description": - "PostgreSQL service timezone", "example": "Europe/Helsinki", "maxLength": 64, - "pattern": "^[\\w/]*$", "requires_restart": false, "type": "string"}, "track_activity_query_size": - {"description": "Specifies the number of bytes reserved to track the currently - executing command for each active session.", "example": 1024, "maximum": 10240, - "minimum": 1024, "requires_restart": true, "type": "integer"}, "track_commit_timestamp": - {"description": "Record commit time of transactions.", "enum": ["off", "on"], - "example": "off", "requires_restart": true, "type": "string"}, "track_functions": - {"description": "Enables tracking of function call counts and time used.", "enum": - ["all", "pl", "none"], "requires_restart": false, "type": "string"}, "track_io_timing": - {"description": "Enables timing of database I/O calls. This parameter is off - by default, because it will repeatedly query the operating system for the current - time, which may cause significant overhead on some platforms.", "enum": ["off", - "on"], "example": "off", "requires_restart": false, "type": "string"}, "wal_sender_timeout": - {"description": "Terminate replication connections that are inactive for longer - than this amount of time, in milliseconds. Setting this value to zero disables - the timeout.", "example": 60000, "requires_restart": false, "type": "integer"}, - "wal_writer_delay": {"description": "WAL flush interval in milliseconds. Note - that setting this value to lower than the default 200ms may negatively impact - performance", "example": 50, "maximum": 200, "minimum": 10, "requires_restart": - false, "type": "integer"}}, "pg_stat_monitor_enable": {"default": false, "description": - "Enable the pg_stat_monitor extension. Enabling this extension will cause the - cluster to be restarted.When this extension is enabled, pg_stat_statements results - for utility commands are unreliable", "requires_restart": true, "type": "boolean"}, - "pglookout": {"max_failover_replication_time_lag": {"default": 60, "description": - "Number of seconds of master unavailability before triggering database failover - to standby", "maximum": 999999, "minimum": 10, "requires_restart": false, "type": - "integer"}}, "shared_buffers_percentage": {"description": "Percentage of total - RAM that the database server uses for shared memory buffers. Valid range is - 20-60 (float), which corresponds to 20% - 60%. This setting adjusts the shared_buffers - configuration value.", "example": 41.5, "maximum": 60.0, "minimum": 20.0, "requires_restart": - true, "type": "number"}, "work_mem": {"description": "Sets the maximum amount - of memory to be used by a query operation (such as a sort or hash table) before - writing to temporary disk files, in MB. Default is 1MB + 0.075% of total RAM - (up to 32MB).", "example": 4, "maximum": 1024, "minimum": 1, "requires_restart": - false, "type": "integer"}}' + false, "type": "string"}, "pg_partman_bgw.interval": {"description": "Sets the + time interval to run pg_partman''s scheduled tasks", "example": 3600, "maximum": + 604800, "minimum": 3600, "requires_restart": false, "type": "integer"}, "pg_partman_bgw.role": + {"description": "Controls which role to use for pg_partman''s scheduled background + tasks.", "example": "myrolename", "maxLength": 64, "pattern": "^[_A-Za-z0-9][-._A-Za-z0-9]{0,63}$", + "requires_restart": false, "type": "string"}, "pg_stat_monitor.pgsm_enable_query_plan": + {"description": "Enables or disables query plan monitoring", "example": false, + "requires_restart": true, "type": "boolean"}, "pg_stat_monitor.pgsm_max_buckets": + {"description": "Sets the maximum number of buckets ", "example": 10, "maximum": + 10, "minimum": 1, "requires_restart": true, "type": "integer"}, "pg_stat_statements.track": + {"description": "Controls which statements are counted. Specify top to track + top-level statements (those issued directly by clients), all to also track nested + statements (such as statements invoked within functions), or none to disable + statement statistics collection. The default value is top.", "enum": ["all", + "top", "none"], "requires_restart": false, "type": "string"}, "temp_file_limit": + {"description": "PostgreSQL temporary file limit in KiB, -1 for unlimited", + "example": 5000000, "maximum": 2147483647, "minimum": -1, "requires_restart": + false, "type": "integer"}, "timezone": {"description": "PostgreSQL service timezone", + "example": "Europe/Helsinki", "maxLength": 64, "pattern": "^[\\w/]*$", "requires_restart": + false, "type": "string"}, "track_activity_query_size": {"description": "Specifies + the number of bytes reserved to track the currently executing command for each + active session.", "example": 1024, "maximum": 10240, "minimum": 1024, "requires_restart": + true, "type": "integer"}, "track_commit_timestamp": {"description": "Record + commit time of transactions.", "enum": ["off", "on"], "example": "off", "requires_restart": + true, "type": "string"}, "track_functions": {"description": "Enables tracking + of function call counts and time used.", "enum": ["all", "pl", "none"], "requires_restart": + false, "type": "string"}, "track_io_timing": {"description": "Enables timing + of database I/O calls. This parameter is off by default, because it will repeatedly + query the operating system for the current time, which may cause significant + overhead on some platforms.", "enum": ["off", "on"], "example": "off", "requires_restart": + false, "type": "string"}, "wal_sender_timeout": {"description": "Terminate replication + connections that are inactive for longer than this amount of time, in milliseconds. + Setting this value to zero disables the timeout.", "example": 60000, "requires_restart": + false, "type": "integer"}, "wal_writer_delay": {"description": "WAL flush interval + in milliseconds. Note that setting this value to lower than the default 200ms + may negatively impact performance", "example": 50, "maximum": 200, "minimum": + 10, "requires_restart": false, "type": "integer"}}, "pg_stat_monitor_enable": + {"default": false, "description": "Enable the pg_stat_monitor extension. Enabling + this extension will cause the cluster to be restarted.When this extension is + enabled, pg_stat_statements results for utility commands are unreliable", "requires_restart": + true, "type": "boolean"}, "pglookout": {"max_failover_replication_time_lag": + {"default": 60, "description": "Number of seconds of master unavailability before + triggering database failover to standby", "maximum": 999999, "minimum": 10, + "requires_restart": false, "type": "integer"}}, "shared_buffers_percentage": + {"description": "Percentage of total RAM that the database server uses for shared + memory buffers. Valid range is 20-60 (float), which corresponds to 20% - 60%. + This setting adjusts the shared_buffers configuration value.", "example": 41.5, + "maximum": 60.0, "minimum": 20.0, "requires_restart": true, "type": "number"}, + "work_mem": {"description": "Sets the maximum amount of memory to be used by + a query operation (such as a sort or hash table) before writing to temporary + disk files, in MB. Default is 1MB + 0.075% of total RAM (up to 32MB).", "example": + 4, "maximum": 1024, "minimum": 1, "requires_restart": false, "type": "integer"}}' headers: Access-Control-Allow-Credentials: - "true" @@ -174,7 +173,7 @@ interactions: Connection: - keep-alive Content-Length: - - "11676" + - "11663" Content-Security-Policy: - default-src 'none' Content-Type: diff --git a/test/integration/postgres_db_config_test.go b/test/integration/postgres_db_config_test.go index 21ae399e6..944732d92 100644 --- a/test/integration/postgres_db_config_test.go +++ b/test/integration/postgres_db_config_test.go @@ -203,7 +203,7 @@ func TestDatabasePostgres_EngineConfig_Get(t *testing.T) { assert.IsType(t, []string{"md5", "scram-sha-256"}, config.PG.PasswordEncryption.Enum) assert.IsType(t, "scram-sha-256", config.PG.PasswordEncryption.Example) assert.IsType(t, false, config.PG.PasswordEncryption.RequiresRestart) - assert.IsType(t, []string{"string", "null"}, config.PG.PasswordEncryption.Type) + assert.IsType(t, "string", config.PG.PasswordEncryption.Type) assert.IsType(t, "Sets the time interval to run pg_partman's scheduled tasks", config.PG.PGPartmanBGWInterval.Description) assert.IsType(t, int(3600), config.PG.PGPartmanBGWInterval.Example) @@ -234,7 +234,7 @@ func TestDatabasePostgres_EngineConfig_Get(t *testing.T) { assert.IsType(t, "Controls which statements are counted. Specify top to track top-level statements (those issued directly by clients), all to also track nested statements (such as statements invoked within functions), or none to disable statement statistics collection. The default value is top.", config.PG.PGStatStatementsTrack.Description) assert.IsType(t, []string{"all", "top", "none"}, config.PG.PGStatStatementsTrack.Enum) assert.IsType(t, false, config.PG.PGStatStatementsTrack.RequiresRestart) - assert.IsType(t, []string{"string"}, config.PG.PGStatStatementsTrack.Type) + assert.IsType(t, "string", config.PG.PGStatStatementsTrack.Type) assert.IsType(t, "PostgreSQL temporary file limit in KiB, -1 for unlimited", config.PG.TempFileLimit.Description) assert.IsType(t, int32(5000000), config.PG.TempFileLimit.Example) diff --git a/test/unit/fixtures/postgresql_database_config_get.json b/test/unit/fixtures/postgresql_database_config_get.json index f66f991a8..0bf6d023d 100644 --- a/test/unit/fixtures/postgresql_database_config_get.json +++ b/test/unit/fixtures/postgresql_database_config_get.json @@ -218,10 +218,7 @@ ], "example": "scram-sha-256", "requires_restart": false, - "type": [ - "string", - "null" - ] + "type": "string" }, "pg_partman_bgw.interval": { "description": "Sets the time interval to run pg_partman's scheduled tasks", @@ -261,9 +258,7 @@ "none" ], "requires_restart": false, - "type": [ - "string" - ] + "type": "string" }, "temp_file_limit": { "description": "PostgreSQL temporary file limit in KiB, -1 for unlimited", diff --git a/test/unit/postgres_test.go b/test/unit/postgres_test.go index 521e68ae1..a3356e7e1 100644 --- a/test/unit/postgres_test.go +++ b/test/unit/postgres_test.go @@ -592,7 +592,7 @@ func TestDatabasePostgreSQLConfig_Get(t *testing.T) { assert.Equal(t, []string{"md5", "scram-sha-256"}, config.PG.PasswordEncryption.Enum) assert.Equal(t, "scram-sha-256", config.PG.PasswordEncryption.Example) assert.False(t, config.PG.PasswordEncryption.RequiresRestart) - assert.Equal(t, []string{"string", "null"}, config.PG.PasswordEncryption.Type) + assert.Equal(t, "string", config.PG.PasswordEncryption.Type) assert.Equal(t, "Sets the time interval to run pg_partman's scheduled tasks", config.PG.PGPartmanBGWInterval.Description) @@ -628,7 +628,7 @@ func TestDatabasePostgreSQLConfig_Get(t *testing.T) { config.PG.PGStatStatementsTrack.Description) assert.Equal(t, []string{"all", "top", "none"}, config.PG.PGStatStatementsTrack.Enum) assert.False(t, config.PG.PGStatStatementsTrack.RequiresRestart) - assert.Equal(t, []string{"string"}, config.PG.PGStatStatementsTrack.Type) + assert.Equal(t, "string", config.PG.PGStatStatementsTrack.Type) assert.Equal(t, "PostgreSQL temporary file limit in KiB, -1 for unlimited", config.PG.TempFileLimit.Description) From 5068ccf71671fb716b81ff307f2094a1324a5ed9 Mon Sep 17 00:00:00 2001 From: Youjung Kim Date: Fri, 16 May 2025 10:54:58 -0700 Subject: [PATCH 2/2] remove pg13 negative test case --- test/integration/postgres_db_config_test.go | 24 --------------------- 1 file changed, 24 deletions(-) diff --git a/test/integration/postgres_db_config_test.go b/test/integration/postgres_db_config_test.go index 944732d92..c1be0867d 100644 --- a/test/integration/postgres_db_config_test.go +++ b/test/integration/postgres_db_config_test.go @@ -325,30 +325,6 @@ func TestDatabasePostgres_EngineConfig_Create_PasswordEncryption_DefaultsToMD5(t assert.Contains(t, *database.EngineConfig.PG.PasswordEncryption, "md5") } -func TestDatabasePostgres_EngineConfig_Create_Fails_LZ4Unsupported_Postgres13(t *testing.T) { - if os.Getenv("LINODE_FIXTURE_MODE") == "play" { - t.Skip("Skipping negative test scenario: LINODE_FIXTURE_MODE is 'play'") - } - - invalidRequestData := linodego.PostgresCreateOptions{ - Label: "example-db-created-fails", - Region: "us-east", - Type: "g6-dedicated-2", - Engine: "postgresql/13", - EngineConfig: &linodego.PostgresDatabaseEngineConfig{ - PG: &linodego.PostgresDatabaseEngineConfigPG{ - DefaultToastCompression: linodego.Pointer("lz4"), - }, - }, - } - - client, _ := createTestClient(t, "") - - _, err := client.CreatePostgresDatabase(context.Background(), invalidRequestData) - - assert.Contains(t, err.Error(), "This setting is only available for postgresql version 14+") -} - func TestDatabasePostgres_EngineConfig_Create_Fails_EmptyDoublePointerValue(t *testing.T) { if os.Getenv("LINODE_FIXTURE_MODE") == "play" { t.Skip("Skipping negative test scenario: LINODE_FIXTURE_MODE is 'play'")