tests: Test volatile state changes

This commit is contained in:
Till Maas 2019-05-26 09:46:14 +02:00
parent a4a3373e3f
commit 1d342ef037
4 changed files with 62 additions and 1 deletions

View file

@ -13,7 +13,7 @@ import yaml
OTHER_PROVIDER_SUFFIX = "_other_provider.yml"
IGNORE = ["tests_unit.yml", "tests_helpers-and-asserts.yml"]
IGNORE = ["tests_unit.yml", "tests_helpers-and-asserts.yml", "tests_states.yml"]
OTHER_PLAYBOOK = """
# SPDX-License-Identifier: BSD-3-Clause

1
tests/playbooks/tasks Symbolic link
View file

@ -0,0 +1 @@
../tasks/

View file

@ -0,0 +1,49 @@
# SPDX-License-Identifier: BSD-3-Clause
---
- hosts: all
vars:
interface: statebr
profile: "{{ interface }}"
network_provider: nm
tasks:
- debug:
msg: Inside states tests
- include_tasks: tasks/show-interfaces.yml
- include_tasks: tasks/assert-device_absent.yml
# create test profile
- include_role:
name: linux-system-roles.network
vars:
network_connections:
- name: statebr
state: up
type: bridge
ip:
dhcp4: false
auto6: false
- include_tasks: tasks/assert-device_present.yml
- include_tasks: tasks/assert-profile_present.yml
# test case (remove profile but keep it up)
# I can remove a profile but keep the configuration active.
- include_role:
name: linux-system-roles.network
vars:
network_connections:
- name: statebr
persistent_state: absent
- include_tasks: tasks/assert-device_present.yml
- include_tasks: tasks/assert-profile_absent.yml
# test case
# I can set a profile down that is up and absent.
- name: Set down
include_role:
name: linux-system-roles.network
vars:
network_connections:
- name: statebr
state: down
- include_tasks: tasks/assert-device_absent.yml
- include_tasks: tasks/assert-profile_absent.yml

11
tests/tests_states.yml Normal file
View file

@ -0,0 +1,11 @@
---
# empty playbook to gather facts for import_playbook when clause
- hosts: all
# workaround for: https://github.com/ansible/ansible/issues/27973
# There is no way in Ansible to abort a playbook hosts with specific OS
# releases Therefore we include the playbook with the tests only if the hosts
# would support it.
# The test requires NetworkManager, therefore it cannot run on RHEL 6 or CentOS 6.
- import_playbook: playbooks/tests_states.yml
when: ansible_distribution_major_version != '6'