Skip to content
Snippets Groups Projects
Commit 5c01b8c0 authored by Nicolas KAROLAK's avatar Nicolas KAROLAK
Browse files

change(test_postgresql): output and format

parent e1ed8a76
No related branches found
No related tags found
No related merge requests found
......@@ -298,10 +298,10 @@ def check_ha(db_conn: dict, errors: int = 0) -> int:
node_host = nodes[node]["host"]
node_port = nodes[node]["port"]
if not check_listen(node_host, node_port):
u.error("Cannot bind {}:{}".format(node_host, node_port))
u.error("cannot bind {}:{}".format(node_host, node_port))
errors += 1
else:
u.success("Can bind {}:{}".format(node_host, node_port))
u.success("can bind {}:{}".format(node_host, node_port))
# check fenced
print("Checking cluster state:")
......@@ -320,10 +320,10 @@ def check_ha(db_conn: dict, errors: int = 0) -> int:
standby["port"] = 54322
status, info = check_replication(primary, standby)
if not status:
u.error("Cannot replicate between primary/standby ({})".format(info))
u.error("cannot replicate between primary/standby ({})".format(info))
errors += 1
else:
u.success("Can replicate between primary/standby ({})".format(info))
u.success("can replicate between primary/standby ({})".format(info))
return errors
......@@ -346,20 +346,20 @@ def check_local(db_conn: dict, errors: int = 0) -> int:
# check listen
print("Checking local PostgreSQL node:")
if not check_listen(host, port):
u.error("Cannot connect to {}:{}".format(host, port))
u.error("cannot connect to {}:{}".format(host, port))
errors += 1
else:
u.success("Can connect to {}:{}".format(host, port))
u.success("can connect to {}:{}".format(host, port))
# check read
print("Checking read operation:")
read_query = "SELECT 1;"
status, info = check_psql(db_conn, read_query)
if not status:
u.error("Cannot read from {}@{}:{} ({})".format(user, host, port, info))
u.error("cannot read from {}@{}:{} ({})".format(user, host, port, info))
errors += 1
else:
u.success("Can read from {}@{}:{}".format(user, host, port))
u.success("can read from {}@{}:{}".format(user, host, port))
# check write
print("Checking write operation:")
......@@ -367,10 +367,10 @@ def check_local(db_conn: dict, errors: int = 0) -> int:
write_query = "CREATE TABLE es_test_{} (id serial PRIMARY KEY);".format(rand)
status, info = check_psql(db_conn, write_query)
if not status:
u.error("Cannot write on {}@{}:{} ({})".format(user, host, port, info))
u.error("cannot write on {}@{}:{} ({})".format(user, host, port, info))
errors += 1
else:
u.success("Can write on {}@{}:{}".format(user, host, port))
u.success("can write on {}@{}:{}".format(user, host, port))
# remove test table
check_psql(db_conn, "DROP TABLE es_test_{};".format(rand))
......@@ -393,11 +393,12 @@ def main():
db_conn.update({"password": db_pass})
# determine if HA setup and run according tests
print("Checking availibility mode:")
if is_ha(db_port):
print("This setup is using a HA database")
u.info("this setup is using a HA database")
errors = check_ha(db_conn)
else:
print("This setup is using a local database")
u.info("this setup is using a local 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