Add sync test

This commit is contained in:
Rafia Sabih 2020-09-23 11:19:01 +02:00
parent 033a7f4e24
commit 1ee79887cf
2 changed files with 20 additions and 2 deletions

View File

@ -905,7 +905,7 @@ func (c *Cluster) initSystemUsers() {
// Connection pooler user is an exception, if requested it's going to be // Connection pooler user is an exception, if requested it's going to be
// created by operator as a normal pgUser // created by operator as a normal pgUser
if c.needMasterConnectionPooler() || c.needReplicaConnectionPooler() { if c.needConnectionPooler() {
// initialize empty connection pooler if not done yet // initialize empty connection pooler if not done yet
if c.Spec.ConnectionPooler == nil { if c.Spec.ConnectionPooler == nil {
c.Spec.ConnectionPooler = &acidv1.ConnectionPooler{} c.Spec.ConnectionPooler = &acidv1.ConnectionPooler{}

View File

@ -215,6 +215,23 @@ func TestConnectionPoolerSynchronization(t *testing.T) {
defaultInstances: 1, defaultInstances: 1,
check: objectsAreSaved, check: objectsAreSaved,
}, },
{
subTest: "create both master and replica",
oldSpec: &acidv1.Postgresql{
Spec: acidv1.PostgresSpec{},
},
newSpec: &acidv1.Postgresql{
Spec: acidv1.PostgresSpec{
ConnectionPooler: &acidv1.ConnectionPooler{},
EnableReplicaConnectionPooler: boolToPointer(true),
EnableConnectionPooler: boolToPointer(true),
},
},
cluster: clusterMissingObjects,
defaultImage: "pooler:1.0",
defaultInstances: 1,
check: objectsAreSaved,
},
{ {
subTest: "delete if not needed", subTest: "delete if not needed",
oldSpec: &acidv1.Postgresql{ oldSpec: &acidv1.Postgresql{
@ -235,6 +252,7 @@ func TestConnectionPoolerSynchronization(t *testing.T) {
oldSpec: &acidv1.Postgresql{ oldSpec: &acidv1.Postgresql{
Spec: acidv1.PostgresSpec{ Spec: acidv1.PostgresSpec{
ConnectionPooler: &acidv1.ConnectionPooler{}, ConnectionPooler: &acidv1.ConnectionPooler{},
EnableConnectionPooler: boolToPointer(true),
}, },
}, },
newSpec: &acidv1.Postgresql{ newSpec: &acidv1.Postgresql{