Skip to content

Commit 9e80d52

Browse files
Updated type for modified fields (#750)
* Updated type for changed fields * remove pg13 negative test case --------- Co-authored-by: Youjung Kim <[email protected]>
1 parent bb0362f commit 9e80d52

File tree

5 files changed

+61
-91
lines changed

5 files changed

+61
-91
lines changed

postgres.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -424,7 +424,7 @@ type PasswordEncryption struct {
424424
Enum []string `json:"enum"`
425425
Example string `json:"example"`
426426
RequiresRestart bool `json:"requires_restart"`
427-
Type []string `json:"type"`
427+
Type string `json:"type"`
428428
}
429429

430430
type PGPartmanBGWInterval struct {
@@ -465,7 +465,7 @@ type PGStatStatementsTrack struct {
465465
Description string `json:"description"`
466466
Enum []string `json:"enum"`
467467
RequiresRestart bool `json:"requires_restart"`
468-
Type []string `json:"type"`
468+
Type string `json:"type"`
469469
}
470470

471471
type TempFileLimit struct {

test/integration/fixtures/TestDatabasePostgres_EngineConfig_Get.yaml

Lines changed: 53 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -104,59 +104,58 @@ interactions:
104104
"maximum": 96, "minimum": 8, "requires_restart": true, "type": "integer"}, "password_encryption":
105105
{"default": "md5", "description": "Chooses the algorithm for encrypting passwords.",
106106
"enum": ["md5", "scram-sha-256"], "example": "scram-sha-256", "requires_restart":
107-
false, "type": ["string", "null"]}, "pg_partman_bgw.interval": {"description":
108-
"Sets the time interval to run pg_partman''s scheduled tasks", "example": 3600,
109-
"maximum": 604800, "minimum": 3600, "requires_restart": false, "type": "integer"},
110-
"pg_partman_bgw.role": {"description": "Controls which role to use for pg_partman''s
111-
scheduled background tasks.", "example": "myrolename", "maxLength": 64, "pattern":
112-
"^[_A-Za-z0-9][-._A-Za-z0-9]{0,63}$", "requires_restart": false, "type": "string"},
113-
"pg_stat_monitor.pgsm_enable_query_plan": {"description": "Enables or disables
114-
query plan monitoring", "example": false, "requires_restart": false, "type":
115-
"boolean"}, "pg_stat_monitor.pgsm_max_buckets": {"description": "Sets the maximum
116-
number of buckets ", "example": 10, "maximum": 10, "minimum": 1, "requires_restart":
117-
true, "type": "integer"}, "pg_stat_statements.track": {"description": "Controls
118-
which statements are counted. Specify top to track top-level statements (those
119-
issued directly by clients), all to also track nested statements (such as statements
120-
invoked within functions), or none to disable statement statistics collection.
121-
The default value is top.", "enum": ["all", "top", "none"], "requires_restart":
122-
false, "type": ["string"]}, "temp_file_limit": {"description": "PostgreSQL temporary
123-
file limit in KiB, -1 for unlimited", "example": 5000000, "maximum": 2147483647,
124-
"minimum": -1, "requires_restart": false, "type": "integer"}, "timezone": {"description":
125-
"PostgreSQL service timezone", "example": "Europe/Helsinki", "maxLength": 64,
126-
"pattern": "^[\\w/]*$", "requires_restart": false, "type": "string"}, "track_activity_query_size":
127-
{"description": "Specifies the number of bytes reserved to track the currently
128-
executing command for each active session.", "example": 1024, "maximum": 10240,
129-
"minimum": 1024, "requires_restart": true, "type": "integer"}, "track_commit_timestamp":
130-
{"description": "Record commit time of transactions.", "enum": ["off", "on"],
131-
"example": "off", "requires_restart": true, "type": "string"}, "track_functions":
132-
{"description": "Enables tracking of function call counts and time used.", "enum":
133-
["all", "pl", "none"], "requires_restart": false, "type": "string"}, "track_io_timing":
134-
{"description": "Enables timing of database I/O calls. This parameter is off
135-
by default, because it will repeatedly query the operating system for the current
136-
time, which may cause significant overhead on some platforms.", "enum": ["off",
137-
"on"], "example": "off", "requires_restart": false, "type": "string"}, "wal_sender_timeout":
138-
{"description": "Terminate replication connections that are inactive for longer
139-
than this amount of time, in milliseconds. Setting this value to zero disables
140-
the timeout.", "example": 60000, "requires_restart": false, "type": "integer"},
141-
"wal_writer_delay": {"description": "WAL flush interval in milliseconds. Note
142-
that setting this value to lower than the default 200ms may negatively impact
143-
performance", "example": 50, "maximum": 200, "minimum": 10, "requires_restart":
144-
false, "type": "integer"}}, "pg_stat_monitor_enable": {"default": false, "description":
145-
"Enable the pg_stat_monitor extension. Enabling this extension will cause the
146-
cluster to be restarted.When this extension is enabled, pg_stat_statements results
147-
for utility commands are unreliable", "requires_restart": true, "type": "boolean"},
148-
"pglookout": {"max_failover_replication_time_lag": {"default": 60, "description":
149-
"Number of seconds of master unavailability before triggering database failover
150-
to standby", "maximum": 999999, "minimum": 10, "requires_restart": false, "type":
151-
"integer"}}, "shared_buffers_percentage": {"description": "Percentage of total
152-
RAM that the database server uses for shared memory buffers. Valid range is
153-
20-60 (float), which corresponds to 20% - 60%. This setting adjusts the shared_buffers
154-
configuration value.", "example": 41.5, "maximum": 60.0, "minimum": 20.0, "requires_restart":
155-
true, "type": "number"}, "work_mem": {"description": "Sets the maximum amount
156-
of memory to be used by a query operation (such as a sort or hash table) before
157-
writing to temporary disk files, in MB. Default is 1MB + 0.075% of total RAM
158-
(up to 32MB).", "example": 4, "maximum": 1024, "minimum": 1, "requires_restart":
159-
false, "type": "integer"}}'
107+
false, "type": "string"}, "pg_partman_bgw.interval": {"description": "Sets the
108+
time interval to run pg_partman''s scheduled tasks", "example": 3600, "maximum":
109+
604800, "minimum": 3600, "requires_restart": false, "type": "integer"}, "pg_partman_bgw.role":
110+
{"description": "Controls which role to use for pg_partman''s scheduled background
111+
tasks.", "example": "myrolename", "maxLength": 64, "pattern": "^[_A-Za-z0-9][-._A-Za-z0-9]{0,63}$",
112+
"requires_restart": false, "type": "string"}, "pg_stat_monitor.pgsm_enable_query_plan":
113+
{"description": "Enables or disables query plan monitoring", "example": false,
114+
"requires_restart": true, "type": "boolean"}, "pg_stat_monitor.pgsm_max_buckets":
115+
{"description": "Sets the maximum number of buckets ", "example": 10, "maximum":
116+
10, "minimum": 1, "requires_restart": true, "type": "integer"}, "pg_stat_statements.track":
117+
{"description": "Controls which statements are counted. Specify top to track
118+
top-level statements (those issued directly by clients), all to also track nested
119+
statements (such as statements invoked within functions), or none to disable
120+
statement statistics collection. The default value is top.", "enum": ["all",
121+
"top", "none"], "requires_restart": false, "type": "string"}, "temp_file_limit":
122+
{"description": "PostgreSQL temporary file limit in KiB, -1 for unlimited",
123+
"example": 5000000, "maximum": 2147483647, "minimum": -1, "requires_restart":
124+
false, "type": "integer"}, "timezone": {"description": "PostgreSQL service timezone",
125+
"example": "Europe/Helsinki", "maxLength": 64, "pattern": "^[\\w/]*$", "requires_restart":
126+
false, "type": "string"}, "track_activity_query_size": {"description": "Specifies
127+
the number of bytes reserved to track the currently executing command for each
128+
active session.", "example": 1024, "maximum": 10240, "minimum": 1024, "requires_restart":
129+
true, "type": "integer"}, "track_commit_timestamp": {"description": "Record
130+
commit time of transactions.", "enum": ["off", "on"], "example": "off", "requires_restart":
131+
true, "type": "string"}, "track_functions": {"description": "Enables tracking
132+
of function call counts and time used.", "enum": ["all", "pl", "none"], "requires_restart":
133+
false, "type": "string"}, "track_io_timing": {"description": "Enables timing
134+
of database I/O calls. This parameter is off by default, because it will repeatedly
135+
query the operating system for the current time, which may cause significant
136+
overhead on some platforms.", "enum": ["off", "on"], "example": "off", "requires_restart":
137+
false, "type": "string"}, "wal_sender_timeout": {"description": "Terminate replication
138+
connections that are inactive for longer than this amount of time, in milliseconds.
139+
Setting this value to zero disables the timeout.", "example": 60000, "requires_restart":
140+
false, "type": "integer"}, "wal_writer_delay": {"description": "WAL flush interval
141+
in milliseconds. Note that setting this value to lower than the default 200ms
142+
may negatively impact performance", "example": 50, "maximum": 200, "minimum":
143+
10, "requires_restart": false, "type": "integer"}}, "pg_stat_monitor_enable":
144+
{"default": false, "description": "Enable the pg_stat_monitor extension. Enabling
145+
this extension will cause the cluster to be restarted.When this extension is
146+
enabled, pg_stat_statements results for utility commands are unreliable", "requires_restart":
147+
true, "type": "boolean"}, "pglookout": {"max_failover_replication_time_lag":
148+
{"default": 60, "description": "Number of seconds of master unavailability before
149+
triggering database failover to standby", "maximum": 999999, "minimum": 10,
150+
"requires_restart": false, "type": "integer"}}, "shared_buffers_percentage":
151+
{"description": "Percentage of total RAM that the database server uses for shared
152+
memory buffers. Valid range is 20-60 (float), which corresponds to 20% - 60%.
153+
This setting adjusts the shared_buffers configuration value.", "example": 41.5,
154+
"maximum": 60.0, "minimum": 20.0, "requires_restart": true, "type": "number"},
155+
"work_mem": {"description": "Sets the maximum amount of memory to be used by
156+
a query operation (such as a sort or hash table) before writing to temporary
157+
disk files, in MB. Default is 1MB + 0.075% of total RAM (up to 32MB).", "example":
158+
4, "maximum": 1024, "minimum": 1, "requires_restart": false, "type": "integer"}}'
160159
headers:
161160
Access-Control-Allow-Credentials:
162161
- "true"
@@ -174,7 +173,7 @@ interactions:
174173
Connection:
175174
- keep-alive
176175
Content-Length:
177-
- "11676"
176+
- "11663"
178177
Content-Security-Policy:
179178
- default-src 'none'
180179
Content-Type:

test/integration/postgres_db_config_test.go

Lines changed: 2 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ func TestDatabasePostgres_EngineConfig_Get(t *testing.T) {
203203
assert.IsType(t, []string{"md5", "scram-sha-256"}, config.PG.PasswordEncryption.Enum)
204204
assert.IsType(t, "scram-sha-256", config.PG.PasswordEncryption.Example)
205205
assert.IsType(t, false, config.PG.PasswordEncryption.RequiresRestart)
206-
assert.IsType(t, []string{"string", "null"}, config.PG.PasswordEncryption.Type)
206+
assert.IsType(t, "string", config.PG.PasswordEncryption.Type)
207207

208208
assert.IsType(t, "Sets the time interval to run pg_partman's scheduled tasks", config.PG.PGPartmanBGWInterval.Description)
209209
assert.IsType(t, int(3600), config.PG.PGPartmanBGWInterval.Example)
@@ -234,7 +234,7 @@ func TestDatabasePostgres_EngineConfig_Get(t *testing.T) {
234234
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)
235235
assert.IsType(t, []string{"all", "top", "none"}, config.PG.PGStatStatementsTrack.Enum)
236236
assert.IsType(t, false, config.PG.PGStatStatementsTrack.RequiresRestart)
237-
assert.IsType(t, []string{"string"}, config.PG.PGStatStatementsTrack.Type)
237+
assert.IsType(t, "string", config.PG.PGStatStatementsTrack.Type)
238238

239239
assert.IsType(t, "PostgreSQL temporary file limit in KiB, -1 for unlimited", config.PG.TempFileLimit.Description)
240240
assert.IsType(t, int32(5000000), config.PG.TempFileLimit.Example)
@@ -325,30 +325,6 @@ func TestDatabasePostgres_EngineConfig_Create_PasswordEncryption_DefaultsToMD5(t
325325
assert.Contains(t, *database.EngineConfig.PG.PasswordEncryption, "md5")
326326
}
327327

328-
func TestDatabasePostgres_EngineConfig_Create_Fails_LZ4Unsupported_Postgres13(t *testing.T) {
329-
if os.Getenv("LINODE_FIXTURE_MODE") == "play" {
330-
t.Skip("Skipping negative test scenario: LINODE_FIXTURE_MODE is 'play'")
331-
}
332-
333-
invalidRequestData := linodego.PostgresCreateOptions{
334-
Label: "example-db-created-fails",
335-
Region: "us-east",
336-
Type: "g6-dedicated-2",
337-
Engine: "postgresql/13",
338-
EngineConfig: &linodego.PostgresDatabaseEngineConfig{
339-
PG: &linodego.PostgresDatabaseEngineConfigPG{
340-
DefaultToastCompression: linodego.Pointer("lz4"),
341-
},
342-
},
343-
}
344-
345-
client, _ := createTestClient(t, "")
346-
347-
_, err := client.CreatePostgresDatabase(context.Background(), invalidRequestData)
348-
349-
assert.Contains(t, err.Error(), "This setting is only available for postgresql version 14+")
350-
}
351-
352328
func TestDatabasePostgres_EngineConfig_Create_Fails_EmptyDoublePointerValue(t *testing.T) {
353329
if os.Getenv("LINODE_FIXTURE_MODE") == "play" {
354330
t.Skip("Skipping negative test scenario: LINODE_FIXTURE_MODE is 'play'")

test/unit/fixtures/postgresql_database_config_get.json

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -218,10 +218,7 @@
218218
],
219219
"example": "scram-sha-256",
220220
"requires_restart": false,
221-
"type": [
222-
"string",
223-
"null"
224-
]
221+
"type": "string"
225222
},
226223
"pg_partman_bgw.interval": {
227224
"description": "Sets the time interval to run pg_partman's scheduled tasks",
@@ -261,9 +258,7 @@
261258
"none"
262259
],
263260
"requires_restart": false,
264-
"type": [
265-
"string"
266-
]
261+
"type": "string"
267262
},
268263
"temp_file_limit": {
269264
"description": "PostgreSQL temporary file limit in KiB, -1 for unlimited",

test/unit/postgres_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -592,7 +592,7 @@ func TestDatabasePostgreSQLConfig_Get(t *testing.T) {
592592
assert.Equal(t, []string{"md5", "scram-sha-256"}, config.PG.PasswordEncryption.Enum)
593593
assert.Equal(t, "scram-sha-256", config.PG.PasswordEncryption.Example)
594594
assert.False(t, config.PG.PasswordEncryption.RequiresRestart)
595-
assert.Equal(t, []string{"string", "null"}, config.PG.PasswordEncryption.Type)
595+
assert.Equal(t, "string", config.PG.PasswordEncryption.Type)
596596

597597
assert.Equal(t, "Sets the time interval to run pg_partman's scheduled tasks",
598598
config.PG.PGPartmanBGWInterval.Description)
@@ -628,7 +628,7 @@ func TestDatabasePostgreSQLConfig_Get(t *testing.T) {
628628
config.PG.PGStatStatementsTrack.Description)
629629
assert.Equal(t, []string{"all", "top", "none"}, config.PG.PGStatStatementsTrack.Enum)
630630
assert.False(t, config.PG.PGStatStatementsTrack.RequiresRestart)
631-
assert.Equal(t, []string{"string"}, config.PG.PGStatStatementsTrack.Type)
631+
assert.Equal(t, "string", config.PG.PGStatStatementsTrack.Type)
632632

633633
assert.Equal(t, "PostgreSQL temporary file limit in KiB, -1 for unlimited",
634634
config.PG.TempFileLimit.Description)

0 commit comments

Comments
 (0)