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 3af6942bc8a..a9aaa12d5dd 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 @@ -61,7 +61,8 @@ private static String checkVersionProgressInternal(String prevVersion, String ne * Returns report callback adding query section to the performance test report. * 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; @@ -73,4 +74,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/repo/repo-sql-impl-test/src/test/java/com/evolveum/midpoint/repo/sql/BaseSQLRepoTest.java b/repo/repo-sql-impl-test/src/test/java/com/evolveum/midpoint/repo/sql/BaseSQLRepoTest.java index 1898d2735ac..672b0de900a 100644 --- a/repo/repo-sql-impl-test/src/test/java/com/evolveum/midpoint/repo/sql/BaseSQLRepoTest.java +++ b/repo/repo-sql-impl-test/src/test/java/com/evolveum/midpoint/repo/sql/BaseSQLRepoTest.java @@ -174,7 +174,8 @@ public TestMonitor createTestMonitor() { queryListener.clear(); return super.createTestMonitor() .addReportCallback(TestReportUtil::reportGlobalPerfData) - .addReportCallback(SqlRepoTestUtil.createReportCallback(queryListener)); + .addReportCallback(SqlRepoTestUtil.reportCallbackQuerySummary(queryListener)) + .addReportCallback(SqlRepoTestUtil.reportCallbackQueryList(queryListener)); } protected boolean isUsingH2() { diff --git a/repo/repo-test-util/src/main/java/com/evolveum/midpoint/test/AbstractIntegrationTest.java b/repo/repo-test-util/src/main/java/com/evolveum/midpoint/test/AbstractIntegrationTest.java index 2b87af3534f..8fce7880e5b 100644 --- a/repo/repo-test-util/src/main/java/com/evolveum/midpoint/test/AbstractIntegrationTest.java +++ b/repo/repo-test-util/src/main/java/com/evolveum/midpoint/test/AbstractIntegrationTest.java @@ -316,7 +316,8 @@ public TestMonitor createTestMonitor() { return super.createTestMonitor() .addReportCallback(TestReportUtil::reportGlobalPerfData) - .addReportCallback(SqlRepoTestUtil.createReportCallback(queryListener)); + .addReportCallback(SqlRepoTestUtil.reportCallbackQuerySummary(queryListener)) + .addReportCallback(SqlRepoTestUtil.reportCallbackQueryList(queryListener)); } protected TracingProfileType getTestMethodTracingProfile() { 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 10e4486f82f..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 @@ -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. @@ -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(); }