diff --git a/repo/repo-sql-impl-test/src/main/java/com/evolveum/midpoint/repo/sql/testing/SqlRepoTestUtil.java b/repo/repo-sql-impl-test/src/main/java/com/evolveum/midpoint/repo/sql/testing/SqlRepoTestUtil.java index 5d7e3defd4a..c1474533a8e 100644 --- a/repo/repo-sql-impl-test/src/main/java/com/evolveum/midpoint/repo/sql/testing/SqlRepoTestUtil.java +++ b/repo/repo-sql-impl-test/src/main/java/com/evolveum/midpoint/repo/sql/testing/SqlRepoTestUtil.java @@ -62,7 +62,8 @@ private static String checkVersionProgressInternal(String prevVersion, String ne * Returns report callback effectively wrapping around "this" at the moment the callback is created. * Note that the section is NOT added if the count of queries is 0. */ - public static TestMonitor.ReportCallback createReportCallback(TestQueryListener testQueryListener) { + public static TestMonitor.ReportCallback reportCallbackQuerySummary( + TestQueryListener testQueryListener) { return testMonitor -> { if (testQueryListener.hasNoEntries()) { return; @@ -74,4 +75,21 @@ public static TestMonitor.ReportCallback createReportCallback(TestQueryListener section.addRow("execution-count", testQueryListener.getExecutionCount()); }; } + + /** + * Returns report callback adding detailed query dump section to the performance test report. + * Note that the section is NOT added if the count of queries is 0. + * This section is more for visual comparison/interpretation than for graphing. + */ + public static TestMonitor.ReportCallback reportCallbackQueryList( + TestQueryListener testQueryListener) { + return testMonitor -> { + if (testQueryListener.hasNoEntries()) { + return; + } + + TestReportSection section = testMonitor.addRawReportSection("query-list"); + testQueryListener.getEntries().forEach(e -> section.addRow(e.query)); + }; + } } diff --git a/tools/test-ng/src/main/java/com/evolveum/midpoint/tools/testng/TestMonitor.java b/tools/test-ng/src/main/java/com/evolveum/midpoint/tools/testng/TestMonitor.java index b9939a45371..84b05c9eb9c 100644 --- a/tools/test-ng/src/main/java/com/evolveum/midpoint/tools/testng/TestMonitor.java +++ b/tools/test-ng/src/main/java/com/evolveum/midpoint/tools/testng/TestMonitor.java @@ -113,6 +113,12 @@ public TestReportSection addReportSection(String sectionName) { return reportSection; } + public TestReportSection addRawReportSection(String sectionName) { + TestReportSection reportSection = new TestReportSection(sectionName, true); + reportSections.add(reportSection); + return reportSection; + } + public void dumpReport(String testName) { ReportMetadata reportMetadata = new ReportMetadata(testName); String perfReportPrefix = System.getProperty(PERF_REPORT_PREFIX_PROPERTY_NAME); diff --git a/tools/test-ng/src/main/java/com/evolveum/midpoint/tools/testng/TestReportSection.java b/tools/test-ng/src/main/java/com/evolveum/midpoint/tools/testng/TestReportSection.java index 763ca29793a..1e33b318bda 100644 --- a/tools/test-ng/src/main/java/com/evolveum/midpoint/tools/testng/TestReportSection.java +++ b/tools/test-ng/src/main/java/com/evolveum/midpoint/tools/testng/TestReportSection.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2010-2020 Evolveum and contributors + * Copyright (C) 2010-2021 Evolveum and contributors * * This work is dual-licensed under the Apache License 2.0 * and European Union Public License. See LICENSE file for details. @@ -19,12 +19,18 @@ public class TestReportSection { public static final char ESCAPE_CHAR = '\\'; private final String sectionName; + private final boolean rawSection; // no CSV header, no test name column private final List rows = new ArrayList<>(); private String[] columnNames; public TestReportSection(String sectionName) { + this(sectionName, false); + } + + public TestReportSection(String sectionName, boolean rawSection) { this.sectionName = sectionName; + this.rawSection = rawSection; } /** @@ -43,19 +49,36 @@ public void addRow(Object... row) { * Dumps the output as CSV including section header preceded by an empty line. * * @param testName common test name used as a first column value (named "test") + * unless {@link #rawSection} is `true` in which case it is skipped */ public void dump(String testName, PrintStream out) { - out.print("\n[" + sectionName + "]\ntest"); - for (String columnName : columnNames) { - out.print(SEPARATOR + format(columnName)); - } + if (rawSection) { + out.print("\n[" + sectionName + "]"); + for (Object[] row : rows) { + StringBuilder sb = new StringBuilder(); + for (Object value : row) { + if (sb.length() > 0) { + sb.append(SEPARATOR); + } + sb.append(format(value)); + } + out.print('\n' + sb.toString()); + } + } else { + // normal CSV output + out.print("\n[" + sectionName + "]\ntest"); + for (String columnName : columnNames) { + out.print(SEPARATOR + format(columnName)); + } - for (Object[] row : rows) { - out.print('\n' + format(testName)); - for (Object value : row) { - out.print(SEPARATOR + format(value)); + for (Object[] row : rows) { + out.print('\n' + format(testName)); + for (Object value : row) { + out.print(SEPARATOR + format(value)); + } } } + out.println(); }