Skip to content

Commit a1bac2e

Browse files
tests: Prioritize find link info by permanent MAC address, with fallback 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 the test requires to know the permanent mac address to match when configuring vlan's parent. Resolves: https://issues.redhat.com/browse/RHEL-74211 Signed-off-by: Wen Liang <[email protected]>
1 parent 2439f44 commit a1bac2e

File tree

4 files changed

+133
-0
lines changed

4 files changed

+133
-0
lines changed
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
# SPDX-License-Identifier: BSD-3-Clause
2+
---
3+
- name: Play for testing MAC address match on device
4+
hosts: all
5+
vars_prompt:
6+
- name: "interface"
7+
prompt: "The test requires matching an Ethernet interface to its
8+
permanent MAC address, ensuring that the permanent MAC address matches
9+
the current MAC address. Please provide the name of an interface where
10+
its permanent MAC address equals its current MAC address (e.g., eno2)"
11+
private: false
12+
vars:
13+
profile: "{{ interface }}"
14+
vlan_profile: "{{ interface }}.3732"
15+
lsr_fail_debug:
16+
- __network_connections_result
17+
tags:
18+
- "tests::mac"
19+
tasks:
20+
- name: Show playbook name
21+
debug:
22+
msg: "this is: playbooks/tests_mac_address_match.yml"
23+
tags:
24+
- always
25+
26+
- name: Install ethtool (test dependency)
27+
package:
28+
name: ethtool
29+
state: present
30+
use: "{{ (__network_is_ostree | d(false)) |
31+
ternary('ansible.posix.rhel_rpm_ostree', omit) }}"
32+
33+
- name: Retrieve MAC address using ethtool
34+
command: ethtool -P {{ interface }}
35+
register: mac_address_result
36+
changed_when: false
37+
failed_when: mac_address_result.rc != 0
38+
39+
- name: Set the MAC address variable
40+
set_fact:
41+
mac: "{{ mac_address_result.stdout_lines[-1].split(' ')[-1] }}"
42+
43+
- name: Display the retrieved MAC address
44+
debug:
45+
msg: "Retrieved MAC address for {{ interface }}: {{ mac }}"
46+
47+
- name: Test the MAC address match
48+
tags:
49+
- tests::mac:match
50+
block:
51+
- name: Include the task 'run_test.yml'
52+
include_tasks: tasks/run_test.yml
53+
vars:
54+
lsr_description: Test MAC address match on device
55+
lsr_setup:
56+
- tasks/assert_profile_absent.yml
57+
lsr_test:
58+
- tasks/create_mac_address_match.yml
59+
- tasks/create_mac_address_match.yml
60+
lsr_assert:
61+
- tasks/assert_profile_present.yml
62+
- tasks/assert_network_connections_succeeded.yml
63+
lsr_cleanup:
64+
- tasks/cleanup_vlan_and_parent_profile+device.yml
65+
- tasks/check_network_dns.yml
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# SPDX-License-Identifier: BSD-3-Clause
2+
---
3+
- name: Assert that configuring network connections is succeeded
4+
assert:
5+
that:
6+
- __network_connections_result.failed == false
7+
msg: Configuring network connections is failed with the error
8+
"{{ __network_connections_result.stderr }}"
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# SPDX-License-Identifier: BSD-3-Clause
2+
---
3+
- name: Clean up the test devices and the connection profiles
4+
tags:
5+
- "tests::cleanup"
6+
block:
7+
- name: Import network role
8+
import_role:
9+
name: linux-system-roles.network
10+
vars:
11+
network_connections:
12+
- name: "{{ profile }}"
13+
persistent_state: absent
14+
state: down
15+
- name: "{{ vlan_profile }}"
16+
persistent_state: absent
17+
state: down
18+
failed_when: false
19+
- name: Delete the device '{{ interface }}'
20+
command: ip link del {{ interface }}
21+
failed_when: false
22+
changed_when: false
23+
...
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# SPDX-License-Identifier: BSD-3-Clause
2+
---
3+
- name: Include network role
4+
include_role:
5+
name: linux-system-roles.network
6+
vars:
7+
network_connections:
8+
- name: "{{ interface }}"
9+
state: up
10+
persistent_state: present
11+
autoconnect: true
12+
type: ethernet
13+
interface_name: "{{ interface }}"
14+
mac: "{{ mac }}"
15+
ip:
16+
dhcp4: false
17+
auto6: false
18+
19+
- name: "{{ vlan_profile }}"
20+
state: up
21+
persistent_state: present
22+
type: vlan
23+
parent: "{{ interface }}"
24+
vlan:
25+
id: 3732
26+
autoconnect: true
27+
ip:
28+
auto_gateway: false
29+
ipv6_disabled: true
30+
gateway4: 10.10.0.1
31+
address: 10.10.0.6/24
32+
dhcp4: false
33+
auto6: false
34+
- name: Show result
35+
debug:
36+
var: __network_connections_result
37+
...

0 commit comments

Comments
 (0)