aboutsummaryrefslogtreecommitdiffstats
path: root/server/sonar-db-dao
diff options
context:
space:
mode:
authorDuarte Meneses <duarte.meneses@sonarsource.com>2020-11-26 20:34:42 -0600
committersonartech <sonartech@sonarsource.com>2020-11-30 20:07:06 +0000
commit736bfc4d5ae032edaf556ee8a41efc1d9b9ce4f9 (patch)
treed17ef789c14df37e5cbe5692356b1d771ade26aa /server/sonar-db-dao
parent59adbb849b1ce3338e6299dea939c454df7d0cdb (diff)
downloadsonarqube-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-db-dao')
-rw-r--r--server/sonar-db-dao/src/testFixtures/java/org/sonar/db/TestDbImpl.java8
1 files changed, 4 insertions, 4 deletions
diff --git a/server/sonar-db-dao/src/testFixtures/java/org/sonar/db/TestDbImpl.java b/server/sonar-db-dao/src/testFixtures/java/org/sonar/db/TestDbImpl.java
index 1f7f2e082ae..b5b2a2cfd96 100644
--- a/server/sonar-db-dao/src/testFixtures/java/org/sonar/db/TestDbImpl.java
+++ b/server/sonar-db-dao/src/testFixtures/java/org/sonar/db/TestDbImpl.java
@@ -23,6 +23,7 @@ import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import java.util.Set;
import java.util.function.BiConsumer;
import java.util.function.Consumer;
import java.util.function.Function;
@@ -38,7 +39,7 @@ import org.sonar.process.logging.LogbackHelper;
class TestDbImpl extends CoreTestDb {
private static TestDbImpl defaultSchemaBaseTestDb;
// instantiating MyBatis objects is costly => we cache them for default schema
- private static final Map<List<String>, TestDbImpl> defaultSchemaTestDbsWithExtensions = new HashMap<>();
+ private static final Map<Set<String>, TestDbImpl> defaultSchemaTestDbsWithExtensions = new HashMap<>();
private boolean isDefault;
private MyBatis myBatis;
@@ -94,11 +95,10 @@ class TestDbImpl extends CoreTestDb {
defaultSchemaBaseTestDb = new TestDbImpl(null);
}
if (confExtensions.length > 0) {
- List<String> key = Arrays.stream(confExtensions)
+ Set<String> key = Arrays.stream(confExtensions)
.flatMap(MyBatisConfExtension::getMapperClasses)
.map(Class::getName)
- .sorted()
- .collect(Collectors.toList());
+ .collect(Collectors.toSet());
return defaultSchemaTestDbsWithExtensions.computeIfAbsent(
key,
k -> new TestDbImpl(defaultSchemaBaseTestDb, newMyBatis(defaultSchemaBaseTestDb.getDatabase(), confExtensions)));