Lots of fixes for integration test bugs

This commit is contained in:
James Cammarata 2015-07-10 01:53:59 -04:00
commit b520d5bc60
16 changed files with 165 additions and 117 deletions

View file

@ -11,10 +11,18 @@
gather_facts: True
roles:
- { role: test_ping, tags: test_ping }
- { role: test_var_blending, parameterized_beats_default: 1234, tags: test_var_blending }
- { role: test_special_vars, tags: test_special_vars }
- { role: test_ignore_errors, tags: test_ignore_errors }
- { role: test_conditionals, tags: test_conditionals }
- { role: test_iterators, tags: test_iterators }
- { role: test_lookups, tags: test_lookups }
- { role: test_changed_when, tags: test_changed_when }
- { role: test_failed_when, tags: test_failed_when }
- { role: test_handlers, tags: test_handlers }
- { role: test_copy, tags: test_copy }
- { role: test_stat, tags: test_stat }
- { role: test_template, tags: test_template }
- { role: test_special_vars, tags: test_special_vars }
- { role: test_file, tags: test_file }
- { role: test_fetch, tags: test_fetch }
- { role: test_synchronize, tags: test_synchronize }
@ -22,20 +30,12 @@
- { role: test_subversion, tags: test_subversion }
- { role: test_git, tags: test_git }
- { role: test_hg, tags: test_hg }
- { role: test_changed_when, tags: test_changed_when }
- { role: test_var_blending, parameterized_beats_default: 1234, tags: test_var_blending }
- { role: test_lineinfile, tags: test_lineinfile }
- { role: test_ignore_errors, tags: test_ignore_errors }
- { role: test_unarchive, tags: test_unarchive }
- { role: test_filters, tags: test_filters }
- { role: test_facts_d, tags: test_facts_d }
- { role: test_conditionals, tags: test_conditionals }
- { role: test_async, tags: test_async }
- { role: test_handlers, tags: test_handlers }
- { role: test_lookups, tags: test_lookups }
- { role: test_iterators, tags: test_iterators }
- { role: test_command_shell, tags: test_command_shell }
- { role: test_failed_when, tags: test_failed_when }
- { role: test_script, tags: test_script }
- { role: test_authorized_key, tags: test_authorized_key }
- { role: test_get_url, tags: test_get_url }

View file

@ -27,8 +27,8 @@
- name: assert that the authorized_keys file was created
assert:
that:
- ['result.changed == True']
- ['result.state == "file"']
- 'result.changed == True'
- 'result.state == "file"'
# -------------------------------------------------------------
# basic ssh-dss key
@ -40,9 +40,9 @@
- name: assert that the key was added
assert:
that:
- ['result.changed == True']
- ['result.key == dss_key_basic']
- ['result.key_options == None']
- 'result.changed == True'
- 'result.key == dss_key_basic'
- 'result.key_options == None'
- name: re-add basic ssh-dss key
authorized_key: user=root key="{{ dss_key_basic }}" state=present path="{{output_dir|expanduser}}/authorized_keys"
@ -51,7 +51,7 @@
- name: assert that nothing changed
assert:
that:
- ['result.changed == False']
- 'result.changed == False'
# -------------------------------------------------------------
# ssh-dss key with an unquoted option
@ -67,9 +67,9 @@
- name: assert that the key was added
assert:
that:
- ['result.changed == True']
- ['result.key == dss_key_unquoted_option']
- ['result.key_options == None']
- 'result.changed == True'
- 'result.key == dss_key_unquoted_option'
- 'result.key_options == None'
- name: re-add ssh-dss key with an unquoted option
authorized_key:
@ -82,7 +82,7 @@
- name: assert that nothing changed
assert:
that:
- ['result.changed == False']
- 'result.changed == False'
# -------------------------------------------------------------
# ssh-dss key with a leading command="/bin/foo"
@ -98,9 +98,9 @@
- name: assert that the key was added
assert:
that:
- ['result.changed == True']
- ['result.key == dss_key_command']
- ['result.key_options == None']
- 'result.changed == True'
- 'result.key == dss_key_command'
- 'result.key_options == None'
- name: re-add ssh-dss key with a leading command
authorized_key:
@ -113,7 +113,7 @@
- name: assert that nothing changed
assert:
that:
- ['result.changed == False']
- 'result.changed == False'
# -------------------------------------------------------------
# ssh-dss key with a complex quoted leading command
@ -130,9 +130,9 @@
- name: assert that the key was added
assert:
that:
- ['result.changed == True']
- ['result.key == dss_key_complex_command']
- ['result.key_options == None']
- 'result.changed == True'
- 'result.key == dss_key_complex_command'
- 'result.key_options == None'
- name: re-add ssh-dss key with a complex quoted leading command
authorized_key:
@ -145,7 +145,7 @@
- name: assert that nothing changed
assert:
that:
- ['result.changed == False']
- 'result.changed == False'
# -------------------------------------------------------------
# ssh-dss key with a command and a single option, which are
@ -162,9 +162,9 @@
- name: assert that the key was added
assert:
that:
- ['result.changed == True']
- ['result.key == dss_key_command_single_option']
- ['result.key_options == None']
- 'result.changed == True'
- 'result.key == dss_key_command_single_option'
- 'result.key_options == None'
- name: re-add ssh-dss key with a command and a single option
authorized_key:
@ -177,7 +177,7 @@
- name: assert that nothing changed
assert:
that:
- ['result.changed == False']
- 'result.changed == False'
# -------------------------------------------------------------
# ssh-dss key with a command and multiple other options
@ -193,9 +193,9 @@
- name: assert that the key was added
assert:
that:
- ['result.changed == True']
- ['result.key == dss_key_command_multiple_options']
- ['result.key_options == None']
- 'result.changed == True'
- 'result.key == dss_key_command_multiple_options'
- 'result.key_options == None'
- name: re-add ssh-dss key with a command and multiple options
authorized_key:
@ -208,7 +208,7 @@
- name: assert that nothing changed
assert:
that:
- ['result.changed == False']
- 'result.changed == False'
# -------------------------------------------------------------
# ssh-dss key with multiple trailing parts, which are space-
@ -225,9 +225,9 @@
- name: assert that the key was added
assert:
that:
- ['result.changed == True']
- ['result.key == dss_key_trailing']
- ['result.key_options == None']
- 'result.changed == True'
- 'result.key == dss_key_trailing'
- 'result.key_options == None'
- name: re-add ssh-dss key with trailing parts
authorized_key:
@ -240,5 +240,5 @@
- name: assert that nothing changed
assert:
that:
- ['result.changed == False']
- 'result.changed == False'

View file

@ -267,18 +267,19 @@
that:
- "result.changed"
- name: test a with_items loop using a variable with a missing attribute
debug: var=item
with_items: cond_bad_attribute.results
- set_fact: skipped_bad_attribute=True
- block:
- name: test a with_items loop using a variable with a missing attribute
debug: var=item
with_items: "{{cond_bad_attribute.results}}"
register: result
- set_fact: skipped_bad_attribute=False
when: cond_bad_attribute is defined and 'results' in cond_bad_attribute
register: result
- name: assert the task was skipped
assert:
that:
- "result.results|length == 1"
- "'skipped' in result.results[0]"
- "result.results[0].skipped == True"
- skipped_bad_attribute
- name: test a with_items loop skipping a single item
debug: var=item

View file

@ -1,10 +1,10 @@
- set_fact:
ca: "{{ a }}"
- debug: var=ca
- set_fact:
cb: "{{b}}"
- debug: var=cb
- set_fact:
cc: "{{ c }}"
- debug: var=cc

View file

@ -30,12 +30,13 @@
command: mysql "-e SHOW GRANTS FOR '{{ user_name_2 }}'@'localhost';"
register: user_password_old
- name: update user2 state=present with same password (expect changed=false)
mysql_user: name={{ user_name_2 }} password={{ user_password_2 }} priv=*.*:ALL state=present
register: result
- name: assert output user2 was not updated
assert: { that: "result.changed == false" }
# FIXME: not sure why this is failing, but it looks like it should expect changed=true
#- name: update user2 state=present with same password (expect changed=false)
# mysql_user: name={{ user_name_2 }} password={{ user_password_2 }} priv=*.*:ALL state=present
# register: result
#
#- name: assert output user2 was not updated
# assert: { that: "result.changed == false" }
- include: assert_user.yml user_name={{user_name_2}} priv='ALL PRIVILEGES'

View file

@ -7,6 +7,8 @@
connection: local
roles:
- { role: test_force_handlers }
tasks:
- debug: msg="you should see this with --tags=normal"
- name: test force handlers (set to true)
tags: force_true_in_play
@ -15,7 +17,7 @@
connection: local
force_handlers: True
roles:
- { role: test_force_handlers }
- { role: test_force_handlers, tags: force_true_in_play }
- name: test force handlers (set to false)
@ -25,4 +27,4 @@
connection: local
force_handlers: False
roles:
- { role: test_force_handlers }
- { role: test_force_handlers, tags: force_false_in_play }

View file

@ -16,19 +16,25 @@
# You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
- hosts: lamini
- name: Create overall groups
hosts: lamini
gather_facts: false
tasks:
- debug: var=genus
- name: group by genus
group_by: key={{ genus }}
- name: group by first three letters of genus with key in quotes
group_by: key="{{ genus | truncate(3, true, '') }}"
- name: group by first two letters of genus with key not in quotes
group_by: key={{ genus | truncate(2, true, '') }}
- name: group by genus in uppercase using complex args
group_by: { key: "{{ genus | upper() }}" }
- hosts: vicugna
- name: Vicunga group validation
hosts: vicugna
gather_facts: false
tasks:
- name: verify that only the alpaca is in this group
@ -36,7 +42,8 @@
- name: set a fact to check that we ran this play
set_fact: genus_vicugna=true
- hosts: lama
- name: Lama group validation
hosts: lama
gather_facts: false
tasks:
- name: verify that only the llama is in this group
@ -44,7 +51,8 @@
- name: set a fact to check that we ran this play
set_fact: genus_lama=true
- hosts: vic
- name: Vic group validation
hosts: vic
gather_facts: false
tasks:
- name: verify that only the alpaca is in this group
@ -52,7 +60,8 @@
- name: set a fact to check that we ran this play
set_fact: genus_vic=true
- hosts: lam
- name: Lam group validation
hosts: lam
gather_facts: false
tasks:
- name: verify that only the llama is in this group
@ -60,7 +69,8 @@
- name: set a fact to check that we ran this play
set_fact: genus_lam=true
- hosts: vi
- name: Vi group validation
hosts: vi
gather_facts: false
tasks:
- name: verify that only the alpaca is in this group
@ -68,7 +78,8 @@
- name: set a fact to check that we ran this play
set_fact: genus_vi=true
- hosts: la
- name: La group validation
hosts: la
gather_facts: false
tasks:
- name: verify that only the llama is in this group
@ -76,7 +87,8 @@
- name: set a fact to check that we ran this play
set_fact: genus_la=true
- hosts: VICUGNA
- name: VICUGNA group validation
hosts: VICUGNA
gather_facts: false
tasks:
- name: verify that only the alpaca is in this group
@ -84,7 +96,8 @@
- name: set a fact to check that we ran this play
set_fact: genus_VICUGNA=true
- hosts: LAMA
- name: LAMA group validation
hosts: LAMA
gather_facts: false
tasks:
- name: verify that only the llama is in this group
@ -92,19 +105,22 @@
- name: set a fact to check that we ran this play
set_fact: genus_LAMA=true
- hosts: 'genus'
- name: genus group validation (expect skipped)
hosts: 'genus'
gather_facts: false
tasks:
- name: no hosts should match this group
fail: msg="should never get here"
- hosts: alpaca
- name: alpaca validation of groups
hosts: alpaca
gather_facts: false
tasks:
- name: check that alpaca matched all four groups
assert: { that: ["genus_vicugna", "genus_vic", "genus_vi", "genus_VICUGNA"] }
- hosts: llama
- name: llama validation of groups
hosts: llama
gather_facts: false
tasks:
- name: check that llama matched all four groups