Add simple test for bridges

This commit is contained in:
Till Maas 2018-05-19 00:36:41 +02:00
parent 7d44710f44
commit 9b3d2d3ad8
4 changed files with 93 additions and 0 deletions

View file

@ -0,0 +1,14 @@
# SPDX-License-Identifier: BSD-3-Clause
---
- name: set variable
set_fact:
profile_path: /etc/sysconfig/network-scripts/ifcfg-{{ profile }}
- name: stat profile file
stat:
path: "{{ profile_path }}"
register: profile_stat
- assert:
name: "assert that {{ profile }} is absent"
that: not profile_stat.stat.exists
msg: "profile {{ profile_path }} does exist"

View file

@ -0,0 +1,14 @@
# SPDX-License-Identifier: BSD-3-Clause
---
- name: set variable
set_fact:
profile_path: /etc/sysconfig/network-scripts/ifcfg-{{ profile }}
- name: stat profile file
stat:
path: "{{ profile_path }}"
register: profile_stat
- assert:
name: "assert that {{ profile }} is present"
that: profile_stat.stat.exists
msg: "profile {{ profile_path }} does not exist"

55
tests/tests_bridge.yml Normal file
View file

@ -0,0 +1,55 @@
# SPDX-License-Identifier: BSD-3-Clause
---
- name: Test configuring bridges
hosts: all
vars:
interface: LSR-TST-br31
tasks:
- name: "set interface={{ interface }}"
set_fact:
interface: "{{ interface }}"
- include_tasks: tasks/show-interfaces.yml
- include_tasks: tasks/assert-device_absent.yml
- name: Add test bridge
hosts: all
vars:
network_connections:
- name: "{{ interface }}"
interface_name: "{{ interface }}"
state: up
type: bridge
ip:
dhcp4: no
auto6: yes
roles:
- linux-system-roles.network
- import_playbook: run-tasks.yml
vars:
task: tasks/assert-device_present.yml
- import_playbook: run-tasks.yml
vars:
profile: "{{ interface }}"
task: tasks/assert-profile_present.yml
- import_playbook: down-profile.yml
vars:
profile: "{{ interface }}"
# FIXME: assert profile/device down
- import_playbook: remove-profile.yml
vars:
profile: "{{ interface }}"
- import_playbook: run-tasks.yml
vars:
profile: "{{ interface }}"
task: tasks/assert-profile_absent.yml
# FIXME: Devices might still be left when profile is absent
#- import_playbook: run-tasks.yml
# vars:
# task: tasks/assert-device_absent.yml

View file

@ -0,0 +1,10 @@
# SPDX-License-Identifier: BSD-3-Clause
---
# empty play to gather facts
- hosts: all
- import_playbook: tests_bridge.yml
vars:
network_provider: initscripts
when:
- ansible_distribution_major_version != '6'