Skip to content

Commit 8a4a4e2

Browse files
committed
[testing]: fixing perf testing for packets w/ packet builder
1 parent 819c331 commit 8a4a4e2

2 files changed

Lines changed: 9 additions & 3 deletions

File tree

katran/lib/testing/framework/BpfTester.cpp

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -431,8 +431,15 @@ std::vector<TestResult> BpfTester::testPerfFromFixture(
431431

432432
// Run all tests and collect results
433433
for (int i = first_index; i < last_index; i++) {
434+
std::string input_packet;
435+
if (config_.testData[i].inputPacketBuilder.has_value()) {
436+
auto inputResult = config_.testData[i].inputPacketBuilder->build();
437+
input_packet = inputResult.base64Packet;
438+
} else {
439+
input_packet = config_.testData[i].inputPacket;
440+
}
434441
auto single_results = runXdpProgPerf(
435-
config_.testData[i].inputPacket,
442+
input_packet,
436443
config_.testData[i].description,
437444
repeat);
438445
results.insert(results.end(), single_results.begin(), single_results.end());
@@ -480,7 +487,7 @@ std::vector<TestResult> BpfTester::runXdpProgPerf(
480487
duration = 1;
481488
}
482489
}
483-
if (repeat > 0) {
490+
if (repeat > 0 && total_duration > 0) {
484491
auto avgDuration = total_duration / repeat;
485492
auto pps = kNanosecInSec / avgDuration;
486493
auto pps_millions = static_cast<double>(pps) / 1000000.0;

katran/lib/testing/framework/katran_tester.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -398,7 +398,6 @@ int main(int argc, char** argv) {
398398
tester.testPcktsFromPcap();
399399
return 0;
400400
} else if (FLAGS_perf_testing) {
401-
// for perf tests to work katran must be compiled w -DINLINE_DECAP
402401
preparePerfTestingLbData(*lb);
403402
auto results = tester.testPerfFromFixture(FLAGS_repeat, FLAGS_position);
404403
printPerfResults(results);

0 commit comments

Comments
 (0)