From 6dc9d721513dca5a573c7ee01b74d703ff41f95f Mon Sep 17 00:00:00 2001 From: omnom62 <75066712+omnom62@users.noreply.github.com> Date: Fri, 21 Aug 2026 23:41:34 +1000 Subject: T8989: prefix_lists module * prefix_lists module * prefix_lists module rst * t8989 prefix_lists module * Converage tests fixes * T8989: SIT updates --- .../vyos_prefix_lists/tests/httpapi/_deleted.yaml | 28 -------- .../vyos_prefix_lists/tests/httpapi/_gathered.yaml | 20 ------ .../vyos_prefix_lists/tests/httpapi/_merged.yaml | 42 ----------- .../vyos_prefix_lists/tests/httpapi/_replaced.yaml | 37 ---------- .../vyos_prefix_lists/tests/httpapi/deleted.yaml | 28 ++++++++ .../vyos_prefix_lists/tests/httpapi/gathered.yaml | 20 ++++++ .../vyos_prefix_lists/tests/httpapi/merged.yaml | 42 +++++++++++ .../tests/httpapi/overridden.yaml | 38 ++++++++++ .../vyos_prefix_lists/tests/httpapi/replaced.yaml | 37 ++++++++++ .../vyos_prefix_lists/tests/httpapi/rtt.yaml | 81 ++++++++++++++++++++++ 10 files changed, 246 insertions(+), 127 deletions(-) delete mode 100644 tests/integration/targets/vyos_prefix_lists/tests/httpapi/_deleted.yaml delete mode 100644 tests/integration/targets/vyos_prefix_lists/tests/httpapi/_gathered.yaml delete mode 100644 tests/integration/targets/vyos_prefix_lists/tests/httpapi/_merged.yaml delete mode 100644 tests/integration/targets/vyos_prefix_lists/tests/httpapi/_replaced.yaml create mode 100644 tests/integration/targets/vyos_prefix_lists/tests/httpapi/deleted.yaml create mode 100644 tests/integration/targets/vyos_prefix_lists/tests/httpapi/gathered.yaml create mode 100644 tests/integration/targets/vyos_prefix_lists/tests/httpapi/merged.yaml create mode 100644 tests/integration/targets/vyos_prefix_lists/tests/httpapi/overridden.yaml create mode 100644 tests/integration/targets/vyos_prefix_lists/tests/httpapi/replaced.yaml create mode 100644 tests/integration/targets/vyos_prefix_lists/tests/httpapi/rtt.yaml (limited to 'tests/integration') diff --git a/tests/integration/targets/vyos_prefix_lists/tests/httpapi/_deleted.yaml b/tests/integration/targets/vyos_prefix_lists/tests/httpapi/_deleted.yaml deleted file mode 100644 index 6cfb063..0000000 --- a/tests/integration/targets/vyos_prefix_lists/tests/httpapi/_deleted.yaml +++ /dev/null @@ -1,28 +0,0 @@ ---- -- debug: - msg: START vyos_prefix_lists deleted integration tests on connection={{ ansible_connection }} - -- include_tasks: _remove_config.yaml -- include_tasks: _populate_config.yaml - -- block: - - name: Delete all prefix_lists configuration - register: result - vyos.rest.vyos_prefix_lists: &id001 - state: deleted - - - assert: - that: - - result.changed == true - - - name: Delete prefix_lists configuration (IDEMPOTENT) - register: result - vyos.rest.vyos_prefix_lists: *id001 - - - name: Assert idempotent - assert: - that: - - result.changed == false - - always: - - include_tasks: _remove_config.yaml diff --git a/tests/integration/targets/vyos_prefix_lists/tests/httpapi/_gathered.yaml b/tests/integration/targets/vyos_prefix_lists/tests/httpapi/_gathered.yaml deleted file mode 100644 index 083cb48..0000000 --- a/tests/integration/targets/vyos_prefix_lists/tests/httpapi/_gathered.yaml +++ /dev/null @@ -1,20 +0,0 @@ ---- -- debug: - msg: START vyos_prefix_lists gathered integration tests on connection={{ ansible_connection }} - -- include_tasks: _remove_config.yaml -- include_tasks: _populate_config.yaml - -- block: - - name: Gather prefix_lists configuration - register: result - vyos.rest.vyos_prefix_lists: - state: gathered - - - assert: - that: - - result.changed == false - - result.gathered | selectattr('afi','eq','ipv4') | list | length > 0 - - always: - - include_tasks: _remove_config.yaml diff --git a/tests/integration/targets/vyos_prefix_lists/tests/httpapi/_merged.yaml b/tests/integration/targets/vyos_prefix_lists/tests/httpapi/_merged.yaml deleted file mode 100644 index a70f826..0000000 --- a/tests/integration/targets/vyos_prefix_lists/tests/httpapi/_merged.yaml +++ /dev/null @@ -1,42 +0,0 @@ ---- -- debug: - msg: START vyos_prefix_lists merged integration tests on connection={{ ansible_connection }} - -- include_tasks: _remove_config.yaml - -- block: - - name: Merge prefix_lists configuration - register: result - vyos.rest.vyos_prefix_lists: &id001 - config: - - afi: ipv4 - prefix_lists: - - name: AnsibleIPv4PrefixList - description: PL configured by ansible - entries: - - sequence: 2 - action: permit - prefix: 92.168.10.0/26 - le: 32 - - sequence: 3 - action: deny - prefix: 72.168.2.0/24 - ge: 26 - state: merged - - - assert: - that: - - result.changed == true - - - name: Merge prefix_lists configuration (IDEMPOTENT) - register: result - vyos.rest.vyos_prefix_lists: *id001 - - - name: Assert idempotent - assert: - that: - - result.changed == false - - result.commands == [] - - always: - - include_tasks: _remove_config.yaml diff --git a/tests/integration/targets/vyos_prefix_lists/tests/httpapi/_replaced.yaml b/tests/integration/targets/vyos_prefix_lists/tests/httpapi/_replaced.yaml deleted file mode 100644 index bd8c5c1..0000000 --- a/tests/integration/targets/vyos_prefix_lists/tests/httpapi/_replaced.yaml +++ /dev/null @@ -1,37 +0,0 @@ ---- -- debug: - msg: START vyos_prefix_lists replaced integration tests on connection={{ ansible_connection }} - -- include_tasks: _remove_config.yaml -- include_tasks: _populate_config.yaml - -- block: - - name: Replace prefix_lists configuration - register: result - vyos.rest.vyos_prefix_lists: &id001 - config: - - afi: ipv4 - prefix_lists: - - name: AnsibleIPv4PrefixList - entries: - - sequence: 10 - action: permit - prefix: 10.0.0.0/8 - state: replaced - - - assert: - that: - - result.changed == true - - - name: Replace prefix_lists configuration (IDEMPOTENT) - register: result - vyos.rest.vyos_prefix_lists: *id001 - - - name: Assert idempotent - assert: - that: - - result.changed == false - - result.commands == [] - - always: - - include_tasks: _remove_config.yaml diff --git a/tests/integration/targets/vyos_prefix_lists/tests/httpapi/deleted.yaml b/tests/integration/targets/vyos_prefix_lists/tests/httpapi/deleted.yaml new file mode 100644 index 0000000..6cfb063 --- /dev/null +++ b/tests/integration/targets/vyos_prefix_lists/tests/httpapi/deleted.yaml @@ -0,0 +1,28 @@ +--- +- debug: + msg: START vyos_prefix_lists deleted integration tests on connection={{ ansible_connection }} + +- include_tasks: _remove_config.yaml +- include_tasks: _populate_config.yaml + +- block: + - name: Delete all prefix_lists configuration + register: result + vyos.rest.vyos_prefix_lists: &id001 + state: deleted + + - assert: + that: + - result.changed == true + + - name: Delete prefix_lists configuration (IDEMPOTENT) + register: result + vyos.rest.vyos_prefix_lists: *id001 + + - name: Assert idempotent + assert: + that: + - result.changed == false + + always: + - include_tasks: _remove_config.yaml diff --git a/tests/integration/targets/vyos_prefix_lists/tests/httpapi/gathered.yaml b/tests/integration/targets/vyos_prefix_lists/tests/httpapi/gathered.yaml new file mode 100644 index 0000000..083cb48 --- /dev/null +++ b/tests/integration/targets/vyos_prefix_lists/tests/httpapi/gathered.yaml @@ -0,0 +1,20 @@ +--- +- debug: + msg: START vyos_prefix_lists gathered integration tests on connection={{ ansible_connection }} + +- include_tasks: _remove_config.yaml +- include_tasks: _populate_config.yaml + +- block: + - name: Gather prefix_lists configuration + register: result + vyos.rest.vyos_prefix_lists: + state: gathered + + - assert: + that: + - result.changed == false + - result.gathered | selectattr('afi','eq','ipv4') | list | length > 0 + + always: + - include_tasks: _remove_config.yaml diff --git a/tests/integration/targets/vyos_prefix_lists/tests/httpapi/merged.yaml b/tests/integration/targets/vyos_prefix_lists/tests/httpapi/merged.yaml new file mode 100644 index 0000000..a70f826 --- /dev/null +++ b/tests/integration/targets/vyos_prefix_lists/tests/httpapi/merged.yaml @@ -0,0 +1,42 @@ +--- +- debug: + msg: START vyos_prefix_lists merged integration tests on connection={{ ansible_connection }} + +- include_tasks: _remove_config.yaml + +- block: + - name: Merge prefix_lists configuration + register: result + vyos.rest.vyos_prefix_lists: &id001 + config: + - afi: ipv4 + prefix_lists: + - name: AnsibleIPv4PrefixList + description: PL configured by ansible + entries: + - sequence: 2 + action: permit + prefix: 92.168.10.0/26 + le: 32 + - sequence: 3 + action: deny + prefix: 72.168.2.0/24 + ge: 26 + state: merged + + - assert: + that: + - result.changed == true + + - name: Merge prefix_lists configuration (IDEMPOTENT) + register: result + vyos.rest.vyos_prefix_lists: *id001 + + - name: Assert idempotent + assert: + that: + - result.changed == false + - result.commands == [] + + always: + - include_tasks: _remove_config.yaml diff --git a/tests/integration/targets/vyos_prefix_lists/tests/httpapi/overridden.yaml b/tests/integration/targets/vyos_prefix_lists/tests/httpapi/overridden.yaml new file mode 100644 index 0000000..f895488 --- /dev/null +++ b/tests/integration/targets/vyos_prefix_lists/tests/httpapi/overridden.yaml @@ -0,0 +1,38 @@ +--- +- debug: + msg: START vyos_prefix_lists overridden integration tests on connection={{ ansible_connection }} + +- include_tasks: _remove_config.yaml +- include_tasks: _populate_config.yaml + +- block: + - name: Override prefix_lists configuration + register: result + vyos.rest.vyos_prefix_lists: &id001 + config: + - afi: ipv4 + prefix_lists: + - name: AnsibleIPv4PrefixList + description: Overridden by ansible + entries: + - sequence: 2 + action: permit + prefix: 92.168.10.0/26 + le: 32 + state: overridden + + - assert: + that: + - result.changed == true + + - name: Override prefix_lists configuration (IDEMPOTENT) + register: result + vyos.rest.vyos_prefix_lists: *id001 + + - assert: + that: + - result.changed == false + - result.commands == [] + + always: + - include_tasks: _remove_config.yaml diff --git a/tests/integration/targets/vyos_prefix_lists/tests/httpapi/replaced.yaml b/tests/integration/targets/vyos_prefix_lists/tests/httpapi/replaced.yaml new file mode 100644 index 0000000..bd8c5c1 --- /dev/null +++ b/tests/integration/targets/vyos_prefix_lists/tests/httpapi/replaced.yaml @@ -0,0 +1,37 @@ +--- +- debug: + msg: START vyos_prefix_lists replaced integration tests on connection={{ ansible_connection }} + +- include_tasks: _remove_config.yaml +- include_tasks: _populate_config.yaml + +- block: + - name: Replace prefix_lists configuration + register: result + vyos.rest.vyos_prefix_lists: &id001 + config: + - afi: ipv4 + prefix_lists: + - name: AnsibleIPv4PrefixList + entries: + - sequence: 10 + action: permit + prefix: 10.0.0.0/8 + state: replaced + + - assert: + that: + - result.changed == true + + - name: Replace prefix_lists configuration (IDEMPOTENT) + register: result + vyos.rest.vyos_prefix_lists: *id001 + + - name: Assert idempotent + assert: + that: + - result.changed == false + - result.commands == [] + + always: + - include_tasks: _remove_config.yaml diff --git a/tests/integration/targets/vyos_prefix_lists/tests/httpapi/rtt.yaml b/tests/integration/targets/vyos_prefix_lists/tests/httpapi/rtt.yaml new file mode 100644 index 0000000..de816eb --- /dev/null +++ b/tests/integration/targets/vyos_prefix_lists/tests/httpapi/rtt.yaml @@ -0,0 +1,81 @@ +--- +- debug: + msg: START vyos_prefix_lists round trip integration tests on connection={{ ansible_connection }} + +- include_tasks: _remove_config.yaml + +- block: + - name: RTT - Apply base configuration + vyos.rest.vyos_prefix_lists: + config: + - afi: ipv4 + prefix_lists: + - name: AnsibleIPv4PrefixList + description: PL configured by ansible + entries: + - sequence: 2 + action: permit + prefix: 92.168.10.0/26 + le: 32 + - sequence: 3 + action: deny + prefix: 72.168.2.0/24 + ge: 26 + state: merged + + - name: RTT - Gather configuration + register: gathered + vyos.rest.vyos_prefix_lists: + state: gathered + + - name: RTT - Assert gathered matches applied + vars: + ipv4_pls: >- + {{ gathered.gathered + | selectattr('afi', 'eq', 'ipv4') + | map(attribute='prefix_lists') + | first }} + assert: + that: + - gathered.gathered | selectattr('afi', 'eq', 'ipv4') | list | length == 1 + - ipv4_pls | selectattr('name', 'eq', 'AnsibleIPv4PrefixList') | list | length == 1 + + - name: RTT - Modify configuration + vyos.rest.vyos_prefix_lists: + config: + - afi: ipv4 + prefix_lists: + - name: AnsibleIPv4PrefixList + description: Modified by ansible + entries: + - sequence: 2 + action: permit + prefix: 92.168.10.0/26 + le: 32 + state: replaced + + - name: RTT - Gather modified configuration + register: gathered2 + vyos.rest.vyos_prefix_lists: + state: gathered + + - name: RTT - Assert modification applied correctly + vars: + ipv4_pls2: >- + {{ gathered2.gathered + | selectattr('afi', 'eq', 'ipv4') + | map(attribute='prefix_lists') + | first }} + pl_entries: >- + {{ ipv4_pls2 + | selectattr('name', 'eq', 'AnsibleIPv4PrefixList') + | map(attribute='entries') + | first }} + assert: + that: + - gathered2.gathered | selectattr('afi', 'eq', 'ipv4') | list | length == 1 + - pl_entries | length == 1 + - pl_entries | selectattr('sequence', 'eq', 2) | list | length == 1 + + always: + - include_tasks: _remove_config.yaml -- cgit v1.2.3