Skip to content

Commit

Permalink
XDPBenchMeasurement: fixed json formatter
Browse files Browse the repository at this point in the history
`JsonRunSummaryFormatter` requires measurement results to be
instance of `MeasurementResult` class.
  • Loading branch information
enhaut authored and olichtne committed Oct 30, 2024
1 parent 92fa582 commit d6c1046
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,11 @@ def _transform_result(self, result: BaseResult) -> Optional[dict]:
measurement_data = {
"bandwidth": result.data["bandwidth"].average,
}
elif result.measurement_type == "xdp-bench":
measurement_data = {
"generator_results": result.data["generator_results"].average,
"receiver_results": result.data["receiver_results"].average,
}
else:
logging.warning(f"unhandled measurement result type: {result.measurement_type}")
measurement_data = None
Expand Down
50 changes: 27 additions & 23 deletions lnst/RecipeCommon/Perf/Measurements/XDPBenchMeasurement.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import time
import logging

from lnst.Controller.Recipe import BaseRecipe
from lnst.RecipeCommon.Perf.Measurements.Results.AggregatedXDPBenchMeasurementResults import (
AggregatedXDPBenchMeasurementResults,
)
Expand All @@ -21,6 +22,7 @@
from lnst.Tests.PktGen import PktGen
from lnst.Tests.XDPBench import XDPBench
from lnst.Controller.Job import Job
from lnst.Controller.RecipeResults import MeasurementResult
from lnst.RecipeCommon.Perf.Measurements.BaseFlowMeasurement import BaseFlowMeasurement


Expand Down Expand Up @@ -186,26 +188,28 @@ def _aggregate_flows(self, old_flow, new_flow):
return new_result

@classmethod
def _report_flow_results(cls, recipe, flow_results):
generator = flow_results.generator_results
receiver = flow_results.receiver_results

desc = []
desc.append(flow_results.describe())

recipe_result = ResultType.PASS
metrics = {"Generator": generator, "Receiver": receiver}
for name, result in metrics.items():
if cls._invalid_flow_duration(result):
recipe_result = ResultType.FAIL
desc.append("{} has invalid duration!".format(name))

recipe.add_result(
recipe_result,
"\n".join(desc),
data=dict(
generator_flow_data=generator,
receiver_flow_data=receiver,
flow_results=flow_results,
),
)
def report_results(cls, recipe: BaseRecipe, results: list[AggregatedXDPBenchMeasurementResults]):
for result in results:
generator = result.generator_results
receiver = result.receiver_results

desc = []
desc.append(result.describe())

recipe_result = ResultType.PASS
metrics = {"Generator": generator, "Receiver": receiver}
for name, result in metrics.items():
if cls._invalid_flow_duration(result):
recipe_result = ResultType.FAIL
desc.append("{} has invalid duration!".format(name))

recipe_result = MeasurementResult(
"xdp-bench",
description="\n".join(desc),
data={
"generator_results": generator,
"receiver_results": receiver,
"flow_results": result,
},
)
recipe.add_custom_result(recipe_result)

0 comments on commit d6c1046

Please sign in to comment.