Skip to content

Commit

Permalink
netinterface: remove redundant verify_set_static_mac testcase
Browse files Browse the repository at this point in the history
  • Loading branch information
sharsonia committed Jul 21, 2023
1 parent 7656817 commit bd7e8e1
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 85 deletions.
17 changes: 0 additions & 17 deletions lisa/tools/ip.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,23 +201,6 @@ def set_mtu(self, nic_name: str, mtu: int) -> None:
new_mtu = self.get_mtu(nic_name=nic_name)
assert_that(new_mtu).described_as("set mtu failed").is_equal_to(mtu)

def set_mac_address(self, nic_name: str, mac_address: str) -> None:
if not self.__mac_address_pattern.match(mac_address):
raise LisaException(f"MAC address {mac_address} is invalid")
self.down(nic_name)
try:
self.node.execute(
f"/sbin/ip link set {nic_name} address {mac_address}",
shell=True,
sudo=True,
expected_exit_code=0,
expected_exit_code_failure_message=(
f"fail to set mac address {mac_address} for nic {nic_name}"
),
)
finally:
self.up(nic_name)

def nic_exists(self, nic_name: str) -> bool:
result = self.run(f"link show {nic_name}", force_run=True, sudo=True)
return not (
Expand Down
68 changes: 0 additions & 68 deletions microsoft/testsuites/network/netinterface.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
from pathlib import Path

from assertpy import assert_that
from randmac import RandMac # type: ignore

from lisa import (
LisaException,
Expand All @@ -23,8 +22,6 @@
from lisa.tools import Ip, KernelConfig, Uname, Wget
from lisa.util import perf_timer

from .common import restore_extra_nics_per_node


@TestSuiteMetadata(
area="network",
Expand Down Expand Up @@ -152,71 +149,6 @@ def verify_network_interface_reload_via_ip_link(
"Cannot access internet from inside VM after test run."
)

@TestCaseMetadata(
description="""
This test case verifies if the second network interface can be brought up
after setting static MAC address.
Steps:
1. Validate the second nic has IP address.
2. Bring down the second nic.
3. Set a random MAC address to the second nic.
4. Bring up the second nic.
""",
priority=3,
requirement=simple_requirement(
network_interface=schema.NetworkInterfaceOptionSettings(
nic_count=2,
),
),
)
def verify_set_static_mac(self, node: Node, log: Logger) -> None:
ip = node.tools[Ip]
node_nic_info = Nics(node)
node_nic_info.initialize()
origin_nic_count = len(node_nic_info)
# attach one more nic for testing if only 1 nic by default
if 1 == origin_nic_count:
network_interface_feature = node.features[NetworkInterface]
network_interface_feature.attach_nics(
extra_nic_count=1, enable_accelerated_networking=True
)
node_nic_info = Nics(node)
node_nic_info.initialize()
# get one nic which is not eth0 for setting new mac address
current_nic_count = len(node_nic_info)
for index in range(0, current_nic_count):
test_nic = node_nic_info.get_nic_by_index(index)
test_nic_name = test_nic.name
if "eth0" == test_nic_name:
continue
assert_that(test_nic).is_not_none()
assert_that(test_nic.ip_addr).is_not_none()
assert_that(test_nic.mac_addr).is_not_none()
origin_mac_address = test_nic.mac_addr
try:
random_mac_address = str(RandMac())
ip.set_mac_address(test_nic_name, random_mac_address)
node_nic_info.load_nics_info(test_nic_name)
assert_that(test_nic.mac_addr).described_as(
f"fail to set network interface {test_nic_name}'s mac "
f"address into {random_mac_address}"
).is_equal_to(random_mac_address)
finally:
# restore the test nic state back to origin state
ip.set_mac_address(test_nic_name, origin_mac_address)
node_nic_info.load_nics_info(test_nic_name)
assert_that(test_nic.mac_addr).described_as(
f"fail to set network interface {test_nic}'s mac "
f"address back into {origin_mac_address}"
).is_equal_to(origin_mac_address)
# restore vm nics status if 1 extra nic attached
if 1 == origin_nic_count:
restore_extra_nics_per_node(node)
node_nic_info = Nics(node)
node_nic_info.initialize()

def _validate_netvsc_built_in(self, node: Node) -> None:
if isinstance(node.os, FreeBSD):
# Use command "config -x /boot/kernel/kernel | grep hyperv" can also check
Expand Down

0 comments on commit bd7e8e1

Please sign in to comment.