summaryrefslogtreecommitdiffstats
path: root/test/integration/targets/mysql_info
diff options
context:
space:
mode:
authorAndrey Klychkov <aaklychkov@mail.ru>2019-05-28 09:10:12 +0200
committerFelix Fontein <felix@fontein.de>2019-05-28 09:10:12 +0200
commitbaac1df93566e985a06ffac97eae0b7c99bbbd4b (patch)
treee094a227581d039e3c20552981e530da53302e74 /test/integration/targets/mysql_info
parent$result.reboot_required = $feature_result.RestartNeeded (#56419) (diff)
downloadansible-baac1df93566e985a06ffac97eae0b7c99bbbd4b.tar.xz
ansible-baac1df93566e985a06ffac97eae0b7c99bbbd4b.zip
New module mysql_info - Gather information about MySQL servers (#55434)
* New module mysql_info: collect info about MySQL server instance * mysql_info - CI tests * mysql_info: fixes * mysql_info: fixes Decimal * mysql_info: fixes Decimal converters.py * mysql_info: fixed err conn message and check_mode * mysql_info: added decimal.Decimal to lib/ansible/parsing/ajson.py * mysql_info: convert Decimal to float * mysql_info: fix * mysql_info: fix * mysql_info: returned the args list as it was * mysql_info: fix typo * mysql_info: fixes * mysql_info: removed aliases for login_db * mysql_info: changed RETURN condition info * mysql_info: fixed doc * mysql_info: fixed role's parsing * mysql_info: fixed role's parsing * mysql_info: fixes * mysql_info: fixed integration tests
Diffstat (limited to 'test/integration/targets/mysql_info')
-rw-r--r--test/integration/targets/mysql_info/aliases4
-rw-r--r--test/integration/targets/mysql_info/defaults/main.yml5
-rw-r--r--test/integration/targets/mysql_info/meta/main.yml3
-rw-r--r--test/integration/targets/mysql_info/tasks/main.yml117
-rw-r--r--test/integration/targets/mysql_info/templates/my.cnf.j23
5 files changed, 132 insertions, 0 deletions
diff --git a/test/integration/targets/mysql_info/aliases b/test/integration/targets/mysql_info/aliases
new file mode 100644
index 0000000000..5eb727b09b
--- /dev/null
+++ b/test/integration/targets/mysql_info/aliases
@@ -0,0 +1,4 @@
+destructive
+shippable/posix/group1
+skip/osx
+skip/freebsd
diff --git a/test/integration/targets/mysql_info/defaults/main.yml b/test/integration/targets/mysql_info/defaults/main.yml
new file mode 100644
index 0000000000..6d44dbd377
--- /dev/null
+++ b/test/integration/targets/mysql_info/defaults/main.yml
@@ -0,0 +1,5 @@
+---
+# defaults file for test_mysql_info
+db_name: data
+user_name: alice
+user_pass: alice
diff --git a/test/integration/targets/mysql_info/meta/main.yml b/test/integration/targets/mysql_info/meta/main.yml
new file mode 100644
index 0000000000..1892924b21
--- /dev/null
+++ b/test/integration/targets/mysql_info/meta/main.yml
@@ -0,0 +1,3 @@
+dependencies:
+ - setup_mysql_db
+ - setup_remote_tmp_dir
diff --git a/test/integration/targets/mysql_info/tasks/main.yml b/test/integration/targets/mysql_info/tasks/main.yml
new file mode 100644
index 0000000000..e4c1be92ad
--- /dev/null
+++ b/test/integration/targets/mysql_info/tasks/main.yml
@@ -0,0 +1,117 @@
+# 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 }}
+ mysql_user:
+ name: '{{ user_name }}'
+ password: '{{ user_pass }}'
+ state: present
+ priv: '*.*:ALL'
+ login_unix_socket: '{{ mysql_socket }}'
+
+# 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: '{{ user_name }}'
+ register: result
+
+- assert:
+ that:
+ - result.changed == false
+ - result.version != {}
+ - result.settings != {}
+ - result.databases != {}
+ - result.engines != {}
+ - result.users != {}
+
+# Access by non-default cred file
+- name: mysql_info - check non-default cred file
+ mysql_info:
+ login_user: '{{ user_name }}'
+ 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:
+ login_user: '{{ user_name }}'
+ login_password: '{{ user_pass }}'
+ register: result
+
+- assert:
+ that:
+ - result.changed == false
+ - result.version != {}
+
+# Test excluding
+- name: Collect all info except settings and users
+ mysql_info:
+ login_user: '{{ user_name }}'
+ login_password: '{{ user_pass }}'
+ filter: "!settings,!users"
+ register: result
+
+- assert:
+ that:
+ - result.changed == false
+ - result.version != {}
+ - 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:
+ login_user: '{{ user_name }}'
+ login_password: '{{ user_pass }}'
+ 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.users is not defined
diff --git a/test/integration/targets/mysql_info/templates/my.cnf.j2 b/test/integration/targets/mysql_info/templates/my.cnf.j2
new file mode 100644
index 0000000000..467afa0746
--- /dev/null
+++ b/test/integration/targets/mysql_info/templates/my.cnf.j2
@@ -0,0 +1,3 @@
+[client]
+user={{ user_name }}
+password={{ user_pass }}