mirror of
https://github.com/zalando/postgres-operator.git
synced 2026-10-08 15:51:19 +02:00
fetch pooler and fes_user system user only when corresponding features are used (#2009)
* fetch pooler and fes_user system user only when corresponding features are used * cover error case in unit test * use string formatting instead of +
This commit is contained in:
@@ -759,11 +759,14 @@ func TestServiceAnnotations(t *testing.T) {
|
||||
func TestInitSystemUsers(t *testing.T) {
|
||||
testName := "Test system users initialization"
|
||||
|
||||
// default cluster without connection pooler
|
||||
// default cluster without connection pooler and event streams
|
||||
cl.initSystemUsers()
|
||||
if _, exist := cl.systemUsers[constants.ConnectionPoolerUserKeyName]; exist {
|
||||
t.Errorf("%s, connection pooler user is present", testName)
|
||||
}
|
||||
if _, exist := cl.systemUsers[constants.EventStreamUserKeyName]; exist {
|
||||
t.Errorf("%s, stream user is present", testName)
|
||||
}
|
||||
|
||||
// cluster with connection pooler
|
||||
cl.Spec.EnableConnectionPooler = boolToPointer(true)
|
||||
@@ -805,6 +808,31 @@ func TestInitSystemUsers(t *testing.T) {
|
||||
if _, exist := cl.systemUsers["pooler"]; !exist {
|
||||
t.Errorf("%s, System users are not allowed to be a connection pool user", testName)
|
||||
}
|
||||
|
||||
// using stream user in manifest but no streams defined should be treated like normal robot user
|
||||
streamUser := fmt.Sprintf("%s%s", constants.EventStreamSourceSlotPrefix, constants.UserRoleNameSuffix)
|
||||
cl.Spec.Users = map[string]acidv1.UserFlags{streamUser: []string{}}
|
||||
cl.initSystemUsers()
|
||||
if _, exist := cl.systemUsers[constants.EventStreamUserKeyName]; exist {
|
||||
t.Errorf("%s, stream user is present", testName)
|
||||
}
|
||||
|
||||
// cluster with streams
|
||||
cl.Spec.Streams = []acidv1.Stream{
|
||||
{
|
||||
ApplicationId: "test-app",
|
||||
Database: "test_db",
|
||||
Tables: map[string]acidv1.StreamTable{
|
||||
"data.test_table": acidv1.StreamTable{
|
||||
EventType: "test_event",
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
cl.initSystemUsers()
|
||||
if _, exist := cl.systemUsers[constants.EventStreamUserKeyName]; !exist {
|
||||
t.Errorf("%s, stream user is not present", testName)
|
||||
}
|
||||
}
|
||||
|
||||
func TestPreparedDatabases(t *testing.T) {
|
||||
|
||||
Reference in New Issue
Block a user