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

Revert "fix(tests): rm type hints in test_postgresql"

This reverts commit 83b7c7dc.
parent 83b7c7dc
No related branches found
No related tags found
No related merge requests found
......@@ -16,7 +16,7 @@ RED = "\033[91m"
DEF = "\033[0m"
def is_ha(port) -> bool:
def is_ha(port: int) -> bool:
"""Check wether this setup is using higlhy-available databases.
:param port: Port number
......@@ -28,7 +28,7 @@ def is_ha(port) -> bool:
return port == 54321
def get_haproxy_conf(path="/etc/haproxy/haproxy.cfg") -> dict:
def get_haproxy_conf(path: str = "/etc/haproxy/haproxy.cfg") -> dict:
"""Get HAProxy configuration in a dictionary.
:param path: HAProxy configuration file, defaults to "/etc/haproxy/haproxy.cfg"
......@@ -66,7 +66,7 @@ def get_haproxy_conf(path="/etc/haproxy/haproxy.cfg") -> dict:
return conf
def get_nodes(conf) -> dict:
def get_nodes(conf: dict) -> dict:
"""Get the list of nodes from HAProxy configuration.
:param conf: The HAProxy configuration file content
......@@ -100,7 +100,7 @@ def get_nodes(conf) -> dict:
return servers
def check_odd_number(number) -> bool:
def check_odd_number(number: int) -> bool:
"""Check if we have an odd number of nodes, ensuring we can have a quorum.
:param number: The number of nodes in the cluster
......@@ -114,7 +114,7 @@ def check_odd_number(number) -> bool:
return modulo != 0
def get_node_state(host, port) -> str:
def get_node_state(host: str, port: int) -> str:
"""Get the curent state of node from its RepHACheck daemon.
:param node: The node's hostname or IP address
......@@ -136,7 +136,7 @@ def get_node_state(host, port) -> str:
return state
def check_primary(nodes) -> tuple:
def check_primary(nodes: dict) -> tuple:
"""Check if we have a primary in the nodes.
:param nodes: The dictionary containing nodes and their informations
......@@ -154,7 +154,7 @@ def check_primary(nodes) -> tuple:
return False, None
def check_standby(nodes) -> tuple:
def check_standby(nodes: dict) -> tuple:
"""Check if we have a standby in the nodes.
:param nodes: The dictionary containing nodes and their informations
......@@ -172,7 +172,7 @@ def check_standby(nodes) -> tuple:
return False, None
def check_witness(nodes) -> tuple:
def check_witness(nodes: dict) -> tuple:
"""Check if we have a witness in the nodes.
:param nodes: The dictionary containing nodes and their informations
......@@ -190,7 +190,7 @@ def check_witness(nodes) -> tuple:
return False, None
def check_fenced(nodes) -> tuple:
def check_fenced(nodes: dict) -> tuple:
"""Check if the cluster have a fenced node.
:param nodes: The dictionary containing nodes and their informations
......@@ -209,7 +209,9 @@ def check_fenced(nodes) -> tuple:
# pylint: disable=bad-continuation
def check_write(host, port, user, pswd, name="postgres") -> bool:
def check_write(
host: str, port: int, user: str, pswd: str, name: str = "postgres"
) -> bool:
"""Check if we can write data on this node.
:param host: Database server's hostname or IP address
......@@ -251,7 +253,9 @@ def check_write(host, port, user, pswd, name="postgres") -> bool:
# pylint: disable=bad-continuation
def check_read(host, port, user, pswd, name="postgres") -> bool:
def check_read(
host: str, port: int, user: str, pswd: str, name: str = "postgres"
) -> bool:
"""Check if we can read data on this node.
:param host: Database server's hostname or IP address
......@@ -291,7 +295,7 @@ def check_read(host, port, user, pswd, name="postgres") -> bool:
return True
def check_replication(primary, standby) -> bool:
def check_replication(primary: dict, standby: dict) -> bool:
"""Check if replication is working between the primary and standby servers.
:param primary: Connection details for primary server
......@@ -330,7 +334,7 @@ def check_replication(primary, standby) -> bool:
return True
def check_listen(host, port) -> bool:
def check_listen(host: str, port: int) -> bool:
"""Check if server is listening (TCP only).
:param host: The hostname or IP address to bind
......@@ -349,7 +353,7 @@ def check_listen(host, port) -> bool:
return result == 0
def check_ha(db_conn, errors=0, warnings=0) -> tuple:
def check_ha(db_conn: dict, errors: int = 0, warnings: int = 0) -> tuple:
"""Run all tests for a highly-available setup.
:param db_conn: Database connection parameters
......@@ -426,7 +430,7 @@ def check_ha(db_conn, errors=0, warnings=0) -> tuple:
return errors, warnings
def check_local(db_conn, errors=0, warnings=0) -> tuple:
def check_local(db_conn: dict, errors: int = 0, warnings: int = 0) -> tuple:
"""Run all tests for a highly-available setup.
:param db_conn: Database connection parameters
......
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