Skip to content

Commit

Permalink
tests: Prioritize find link info by permanent MAC address, with fallb…
Browse files Browse the repository at this point in the history
…ack to current address

Add the integration test `tests_mac_address_match.yml` to verify that
the commit "Prioritize find link info by permanent MAC address, with
fallback to current address" (c341683) can properly resolve the
scenarios where multiple network interfaces share the same current MAC
address, leading to potential ambiguity in link matching (for example,
Virtual interfaces or VLANs, which often lack a valid perm-address and
rely on the parent interface's address).

Notice that the test `tests_mac_address_match.yml` will be skipped in
upstream testing and it will only be manually tested downstream since it
requires to know the mac address to match when configuring vlan's
parent.

Signed-off-by: Wen Liang <liangwen12year@gmail.com>
  • Loading branch information
liangwen12year authored and Wen Liang committed Jan 18, 2025
1 parent 2439f44 commit 890a2ad
Show file tree
Hide file tree
Showing 3 changed files with 74 additions and 0 deletions.
43 changes: 43 additions & 0 deletions tests/playbooks/tests_mac_address_match.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# SPDX-License-Identifier: BSD-3-Clause
---
- name: Play for testing MAC address match on device
hosts: all
vars_prompt:
- name: "interface"
prompt: "Please provide the interface name (e.g., eno2)"
private: no
- name: "mac"
prompt: "Please provide the MAC address to match (e.g., ec:f4:BB:d3:EC:92)"
private: no
vars:
profile: "{{ interface }}"
vlan_profile: "{{ interface }}.3732"
lsr_fail_debug:
- __network_connections_result
tags:
- "tests::mac"
tasks:
- name: Show playbook name
debug:
msg: "this is: playbooks/tests_mac_address_match.yml"
tags:
- always

- name: Test the MAC address match
tags:
- tests::mac:match
block:
- name: Include the task 'run_test.yml'
include_tasks: tasks/run_test.yml
vars:
lsr_description: Test MAC address match on device
lsr_setup:
- tasks/assert_profile_absent.yml
lsr_test:
- tasks/create_mac_address_match.yml
lsr_assert:
- tasks/assert_profile_present.yml
- tasks/assert_network_connections_succeeded.yml
lsr_cleanup:
- tasks/cleanup_vlan_and_parent_profile+device.yml
- tasks/check_network_dns.yml
8 changes: 8 additions & 0 deletions tests/tasks/assert_network_connections_succeeded.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# SPDX-License-Identifier: BSD-3-Clause
---
- name: Assert that configuring network connections is succeeded
assert:
that:
- __network_connections_result.failed == false
msg: Configuring network connections is failed with the error
"{{ __network_connections_result.stderr }}"
23 changes: 23 additions & 0 deletions tests/tasks/cleanup_vlan_and_parent_profile+device.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# SPDX-License-Identifier: BSD-3-Clause
---
- name: Clean up the test devices and the connection profiles
tags:
- "tests::cleanup"
block:
- name: Import network role
import_role:
name: linux-system-roles.network
vars:
network_connections:
- name: "{{ profile }}"
persistent_state: absent
state: down
- name: "{{ vlan_profile }}"
persistent_state: absent
state: down
failed_when: false
- name: Delete the device '{{ interface }}'
command: ip link del {{ interface }}
failed_when: false
changed_when: false
...

0 comments on commit 890a2ad

Please sign in to comment.