diff --git a/gui/admin-gui/src/test/java/com/evolveum/midpoint/gui/MidScaleGuiTest.java b/gui/admin-gui/src/test/java/com/evolveum/midpoint/gui/MidScaleGuiTest.java index 338c3a39a6f..f71ce0e8458 100644 --- a/gui/admin-gui/src/test/java/com/evolveum/midpoint/gui/MidScaleGuiTest.java +++ b/gui/admin-gui/src/test/java/com/evolveum/midpoint/gui/MidScaleGuiTest.java @@ -8,6 +8,8 @@ import com.evolveum.midpoint.gui.api.component.MainObjectListPanel; +import com.evolveum.midpoint.prism.PrismObject; +import com.evolveum.midpoint.web.AbstractGuiIntegrationTest; import com.evolveum.midpoint.tools.testng.PerformanceTestMethodMixin; import com.evolveum.midpoint.web.page.admin.configuration.PageSystemConfiguration; @@ -47,7 +49,7 @@ @DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_CLASS) @ActiveProfiles("test") @SpringBootTest(classes = TestMidPointSpringApplication.class) -public class MidScaleGuiTest extends AbstractInitializedGuiIntegrationTest implements PerformanceTestMethodMixin { +public class MidScaleGuiTest extends AbstractGuiIntegrationTest implements PerformanceTestMethodMixin { private static final String TEST_DIR = "./src/test/resources/midScale"; @@ -57,17 +59,22 @@ public class MidScaleGuiTest extends AbstractInitializedGuiIntegrationTest imple private static final int REPETITION_COUNT = 10; @Autowired TestQueryListener queryListener; + protected PrismObject userAdministrator; @Override public void initSystem(Task initTask, OperationResult initResult) throws Exception { super.initSystem(initTask, initResult); - importObjectsFromFileNotRaw(FILE_ORG_STRUCT, initTask, initResult); - initResult.computeStatusIfUnknown(); - if (!initResult.isSuccess()) { - System.out.println("init result:\n" + initResult); - } - importObjectsFromFileNotRaw(FILE_USERS, initTask, initResult); + modelService.postInit(initResult); + userAdministrator = repositoryService.getObject(UserType.class, USER_ADMINISTRATOR_OID, null, initResult); + login(userAdministrator); + +// importObjectsFromFileNotRaw(FILE_ORG_STRUCT, initTask, initResult); +// initResult.computeStatusIfUnknown(); +// if (!initResult.isSuccess()) { +// System.out.println("init result:\n" + initResult); +// } +// importObjectsFromFileNotRaw(FILE_USERS, initTask, initResult); modifyObjectReplaceProperty(SystemConfigurationType.class, SystemObjectsType.SYSTEM_CONFIGURATION.value(), ItemPath.create(SystemConfigurationType.F_ADMIN_GUI_CONFIGURATION, AdminGuiConfigurationType.F_ENABLE_EXPERIMENTAL_FEATURES), @@ -191,9 +198,8 @@ public void test231editUserTabProjections() { Stopwatch stopwatch = stopwatch("showProjections", "User's projection tab"); try (Split ignored = stopwatch.start()) { - clickOnTab(1, PageUser.class); queryListener.start(); - + clickOnTab(1, PageUser.class); } } diff --git a/gui/admin-gui/src/test/resources/schema/midscale.xsd b/gui/admin-gui/src/test/resources/schema/midscale.xsd new file mode 100644 index 00000000000..e22a75d7ae9 --- /dev/null +++ b/gui/admin-gui/src/test/resources/schema/midscale.xsd @@ -0,0 +1,976 @@ + + + + + + + + + + + + User Attribut 1 + 1010 + + + + + + + User Attribut 2 + 1020 + + + + + + + User Attribut 3 + 1030 + + + + + + + User Attribut 4 + 1040 + + + + + + + User Attribut 5 + 1050 + + + + + + + User Attribut 6 + 1060 + + + + + + + User Attribut 7 + 1070 + + + + + + + User Attribut 8 + 1080 + + + + + + + User Attribut 9 + 1090 + + + + + + + User Attribut 10 + 1100 + + + + + + + User Attribut 11 + 1110 + + + + + + + User Attribut 12 + 1120 + + + + + + + User Attribut 13 + 1130 + + + + + + + User Attribut 14 + 1140 + + + + + + + User Attribut 15 + 1150 + + + + + + + User Attribut 16 + 1160 + + + + + + + User Attribut 17 + 1170 + + + + + + + User Attribut 18 + 1180 + + + + + + + User Attribut 19 + 1190 + + + + + + + User Attribut 20 + 1200 + + + + + + + User Attribut 21 + 1210 + + + + + + + User Attribut 22 + 1220 + + + + + + + User Attribut 23 + 1230 + + + + + + + User Attribut 24 + 1240 + + + + + + + User Attribut 25 + 1250 + + + + + + + User Attribut 26 + 1260 + + + + + + + User Attribut 27 + 1270 + + + + + + + User Attribut 28 + 1280 + + + + + + + User Attribut 29 + 1290 + + + + + + + User Attribut 30 + 1300 + + + + + + + User Attribut 31 + 1310 + + + + + + + User Attribut 32 + 1320 + + + + + + + User Attribut 33 + 1330 + + + + + + + User Attribut 34 + 1340 + + + + + + + User Attribut 35 + 1350 + + + + + + + User Attribut 36 + 1360 + + + + + + + User Attribut 37 + 1370 + + + + + + + User Attribut 38 + 1380 + + + + + + + User Attribut 39 + 1390 + + + + + + + User Attribut 40 + 1400 + + + + + + + User Attribut 41 + 1410 + + + + + + + User Attribut 42 + 1420 + + + + + + + User Attribut 43 + 1430 + + + + + + + User Attribut 44 + 1440 + + + + + + + User Attribut 45 + 1450 + + + + + + + User Attribut 46 + 1460 + + + + + + + User Attribut 47 + 1470 + + + + + + + User Attribut 48 + 1480 + + + + + + + User Attribut 49 + 1490 + + + + + + + User Attribut 50 + 1500 + + + + + + + User Attribut 51 + 1510 + + + + + + + User Attribut 52 + 1520 + + + + + + + User Attribut 53 + 1530 + + + + + + + User Attribut 54 + 1540 + + + + + + + User Attribut 55 + 1550 + + + + + + + User Attribut 56 + 1560 + + + + + + + User Attribut 57 + 1570 + + + + + + + User Attribut 58 + 1580 + + + + + + + User Attribut 59 + 1590 + + + + + + + User Attribut 60 + 1600 + + + + + + + User Attribut 61 + 1610 + + + + + + + User Attribut 62 + 1620 + + + + + + + User Attribut 63 + 1630 + + + + + + + User Attribut 64 + 1640 + + + + + + + User Attribut 65 + 1650 + + + + + + + User Attribut 66 + 1660 + + + + + + + User Attribut 67 + 1670 + + + + + + + User Attribut 68 + 1680 + + + + + + + User Attribut 69 + 1690 + + + + + + + User Attribut 70 + 1700 + + + + + + + User Attribut 71 + 1710 + + + + + + + User Attribut 72 + 1720 + + + + + + + User Attribut 73 + 1730 + + + + + + + User Attribut 74 + 1740 + + + + + + + User Attribut 75 + 1750 + + + + + + + User Attribut 76 + 1760 + + + + + + + User Attribut 77 + 1770 + + + + + + + User Attribut 78 + 1780 + + + + + + + User Attribut 79 + 1790 + + + + + + + User Attribut 80 + 1800 + + + + + + + User Attribut 81 + 1810 + + + + + + + User Attribut 82 + 1820 + + + + + + + User Attribut 83 + 1830 + + + + + + + User Attribut 84 + 1840 + + + + + + + User Attribut 85 + 1850 + + + + + + + User Attribut 86 + 1860 + + + + + + + User Attribut 87 + 1870 + + + + + + + User Attribut 88 + 1880 + + + + + + + User Attribut 89 + 1890 + + + + + + + User Attribut 90 + 1900 + + + + + + + User Attribut 91 + 1910 + + + + + + + User Attribut 92 + 1920 + + + + + + + User Attribut 93 + 1930 + + + + + + + User Attribut 94 + 1940 + + + + + + + User Attribut 95 + 1950 + + + + + + + User Attribut 96 + 1960 + + + + + + + User Attribut 97 + 1970 + + + + + + + User Attribut 98 + 1980 + + + + + + + User Attribut 99 + 1990 + + + + + + + User Attribut 100 + 2000 + + + + + + + User Attribut 101 + 2010 + + + + + + + User Attribut 102 + 2020 + + + + + + + User Attribut 103 + 2030 + + + + + + + User Attribut 104 + 2040 + + + + + + + User Attribut 105 + 2050 + + + + + + + User Attribut 106 + 2060 + + + + + + + User Attribut 107 + 2070 + + + + + + + User Attribut 108 + 2080 + + + + + + + User Attribut 109 + 2090 + + + + + + + User Attribut 110 + 2100 + + + + + + + User Attribut 111 + 2110 + + + + + + + User Attribut 112 + 2120 + + + + + + + User Attribut 113 + 2130 + + + + + + + User Attribut 114 + 2140 + + + + + + + User Attribut 115 + 2150 + + + + + + + User Attribut 116 + 2160 + + + + + + + User Attribut 117 + 2170 + + + + + + + User Attribut 118 + 2180 + + + + + + + User Attribut 119 + 2190 + + + + + + + User Attribut 120 + 2200 + + + + + + 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 a885129bceb..5d7e3defd4a 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 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010-2013 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. @@ -9,10 +9,9 @@ import org.testng.AssertJUnit; -/** - * @author semancik - * - */ +import com.evolveum.midpoint.tools.testng.TestMonitor; +import com.evolveum.midpoint.tools.testng.TestReportSection; + public class SqlRepoTestUtil { public static void assertVersionProgress(String prevVersion, String nextVersion) { @@ -27,7 +26,7 @@ public static String checkVersionProgress(String prevVersion, String nextVersion if (error == null) { return null; } - return "Invalid version progress from '"+prevVersion+"' to '"+nextVersion+"': "+error; + return "Invalid version progress from '" + prevVersion + "' to '" + nextVersion + "': " + error; } private static String checkVersionProgressInternal(String prevVersion, String nextVersion) { @@ -59,4 +58,20 @@ private static String checkVersionProgressInternal(String prevVersion, String ne return null; } + /** + * 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) { + return testMonitor -> { + if (testQueryListener.hasNoEntries()) { + return; + } + + TestReportSection section = testMonitor.addReportSection("query") + .withColumns("metric", "count"); + section.addRow("query-count", testQueryListener.getQueryCount()); + section.addRow("execution-count", testQueryListener.getExecutionCount()); + }; + } } 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 635ee219924..6243d6ca1b2 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 @@ -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. @@ -14,7 +14,6 @@ import java.io.File; import java.io.IOException; -import java.lang.reflect.Method; import java.util.*; import java.util.stream.Collectors; import javax.annotation.PostConstruct; @@ -32,7 +31,6 @@ import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.orm.hibernate5.LocalSessionFactoryBean; import org.testng.AssertJUnit; -import org.testng.annotations.AfterClass; import org.testng.annotations.AfterMethod; import org.testng.annotations.BeforeSuite; import org.xml.sax.SAXException; @@ -58,6 +56,7 @@ import com.evolveum.midpoint.repo.sql.helpers.JdbcSession; import com.evolveum.midpoint.repo.sql.pure.FlexibleRelationalPathBase; import com.evolveum.midpoint.repo.sql.pure.mapping.QueryModelMapping; +import com.evolveum.midpoint.repo.sql.testing.SqlRepoTestUtil; import com.evolveum.midpoint.repo.sql.testing.TestQueryListener; import com.evolveum.midpoint.repo.sql.util.HibernateToSqlTranslator; import com.evolveum.midpoint.repo.sql.util.RUtil; @@ -69,10 +68,12 @@ import com.evolveum.midpoint.test.util.InfraTestMixin; import com.evolveum.midpoint.test.util.TestReportUtil; import com.evolveum.midpoint.test.util.TestUtil; +import com.evolveum.midpoint.tools.testng.TestMonitor; import com.evolveum.midpoint.util.DebugDumpable; import com.evolveum.midpoint.util.PrettyPrinter; import com.evolveum.midpoint.util.exception.ObjectNotFoundException; import com.evolveum.midpoint.util.exception.SchemaException; +import com.evolveum.midpoint.util.statistics.OperationsPerformanceMonitor; import com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType; import com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType; import com.evolveum.midpoint.xml.ns._public.common.common_3.UserType; @@ -150,7 +151,7 @@ public void initializeTestClass() throws Exception { } @AfterMethod - public void afterMethod(Method method) { + public void afterMethod() { try { Session session = factory.getCurrentSession(); if (session != null) { @@ -163,11 +164,14 @@ public void afterMethod(Method method) { } } - @AfterClass - public void reportPerfData() { - if (testMonitor() != null) { - TestReportUtil.reportPerfData(testMonitor()); - } + /** Called only by performance tests. */ + @Override + public TestMonitor createTestMonitor() { + OperationsPerformanceMonitor.INSTANCE.clearGlobalPerformanceInformation(); + queryListener.clear(); + return super.createTestMonitor() + .addReportCallback(TestReportUtil::reportPerfData) + .addReportCallback(SqlRepoTestUtil.createReportCallback(queryListener)); } protected boolean isUsingH2() { diff --git a/repo/repo-test-util/pom.xml b/repo/repo-test-util/pom.xml index 60910941b87..ed9992e08b2 100644 --- a/repo/repo-test-util/pom.xml +++ b/repo/repo-test-util/pom.xml @@ -85,6 +85,11 @@ util ${project.version} + + com.evolveum.midpoint.repo + repo-sql-impl-test + ${project.version} + commons-lang 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 a6d962baa2f..9560fab171c 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 @@ -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. @@ -49,7 +49,6 @@ import org.testng.Assert; import org.testng.AssertJUnit; import org.testng.ITestResult; -import org.testng.annotations.AfterClass; import org.testng.annotations.AfterMethod; import org.testng.annotations.BeforeMethod; import org.testng.annotations.Listeners; @@ -83,6 +82,8 @@ import com.evolveum.midpoint.prism.xml.XmlTypeConverter; import com.evolveum.midpoint.repo.api.RepoAddOptions; import com.evolveum.midpoint.repo.api.RepositoryService; +import com.evolveum.midpoint.repo.sql.testing.SqlRepoTestUtil; +import com.evolveum.midpoint.repo.sql.testing.TestQueryListener; import com.evolveum.midpoint.schema.*; import com.evolveum.midpoint.schema.constants.ConnectorTestOperation; import com.evolveum.midpoint.schema.constants.MidPointConstants; @@ -111,8 +112,10 @@ import com.evolveum.midpoint.test.util.*; import com.evolveum.midpoint.tools.testng.CurrentTestResultHolder; import com.evolveum.midpoint.tools.testng.MidpointTestContext; +import com.evolveum.midpoint.tools.testng.TestMonitor; import com.evolveum.midpoint.util.*; import com.evolveum.midpoint.util.exception.*; +import com.evolveum.midpoint.util.statistics.OperationsPerformanceMonitor; import com.evolveum.midpoint.xml.ns._public.common.common_3.*; import com.evolveum.prism.xml.ns._public.types_3.PolyStringType; import com.evolveum.prism.xml.ns._public.types_3.ProtectedStringType; @@ -171,6 +174,7 @@ public abstract class AbstractIntegrationTest extends AbstractSpringTest @Autowired protected SchemaHelper schemaHelper; @Autowired protected MatchingRuleRegistry matchingRuleRegistry; @Autowired protected LocalizationService localizationService; + @Autowired protected TestQueryListener queryListener; @Autowired(required = false) @Qualifier("repoSimpleObjectResolver") @@ -303,11 +307,15 @@ public void finishTestContext(ITestResult testResult) { } } - @AfterClass - public void reportPerfData() { - if (testMonitor() != null) { - TestReportUtil.reportPerfData(testMonitor()); - } + /** Called only by performance tests. */ + @Override + public TestMonitor createTestMonitor() { + OperationsPerformanceMonitor.INSTANCE.clearGlobalPerformanceInformation(); + queryListener.clear(); + + return super.createTestMonitor() + .addReportCallback(TestReportUtil::reportPerfData) + .addReportCallback(SqlRepoTestUtil.createReportCallback(queryListener)); } protected TracingProfileType getTestMethodTracingProfile() { diff --git a/tools/perf-test/perf-test-process.sh b/tools/perf-test/perf-test-process.sh index 1385e3c525a..3a0cf23bf0e 100644 --- a/tools/perf-test/perf-test-process.sh +++ b/tools/perf-test/perf-test-process.sh @@ -18,6 +18,7 @@ set -eu : "${BUILD_NUMBER:="dev"}" : "${BRANCH:=$(git rev-parse --abbrev-ref HEAD)}" : "${GIT_COMMIT:=$(git show -s --format=%H)}" +: "${BUILD_ENV:="dev"}" # TODO use this # backup mkdir -p "${HOME}/perf-out/" @@ -31,25 +32,33 @@ if [ -z "${TGZFILE:-}" ]; then echo "Performance reports backed up to ${TGZFILE}" else echo "Importing ${TGZFILE} to DB" - BRANCH=$(basename $TGZFILE | cut -d- -f3) - # _ was likely / originally, see above - BRANCH="${BRANCH/_/\/}" - BUILD_NUMBER=$(basename $TGZFILE | cut -d- -f4) - GIT_COMMIT=$(basename $TGZFILE | cut -d- -f5 | cut -d. -f1) + + # amount of dashes in the filename - to check if branch name contain the dash + delimcount=$(( $(echo ${TGZFILE} | wc -c) - $(echo ${TGZFILE} | tr -d - | wc -c) )) + + # the option to not overwrite previously checked / set values + if [ -z ${TGZFILE_RAW:-} ]; then + BRANCH="$( basename ${TGZFILE} | cut -d- -f3-$(( ${delimcount} - 1 )) | sed "s-_-/-" )" + BUILD_NUMBER="$(basename ${TGZFILE} | cut -d- -f${delimcount} )" + GIT_COMMIT="$(basename ${TGZFILE} | cut -d- -f$(( ${delimcount} + 1 )) | sed "s-.tar.gz\$--")" + else + echo "The filename was not parsed for the variable value..." + fi fi -COMMIT_DATE=$(git show -s --format=%cI "${GIT_COMMIT}") +# check for commit date in case the date is not already set +: "${COMMIT_DATE:=$(git show -s --format=%cI "${GIT_COMMIT}")}" # load to DB -BUILD_ID=$(psql -tc "select id from mst_build where commit_hash='${GIT_COMMIT}'") +BUILD_ID=$(${PSQL} -tc "select id from mst_build where commit_hash='${GIT_COMMIT}' and env='${BUILD_ENV}'") if [ -n "${BUILD_ID}" ]; then - echo "Results for commit ${GIT_COMMIT} already processed, no action needed." + echo "Results for commit ${GIT_COMMIT} from environment ${BUILD_ENV} already processed, no action needed." exit fi # create new build entry BUILD_ID=$( - "${PSQL}" -qtAX -c "insert into mst_build (build, branch, commit_hash, date) values ('${BUILD_NUMBER}', '${BRANCH}', '${GIT_COMMIT}', '${COMMIT_DATE}') returning id" + "${PSQL}" -qtAX -c "insert into mst_build (build, branch, commit_hash, date, env) values ('${BUILD_NUMBER}', '${BRANCH}', '${GIT_COMMIT}', '${COMMIT_DATE}', '${BUILD_ENV}') returning id" ) echo "BUILD_ID = $BUILD_ID"