Skip to content

Commit

Permalink
give more precise error type matching
Browse files Browse the repository at this point in the history
  • Loading branch information
LiliDeng committed Dec 2, 2023
1 parent abc4251 commit e208f20
Showing 1 changed file with 32 additions and 2 deletions.
34 changes: 32 additions & 2 deletions microsoft/testsuites/network/sriov.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
import re
from pathlib import Path
from typing import Any, Dict, List, cast

Expand All @@ -26,8 +27,21 @@
from lisa.features import NetworkInterface, SerialConsole, StartStop
from lisa.nic import NicInfo
from lisa.sut_orchestrator import AZURE
from lisa.tools import Cat, Ethtool, Firewall, InterruptInspector, Iperf3, Lscpu
from lisa.util import UnsupportedDistroException, check_till_timeout
from lisa.tools import (
Cat,
Ethtool,
Firewall,
InterruptInspector,
Iperf3,
Journalctl,
Lscpu,
)
from lisa.util import (
LisaException,
LisaTimeoutException,
UnsupportedDistroException,
check_till_timeout,
)
from lisa.util.shell import wait_tcp_port_ready
from microsoft.testsuites.network.common import (
cleanup_iperf3,
Expand All @@ -51,6 +65,12 @@
)
class Sriov(TestSuite):
TIME_OUT = 300
# Failed to rename network interface 3 from 'eth1' to 'enP45159s1': Device or resource busy # noqa: E501
_device_rename_pattern = re.compile(
r"Failed to rename network interface .* from '.*' "
"to '.*': Device or resource busy",
re.M,
)

def before_case(self, log: Logger, **kwargs: Any) -> None:
environment: Environment = kwargs.pop("environment")
Expand Down Expand Up @@ -80,6 +100,16 @@ def verify_services_state(self, node: Node) -> None:
lambda: node.tools[Systemctl].state() == "running",
timeout_message="wait for systemctl status to be running",
)
except LisaTimeoutException:
udevd_status = node.tools[Journalctl].logs_for_unit("systemd-udevd")
matched = self._device_rename_pattern.search(udevd_status)
if matched:
raise LisaException(
f"found {matched[0]} message "
"there is a race condition when rename VF nics, "
"it causes boot delay, it should be fixed in "
"systemd - 245.4-4ubuntu3.21"
)
except UnsupportedDistroException as e:
raise SkippedException(e) from e

Expand Down

0 comments on commit e208f20

Please sign in to comment.