test(config): cover ConfigPath and Command overrides

This commit is contained in:
Mitch Murphy 2026-06-05 13:49:23 -04:00
parent 9787922bf9
commit c49aac8cc2
2 changed files with 24 additions and 15 deletions

View File

@ -153,21 +153,22 @@ type LogicalBackup struct {
// Operator options for connection pooler
type ConnectionPooler struct {
NumberOfInstances *int32 `name:"connection_pooler_number_of_instances" default:"2"`
Schema string `name:"connection_pooler_schema" default:"pooler"`
User string `name:"connection_pooler_user" default:"pooler"`
Image string `name:"connection_pooler_image" default:"ghcr.io/zalando/postgres-operator/pgbouncer:latest"`
Mode string `name:"connection_pooler_mode" default:"transaction"`
MaxDBConnections *int32 `name:"connection_pooler_max_db_connections" default:"60"`
ConnectionPoolerDefaultCPURequest string `name:"connection_pooler_default_cpu_request"`
ConnectionPoolerDefaultMemoryRequest string `name:"connection_pooler_default_memory_request"`
ConnectionPoolerDefaultCPULimit string `name:"connection_pooler_default_cpu_limit"`
ConnectionPoolerDefaultMemoryLimit string `name:"connection_pooler_default_memory_limit"`
GenerateConfig bool `name:"connection_pooler_generate_config" default:"false"`
Command []string `name:"connection_pooler_command"`
Args []string `name:"connection_pooler_args" default:"/etc/pgbouncer/pgbouncer.ini"`
AuthType string `name:"connection_pooler_auth_type" default:"scram-sha-256"`
ConfigPath string `name:"connection_pooler_config_path" default:"/etc/pgbouncer/pgbouncer.ini"`
NumberOfInstances *int32 `name:"connection_pooler_number_of_instances" default:"2"`
Schema string `name:"connection_pooler_schema" default:"pooler"`
User string `name:"connection_pooler_user" default:"pooler"`
Image string `name:"connection_pooler_image" default:"ghcr.io/zalando/postgres-operator/pgbouncer:latest"`
Mode string `name:"connection_pooler_mode" default:"transaction"`
MaxDBConnections *int32 `name:"connection_pooler_max_db_connections" default:"60"`
ConnectionPoolerDefaultCPURequest string `name:"connection_pooler_default_cpu_request"`
ConnectionPoolerDefaultMemoryRequest string `name:"connection_pooler_default_memory_request"`
ConnectionPoolerDefaultCPULimit string `name:"connection_pooler_default_cpu_limit"`
ConnectionPoolerDefaultMemoryLimit string `name:"connection_pooler_default_memory_limit"`
GenerateConfig bool `name:"connection_pooler_generate_config" default:"false"`
// Command is nil when not configured (keeps the image entrypoint).
Command []string `name:"connection_pooler_command"`
Args []string `name:"connection_pooler_args" default:"/etc/pgbouncer/pgbouncer.ini"`
AuthType string `name:"connection_pooler_auth_type" default:"scram-sha-256"`
ConfigPath string `name:"connection_pooler_config_path" default:"/etc/pgbouncer/pgbouncer.ini"`
}
// Config describes operator config

View File

@ -356,6 +356,8 @@ func TestConnectionPoolerGenerateConfigDefaults(t *testing.T) {
"connection_pooler_generate_config": "true",
"connection_pooler_auth_type": "md5",
"connection_pooler_args": "/custom/pgbouncer.ini",
"connection_pooler_config_path": "/custom/pgbouncer.ini",
"connection_pooler_command": "/usr/bin/pgbouncer",
})
if !cfg2.ConnectionPooler.GenerateConfig {
t.Errorf("expected GenerateConfig true")
@ -366,4 +368,10 @@ func TestConnectionPoolerGenerateConfigDefaults(t *testing.T) {
if len(cfg2.ConnectionPooler.Args) != 1 || cfg2.ConnectionPooler.Args[0] != "/custom/pgbouncer.ini" {
t.Errorf("expected Args [/custom/pgbouncer.ini], got %#v", cfg2.ConnectionPooler.Args)
}
if cfg2.ConnectionPooler.ConfigPath != "/custom/pgbouncer.ini" {
t.Errorf("expected ConfigPath /custom/pgbouncer.ini, got %q", cfg2.ConnectionPooler.ConfigPath)
}
if len(cfg2.ConnectionPooler.Command) != 1 || cfg2.ConnectionPooler.Command[0] != "/usr/bin/pgbouncer" {
t.Errorf("expected Command [/usr/bin/pgbouncer], got %#v", cfg2.ConnectionPooler.Command)
}
}