Using show all slaves status when using MariaDB to be consistent with MySQL (#602)

* Using `show all slaves status` whe using MariaDB to be consistent
with the MySQL behaviour.

* Fixing lint issues

* Fix issue by using dict attribute

* Fix unit tests

* fix lint test

* Add unit tests

* Fix unit tests

* Adding changlog fragment

* Update changelogs/fragments/602-show-all-slaves-status.yaml

Co-authored-by: Laurent Indermühle <laurent.indermuehle@pm.me>

* Refactoring change by moving common logic to the module_utils

* Fix sanity checks

* Fix sanity checks

* Adding lines to fix sanity checks

* Fixing sanity checks

* Update changelogs/fragments/602-show-all-slaves-status.yaml

Co-authored-by: Andrew Klychkov <aaklychkov@mail.ru>

* Removing is_mariadb and is_mysql functions

---------

Co-authored-by: Laurent Indermühle <laurent.indermuehle@pm.me>
Co-authored-by: Andrew Klychkov <aaklychkov@mail.ru>
This commit is contained in:
William Felipe Welter 2024-01-19 14:41:29 +00:00 committed by GitHub
parent 051aa48d8d
commit 852c19a78a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 47 additions and 11 deletions

View file

@ -14,15 +14,15 @@ from ansible_collections.community.mysql.plugins.modules.mysql_info import MySQL
@pytest.mark.parametrize(
'suffix,cursor_output',
'suffix,cursor_output,server_implementation',
[
('mysql', '5.5.1-mysql'),
('log', '5.7.31-log'),
('mariadb', '10.5.0-mariadb'),
('', '8.0.22'),
('mysql', '5.5.1-mysql', 'mysql'),
('log', '5.7.31-log', 'mysql'),
('mariadb', '10.5.0-mariadb', 'mariadb'),
('', '8.0.22', 'mysql'),
]
)
def test_get_info_suffix(suffix, cursor_output):
def test_get_info_suffix(suffix, cursor_output, server_implementation):
def __cursor_return_value(input_parameter):
if input_parameter == "SHOW GLOBAL VARIABLES":
cursor.fetchall.return_value = [{"Variable_name": "version", "Value": cursor_output}]
@ -32,6 +32,6 @@ def test_get_info_suffix(suffix, cursor_output):
cursor = MagicMock()
cursor.execute.side_effect = __cursor_return_value
info = MySQL_Info(MagicMock(), cursor)
info = MySQL_Info(MagicMock(), cursor, server_implementation)
assert info.get_info([], [], False)['version']['suffix'] == suffix