Skip to content
Snippets Groups Projects
Commit 8c3f03ea authored by Stéphane Diemer's avatar Stéphane Diemer
Browse files

Change postgresql test to handle server with no standby db access | refs #33528

parent 3dc585ee
No related branches found
No related tags found
No related merge requests found
......@@ -44,15 +44,6 @@ def check_listen(host: str, port: int) -> bool:
return result == 0
def is_ha() -> bool:
"""Check wether this setup is using higlhy-available databases.
:return: Wether it is a highly-available setup or not
:rtype: bool
"""
return check_listen("127.0.0.1", 54321)
def get_haproxy_conf(path: str = "/etc/haproxy/haproxy.cfg") -> dict:
"""Get HAProxy configuration in a dictionary.
......@@ -397,7 +388,7 @@ def main():
# get database configuration
db_host = conf.get("DB_HOST") if conf.get("DB_HOST") else "127.0.0.1"
db_port = 54321 if is_ha() else 5432
db_port = 54321 if check_listen("127.0.0.1", 54321) else 5432
db_user = conf.get("DB_USER") if conf.get("DB_USER") else "postgres"
db_pass = conf.get("DB_PG_ROOT_PWD")
db_conn = {"dbname": db_user, "host": db_host, "port": db_port, "user": db_user}
......@@ -406,11 +397,11 @@ def main():
# determine if HA setup and run according tests
lg.log("Checking availibility mode:")
if is_ha():
lg.info("this setup is using a HA database")
if check_listen("127.0.0.1", 54321) and check_listen("127.0.0.1", 54322):
lg.info("this setup is using a master and standby database")
errors = check_ha(db_conn)
else:
lg.info("this setup is using a local database")
lg.info("this setup is using a single database")
errors = check_local(db_conn)
if errors:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment