Skip to content

Commit d2f82ab

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 it requires to know the 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 d2f82ab

File tree

4 files changed

+131
-0
lines changed

4 files changed

+131
-0
lines changed
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
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. Please provide the name of an
9+
interface that has a permanent MAC address (e.g., eno2)"
10+
private: false
11+
vars:
12+
profile: "{{ interface }}"
13+
vlan_profile: "{{ interface }}.3732"
14+
lsr_fail_debug:
15+
- __network_connections_result
16+
tags:
17+
- "tests::mac"
18+
tasks:
19+
- name: Show playbook name
20+
debug:
21+
msg: "this is: playbooks/tests_mac_address_match.yml"
22+
tags:
23+
- always
24+
25+
- name: Install ethtool (test dependency)
26+
package:
27+
name: ethtool
28+
state: present
29+
use: "{{ (__network_is_ostree | d(false)) |
30+
ternary('ansible.posix.rhel_rpm_ostree', omit) }}"
31+
32+
- name: Retrieve MAC address using ethtool
33+
command: ethtool -P {{ interface }}
34+
register: mac_address_result
35+
changed_when: false
36+
failed_when: mac_address_result.rc != 0
37+
38+
- name: Set the MAC address variable
39+
set_fact:
40+
mac: "{{ mac_address_result.stdout_lines[-1].split(' ')[-1] }}"
41+
42+
- name: Display the retrieved MAC address
43+
debug:
44+
msg: "Retrieved MAC address for {{ interface }}: {{ mac }}"
45+
46+
- name: Test the MAC address match
47+
tags:
48+
- tests::mac:match
49+
block:
50+
- name: Include the task 'run_test.yml'
51+
include_tasks: tasks/run_test.yml
52+
vars:
53+
lsr_description: Test MAC address match on device
54+
lsr_setup:
55+
- tasks/assert_profile_absent.yml
56+
lsr_test:
57+
- tasks/create_mac_address_match.yml
58+
lsr_assert:
59+
- tasks/assert_profile_present.yml
60+
- tasks/assert_network_connections_succeeded.yml
61+
lsr_cleanup:
62+
- tasks/cleanup_vlan_and_parent_profile+device.yml
63+
- 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)