mirror of
https://github.com/ansible-collections/community.mysql.git
synced 2025-07-24 13:50:26 -07:00
fix tests (include
deprecation) (#554)
* tests: change deprecated "include" to "include_tasks" * tests: fix syntax --------- Co-authored-by: Felix Hamme <felix.hamme@ionos.com>
This commit is contained in:
parent
b6ad472c78
commit
2fcfb103f6
19 changed files with 352 additions and 101 deletions
|
@ -37,7 +37,11 @@
|
|||
variable: '{{ set_name }}'
|
||||
register: result
|
||||
|
||||
- include: assert_var_output.yml changed=false output={{ result }} var_name={{ set_name }}
|
||||
- include_tasks: assert_var_output.yml
|
||||
vars:
|
||||
changed: false
|
||||
output: "{{ result }}"
|
||||
var_name: "{{ set_name }}"
|
||||
|
||||
# ============================================================
|
||||
# Verify mysql_variable successfully updates a variable (issue:4568)
|
||||
|
@ -59,7 +63,12 @@
|
|||
value: '{{ set_value }}'
|
||||
register: result
|
||||
|
||||
- include: assert_var.yml changed=false output={{ result }} var_name={{ set_name }} var_value={{ set_value }}
|
||||
- include_tasks: assert_var.yml
|
||||
vars:
|
||||
changed: false
|
||||
output: "{{ result }}"
|
||||
var_name: "{{ set_name }}"
|
||||
var_value: "{{ set_value }}"
|
||||
|
||||
# ============================================================
|
||||
# Verify mysql_variable successfully updates a variable using single quotes
|
||||
|
@ -85,7 +94,12 @@
|
|||
that:
|
||||
- result.queries == ["SET GLOBAL `{{ set_name }}` = {{ set_value }}"]
|
||||
|
||||
- include: assert_var.yml changed=true output={{ result }} var_name={{ set_name }} var_value='{{ set_value }}'
|
||||
- include_tasks: assert_var.yml
|
||||
vars:
|
||||
changed: true
|
||||
output: "{{ result }}"
|
||||
var_name: "{{ set_name }}"
|
||||
var_value: '{{ set_value }}'
|
||||
|
||||
# ============================================================
|
||||
# Verify mysql_variable successfully updates a variable using double quotes
|
||||
|
@ -107,7 +121,12 @@
|
|||
value: '{{ set_value }}'
|
||||
register: result
|
||||
|
||||
- include: assert_var.yml changed=true output={{ result }} var_name={{ set_name }} var_value='{{ set_value }}'
|
||||
- include_tasks: assert_var.yml
|
||||
vars:
|
||||
changed: true
|
||||
output: "{{ result }}"
|
||||
var_name: "{{ set_name }}"
|
||||
var_value: '{{ set_value }}'
|
||||
|
||||
# ============================================================
|
||||
# Verify mysql_variable successfully updates a variable using no quotes
|
||||
|
@ -129,7 +148,12 @@
|
|||
value: '{{ set_value }}'
|
||||
register: result
|
||||
|
||||
- include: assert_var.yml changed=true output={{ result }} var_name={{ set_name }} var_value='{{ set_value }}'
|
||||
- include_tasks: assert_var.yml
|
||||
vars:
|
||||
changed: true
|
||||
output: "{{ result }}"
|
||||
var_name: "{{ set_name }}"
|
||||
var_value: '{{ set_value }}'
|
||||
|
||||
# ============================================================
|
||||
# Verify mysql_variable successfully updates a variable using an expression (e.g. 1024*4)
|
||||
|
@ -142,7 +166,10 @@
|
|||
register: result
|
||||
ignore_errors: true
|
||||
|
||||
- include: assert_fail_msg.yml output={{ result }} msg='Incorrect argument type to variable'
|
||||
- include_tasks: assert_fail_msg.yml
|
||||
vars:
|
||||
output: "{{ result }}"
|
||||
msg: 'Incorrect argument type to variable'
|
||||
|
||||
# ============================================================
|
||||
# Verify mysql_variable fails when setting an incorrect value (out of range)
|
||||
|
@ -155,12 +182,20 @@
|
|||
register: oor_result
|
||||
ignore_errors: true
|
||||
|
||||
- include: assert_var.yml changed=true output={{ oor_result }} var_name=max_connect_errors var_value=1
|
||||
- include_tasks: assert_var.yml
|
||||
vars:
|
||||
changed: true
|
||||
output: "{{ oor_result }}"
|
||||
var_name: max_connect_errors
|
||||
var_value: 1
|
||||
when:
|
||||
- connector_name == 'mysqlclient'
|
||||
- db_engine == 'mysql' # mysqlclient returns "changed" with MariaDB
|
||||
|
||||
- include: assert_fail_msg.yml output={{ oor_result }} msg='Truncated incorrect'
|
||||
- include_tasks: assert_fail_msg.yml
|
||||
vars:
|
||||
output: "{{ oor_result }}"
|
||||
msg: 'Truncated incorrect'
|
||||
when:
|
||||
- connector_name == 'pymsql'
|
||||
|
||||
|
@ -175,7 +210,10 @@
|
|||
register: nvv_result
|
||||
ignore_errors: true
|
||||
|
||||
- include: assert_fail_msg.yml output={{ nvv_result }} msg='Incorrect argument type to variable'
|
||||
- include_tasks: assert_fail_msg.yml
|
||||
vars:
|
||||
output: "{{ nvv_result }}"
|
||||
msg: 'Incorrect argument type to variable'
|
||||
|
||||
# ============================================================
|
||||
# Verify mysql_variable fails when setting an unknown variable
|
||||
|
@ -188,7 +226,10 @@
|
|||
register: result
|
||||
ignore_errors: true
|
||||
|
||||
- include: assert_fail_msg.yml output={{ result }} msg='Variable not available'
|
||||
- include_tasks: assert_fail_msg.yml
|
||||
vars:
|
||||
output: "{{ result }}"
|
||||
msg: 'Variable not available'
|
||||
|
||||
# ============================================================
|
||||
# Verify mysql_variable fails when setting a read-only variable
|
||||
|
@ -201,7 +242,10 @@
|
|||
register: result
|
||||
ignore_errors: true
|
||||
|
||||
- include: assert_fail_msg.yml output={{ result }} msg='read only variable'
|
||||
- include_tasks: assert_fail_msg.yml
|
||||
vars:
|
||||
output: "{{ result }}"
|
||||
msg: 'read only variable'
|
||||
|
||||
#=============================================================
|
||||
# Verify mysql_variable works with the login_user and login_password parameters
|
||||
|
@ -216,7 +260,11 @@
|
|||
variable: '{{ set_name }}'
|
||||
register: result
|
||||
|
||||
- include: assert_var_output.yml changed=false output={{ result }} var_name={{ set_name }}
|
||||
- include_tasks: assert_var_output.yml
|
||||
vars:
|
||||
changed: false
|
||||
output: "{{ result }}"
|
||||
var_name: "{{ set_name }}"
|
||||
|
||||
- name: set mysql variable to temp value using user login and password (expect changed=true)
|
||||
mysql_variables:
|
||||
|
@ -232,7 +280,12 @@
|
|||
value: '{{set_value}}'
|
||||
register: result
|
||||
|
||||
- include: assert_var.yml changed=true output={{result}} var_name={{set_name}} var_value='{{set_value}}'
|
||||
- include_tasks: assert_var.yml
|
||||
vars:
|
||||
changed: true
|
||||
output: "{{result}}"
|
||||
var_name: "{{set_name}}"
|
||||
var_value: '{{set_value}}'
|
||||
|
||||
#============================================================
|
||||
# Verify mysql_variable fails with an incorrect login_password parameter
|
||||
|
@ -251,7 +304,10 @@
|
|||
register: result
|
||||
ignore_errors: true
|
||||
|
||||
- include: assert_fail_msg.yml output={{ result }} msg='unable to connect to database'
|
||||
- include_tasks: assert_fail_msg.yml
|
||||
vars:
|
||||
output: "{{ result }}"
|
||||
msg: 'unable to connect to database'
|
||||
|
||||
- name: update mysql variable value using incorrect login_password (expect failed=true)
|
||||
mysql_variables:
|
||||
|
@ -264,7 +320,10 @@
|
|||
register: result
|
||||
ignore_errors: true
|
||||
|
||||
- include: assert_fail_msg.yml output={{ result }} msg='unable to connect to database'
|
||||
- include_tasks: assert_fail_msg.yml
|
||||
vars:
|
||||
output: "{{ result }}"
|
||||
msg: 'unable to connect to database'
|
||||
|
||||
#============================================================
|
||||
# Verify mysql_variable fails with an incorrect login_host parameter
|
||||
|
@ -280,7 +339,10 @@
|
|||
register: result
|
||||
ignore_errors: true
|
||||
|
||||
- include: assert_fail_msg.yml output={{ result }} msg='unable to connect to database'
|
||||
- include_tasks: assert_fail_msg.yml
|
||||
vars:
|
||||
output: "{{ result }}"
|
||||
msg: 'unable to connect to database'
|
||||
|
||||
- block:
|
||||
|
||||
|
@ -299,7 +361,12 @@
|
|||
that:
|
||||
- result.queries == ["SET PERSIST `{{ set_name }}` = {{ set_value }}"]
|
||||
|
||||
- include: assert_var.yml changed=true output={{ result }} var_name={{ set_name }} var_value='{{ set_value }}'
|
||||
- include_tasks: assert_var.yml
|
||||
vars:
|
||||
changed: true
|
||||
output: "{{ result }}"
|
||||
var_name: "{{ set_name }}"
|
||||
var_value: '{{ set_value }}'
|
||||
|
||||
- name: try to update mysql variable value (expect changed=false) in persist mode again
|
||||
mysql_variables:
|
||||
|
@ -309,7 +376,12 @@
|
|||
mode: persist
|
||||
register: result
|
||||
|
||||
- include: assert_var.yml changed=false output={{ result }} var_name={{ set_name }} var_value='{{ set_value }}'
|
||||
- include_tasks: assert_var.yml
|
||||
vars:
|
||||
changed: false
|
||||
output: "{{ result }}"
|
||||
var_name: "{{ set_name }}"
|
||||
var_value: '{{ set_value }}'
|
||||
|
||||
- name: set mysql variable to a temp value
|
||||
mysql_variables:
|
||||
|
@ -356,7 +428,12 @@
|
|||
mode: persist_only
|
||||
register: result
|
||||
|
||||
- include: assert_var.yml changed=true output={{ result }} var_name={{ set_name }} var_value='{{ def_val }}'
|
||||
- include_tasks: assert_var.yml
|
||||
vars:
|
||||
changed: true
|
||||
output: "{{ result }}"
|
||||
var_name: "{{ set_name }}"
|
||||
var_value: '{{ def_val }}'
|
||||
|
||||
when:
|
||||
- db_engine == 'mysql'
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue