diff options
author | GomathiselviS <gomathiselvi@gmail.com> | 2020-10-30 20:21:45 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-10-31 00:21:45 +0000 |
commit | de18ed01ddd7ac1db3bbde83a156624a972a43ae (patch) | |
tree | 6cf49ffa7c500d0ec0ff147326c5e079a7e570ab /tests/integration/targets | |
parent | f5e6f4e2111890012b4bce4ce5096912e2eb3094 (diff) | |
download | vyos.vyos-de18ed01ddd7ac1db3bbde83a156624a972a43ae.tar.gz vyos.vyos-de18ed01ddd7ac1db3bbde83a156624a972a43ae.zip |
Add ospf_interfaces resource module (#96)
Add ospf_interfaces resource module
Reviewed-by: https://github.com/apps/ansible-zuul
Diffstat (limited to 'tests/integration/targets')
18 files changed, 613 insertions, 0 deletions
diff --git a/tests/integration/targets/vyos_ospf_interfaces/defaults/main.yaml b/tests/integration/targets/vyos_ospf_interfaces/defaults/main.yaml new file mode 100644 index 0000000..852a6be --- /dev/null +++ b/tests/integration/targets/vyos_ospf_interfaces/defaults/main.yaml @@ -0,0 +1,3 @@ +--- +testcase: '[^_].*' +test_items: [] diff --git a/tests/integration/targets/vyos_ospf_interfaces/meta/main.yaml b/tests/integration/targets/vyos_ospf_interfaces/meta/main.yaml new file mode 100644 index 0000000..7413320 --- /dev/null +++ b/tests/integration/targets/vyos_ospf_interfaces/meta/main.yaml @@ -0,0 +1,3 @@ +--- +dependencies: + - prepare_vyos_tests diff --git a/tests/integration/targets/vyos_ospf_interfaces/tasks/cli.yaml b/tests/integration/targets/vyos_ospf_interfaces/tasks/cli.yaml new file mode 100644 index 0000000..93eb2fe --- /dev/null +++ b/tests/integration/targets/vyos_ospf_interfaces/tasks/cli.yaml @@ -0,0 +1,19 @@ +--- +- name: Collect all cli test cases + find: + paths: '{{ role_path }}/tests/cli' + patterns: '{{ testcase }}.yaml' + use_regex: true + 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=ansible.netcommon.network_cli) + include: '{{ test_case_to_run }}' + vars: + ansible_connection: ansible.netcommon.network_cli + with_items: '{{ test_items }}' + loop_control: + loop_var: test_case_to_run diff --git a/tests/integration/targets/vyos_ospf_interfaces/tasks/main.yaml b/tests/integration/targets/vyos_ospf_interfaces/tasks/main.yaml new file mode 100644 index 0000000..b957d2f --- /dev/null +++ b/tests/integration/targets/vyos_ospf_interfaces/tasks/main.yaml @@ -0,0 +1,4 @@ +--- +- include: cli.yaml + tags: + - network_cli diff --git a/tests/integration/targets/vyos_ospf_interfaces/tests/cli/_parsed.cfg b/tests/integration/targets/vyos_ospf_interfaces/tests/cli/_parsed.cfg new file mode 100644 index 0000000..aa57677 --- /dev/null +++ b/tests/integration/targets/vyos_ospf_interfaces/tests/cli/_parsed.cfg @@ -0,0 +1,6 @@ +set interfaces ethernet eth0 ip ospf cost '50' +set interfaces ethernet eth0 ip ospf priority '26' +set interfaces ethernet eth0 ipv6 ospfv3 'mtu-ignore' +set interfaces ethernet eth0 ipv6 ospfv3 instance-id '33' +set interfaces bonding bond2 ip ospf transmit-delay '45' +set interfaces bonding bond2 ipv6 ospfv3 'passive' diff --git a/tests/integration/targets/vyos_ospf_interfaces/tests/cli/_parsed_config.cfg b/tests/integration/targets/vyos_ospf_interfaces/tests/cli/_parsed_config.cfg new file mode 100644 index 0000000..54696e8 --- /dev/null +++ b/tests/integration/targets/vyos_ospf_interfaces/tests/cli/_parsed_config.cfg @@ -0,0 +1,10 @@ +set interfaces ethernet eth1 firewall in name 'INBOUND' +set interfaces ethernet eth1 firewall out name 'OUTBOUND' +set interfaces ethernet eth1 firewall local name 'LOCAL' +set interfaces ethernet eth1 firewall local ipv6-name 'V6-LOCAL' +set interfaces ethernet eth2 firewall in name 'INBOUND' +set interfaces ethernet eth2 firewall out name 'OUTBOUND' +set interfaces ethernet eth2 firewall local name 'LOCAL' +set interfaces ethernet eth2 firewall local ipv6-name 'V6-LOCAL' +set interfaces ethernet eth0 + diff --git a/tests/integration/targets/vyos_ospf_interfaces/tests/cli/_populate.yaml b/tests/integration/targets/vyos_ospf_interfaces/tests/cli/_populate.yaml new file mode 100644 index 0000000..c4749d3 --- /dev/null +++ b/tests/integration/targets/vyos_ospf_interfaces/tests/cli/_populate.yaml @@ -0,0 +1,13 @@ +--- +- name: setup + vyos.vyos.vyos_config: + lines: + - set interfaces ethernet eth0 ip ospf cost 50 + - set interfaces ethernet eth0 ip ospf priority 26 + - set interfaces ethernet eth0 ipv6 ospfv3 mtu-ignore + - set interfaces ethernet eth0 ipv6 ospfv3 instance-id 33 + - set interfaces bonding bond2 ip ospf transmit-delay 45 + - set interfaces bonding bond2 ipv6 ospfv3 passive + ignore_errors: true + vars: + ansible_connection: ansible.netcommon.network_cli diff --git a/tests/integration/targets/vyos_ospf_interfaces/tests/cli/_remove_config.yaml b/tests/integration/targets/vyos_ospf_interfaces/tests/cli/_remove_config.yaml new file mode 100644 index 0000000..9a2e699 --- /dev/null +++ b/tests/integration/targets/vyos_ospf_interfaces/tests/cli/_remove_config.yaml @@ -0,0 +1,15 @@ +--- +- name: Remove pre-existing OSPF processes + vyos.vyos.vyos_config: + lines: + - delete interfaces ethernet eth0 ip ospf + - delete interfaces ethernet eth0 ipv6 ospfv3 + - delete interfaces ethernet eth1 ip ospf + - delete interfaces ethernet eth1 ipv6 ospfv3 + - delete interfaces bonding bond1 ip ospf + - delete interfaces bonding bond1 ipv6 ospfv3 + - delete interfaces bonding bond2 ip ospf + - delete interfaces bonding bond2 ipv6 ospfv3 + ignore_errors: true + vars: + ansible_connection: ansible.netcommon.network_cli diff --git a/tests/integration/targets/vyos_ospf_interfaces/tests/cli/deleted.yaml b/tests/integration/targets/vyos_ospf_interfaces/tests/cli/deleted.yaml new file mode 100644 index 0000000..573e611 --- /dev/null +++ b/tests/integration/targets/vyos_ospf_interfaces/tests/cli/deleted.yaml @@ -0,0 +1,42 @@ +--- +- debug: + msg: START vyos_ospf_interfaces deleted integration tests on connection={{ + ansible_connection }} + +- include_tasks: _remove_config.yaml + +- include_tasks: _populate.yaml + +- block: + + - name: Delete the provided configuration + register: result + vyos.vyos.vyos_ospf_interfaces: &id001 + config: + - name: "bond2" + state: deleted + + - become: true + vyos.vyos.vyos_facts: + gather_network_resources: ospf_interfaces + + - assert: + that: + - result.commands|length == 2 + - result.changed == true + - result.commands|symmetric_difference(deleted.commands) == [] + - result.after|symmetric_difference(ansible_facts['network_resources']['ospf_interfaces']) == [] + + - name: Delete the existing configuration with the provided running configuration + (IDEMPOTENT) + register: result + vyos.vyos.vyos_ospf_interfaces: *id001 + + - name: Assert that the previous task was idempotent + assert: + that: + - result['changed'] == false + + always: + + - include_tasks: _remove_config.yaml diff --git a/tests/integration/targets/vyos_ospf_interfaces/tests/cli/empty_config.yaml b/tests/integration/targets/vyos_ospf_interfaces/tests/cli/empty_config.yaml new file mode 100644 index 0000000..aff0f66 --- /dev/null +++ b/tests/integration/targets/vyos_ospf_interfaces/tests/cli/empty_config.yaml @@ -0,0 +1,60 @@ +--- +- debug: + msg: START vyos_ospf_interfaces empty_config integration tests on connection={{ + ansible_connection }} + +- name: Merged with empty config should give appropriate error message + register: result + ignore_errors: true + vyos.vyos.vyos_ospf_interfaces: + config: + state: merged + +- assert: + that: + - result.msg == 'value of config parameter must not be empty for state merged' + +- name: Replaced with empty config should give appropriate error message + register: result + ignore_errors: true + vyos.vyos.vyos_ospf_interfaces: + config: + state: replaced + +- assert: + that: + - result.msg == 'value of config parameter must not be empty for state replaced' + +- name: Overridden with empty config should give appropriate error message + register: result + ignore_errors: true + vyos.vyos.vyos_ospf_interfaces: + config: + state: overridden + +- assert: + that: + - result.msg == 'value of config parameter must not be empty for state overridden' + +- name: Parsed with empty running_config should give appropriate error message + register: result + ignore_errors: true + vyos.vyos.vyos_ospf_interfaces: + running_config: + state: parsed + +- assert: + that: + - result.msg == 'value of running_config parameter must not be empty for state + parsed' + +- name: Rendered with empty config should give appropriate error message + register: result + ignore_errors: true + vyos.vyos.vyos_ospf_interfaces: + config: + state: rendered + +- assert: + that: + - result.msg == 'value of config parameter must not be empty for state rendered' diff --git a/tests/integration/targets/vyos_ospf_interfaces/tests/cli/gathered.yaml b/tests/integration/targets/vyos_ospf_interfaces/tests/cli/gathered.yaml new file mode 100644 index 0000000..ec320c3 --- /dev/null +++ b/tests/integration/targets/vyos_ospf_interfaces/tests/cli/gathered.yaml @@ -0,0 +1,24 @@ +--- +- debug: + msg: START vyos_ospf_interfaces gathered integration tests on connection={{ + ansible_connection }} + +- include_tasks: _remove_config.yaml + +- include_tasks: _populate.yaml + +- block: + + - name: Gather config from the device in structured format. + register: result + vyos.vyos.vyos_ospf_interfaces: + state: gathered + + - become: true + vyos.vyos.vyos_facts: + gather_network_resources: ospf_interfaces + + - assert: + that: + - result.changed == false + - result.gathered|symmetric_difference(ansible_facts['network_resources']['ospf_interfaces']) == [] diff --git a/tests/integration/targets/vyos_ospf_interfaces/tests/cli/merged.yaml b/tests/integration/targets/vyos_ospf_interfaces/tests/cli/merged.yaml new file mode 100644 index 0000000..294b6f1 --- /dev/null +++ b/tests/integration/targets/vyos_ospf_interfaces/tests/cli/merged.yaml @@ -0,0 +1,53 @@ +--- +- debug: + msg: START vyos_ospf_interfaces merged integration tests on connection={{ + ansible_connection }} + +- include_tasks: _remove_config.yaml + +- block: + + - name: Merge the provided configuration with the exisiting running configuration + register: result + vyos.vyos.vyos_ospf_interfaces: &id001 + config: + - name: "eth0" + address_family: + - afi: "ipv4" + cost: 50 + priority: 26 + - afi: "ipv6" + mtu_ignore: true + instance: 33 + - name: "bond2" + address_family: + - afi: "ipv4" + transmit_delay: 45 + - afi: "ipv6" + passive: true + state: merged + + - become: true + vyos.vyos.vyos_facts: + gather_network_resources: ospf_interfaces + + - assert: + that: + - result.commands|length == 6 + - result.changed == true + - result.commands|symmetric_difference(merged.commands) == [] + - result.after|symmetric_difference(ansible_facts['network_resources']['ospf_interfaces']) == [] + + - name: Merge the provided configuration with the existing running configuration + (IDEMPOTENT) + register: result + vyos.vyos.vyos_ospf_interfaces: *id001 + + - name: Assert that the previous task was idempotent + assert: + that: + - result['changed'] == false + + always: + + - include_tasks: _remove_config.yaml diff --git a/tests/integration/targets/vyos_ospf_interfaces/tests/cli/overridden.yaml b/tests/integration/targets/vyos_ospf_interfaces/tests/cli/overridden.yaml new file mode 100644 index 0000000..67bbca1 --- /dev/null +++ b/tests/integration/targets/vyos_ospf_interfaces/tests/cli/overridden.yaml @@ -0,0 +1,49 @@ +--- +- debug: + msg: START vyos_ospf_interfaces overridden integration tests on connection={{ + ansible_connection }} + +- include_tasks: _remove_config.yaml + +- include_tasks: _populate.yaml + +- block: + + - name: Override the existing configuration with the provided running configuration + register: result + vyos.vyos.vyos_ospf_interfaces: &id001 + config: + - name: "eth0" + address_family: + - afi: "ipv4" + transmit_delay: 50 + priority: 26 + network: "point-to-point" + - afi: "ipv6" + dead_interval: 39 + state: overridden + + - become: true + vyos.vyos.vyos_facts: + gather_network_resources: ospf_interfaces + + - assert: + that: + - result.commands|length == 8 + - result.changed == true + - result.commands|symmetric_difference(overridden.commands) == [] + - result.after|symmetric_difference(ansible_facts['network_resources']['ospf_interfaces']) == [] + + - name: Override the existing configuration with the provided running configuration + (IDEMPOTENT) + register: result + vyos.vyos.vyos_ospf_interfaces: *id001 + + - name: Assert that the previous task was idempotent + assert: + that: + - result['changed'] == false + + always: + + - include_tasks: _remove_config.yaml diff --git a/tests/integration/targets/vyos_ospf_interfaces/tests/cli/parsed.yaml b/tests/integration/targets/vyos_ospf_interfaces/tests/cli/parsed.yaml new file mode 100644 index 0000000..a065a00 --- /dev/null +++ b/tests/integration/targets/vyos_ospf_interfaces/tests/cli/parsed.yaml @@ -0,0 +1,16 @@ +--- +- debug: + msg: START vyos_ospfv3_interfaces parsed integration tests on connection={{ ansible_connection + }} + +- name: Provide the running configuration for parsing (config to be parsed) + become: true + register: result + vyos.vyos.vyos_ospf_interfaces: + running_config: "{{ lookup('file', '_parsed.cfg') }}" + state: parsed + +- assert: + that: + - result.changed == false + - result.parsed|symmetric_difference(merged.after) == [] diff --git a/tests/integration/targets/vyos_ospf_interfaces/tests/cli/rendered.yaml b/tests/integration/targets/vyos_ospf_interfaces/tests/cli/rendered.yaml new file mode 100644 index 0000000..328406b --- /dev/null +++ b/tests/integration/targets/vyos_ospf_interfaces/tests/cli/rendered.yaml @@ -0,0 +1,33 @@ +--- +- debug: + msg: START vyos_ospf_interfaces rendered integration tests on connection={{ + ansible_connection }} + +- include_tasks: _remove_config.yaml + +- block: + + - name: Structure provided configuration into device specific commands + register: result + vyos.vyos.vyos_ospf_interfaces: + config: + - name: "eth0" + address_family: + - afi: "ipv4" + cost: 50 + priority: 26 + - afi: "ipv6" + mtu_ignore: true + instance: 33 + - name: "bond2" + address_family: + - afi: "ipv4" + transmit_delay: 45 + - afi: "ipv6" + passive: true + state: rendered + + - assert: + that: + - result.changed == false + - result.rendered|symmetric_difference(merged.commands) == [] diff --git a/tests/integration/targets/vyos_ospf_interfaces/tests/cli/replaced.yaml b/tests/integration/targets/vyos_ospf_interfaces/tests/cli/replaced.yaml new file mode 100644 index 0000000..ff32012 --- /dev/null +++ b/tests/integration/targets/vyos_ospf_interfaces/tests/cli/replaced.yaml @@ -0,0 +1,60 @@ +--- +- debug: + msg: START vyos_ospf_interfaces replaced integration tests on connection={{ + ansible_connection }} + +- include_tasks: _remove_config.yaml + +- include_tasks: _populate.yaml + +- block: + + - name: Replace the existing configuration with the provided running configuration + register: result + vyos.vyos.vyos_ospf_interfaces: &id001 + config: + - name: "eth0" + address_family: + - afi: "ipv4" + transmit_delay: 50 + priority: 26 + network: "point-to-point" + - afi: "ipv6" + dead_interval: 39 + - name: "bond2" + address_family: + - afi: "ipv4" + transmit_delay: 45 + bandwidth: 70 + authentication: + md5_key: + key_id: 10 + key: "1111111111232345" + - afi: "ipv6" + passive: true + state: replaced + + - become: true + vyos.vyos.vyos_facts: + gather_network_resources: ospf_interfaces + + - assert: + that: + - result.commands|length == 8 + - result.changed == true + - result.commands|symmetric_difference(replaced.commands) == [] + - result.after|symmetric_difference(ansible_facts['network_resources']['ospf_interfaces']) == [] + + - name: Replace the existing configuration with the provided running configuration + (IDEMPOTENT) + register: result + vyos.vyos.vyos_ospf_interfaces: *id001 + + - name: Assert that the previous task was idempotent + assert: + that: + - result['changed'] == false + + always: + + - include_tasks: _remove_config.yaml diff --git a/tests/integration/targets/vyos_ospf_interfaces/tests/cli/rtt.yaml b/tests/integration/targets/vyos_ospf_interfaces/tests/cli/rtt.yaml new file mode 100644 index 0000000..46eb79d --- /dev/null +++ b/tests/integration/targets/vyos_ospf_interfaces/tests/cli/rtt.yaml @@ -0,0 +1,70 @@ +--- +- debug: + msg: START vyos_ospf_interfaces rtt integration tests on connection={{ + ansible_connection }} + +- include_tasks: _remove_config.yaml + + +- block: + + - name: Merge the provided configuration with the exisiting running configuration + register: baseconfig + vyos.vyos.vyos_ospf_interfaces: &id001 + config: + - name: "eth0" + address_family: + - afi: "ipv4" + cost: 50 + priority: 26 + - afi: "ipv6" + mtu_ignore: true + instance: 33 + - name: "bond2" + address_family: + - afi: "ipv4" + transmit_delay: 45 + - afi: "ipv6" + passive: true + state: merged + + - become: true + vyos.vyos.vyos_facts: + gather_network_resources: ospf_interfaces + + - assert: + that: + - baseconfig.commands|length == 6 + - baseconfig.changed == true + - baseconfig.commands|symmetric_difference(merged.commands) == [] + - baseconfig.after|symmetric_difference(ansible_facts['network_resources']['ospf_interfaces']) == [] + + - name: Apply the provided configuration (config to be reverted) + become: true + register: result + vyos.vyos.vyos_ospf_interfaces: + config: + - name: "eth0" + address_family: + - afi: "ipv4" + transmit_delay: 50 + priority: 26 + network: "point-to-point" + - afi: "ipv6" + dead_interval: 39 + + + - name: Revert back to base config using facts round trip + become: true + register: revert + vyos.vyos.vyos_ospf_interfaces: + config: "{{ ansible_facts['network_resources']['ospf_interfaces'] }}" + state: overridden + + - name: Assert that config was reverted + assert: + that: baseconfig.after == revert.after + + always: + + - include_tasks: _remove_config.yaml diff --git a/tests/integration/targets/vyos_ospf_interfaces/vars/main.yaml b/tests/integration/targets/vyos_ospf_interfaces/vars/main.yaml new file mode 100644 index 0000000..a98d351 --- /dev/null +++ b/tests/integration/targets/vyos_ospf_interfaces/vars/main.yaml @@ -0,0 +1,133 @@ +--- +merged: + commands: + - set interfaces ethernet eth0 ip ospf cost 50 + - set interfaces ethernet eth0 ip ospf priority 26 + - set interfaces ethernet eth0 ipv6 ospfv3 mtu-ignore + - set interfaces ethernet eth0 ipv6 ospfv3 instance-id 33 + - set interfaces bonding bond2 ip ospf transmit-delay 45 + - set interfaces bonding bond2 ipv6 ospfv3 passive + after: + - address_family: + - afi: "ipv4" + transmit_delay: 45 + - afi: "ipv6" + passive: true + name: "bond2" + - address_family: + - afi: "ipv4" + cost: 50 + priority: 26 + - afi: "ipv6" + instance: "33" + mtu_ignore: true + name: "eth0" + +replaced: + commands: + - set interfaces ethernet eth0 ip ospf transmit-delay 50 + - set interfaces ethernet eth0 ip ospf network point-to-point + - set interfaces ethernet eth0 ipv6 ospfv3 dead-interval 39 + - delete interfaces ethernet eth0 ip ospf cost 50 + - delete interfaces ethernet eth0 ipv6 ospfv3 instance-id 33 + - delete interfaces ethernet eth0 ipv6 ospfv3 mtu-ignore + - set interfaces bonding bond2 ip ospf bandwidth 70 + - set interfaces bonding bond2 ip ospf authentication md5 key-id 10 md5-key 1111111111232345 + + after: + - address_family: + - afi: "ipv4" + authentication: + md5_key: + key: "1111111111232345" + key_id: 10 + bandwidth: 70 + transmit_delay: 45 + - afi: "ipv6" + passive: true + name: "bond2" + - address_family: + - afi: "ipv4" + network: "point-to-point" + priority: 26 + transmit_delay: 50 + - afi: "ipv6" + dead_interval: 39 + name: "eth0" + +overridden: + commands: + - delete interfaces bonding bond2 ip ospf + - delete interfaces bonding bond2 ipv6 ospfv3 + - set interfaces ethernet eth0 ip ospf transmit-delay 50 + - set interfaces ethernet eth0 ip ospf network point-to-point + - set interfaces ethernet eth0 ipv6 ospfv3 dead-interval 39 + - delete interfaces ethernet eth0 ip ospf cost 50 + - delete interfaces ethernet eth0 ipv6 ospfv3 instance-id 33 + - delete interfaces ethernet eth0 ipv6 ospfv3 mtu-ignore + + after: + - address_family: + - afi: "ipv4" + network: "point-to-point" + priority: 26 + transmit_delay: 50 + - afi: "ipv6" + dead_interval: 39 + name: "eth0" + +deleted: + commands: + - delete interfaces bonding bond2 ip ospf + - delete interfaces bonding bond2 ipv6 ospfv3 + after: + - address_family: + - afi: "ipv4" + cost: 50 + priority: 26 + - afi: "ipv6" + instance: "33" + mtu_ignore: true + name: "eth0" + +rendered: + commands: + - set interfaces ethernet eth1 firewall in name 'INBOUND' + - set interfaces ethernet eth1 firewall out name 'OUTBOUND' + - set interfaces ethernet eth1 firewall local name 'LOCAL' + - set interfaces ethernet eth1 firewall local ipv6-name 'V6-LOCAL' + - set interfaces ethernet eth2 firewall in name 'INBOUND' + - set interfaces ethernet eth2 firewall out name 'OUTBOUND' + - set interfaces ethernet eth2 firewall local name 'LOCAL' + - set interfaces ethernet eth2 firewall local ipv6-name 'V6-LOCAL' +round_trip: + after: + - name: eth0 + - access_rules: + - afi: ipv4 + rules: + - direction: in + name: INBOUND + - direction: local + name: LOCAL + - direction: out + name: OUTBOUND + - afi: ipv6 + rules: + - direction: local + name: V6-LOCAL + name: eth1 + - name: eth2 + access_rules: + - afi: ipv4 + rules: + - direction: in + name: INBOUND + - direction: local + name: LOCAL + - direction: out + name: OUTBOUND + - afi: ipv6 + rules: + - direction: local + name: V6-LOCAL |