Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

migrate ntttcp test cases. #1698

Merged
merged 7 commits into from
Feb 7, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
131 changes: 93 additions & 38 deletions lisa/messages.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,14 @@
from datetime import datetime
from decimal import Decimal
from enum import Enum
from typing import List, Optional
from typing import TYPE_CHECKING, Any, Dict, List, Optional, Type, TypeVar

from lisa.util import constants
from lisa.schema import NetworkDataPath
from lisa.util import dict_to_fields

if TYPE_CHECKING:
from lisa import Node
from lisa.environment import Environment


@dataclass
Expand Down Expand Up @@ -35,11 +40,37 @@ class TestRunMessage(MessageBase):
message: str = ""


class NetworkProtocol(str, Enum):
IPv4 = "IPv4"
IPv6 = "IPv6"


class TransportProtocol(str, Enum):
Tcp = "TCP"
Udp = "UDP"


@dataclass
class PerfMessage(MessageBase):
type: str = "Performance"
tool: str = ""
test_case_name: str = ""
squirrelsc marked this conversation as resolved.
Show resolved Hide resolved
platform: str = ""
location: str = ""
host_version: str = ""
guest_os_type: str = "Linux"
distro_version: str = ""
vmsize: str = ""
kernel_version: str = ""
lis_version: str = ""
ip_version: str = NetworkProtocol.IPv4
protocol_type: str = TransportProtocol.Tcp
data_path: str = ""
test_date: datetime = datetime.utcnow()


T = TypeVar("T", bound=PerfMessage)

DiskSetupType = Enum(
"DiskSetupType",
[
Expand All @@ -60,16 +91,6 @@ class PerfMessage(MessageBase):

@dataclass
class DiskPerformanceMessage(PerfMessage):
tool: str = constants.DISK_PERFORMANCE_TOOL
test_case_name: str = ""
platform: str = ""
location: str = ""
host_version: str = ""
guest_os_type: str = "Linux"
distro_version: str = ""
vmsize: str = ""
kernel_version: str = ""
lis_version: str = ""
disk_setup_type: DiskSetupType = DiskSetupType.raw
block_size: int = 0
disk_type: DiskType = DiskType.nvme
Expand All @@ -78,7 +99,6 @@ class DiskPerformanceMessage(PerfMessage):
qdepth: int = 0
iodepth: int = 0
numjob: int = 0
test_date: datetime = datetime.utcnow()
read_iops: Decimal = Decimal(0)
read_lat_usec: Decimal = Decimal(0)
randread_iops: Decimal = Decimal(0)
Expand All @@ -91,19 +111,6 @@ class DiskPerformanceMessage(PerfMessage):

@dataclass
class NetworkLatencyPerformanceMessage(PerfMessage):
test_case_name: str = ""
platform: str = ""
location: str = ""
host_version: str = ""
guest_os_type: str = "Linux"
distro_version: str = ""
vmsize: str = ""
kernel_version: str = ""
lis_version: str = ""
ip_version: str = "IPv4"
protocol_type: str = "TCP"
data_path: str = ""
test_date: datetime = datetime.utcnow()
max_latency_us: Decimal = Decimal(0)
average_latency_us: Decimal = Decimal(0)
min_latency_us: Decimal = Decimal(0)
Expand All @@ -115,19 +122,7 @@ class NetworkLatencyPerformanceMessage(PerfMessage):

@dataclass
class NetworkPPSPerformanceMessage(PerfMessage):
test_execution_tag: str = ""
platform: str = ""
location: str = ""
host_version: str = ""
guest_os_type: str = "Linux"
distro_version: str = ""
vmsize: str = ""
kernel_version: str = ""
ip_version: str = "IPv4"
protocol_type: str = "TCP"
data_path: str = ""
test_type: str = ""
test_date: datetime = datetime.utcnow()
rx_pps_minimum: Decimal = Decimal(0)
rx_pps_average: Decimal = Decimal(0)
rx_pps_maximum: Decimal = Decimal(0)
Expand All @@ -137,3 +132,63 @@ class NetworkPPSPerformanceMessage(PerfMessage):
rx_tx_pps_minimum: Decimal = Decimal(0)
rx_tx_pps_average: Decimal = Decimal(0)
rx_tx_pps_maximum: Decimal = Decimal(0)


@dataclass
class NetworkTCPPerformanceMessage(PerfMessage):
connections_num: int = 0
throughput_in_gbps: Decimal = Decimal(0)
latency_us: Decimal = Decimal(0)
buffer_size: Decimal = Decimal(0)
tx_packets: Decimal = Decimal(0)
rx_packets: Decimal = Decimal(0)
pkts_interrupts: Decimal = Decimal(0)
number_of_receivers: int = 1
number_of_senders: int = 1
sender_cycles_per_byte: Decimal = Decimal(0)
connections_created_time: int = 0
retrans_segments: int = 0
receiver_cycles_rer_byte: Decimal = Decimal(0)
# iperf tcp fields
buffer_size_bytes: Decimal = Decimal(0)
tx_throughput_in_gbps: Decimal = Decimal(0)
rx_throughput_in_gbps: Decimal = Decimal(0)
retransmitted_segments: Decimal = Decimal(0)
congestion_windowsize_kb: Decimal = Decimal(0)


@dataclass
class NetworkUDPPerformanceMessage(PerfMessage):
connections_num: int = 0
number_of_receivers: int = 1
number_of_senders: int = 1
connections_created_time: int = 0
receiver_cycles_rer_byte: Decimal = Decimal(0)
send_buffer_size: Decimal = Decimal(0)
tx_throughput_in_gbps: Decimal = Decimal(0)
rx_throughput_in_gbps: Decimal = Decimal(0)
data_loss: Decimal = Decimal(0)
packet_size_kbytes: Decimal = Decimal(0)


def create_message(
message_type: Type[T],
node: "Node",
environment: "Environment",
test_case_name: str = "",
other_fields: Optional[Dict[str, Any]] = None,
) -> T:
data_path: str = ""
assert (
node.capability.network_interface
and node.capability.network_interface.data_path
)
if isinstance(node.capability.network_interface.data_path, NetworkDataPath):
data_path = node.capability.network_interface.data_path.value
message = message_type()
dict_to_fields(environment.get_information(), message)
message.test_case_name = test_case_name
message.data_path = data_path
if other_fields:
dict_to_fields(other_fields, message)
return message
16 changes: 15 additions & 1 deletion lisa/tools/fdisk.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@


class Fdisk(Tool):
# fdisk: invalid option -- 'w'
not_support_option_pattern = re.compile(r"fdisk: invalid option -- 'w'.*", re.M)

@property
def command(self) -> str:
return "fdisk"
Expand Down Expand Up @@ -41,12 +44,23 @@ def make_partition(
# fdisk -w always => always to wipe signatures
# fdisk -W always => always to wipe signatures from new partitions
mkfs = self.node.tools[Mkfs]
self.node.execute(
cmd_result = self.node.execute(
f"(echo n; echo p; echo 1; echo ; echo; echo ; echo w) | "
f"{self.command} -w always -W always {disk_name}",
shell=True,
sudo=True,
)
# remove '-w' and '-W' options
# when lower fdisk version doesn't support
if self.not_support_option_pattern.match(cmd_result.stdout):
squirrelsc marked this conversation as resolved.
Show resolved Hide resolved
self.node.execute(
f"(echo n; echo p; echo 1; echo ; echo; echo ; echo w) | "
f"{self.command} {disk_name}",
shell=True,
sudo=True,
expected_exit_code=0,
expected_exit_code_failure_message=f"fail to format disk {disk_name}.",
)
# get the partition, e.g. /dev/sdc1 or /dev/nvme0n1p1
partition_disk = self._get_partitions(disk_name)
if format:
Expand Down
28 changes: 22 additions & 6 deletions lisa/tools/fio.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,18 @@
import re
from decimal import Decimal
from enum import Enum
from typing import Any, Dict, List, Optional, cast
from typing import TYPE_CHECKING, Any, Dict, List, Optional, cast

from lisa.executable import Tool
from lisa.messages import DiskPerformanceMessage
from lisa.messages import DiskPerformanceMessage, create_message
from lisa.operating_system import Debian, Posix, Redhat, Suse
from lisa.util import LisaException, dict_to_fields
from lisa.util import LisaException, constants

from .git import Git

if TYPE_CHECKING:
from lisa.environment import Environment


class FIOResult:
qdepth: int = 0
Expand Down Expand Up @@ -121,7 +124,11 @@ def launch(
return fio_result

def create_performance_messages(
self, fio_results_list: List[FIOResult]
self,
fio_results_list: List[FIOResult],
test_name: str,
environment: "Environment",
other_fields: Optional[Dict[str, Any]] = None,
) -> List[DiskPerformanceMessage]:
fio_message: List[DiskPerformanceMessage] = []
mode_iops_latency: Dict[int, Dict[str, Any]] = {}
Expand All @@ -137,8 +144,17 @@ def create_performance_messages(
mode_iops_latency[fio_result.qdepth] = temp

for result in mode_iops_latency.values():
fio_result_message = DiskPerformanceMessage()
fio_result_message = dict_to_fields(result, fio_result_message)
result_copy = result.copy()
result_copy["tool"] = constants.DISK_PERFORMANCE_TOOL_FIO
if other_fields:
result_copy.update(other_fields)
fio_result_message = create_message(
DiskPerformanceMessage,
self.node,
environment,
test_name,
result_copy,
)
fio_message.append(fio_result_message)
return fio_message

Expand Down
Loading