diff options
author | Duarte Meneses <duarte.meneses@sonarsource.com> | 2020-11-26 20:34:42 -0600 |
---|---|---|
committer | sonartech <sonartech@sonarsource.com> | 2020-11-30 20:07:06 +0000 |
commit | 736bfc4d5ae032edaf556ee8a41efc1d9b9ce4f9 (patch) | |
tree | d17ef789c14df37e5cbe5692356b1d771ade26aa /server/sonar-webserver-core | |
parent | 59adbb849b1ce3338e6299dea939c454df7d0cdb (diff) | |
download | sonarqube-736bfc4d5ae032edaf556ee8a41efc1d9b9ce4f9.tar.gz sonarqube-736bfc4d5ae032edaf556ee8a41efc1d9b9ce4f9.zip |
Speed up unit tests by improving indexing in unit tests
* Unit tests no longer use the LargeSizeHandler for indexing. This handler is designed for indexing large amounts of data and is slower for the data sets used in unit tests.
* Insert all data in DB before indexing in unit tests (there is a huge overhead in each call to index)
Diffstat (limited to 'server/sonar-webserver-core')
-rw-r--r-- | server/sonar-webserver-core/src/test/java/org/sonar/server/telemetry/TelemetryDataLoaderImplTest.java | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/server/sonar-webserver-core/src/test/java/org/sonar/server/telemetry/TelemetryDataLoaderImplTest.java b/server/sonar-webserver-core/src/test/java/org/sonar/server/telemetry/TelemetryDataLoaderImplTest.java index 6d62af2a617..5e47becce65 100644 --- a/server/sonar-webserver-core/src/test/java/org/sonar/server/telemetry/TelemetryDataLoaderImplTest.java +++ b/server/sonar-webserver-core/src/test/java/org/sonar/server/telemetry/TelemetryDataLoaderImplTest.java @@ -46,7 +46,6 @@ import org.sonar.server.user.index.UserIndexer; import org.sonar.updatecenter.common.Version; import static java.util.Arrays.asList; -import static java.util.Collections.emptySet; import static org.apache.commons.lang.RandomStringUtils.randomAlphabetic; import static org.apache.commons.lang.RandomStringUtils.randomAlphanumeric; import static org.assertj.core.api.Assertions.assertThat; @@ -99,7 +98,7 @@ public class TelemetryDataLoaderImplTest { int userCount = 3; IntStream.range(0, userCount).forEach(i -> db.users().insertUser()); db.users().insertUser(u -> u.setActive(false)); - userIndexer.indexOnStartup(emptySet()); + userIndexer.indexAll(); MetricDto lines = db.measures().insertMetric(m -> m.setKey(LINES_KEY)); MetricDto ncloc = db.measures().insertMetric(m -> m.setKey(NCLOC_KEY)); @@ -118,7 +117,7 @@ public class TelemetryDataLoaderImplTest { db.measures().insertLiveMeasure(project2, ncloc, m -> m.setValue(200d)); db.measures().insertLiveMeasure(project2, coverage, m -> m.setValue(80d)); db.measures().insertLiveMeasure(project2, nclocDistrib, m -> m.setValue(null).setData("java=300;kotlin=2500")); - projectMeasuresIndexer.indexOnStartup(emptySet()); + projectMeasuresIndexer.indexAll(); TelemetryData data = communityUnderTest.load(); assertThat(data.getServerId()).isEqualTo(serverId); @@ -157,7 +156,7 @@ public class TelemetryDataLoaderImplTest { db.measures().insertLiveMeasure(project, ncloc, m -> m.setValue(10d)); db.measures().insertLiveMeasure(branch1, ncloc, m -> m.setValue(20d)); db.measures().insertLiveMeasure(pr, ncloc, m -> m.setValue(30d)); - projectMeasuresIndexer.indexOnStartup(emptySet()); + projectMeasuresIndexer.indexAll(); TelemetryData data = communityUnderTest.load(); |