From 778fbd497c8a9bcd58ff3c748c3620e418b70a36 Mon Sep 17 00:00:00 2001 From: Tomas Date: Wed, 29 Nov 2023 09:16:05 +0200 Subject: [PATCH] make integration tests work --- plugins/modules/mysql_role.py | 3 ++- .../targets/setup_controller/tasks/verify.yml | 8 ++++---- .../test_mysql_db/tasks/state_dump_import.yml | 4 +++- .../tasks/mysql_replication_initial.yml | 18 +++++++++++++----- 4 files changed, 22 insertions(+), 11 deletions(-) diff --git a/plugins/modules/mysql_role.py b/plugins/modules/mysql_role.py index e892093..24d8aae 100644 --- a/plugins/modules/mysql_role.py +++ b/plugins/modules/mysql_role.py @@ -932,7 +932,8 @@ class Role(): result = user_mod(self.cursor, self.name, self.host, None, None, None, None, None, None, privs, append_privs, subtract_privs, None, - self.module, role=True, maria_role=self.is_mariadb) + self.module, None, None, role=True, + maria_role=self.is_mariadb) changed = result['changed'] if admin: diff --git a/tests/integration/targets/setup_controller/tasks/verify.yml b/tests/integration/targets/setup_controller/tasks/verify.yml index 5140533..a1e7717 100644 --- a/tests/integration/targets/setup_controller/tasks/verify.yml +++ b/tests/integration/targets/setup_controller/tasks/verify.yml @@ -16,15 +16,15 @@ - version register: primary_info - - set_fact: - registred_db_version: "'{{ primary_info.version.major }}.{{ primary_info.version.minor }}\ - .{{ primary_info.version.release }}'" - db_version_value: "'{{ db_version }}'" - name: Assert that test container runs the expected MySQL/MariaDB version assert: that: - registred_db_version == db_version_value + vars: + registred_db_version: "'{{ primary_info.version.major }}.{{ primary_info.version.minor }}\ + .{{ primary_info.version.release }}'" + db_version_value: "'{{ db_version }}'" - name: Assert that mysql_info module used the expected version of pymysql assert: diff --git a/tests/integration/targets/test_mysql_db/tasks/state_dump_import.yml b/tests/integration/targets/test_mysql_db/tasks/state_dump_import.yml index b4f9cda..79a23de 100644 --- a/tests/integration/targets/test_mysql_db/tasks/state_dump_import.yml +++ b/tests/integration/targets/test_mysql_db/tasks/state_dump_import.yml @@ -339,7 +339,9 @@ assert: that: - result is changed - - "result.db =='{{ db_name }}'" + - result.db == db_name_value + vars: + db_name_value: "{{ db_name }}" # - name: Dump and Import | Assert database was backed up successfully # command: "file {{ db_file_name }}" diff --git a/tests/integration/targets/test_mysql_replication/tasks/mysql_replication_initial.yml b/tests/integration/targets/test_mysql_replication/tasks/mysql_replication_initial.yml index ca7301c..806fb48 100644 --- a/tests/integration/targets/test_mysql_replication/tasks/mysql_replication_initial.yml +++ b/tests/integration/targets/test_mysql_replication/tasks/mysql_replication_initial.yml @@ -158,7 +158,9 @@ assert: that: - result is changed - - result.queries == ["CHANGE MASTER TO MASTER_HOST='{{ mysql_host }}',MASTER_USER='{{ replication_user }}',MASTER_PASSWORD='********',MASTER_PORT={{ mysql_primary_port }},MASTER_LOG_FILE='{{ mysql_primary_status.File }}',MASTER_LOG_POS={{ mysql_primary_status.Position }},MASTER_SSL=0,MASTER_SSL_CA=''"] + - result.queries == result_query + vars: + result_query: ["CHANGE MASTER TO MASTER_HOST='{{ mysql_host }}',MASTER_USER='{{ replication_user }}',MASTER_PASSWORD='********',MASTER_PORT={{ mysql_primary_port }},MASTER_LOG_FILE='{{ mysql_primary_status.File }}',MASTER_LOG_POS={{ mysql_primary_status.Position }},MASTER_SSL=0,MASTER_SSL_CA=''"] # Test startreplica mode: - name: Start replica @@ -186,25 +188,31 @@ assert: that: - replica_status.Is_Replica == true - - replica_status.Master_Host == '{{ mysql_host }}' + - replica_status.Master_Host == mysql_host_value - replica_status.Exec_Master_Log_Pos == mysql_primary_status.Position - - replica_status.Master_Port == {{ mysql_primary_port }} + - replica_status.Master_Port == mysql_primary_port_value - replica_status.Last_IO_Errno == 0 - replica_status.Last_IO_Error == '' - replica_status is not changed when: mysql8022_and_higher == false + vars: + mysql_host_value: "{{ mysql_host }}" + mysql_primary_port_value: "{{ mysql_primary_port }}" - name: Assert that getreplica returns expected values for MySQL newer than 8.0.22 assert: that: - replica_status.Is_Replica == true - - replica_status.Source_Host == '{{ mysql_host }}' + - replica_status.Source_Host == mysql_host_value - replica_status.Exec_Source_Log_Pos == mysql_primary_status.Position - - replica_status.Source_Port == {{ mysql_primary_port }} + - replica_status.Source_Port == mysql_primary_port_value - replica_status.Last_IO_Errno == 0 - replica_status.Last_IO_Error == '' - replica_status is not changed when: mysql8022_and_higher == true + vars: + mysql_host_value: "{{ mysql_host }}" + mysql_primary_port_value: "{{ mysql_primary_port }}" # Create test table and add data to it: - name: Create test table