diff options
author | CaptTrews <capttrews@gmail.com> | 2019-08-29 14:21:30 +0000 |
---|---|---|
committer | CaptTrews <capttrews@gmail.com> | 2019-08-29 14:21:30 +0000 |
commit | ae8514ce0289ee2096a3a9f54be6a4654153c880 (patch) | |
tree | 2d9a958c135c5ec4cad86650e8f7d7ef173d33c2 /tests/integration/targets/vyos_vlan | |
parent | 59af486ab07108815ad1774205959fa8287d6e53 (diff) | |
download | vyos-ansible-collection-ae8514ce0289ee2096a3a9f54be6a4654153c880.tar.gz vyos-ansible-collection-ae8514ce0289ee2096a3a9f54be6a4654153c880.zip |
Updated from network content collector
Signed-off-by: CaptTrews <capttrews@gmail.com>
Diffstat (limited to 'tests/integration/targets/vyos_vlan')
7 files changed, 247 insertions, 0 deletions
diff --git a/tests/integration/targets/vyos_vlan/aliases b/tests/integration/targets/vyos_vlan/aliases new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/tests/integration/targets/vyos_vlan/aliases diff --git a/tests/integration/targets/vyos_vlan/defaults/main.yaml b/tests/integration/targets/vyos_vlan/defaults/main.yaml new file mode 100644 index 0000000..9ef5ba5 --- /dev/null +++ b/tests/integration/targets/vyos_vlan/defaults/main.yaml @@ -0,0 +1,3 @@ +--- +testcase: "*" +test_items: [] diff --git a/tests/integration/targets/vyos_vlan/tasks/cli.yaml b/tests/integration/targets/vyos_vlan/tasks/cli.yaml new file mode 100644 index 0000000..890d3ac --- /dev/null +++ b/tests/integration/targets/vyos_vlan/tasks/cli.yaml @@ -0,0 +1,22 @@ +--- +- name: collect all cli test cases + find: + paths: "{{ role_path }}/tests/cli" + patterns: "{{ testcase }}.yaml" + register: test_cases + delegate_to: localhost + +- name: set test_items + set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}" + +- name: run test case (connection=network_cli) + include: "{{ test_case_to_run }} ansible_connection=network_cli" + with_items: "{{ test_items }}" + loop_control: + loop_var: test_case_to_run + +- name: run test case (connection=local) + include: "{{ test_case_to_run }} ansible_connection=local" + with_first_found: "{{ test_items }}" + loop_control: + loop_var: test_case_to_run diff --git a/tests/integration/targets/vyos_vlan/tasks/main.yaml b/tests/integration/targets/vyos_vlan/tasks/main.yaml new file mode 100644 index 0000000..415c99d --- /dev/null +++ b/tests/integration/targets/vyos_vlan/tasks/main.yaml @@ -0,0 +1,2 @@ +--- +- { include: cli.yaml, tags: ['cli'] } diff --git a/tests/integration/targets/vyos_vlan/tests/cli/basic.yaml b/tests/integration/targets/vyos_vlan/tests/cli/basic.yaml new file mode 100644 index 0000000..6e4417e --- /dev/null +++ b/tests/integration/targets/vyos_vlan/tests/cli/basic.yaml @@ -0,0 +1,101 @@ +--- +- debug: msg="START cli/basic.yaml on connection={{ ansible_connection }}" + +- name: setup - remove vlan used in test + vyos.vyos.vyos_config: + lines: + - delete interfaces ethernet eth1 vif 100 + - delete interfaces ethernet eth0 vif 5 + - delete interfaces ethernet eth0 vif 100 + - delete interfaces ethernet eth0 vif 101 + - delete interfaces ethernet eth1 vif 201 + +- name: set vlan with name + vyos.vyos.vyos_vlan: &name + vlan_id: 100 + name: vlan-100 + interfaces: eth1 + register: result + +- assert: + that: + - "result.changed == true" + - "'set interfaces ethernet eth1 vif 100 description vlan-100' in result.commands" + +- name: set vlan with name(idempotence) + vyos.vyos.vyos_vlan: *name + register: result + +- assert: + that: + - "result.changed == false" + +- name: set vlan with address + vyos.vyos.vyos_vlan: &address + vlan_id: 5 + address: 192.168.5.12/24 + interfaces: eth0 + register: result + +- assert: + that: + - "result.changed == true" + - "'set interfaces ethernet eth0 vif 5 address 192.168.5.12/24' in result.commands" + +- name: set vlan with address(idempotence) + vyos.vyos.vyos_vlan: *address + register: result + +- assert: + that: + - "result.changed == false" + +- name: delete + vyos.vyos.vyos_vlan: &delete + vlan_id: 100 + interfaces: eth1 + state: absent + register: result + +- assert: + that: + - "result.changed == true" + - "'delete interfaces ethernet eth1 vif 100' in result.commands" + +- name: delete(idempotence) + vyos.vyos.vyos_vlan: *delete + register: result + +- assert: + that: + - "result.changed == false" + +- name: Create VLANs using aggregate + vyos.vyos.vyos_vlan: &agg_vlan + aggregate: + - { vlan_id: 101, name: voice, interfaces: "eth0" } + - { vlan_id: 201, name: mgm, interfaces: "eth1" } + state: present + register: result + +- assert: + that: + - "result.changed == true" + - "'set interfaces ethernet eth0 vif 101 description voice' in result.commands" + - "'set interfaces ethernet eth1 vif 201 description mgm' in result.commands" + +- name: Create VLANs using aggregate (idempotent) + vyos.vyos.vyos_vlan: *agg_vlan + register: result + +- assert: + that: + - "result.changed == false" + +- name: teardown + vyos.vyos.vyos_config: + lines: + - delete interfaces ethernet eth1 vif 100 + - delete interfaces ethernet eth0 vif 5 + - delete interfaces ethernet eth0 vif 101 + - delete interfaces ethernet eth1 vif 201 diff --git a/tests/integration/targets/vyos_vlan/tests/cli/intent.yaml b/tests/integration/targets/vyos_vlan/tests/cli/intent.yaml new file mode 100644 index 0000000..7c78937 --- /dev/null +++ b/tests/integration/targets/vyos_vlan/tests/cli/intent.yaml @@ -0,0 +1,59 @@ +--- +- debug: msg="START cli/intent.yaml on connection={{ ansible_connection }}" + +- name: setup - remove vlan used in test + vyos.vyos.vyos_config: &delete + lines: + - delete interfaces ethernet eth1 vif 100 + - delete interfaces ethernet eth0 vif 100 + +- name: set vlan with name + vyos.vyos.vyos_vlan: + vlan_id: 100 + name: vlan-100 + interfaces: eth1 + register: result + +- assert: + that: + - "result.changed == true" + - "'set interfaces ethernet eth1 vif 100 description vlan-100' in result.commands" + +- name: check vlan interface intent + vyos.vyos.vyos_vlan: + vlan_id: 100 + name: vlan-100 + associated_interfaces: eth1 + register: result + +- assert: + that: + - "result.failed == false" + +- name: vlan interface config + intent + vyos.vyos.vyos_vlan: + vlan_id: 100 + interfaces: eth0 + associated_interfaces: + - eth0 + - eth1 + register: result + +- assert: + that: + - "result.failed == false" + +- name: vlan intent fail + vyos.vyos.vyos_vlan: + vlan_id: 100 + associated_interfaces: + - eth3 + - eth4 + register: result + ignore_errors: yes + +- assert: + that: + - "result.failed == True" + +- debug: msg="End cli/intent.yaml on connection={{ ansible_connection }}" diff --git a/tests/integration/targets/vyos_vlan/tests/cli/multiple.yaml b/tests/integration/targets/vyos_vlan/tests/cli/multiple.yaml new file mode 100644 index 0000000..53e93fd --- /dev/null +++ b/tests/integration/targets/vyos_vlan/tests/cli/multiple.yaml @@ -0,0 +1,60 @@ +--- +- debug: msg="START cli/multiple.yaml on connection={{ ansible_connection }}" + +- name: setup - remove vlan used in test + vyos.vyos.vyos_config: + lines: + - delete interfaces ethernet eth0 vif 5 + - delete interfaces ethernet eth0 vif 100 + - delete interfaces ethernet eth1 vif 100 + +- name: Add multiple interfaces to vlan + vyos.vyos.vyos_vlan: &multiple + vlan_id: 100 + interfaces: + - eth0 + - eth1 + register: result + +- assert: + that: + - "result.changed == true" + - "'set interfaces ethernet eth0 vif 100' in result.commands" + - "'set interfaces ethernet eth1 vif 100' in result.commands" + +- name: Add multiple interfaces to vlan(idempotence) + vyos.vyos.vyos_vlan: *multiple + register: result + +- assert: + that: + - "result.changed == false" + +- name: delete vlan with multiple interfaces + vyos.vyos.vyos_vlan: &delete_multiple + vlan_id: 100 + interfaces: + - eth0 + - eth1 + state: absent + register: result + +- assert: + that: + - "result.changed == true" + - "'delete interfaces ethernet eth0 vif 100' in result.commands" + - "'delete interfaces ethernet eth1 vif 100' in result.commands" + +- name: delete vlan with multiple interfaces(idempotence) + vyos.vyos.vyos_vlan: *delete_multiple + register: result + +- assert: + that: + - "result.changed == false" + +- name: teardown + vyos.vyos.vyos_config: + lines: + - delete interfaces ethernet eth0 vif 100 + - delete interfaces ethernet eth1 vif 100 |