Skip to content

Commit

Permalink
Fix latency network tests in BSD
Browse files Browse the repository at this point in the history
  • Loading branch information
dsrivastavv committed Sep 6, 2023
1 parent d0b7fd1 commit fa6b18e
Show file tree
Hide file tree
Showing 2 changed files with 95 additions and 2 deletions.
59 changes: 59 additions & 0 deletions lisa/tools/lagscope.py
Original file line number Diff line number Diff line change
Expand Up @@ -409,3 +409,62 @@ def run_as_client_async(
daemon: bool = False,
) -> Process:
return self.node.tools[Sockperf].run_client_async("tcp", server_ip)

def run_as_client(
self,
server_ip: str,
test_interval: int = 0,
run_time_seconds: int = 10,
ping_count: int = 0,
print_histogram: bool = True,
print_percentile: bool = True,
histogram_1st_interval_start_value: int = 30,
length_of_histogram_intervals: int = 15,
count_of_histogram_intervals: int = 30,
dump_csv: bool = True,
daemon: bool = False,
) -> ExecutableResult:
process = self.run_as_client_async(
server_ip,
test_interval,
run_time_seconds,
ping_count,
print_histogram,
print_percentile,
histogram_1st_interval_start_value,
length_of_histogram_intervals,
count_of_histogram_intervals,
dump_csv,
daemon,
)
result = process.wait_result()
return result

def create_latency_performance_messages(
self, result: ExecutableResult, test_case_name: str, test_result: "TestResult"
) -> List[NetworkLatencyPerformanceMessage]:
stats = self.node.tools[Sockperf].get_statistics(result.stdout)

perf_message_list: List[NetworkLatencyPerformanceMessage] = []
other_fields: Dict[str, Any] = {}
other_fields["tool"] = constants.NETWORK_PERFORMANCE_TOOL_LAGSCOPE
other_fields["min_latency_us"] = stats["min_latency_us"]
other_fields["max_latency_us"] = stats["max_latency_us"]
other_fields["average_latency_us"] = stats["average_latency_us"]
other_fields["latency99_percentile_us"] = stats["latency99_percentile_us"]
other_fields["frequency"] = (
stats["total_observations"] / stats["run_time_seconds"]
)
other_fields["interval_us"] = stats["run_time_seconds"] * 1000000

message = create_perf_message(
NetworkLatencyPerformanceMessage,
self.node,
test_result,
test_case_name,
other_fields,
)
perf_message_list.append(message)
notifier.notify(message)

return perf_message_list
38 changes: 36 additions & 2 deletions lisa/tools/sockperf.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,18 @@ def can_install(self) -> bool:
r"=\s+(?P<min_latency_us>[0-9]+\.[0-9]+)"
)

# ====> avg-rtt=3770.433 (std-dev=4585.840, mean-ad=4427.419, median-ad=171.194, siqr=4674.992, cv=1.216, std-error=369.538, 99.0% ci=[2818.566, 4722.300]) # noqa: E501
sockperf_average_latency = re.compile(r"avg-rtt=(?P<avg_latency_us>[0-9]+\.[0-9]+)")
# Summary: Round trip is 297.328 usec
sockperf_average_latency = re.compile(
r"Summary: Round trip is (?P<avg_latency_us>[0-9]+\.[0-9]+) usec"
) # noqa: E501

# Total 1283 observations;
sockperf_total_observations = re.compile(
r"Total (?P<total_observations>[0-9]+) observations"
) # noqa: E501

# [Valid Duration] RunTime=0.546 sec; SentMessages=1283; ReceivedMessages=1283
sockperf_run_time = re.compile(r"RunTime=(?P<run_time>[0-9]+\.[0-9]+) sec")

def _get_protocol_flag(self, mode: str) -> str:
assert_that(mode).described_as(
Expand Down Expand Up @@ -218,3 +228,27 @@ def get_average_latency(self, sockperf_output: str) -> Decimal:
matched_results = self.sockperf_average_latency.search(sockperf_output)
assert matched_results, "Could not find sockperf latency results in output."
return Decimal(matched_results.group("avg_latency_us"))

def get_total_observations(self, sockperf_output: str) -> int:
matched_results = self.sockperf_total_observations.search(sockperf_output)
assert matched_results, "Could not find sockperf latency results in output."
return int(matched_results.group("total_observations"))

def get_run_time(self, sockperf_output: str) -> Decimal:
matched_results = self.sockperf_run_time.search(sockperf_output)
assert matched_results, "Could not find sockperf latency results in output."
return Decimal(matched_results.group("run_time"))

def get_statistics(self, sockperf_output: str) -> Dict[str, Any]:
matched_results = self.sockperf_result_regex.search(sockperf_output)
assert matched_results, "Could not find sockperf latency results in output."
stats: Dict[str, Any] = {}
stats["min_latency_us"] = Decimal(matched_results.group("min_latency_us"))
stats["max_latency_us"] = Decimal(matched_results.group("max_latency_us"))
stats["average_latency_us"] = self.get_average_latency(sockperf_output)
stats["latency99_percentile_us"] = Decimal(
matched_results.group("latency99_percentile_us")
)
stats["total_observations"] = self.get_total_observations(sockperf_output)
stats["run_time_seconds"] = self.get_run_time(sockperf_output)
return stats

0 comments on commit fa6b18e

Please sign in to comment.