mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
mysql_info: added spaces to CI tests (#146)
* mysql_info: added spaces to CI tests * added comments * added comments
This commit is contained in:
parent
6dd5cb5dea
commit
758561070a
1 changed files with 49 additions and 0 deletions
|
@ -1,3 +1,12 @@
|
||||||
|
# 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
|
||||||
|
#
|
||||||
|
|
||||||
|
# Create role for tests
|
||||||
- name: mysql_info - create mysql user {{ user_name }}
|
- name: mysql_info - create mysql user {{ user_name }}
|
||||||
mysql_user:
|
mysql_user:
|
||||||
name: '{{ user_name }}'
|
name: '{{ user_name }}'
|
||||||
|
@ -5,20 +14,30 @@
|
||||||
state: present
|
state: present
|
||||||
priv: '*.*:ALL'
|
priv: '*.*:ALL'
|
||||||
login_unix_socket: '{{ mysql_socket }}'
|
login_unix_socket: '{{ mysql_socket }}'
|
||||||
|
|
||||||
|
# Create default MySQL config file with credentials
|
||||||
- name: mysql_info - create default config file
|
- name: mysql_info - create default config file
|
||||||
template:
|
template:
|
||||||
src: my.cnf.j2
|
src: my.cnf.j2
|
||||||
dest: /root/.my.cnf
|
dest: /root/.my.cnf
|
||||||
mode: '0400'
|
mode: '0400'
|
||||||
|
|
||||||
|
# Create non-default MySQL config file with credentials
|
||||||
- name: mysql_info - create non-default config file
|
- name: mysql_info - create non-default config file
|
||||||
template:
|
template:
|
||||||
src: my.cnf.j2
|
src: my.cnf.j2
|
||||||
dest: /root/non-default_my.cnf
|
dest: /root/non-default_my.cnf
|
||||||
mode: '0400'
|
mode: '0400'
|
||||||
|
|
||||||
|
###############
|
||||||
|
# Do tests
|
||||||
|
|
||||||
|
# Access by default cred file
|
||||||
- name: mysql_info - collect default cred file
|
- name: mysql_info - collect default cred file
|
||||||
mysql_info:
|
mysql_info:
|
||||||
login_user: '{{ user_name }}'
|
login_user: '{{ user_name }}'
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- assert:
|
- assert:
|
||||||
that:
|
that:
|
||||||
- result.changed == false
|
- result.changed == false
|
||||||
|
@ -28,15 +47,20 @@
|
||||||
- result.databases != {}
|
- result.databases != {}
|
||||||
- result.engines != {}
|
- result.engines != {}
|
||||||
- result.users != {}
|
- result.users != {}
|
||||||
|
|
||||||
|
# Access by non-default cred file
|
||||||
- name: mysql_info - check non-default cred file
|
- name: mysql_info - check non-default cred file
|
||||||
mysql_info:
|
mysql_info:
|
||||||
login_user: '{{ user_name }}'
|
login_user: '{{ user_name }}'
|
||||||
config_file: /root/non-default_my.cnf
|
config_file: /root/non-default_my.cnf
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- assert:
|
- assert:
|
||||||
that:
|
that:
|
||||||
- result.changed == false
|
- result.changed == false
|
||||||
- result.version != {}
|
- result.version != {}
|
||||||
|
|
||||||
|
# Remove cred files
|
||||||
- name: mysql_info - remove cred files
|
- name: mysql_info - remove cred files
|
||||||
file:
|
file:
|
||||||
path: '{{ item }}'
|
path: '{{ item }}'
|
||||||
|
@ -44,21 +68,27 @@
|
||||||
with_items:
|
with_items:
|
||||||
- /root/.my.cnf
|
- /root/.my.cnf
|
||||||
- /root/non-default_my.cnf
|
- /root/non-default_my.cnf
|
||||||
|
|
||||||
|
# Access with password
|
||||||
- name: mysql_info - check access with password
|
- name: mysql_info - check access with password
|
||||||
mysql_info:
|
mysql_info:
|
||||||
login_user: '{{ user_name }}'
|
login_user: '{{ user_name }}'
|
||||||
login_password: '{{ user_pass }}'
|
login_password: '{{ user_pass }}'
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- assert:
|
- assert:
|
||||||
that:
|
that:
|
||||||
- result.changed == false
|
- result.changed == false
|
||||||
- result.version != {}
|
- result.version != {}
|
||||||
|
|
||||||
|
# Test excluding
|
||||||
- name: Collect all info except settings and users
|
- name: Collect all info except settings and users
|
||||||
mysql_info:
|
mysql_info:
|
||||||
login_user: '{{ user_name }}'
|
login_user: '{{ user_name }}'
|
||||||
login_password: '{{ user_pass }}'
|
login_password: '{{ user_pass }}'
|
||||||
filter: '!settings,!users'
|
filter: '!settings,!users'
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- assert:
|
- assert:
|
||||||
that:
|
that:
|
||||||
- result.changed == false
|
- result.changed == false
|
||||||
|
@ -68,6 +98,8 @@
|
||||||
- result.engines != {}
|
- result.engines != {}
|
||||||
- result.settings is not defined
|
- result.settings is not defined
|
||||||
- result.users is not defined
|
- result.users is not defined
|
||||||
|
|
||||||
|
# Test including
|
||||||
- name: Collect info only about version and databases
|
- name: Collect info only about version and databases
|
||||||
mysql_info:
|
mysql_info:
|
||||||
login_user: '{{ user_name }}'
|
login_user: '{{ user_name }}'
|
||||||
|
@ -76,6 +108,7 @@
|
||||||
- version
|
- version
|
||||||
- databases
|
- databases
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- assert:
|
- assert:
|
||||||
that:
|
that:
|
||||||
- result.changed == false
|
- result.changed == false
|
||||||
|
@ -85,6 +118,10 @@
|
||||||
- result.settings is not defined
|
- result.settings is not defined
|
||||||
- result.global_status is not defined
|
- result.global_status is not defined
|
||||||
- result.users 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
|
- name: Collect info about databases excluding their sizes
|
||||||
mysql_info:
|
mysql_info:
|
||||||
login_user: '{{ user_name }}'
|
login_user: '{{ user_name }}'
|
||||||
|
@ -95,16 +132,22 @@
|
||||||
- db_size
|
- db_size
|
||||||
- unsupported
|
- unsupported
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- assert:
|
- assert:
|
||||||
that:
|
that:
|
||||||
- result.changed == false
|
- result.changed == false
|
||||||
- result.databases != {}
|
- result.databases != {}
|
||||||
- result.databases.mysql == {}
|
- result.databases.mysql == {}
|
||||||
|
|
||||||
|
########################################################
|
||||||
|
# Issue #65727, empty databases must be in returned dict
|
||||||
|
#
|
||||||
- name: Create empty database acme
|
- name: Create empty database acme
|
||||||
mysql_db:
|
mysql_db:
|
||||||
login_user: '{{ user_name }}'
|
login_user: '{{ user_name }}'
|
||||||
login_password: '{{ user_pass }}'
|
login_password: '{{ user_pass }}'
|
||||||
name: acme
|
name: acme
|
||||||
|
|
||||||
- name: Collect info about databases
|
- name: Collect info about databases
|
||||||
mysql_info:
|
mysql_info:
|
||||||
login_user: '{{ user_name }}'
|
login_user: '{{ user_name }}'
|
||||||
|
@ -113,11 +156,14 @@
|
||||||
- databases
|
- databases
|
||||||
return_empty_dbs: true
|
return_empty_dbs: true
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
|
# Check acme is in returned dict
|
||||||
- assert:
|
- assert:
|
||||||
that:
|
that:
|
||||||
- result.changed == false
|
- result.changed == false
|
||||||
- result.databases.acme.size == 0
|
- result.databases.acme.size == 0
|
||||||
- result.databases.mysql != {}
|
- result.databases.mysql != {}
|
||||||
|
|
||||||
- name: Collect info about databases excluding their sizes
|
- name: Collect info about databases excluding their sizes
|
||||||
mysql_info:
|
mysql_info:
|
||||||
login_user: '{{ user_name }}'
|
login_user: '{{ user_name }}'
|
||||||
|
@ -128,11 +174,14 @@
|
||||||
- db_size
|
- db_size
|
||||||
return_empty_dbs: true
|
return_empty_dbs: true
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
|
# Check acme is in returned dict
|
||||||
- assert:
|
- assert:
|
||||||
that:
|
that:
|
||||||
- result.changed == false
|
- result.changed == false
|
||||||
- result.databases.acme == {}
|
- result.databases.acme == {}
|
||||||
- result.databases.mysql == {}
|
- result.databases.mysql == {}
|
||||||
|
|
||||||
- name: Remove acme database
|
- name: Remove acme database
|
||||||
mysql_db:
|
mysql_db:
|
||||||
login_user: '{{ user_name }}'
|
login_user: '{{ user_name }}'
|
||||||
|
|
Loading…
Reference in a new issue