Skip to content

Updated type for modified fields #750

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

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
4 changes: 2 additions & 2 deletions postgres.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down
107 changes: 53 additions & 54 deletions test/integration/fixtures/TestDatabasePostgres_EngineConfig_Get.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -174,7 +173,7 @@ interactions:
Connection:
- keep-alive
Content-Length:
- "11676"
- "11663"
Content-Security-Policy:
- default-src 'none'
Content-Type:
Expand Down
28 changes: 2 additions & 26 deletions test/integration/postgres_db_config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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'")
Expand Down
9 changes: 2 additions & 7 deletions test/unit/fixtures/postgresql_database_config_get.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down
4 changes: 2 additions & 2 deletions test/unit/postgres_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down