diff --git a/test/integration/inventory.network b/test/integration/inventory.network index d90e1aff93..fd0250115a 100644 --- a/test/integration/inventory.network +++ b/test/integration/inventory.network @@ -25,7 +25,7 @@ vsrx01 ansible_network_os=junos clvx01 [vyos] -vyos01 ansible_network_os=vyos +vyos02 ansible_network_os=vyos [ops] ops01 diff --git a/test/integration/platform_agnostic.yaml b/test/integration/platform_agnostic.yaml index 614567e581..b364d83db2 100644 --- a/test/integration/platform_agnostic.yaml +++ b/test/integration/platform_agnostic.yaml @@ -78,8 +78,15 @@ rescue: - set_fact: test_failed=true + - block: + - include_role: + name: net_linkagg + when: "limit_to in ['*', 'net_linkagg']" + rescue: + - set_fact: test_failed=true + ########### - name: Has any previous test failed? fail: msg: "One or more tests failed, check log for details" - when: test_failed \ No newline at end of file + when: test_failed diff --git a/test/integration/targets/net_linkagg/aliases b/test/integration/targets/net_linkagg/aliases new file mode 100644 index 0000000000..e69de29bb2 diff --git a/test/integration/targets/net_linkagg/defaults/main.yaml b/test/integration/targets/net_linkagg/defaults/main.yaml new file mode 100644 index 0000000000..9ef5ba5165 --- /dev/null +++ b/test/integration/targets/net_linkagg/defaults/main.yaml @@ -0,0 +1,3 @@ +--- +testcase: "*" +test_items: [] diff --git a/test/integration/targets/net_linkagg/tasks/cli.yaml b/test/integration/targets/net_linkagg/tasks/cli.yaml new file mode 100644 index 0000000000..d675462dd0 --- /dev/null +++ b/test/integration/targets/net_linkagg/tasks/cli.yaml @@ -0,0 +1,15 @@ +--- +- name: collect all cli test cases + find: + paths: "{{ role_path }}/tests/cli" + patterns: "{{ testcase }}.yaml" + register: test_cases + +- name: set test_items + set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}" + +- name: run test case + include: "{{ test_case_to_run }}" + with_items: "{{ test_items }}" + loop_control: + loop_var: test_case_to_run diff --git a/test/integration/targets/net_linkagg/tasks/main.yaml b/test/integration/targets/net_linkagg/tasks/main.yaml new file mode 100644 index 0000000000..415c99d8b1 --- /dev/null +++ b/test/integration/targets/net_linkagg/tasks/main.yaml @@ -0,0 +1,2 @@ +--- +- { include: cli.yaml, tags: ['cli'] } diff --git a/test/integration/targets/net_linkagg/tests/cli/basic.yaml b/test/integration/targets/net_linkagg/tests/cli/basic.yaml new file mode 100644 index 0000000000..29e7b06be1 --- /dev/null +++ b/test/integration/targets/net_linkagg/tests/cli/basic.yaml @@ -0,0 +1,4 @@ +--- + +- include: "{{ role_path }}/tests/vyos/basic.yaml" + when: hostvars[inventory_hostname]['ansible_network_os'] == 'vyos' diff --git a/test/integration/targets/net_linkagg/tests/vyos/basic.yaml b/test/integration/targets/net_linkagg/tests/vyos/basic.yaml new file mode 100644 index 0000000000..64ddb667a1 --- /dev/null +++ b/test/integration/targets/net_linkagg/tests/vyos/basic.yaml @@ -0,0 +1,185 @@ +--- +- name: Remove linkagg + net_linkagg: + name: bond0 + state: absent + +- name: Create linkagg + net_linkagg: + name: bond0 + members: + - eth1 + - eth2 + state: present + register: result + +- assert: + that: + - 'result.changed == true' + - '"set interfaces bonding bond0 mode 802.3ad" in result.commands' + - '"set interfaces ethernet eth1 bond-group bond0" in result.commands' + - '"set interfaces ethernet eth2 bond-group bond0" in result.commands' + +- name: Create linkagg again (idempotent) + net_linkagg: + name: bond0 + members: + - eth1 + - eth2 + state: present + register: result + +- assert: + that: + - 'result.changed == false' + +- name: Add linkagg member + net_linkagg: + name: bond0 + members: + - eth3 + state: present + register: result + +- assert: + that: + - 'result.changed == true' + - '"set interfaces ethernet eth3 bond-group bond0" in result.commands' + +- name: Add linkagg member again (idempotent) + net_linkagg: + name: bond0 + members: + - eth3 + state: present + register: result + +- assert: + that: + - 'result.changed == false' + +- name: Disable linkagg + net_linkagg: + name: bond0 + state: down + register: result + +- assert: + that: + - 'result.changed == true' + - '"set interfaces bonding bond0 disable" in result.commands' + +- name: Disable linkagg again (idempotent) + net_linkagg: + name: bond0 + state: down + register: result + +- assert: + that: + - 'result.changed == false' + +- name: Enable linkagg + net_linkagg: + name: bond0 + state: up + register: result + +- assert: + that: + - 'result.changed == true' + - '"delete interfaces bonding bond0 disable" in result.commands[0]' + +- name: Enable linkagg again (idempotent) + net_linkagg: + name: bond0 + state: up + register: result + +- assert: + that: + - 'result.changed == false' + +- name: Remove linkagg + net_linkagg: + name: bond0 + state: absent + register: result + +- assert: + that: + - 'result.changed == true' + - '"delete interfaces ethernet eth1 bond-group" in result.commands' + - '"delete interfaces ethernet eth2 bond-group" in result.commands' + - '"delete interfaces ethernet eth3 bond-group" in result.commands' + - '"delete interfaces bonding bond0" in result.commands' + +- name: Remove linkagg again (idempotent) + net_linkagg: + name: bond0 + state: absent + register: result + +- assert: + that: + - 'result.changed == false' + +- name: Create collection of linkagg definitions + net_linkagg: + collection: + - { name: bond0, members: [eth1, eth2] } + - { name: bond1, members: [eth3, eth4] } + state: present + register: result + +- assert: + that: + - 'result.changed == true' + - '"set interfaces bonding bond0 mode 802.3ad" in result.commands' + - '"set interfaces ethernet eth1 bond-group bond0" in result.commands' + - '"set interfaces ethernet eth2 bond-group bond0" in result.commands' + - '"set interfaces bonding bond1 mode 802.3ad" in result.commands' + - '"set interfaces ethernet eth3 bond-group bond1" in result.commands' + - '"set interfaces ethernet eth4 bond-group bond1" in result.commands' + +- name: Create collection of linkagg definitions again (idempotent) + net_linkagg: + collection: + - { name: bond0, members: [eth1, eth2] } + - { name: bond1, members: [eth3, eth4] } + state: present + register: result + +- assert: + that: + - 'result.changed == false' + +- name: Remove collection of linkagg definitions + net_linkagg: + collection: + - { name: bond0 } + - { name: bond1 } + state: absent + register: result + +- assert: + that: + - 'result.changed == true' + - '"delete interfaces ethernet eth1 bond-group" in result.commands' + - '"delete interfaces ethernet eth2 bond-group" in result.commands' + - '"delete interfaces bonding bond0" in result.commands' + - '"delete interfaces ethernet eth1 bond-group" in result.commands' + - '"delete interfaces ethernet eth2 bond-group" in result.commands' + - '"delete interfaces bonding bond1" in result.commands' + +- name: Remove collection of linkagg definitions again (idempotent) + net_linkagg: + collection: + - { name: bond0 } + - { name: bond1 } + state: absent + register: result + +- assert: + that: + - 'result.changed == false'