From 5c01b8c0f17080d695506db1bdc72d315ce9a64c Mon Sep 17 00:00:00 2001 From: Nicolas KAROLAK <nicolas@karolak.fr> Date: Tue, 18 Sep 2018 11:16:49 +0200 Subject: [PATCH] change(test_postgresql): output and format --- tests/test_postgresql.py | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/tests/test_postgresql.py b/tests/test_postgresql.py index 47dfae22..c89bc90a 100755 --- a/tests/test_postgresql.py +++ b/tests/test_postgresql.py @@ -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: -- GitLab