Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
ansible
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
OpenEdx
ansible
Commits
a88dc7a2
Commit
a88dc7a2
authored
Aug 02, 2014
by
Michael DeHaan
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #8398 from wrosario/integration_mysql_variables
Adding test Coverage for mysql_variable module
parents
78ee3b4a
2957a8de
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
313 additions
and
0 deletions
+313
-0
test/integration/destructive.yml
+2
-0
test/integration/roles/test_mysql_variables/defaults/main.yml
+5
-0
test/integration/roles/test_mysql_variables/meta/main.yml
+2
-0
test/integration/roles/test_mysql_variables/tasks/assert_fail_msg.yml
+27
-0
test/integration/roles/test_mysql_variables/tasks/assert_var.yml
+36
-0
test/integration/roles/test_mysql_variables/tasks/assert_var_output.yml
+38
-0
test/integration/roles/test_mysql_variables/tasks/main.yml
+203
-0
No files found.
test/integration/destructive.yml
View file @
a88dc7a2
...
@@ -9,3 +9,5 @@
...
@@ -9,3 +9,5 @@
-
{
role
:
test_apt_repository
,
tags
:
test_apt_repository
}
-
{
role
:
test_apt_repository
,
tags
:
test_apt_repository
}
-
{
role
:
test_mysql_db
,
tags
:
test_mysql_db
}
-
{
role
:
test_mysql_db
,
tags
:
test_mysql_db
}
-
{
role
:
test_mysql_user
,
tags
:
test_mysql_user
}
-
{
role
:
test_mysql_user
,
tags
:
test_mysql_user
}
-
{
role
:
test_mysql_user
,
tags
:
test_mysql_user
}
-
{
role
:
test_mysql_variables
,
tags
:
test_mysql_variables
}
test/integration/roles/test_mysql_variables/defaults/main.yml
0 → 100644
View file @
a88dc7a2
---
# defaults file for test_mysql_variables
user
:
'
user1'
password
:
'
password1'
test/integration/roles/test_mysql_variables/meta/main.yml
0 → 100644
View file @
a88dc7a2
dependencies
:
-
setup_mysql_db
test/integration/roles/test_mysql_variables/tasks/assert_fail_msg.yml
0 → 100644
View file @
a88dc7a2
# test code to assert message in mysql_variables module
# (c) 2014, Wayne Rosario <wrosario@ansible.com>
# This file is part of Ansible
#
# Ansible is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Ansible is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
# ============================================================
# Assert message failure and confirm failed=true
#
-
name
:
assert message failure (expect failed=true)
assert
:
that
:
-
"
output.failed
==
true"
-
"
'{{msg}}'
in
output.msg"
test/integration/roles/test_mysql_variables/tasks/assert_var.yml
0 → 100644
View file @
a88dc7a2
# test code to assert variables in mysql_variables module
# (c) 2014, Wayne Rosario <wrosario@ansible.com>
# This file is part of Ansible
#
# Ansible is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Ansible is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
# ============================================================
# Assert mysql variable name and value from mysql database
#
-
name
:
assert output message changed value
assert
:
{
that
:
"
output.changed
==
{{changed}}"
}
-
name
:
run mysql command to show variable
command
:
mysql "-e show variables like '{{var_name}}';"
register
:
result
-
name
:
assert output mysql variable name and value
assert
:
that
:
-
"
result.changed
==
true"
-
"
'{{var_name}}'
in
result.stdout"
-
"
'{{var_value}}'
in
result.stdout"
test/integration/roles/test_mysql_variables/tasks/assert_var_output.yml
0 → 100644
View file @
a88dc7a2
# test code to assert variables in mysql_variables module
# (c) 2014, Wayne Rosario <wrosario@ansible.com>
# This file is part of Ansible
#
# Ansible is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Ansible is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
# ============================================================
# Assert output variable name/value match mysql variable name/value
#
-
name
:
assert output message changed value
assert
:
{
that
:
"
output.changed
==
{{changed}}"
}
-
set_fact
:
key_name
:
"
{{output.msg[0][0]}}"
key_value
:
"
{{output.msg[0][1]}}"
-
name
:
run mysql command to show variable
command
:
mysql "-e show variables like '{{var_name}}';"
register
:
result
-
name
:
assert output variable info match mysql variable info
assert
:
that
:
-
"
result.changed
==
true"
-
"
key_name
in
result.stdout"
-
"
key_value
in
result.stdout"
test/integration/roles/test_mysql_variables/tasks/main.yml
0 → 100644
View file @
a88dc7a2
# test code for the mysql_variables module
# (c) 2014, Wayne Rosario <wrosario@ansible.com>
# This file is part of Ansible
#
# Ansible is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Ansible is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
# ============================================================
# Verify mysql_variable successfully queries a variable
#
-
set_fact
:
set_name='version'
-
name
:
read mysql variables (expect changed=false)
mysql_variables
:
variable={{set_name}}
register
:
result
-
include
:
assert_var_output.yml changed=false output={{result}} var_name={{set_name}}
# ============================================================
# Verify mysql_variable successfully updates a variable (issue:4568)
#
-
set_fact
:
set_name
:
'
delay_key_write'
set_value
:
'
ON'
-
name
:
set mysql variable
mysql_variables
:
variable={{set_name}} value={{set_value}}
-
name
:
update mysql variable to same value (expect changed=false)
mysql_variables
:
variable={{set_name}} value={{set_value}}
register
:
result
-
include
:
assert_var.yml changed=false output={{result}} var_name={{set_name}} var_value={{set_value}}
# ============================================================
# Verify mysql_variable successfully updates a variable using single quotes
#
-
set_fact
:
set_name
:
'
wait_timeout'
set_value
:
'
300'
-
name
:
set mysql variable to a temp value
mysql_variables
:
variable={{set_name}} value='200'
-
name
:
update mysql variable value (expect changed=true)
mysql_variables
:
variable={{set_name}} value={{set_value}}
register
:
result
-
include
:
assert_var.yml changed=true output={{result}} var_name={{set_name}} var_value='{{set_value}}'
# ============================================================
# Verify mysql_variable successfully updates a variable using double quotes
#
-
set_fact
:
set_name
:
"
wait_timeout"
set_value
:
"
400"
-
name
:
set mysql variable to a temp value
mysql_variables
:
variable={{set_name}} value="200"
-
name
:
update mysql variable value (expect changed=true)
mysql_variables
:
variable={{set_name}} value={{set_value}}
register
:
result
-
include
:
assert_var.yml changed=true output={{result}} var_name={{set_name}} var_value='{{set_value}}'
# ============================================================
# Verify mysql_variable successfully updates a variable using no quotes
#
-
set_fact
:
set_name
:
wait_timeout
set_value
:
500
-
name
:
set mysql variable to a temp value
mysql_variables
:
variable={{set_name}} value=200
-
name
:
update mysql variable value (expect changed=true)
mysql_variables
:
variable={{set_name}} value={{set_value}}
register
:
result
-
include
:
assert_var.yml 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)
#
-
name
:
set mysql variable value to an expression
mysql_variables
:
variable=max_tmp_tables value="1024*4"
register
:
result
ignore_errors
:
true
-
include
:
assert_fail_msg.yml output={{result}} msg='Incorrect argument type to variable'
# ============================================================
# Verify mysql_variable fails when setting an incorrect value (out of range)
#
-
name
:
set mysql variable value to a number out of range
mysql_variables
:
variable=max_tmp_tables value=-1
register
:
result
ignore_errors
:
true
-
include
:
assert_fail_msg.yml output={{result}} msg='Truncated incorrect'
# ============================================================
# Verify mysql_variable fails when setting an incorrect value (incorrect type)
#
-
name
:
set mysql variable value to a non-valid value number
mysql_variables
:
variable=max_tmp_tables value=TEST
register
:
result
ignore_errors
:
true
-
include
:
assert_fail_msg.yml output={{result}} msg='Incorrect argument type to variable'
# ============================================================
# Verify mysql_variable fails when setting an unknown variable
#
-
name
:
set a non mysql variable
mysql_variables
:
variable=my_sql_variable value=ON
register
:
result
ignore_errors
:
true
-
include
:
assert_fail_msg.yml output={{result}} msg='Variable not available'
# ============================================================
# Verify mysql_variable fails when setting a read-only variable
#
-
name
:
set value of a read only mysql variable
mysql_variables
:
variable=character_set_system value=utf16
register
:
result
ignore_errors
:
true
-
include
:
assert_fail_msg.yml output={{result}} msg='read only variable'
#=============================================================
# Verify mysql_variable works with the login_user and login_password parameters
#
-
name
:
create mysql user
mysql_user
:
name={{user}} password={{password}} state=present priv=*.*:ALL
-
set_fact
:
set_name
:
wait_timeout
set_value
:
77
-
name
:
query mysql_variable using login_user and password_password
mysql_variables
:
variable={{set_name}} login_user={{user}} login_password={{password}}
register
:
result
-
include
:
assert_var_output.yml 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
:
variable={{set_name}} value=20 login_user={{user}} login_password={{password}}
register
:
result
-
name
:
update mysql variable value using user login and password (expect changed=true)
mysql_variables
:
variable={{set_name}} value={{set_value}} login_user={{user}} login_password={{password}}
register
:
result
-
include
:
assert_var.yml changed=true output={{result}} var_name={{set_name}} var_value='{{set_value}}'
#============================================================
# Verify mysql_variable fails with an incorrect login_password parameter
#
-
set_fact
:
set_name
:
connect_timeout
set_value
:
10
-
name
:
query mysql_variable using incorrect login_password
mysql_variables
:
variable={{set_name}} login_user={{user}} login_password=wrongpassword
register
:
result
ignore_errors
:
true
-
include
:
assert_fail_msg.yml output={{result}} msg='unable to connect to database'
-
name
:
update mysql variable value using incorrect login_password (expect failed=true)
mysql_variables
:
variable={{set_name}} value={{set_value}} login_user={{user}} login_password='this is an incorrect password'
register
:
result
ignore_errors
:
true
-
include
:
assert_fail_msg.yml output={{result}} msg='unable to connect to database'
-
name
:
remove mysql_user {{user}}
mysql_user
:
name={{user}} state=absent
#============================================================
# Verify mysql_variable fails with an incorrect login_host parameter
#
-
name
:
query mysql_variable using incorrect login_host
mysql_variables
:
variable=wait_timeout login_host=12.0.0.9
register
:
result
ignore_errors
:
true
-
include
:
assert_fail_msg.yml output={{result}} msg='unable to connect to database'
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment