mirror of
https://github.com/ansible-collections/community.mysql.git
synced 2025-04-10 04:30:38 -07:00
* Replace matrix.mysql by matrix.db_engine_version * Specify db flavor * Upgrade dbdeployer to 1.56.0 See https://github.com/datacharmer/dbdeployer/issues/120 * Fix: github workflow syntax * Fix: mysql version file for mariadb engine * Do not test mysql_variables modes persist and persist_only on mariadb Those modes do not exist on mariadb. See https://mariadb.com/kb/en/set/ * Exclude integration tests for mariadb_10.5.4 with pymysql==0.7.10 * TLS on mariadb is disabled by default * Configure mariadb supported versions in matrix As discussed in https://github.com/ansible-collections/community.mysql/discussions/141#discussioncomment-643657 * Fix: test_mysql_db : assert that databases does not exist "assertion": "database1 not in mysql_result.stdout" * Fix: assertion mysql_version in result.version.full * Fix: test_mysql_user : Check that the module made a change and that the expected plugin type is set 'mysql_native_password' in show_create_user.stdout * Fix: test_mysql_replication : Create user for replication ERROR 1064 (42000) at line 1: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'BY 'replication_pass'' at line 1 https://dev.mysql.com/doc/mysql-replication-excerpt/5.7/en/replication-howto-repuser.html https://dev.mysql.com/doc/mysql-replication-excerpt/8.0/en/replication-howto-repuser.html https://mariadb.com/kb/en/setting-up-replication/#example-enabling-replication-for-mariadb Create user syntax compatible with auth plugin and password on both mysql and mariadb. https://dev.mysql.com/doc/refman/8.0/en/create-user.html https://mariadb.com/kb/en/create-user/ * Fix: test_mysql_replication: replica_status 'dict object' has no attribute 'Source_Host' * Do not test mysql_replication_channel.yml on mariadb * Do not test target 'test_mysql_role' with mariadb, too much errors to fix * Setup mysql_version_parts depending on install type (mysql or mariadb) * Install mariadb-client when install_type is mariadb To use the same client tools as the database engine. And to use a more updated mysqldump version, in order to fix this error: ERROR 1556 (HY000) at line 776: You can't use locks with log tables * Fix: mysql auth plugin is set on mariadb >10.2 * Fix: skip assertion on mariadb 10.2 * Do not execute test_user_plugin_auth.yml tests on mariadb, create/update useer sql syntax not compatible * Fix: test_mysql_user : assert user1 TLS requirements Remove test for oldd versions * Fix: typo * Fix: test_mysql_user : Test idempotency (expect ok) ignore mariadb 10.5 * [ci skip] Add changelog fragment * Delete changelog fragment
215 lines
5.7 KiB
YAML
215 lines
5.7 KiB
YAML
####################################################################
|
|
# WARNING: These are designed specifically for Ansible tests #
|
|
# and should not be used as examples of how to write Ansible roles #
|
|
####################################################################
|
|
|
|
# Test code for mysql_info module
|
|
# Copyright: (c) 2019, Andrew Klychkov (@Andersson007) <aaklychkov@mail.ru>
|
|
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
|
|
|
###################
|
|
# Prepare for tests
|
|
#
|
|
|
|
- vars:
|
|
mysql_parameters: &mysql_params
|
|
login_user: '{{ mysql_user }}'
|
|
login_password: '{{ mysql_password }}'
|
|
login_host: '{{ mysql_host }}'
|
|
login_port: '{{ mysql_primary_port }}'
|
|
|
|
block:
|
|
|
|
# Create default MySQL config file with credentials
|
|
- name: mysql_info - create default config file
|
|
template:
|
|
src: my.cnf.j2
|
|
dest: /root/.my.cnf
|
|
mode: '0400'
|
|
|
|
# Create non-default MySQL config file with credentials
|
|
- name: mysql_info - create non-default config file
|
|
template:
|
|
src: my.cnf.j2
|
|
dest: /root/non-default_my.cnf
|
|
mode: '0400'
|
|
|
|
###############
|
|
# Do tests
|
|
|
|
# Access by default cred file
|
|
- name: mysql_info - collect default cred file
|
|
mysql_info:
|
|
login_user: '{{ mysql_user }}'
|
|
login_host: '{{ mysql_host }}'
|
|
login_port: '{{ mysql_primary_port }}'
|
|
register: result
|
|
|
|
- assert:
|
|
that:
|
|
- result.changed == false
|
|
- "mysql_version in result.version.full or mariadb_version in result.version.full"
|
|
- result.settings != {}
|
|
- result.global_status != {}
|
|
- result.databases != {}
|
|
- result.engines != {}
|
|
- result.users != {}
|
|
|
|
# Access by non-default cred file
|
|
- name: mysql_info - check non-default cred file
|
|
mysql_info:
|
|
login_user: '{{ mysql_user }}'
|
|
login_host: '{{ mysql_host }}'
|
|
login_port: '{{ mysql_primary_port }}'
|
|
config_file: /root/non-default_my.cnf
|
|
register: result
|
|
|
|
- assert:
|
|
that:
|
|
- result.changed == false
|
|
- result.version != {}
|
|
|
|
# Remove cred files
|
|
- name: mysql_info - remove cred files
|
|
file:
|
|
path: '{{ item }}'
|
|
state: absent
|
|
with_items:
|
|
- /root/.my.cnf
|
|
- /root/non-default_my.cnf
|
|
|
|
# Access with password
|
|
- name: mysql_info - check access with password
|
|
mysql_info:
|
|
<<: *mysql_params
|
|
register: result
|
|
|
|
- assert:
|
|
that:
|
|
- result.changed == false
|
|
- result.version != {}
|
|
|
|
# Test excluding
|
|
- name: Collect all info except settings and users
|
|
mysql_info:
|
|
<<: *mysql_params
|
|
filter: '!settings,!users'
|
|
register: result
|
|
|
|
- assert:
|
|
that:
|
|
- result.changed == false
|
|
- result.version != {}
|
|
- result.global_status != {}
|
|
- result.databases != {}
|
|
- result.engines != {}
|
|
- result.settings is not defined
|
|
- result.users is not defined
|
|
|
|
# Test including
|
|
- name: Collect info only about version and databases
|
|
mysql_info:
|
|
<<: *mysql_params
|
|
filter:
|
|
- version
|
|
- databases
|
|
register: result
|
|
|
|
- assert:
|
|
that:
|
|
- result.changed == false
|
|
- result.version != {}
|
|
- result.databases != {}
|
|
- result.engines is not defined
|
|
- result.settings is not defined
|
|
- result.global_status is not defined
|
|
- result.users is not defined
|
|
|
|
# Test exclude_fields: db_size
|
|
# 'unsupported' element is passed to check that an unsupported value
|
|
# won't break anything (will be ignored regarding to the module's documentation).
|
|
- name: Collect info about databases excluding their sizes
|
|
mysql_info:
|
|
<<: *mysql_params
|
|
filter:
|
|
- databases
|
|
exclude_fields:
|
|
- db_size
|
|
- unsupported
|
|
register: result
|
|
|
|
- assert:
|
|
that:
|
|
- result.changed == false
|
|
- result.databases != {}
|
|
- result.databases.mysql == {}
|
|
|
|
########################################################
|
|
# Issue #65727, empty databases must be in returned dict
|
|
#
|
|
- name: Create empty database acme
|
|
mysql_db:
|
|
<<: *mysql_params
|
|
name: acme
|
|
|
|
- name: Collect info about databases
|
|
mysql_info:
|
|
<<: *mysql_params
|
|
filter:
|
|
- databases
|
|
return_empty_dbs: true
|
|
register: result
|
|
|
|
# Check acme is in returned dict
|
|
- assert:
|
|
that:
|
|
- result.changed == false
|
|
- result.databases.acme.size == 0
|
|
- result.databases.mysql != {}
|
|
|
|
- name: Collect info about databases excluding their sizes
|
|
mysql_info:
|
|
<<: *mysql_params
|
|
filter:
|
|
- databases
|
|
exclude_fields:
|
|
- db_size
|
|
return_empty_dbs: true
|
|
register: result
|
|
|
|
# Check acme is in returned dict
|
|
- assert:
|
|
that:
|
|
- result.changed == false
|
|
- result.databases.acme == {}
|
|
- result.databases.mysql == {}
|
|
|
|
- name: Remove acme database
|
|
mysql_db:
|
|
<<: *mysql_params
|
|
name: acme
|
|
state: absent
|
|
|
|
- include: issue-28.yml
|
|
|
|
# https://github.com/ansible-collections/community.mysql/issues/204
|
|
- name: Create database containing only views
|
|
mysql_db:
|
|
<<: *mysql_params
|
|
name: allviews
|
|
|
|
- name: Create view
|
|
mysql_query:
|
|
<<: *mysql_params
|
|
login_db: allviews
|
|
query: 'CREATE VIEW v_today (today) AS SELECT CURRENT_DATE'
|
|
|
|
- name: Fetch info
|
|
mysql_info:
|
|
<<: *mysql_params
|
|
register: result
|
|
|
|
- name: Check
|
|
assert:
|
|
that:
|
|
result.databases.allviews.size == 0
|