aboutsummaryrefslogtreecommitdiffstats
path: root/server/sonar-server-benchmarks
diff options
context:
space:
mode:
authorJulien Lancelot <julien.lancelot@sonarsource.com>2015-06-03 10:15:21 +0200
committerJulien Lancelot <julien.lancelot@sonarsource.com>2015-06-03 10:50:00 +0200
commit08f807ca759212e6f6b2c05063bc2d32e5383615 (patch)
tree1af3117dabb4b372029de27f69d7365343980c36 /server/sonar-server-benchmarks
parent51206aba146d10efa6f57ed5f1038298be6792a0 (diff)
downloadsonarqube-08f807ca759212e6f6b2c05063bc2d32e5383615.tar.gz
sonarqube-08f807ca759212e6f6b2c05063bc2d32e5383615.zip
SONAR-6253 Cache of component ids do not contains anymore key and uuid
Instead, use TreeRootHolder to get component key and uuid
Diffstat (limited to 'server/sonar-server-benchmarks')
-rw-r--r--server/sonar-server-benchmarks/src/test/java/org/sonar/server/benchmark/PersistFileSourcesStepTest.java26
1 files changed, 15 insertions, 11 deletions
diff --git a/server/sonar-server-benchmarks/src/test/java/org/sonar/server/benchmark/PersistFileSourcesStepTest.java b/server/sonar-server-benchmarks/src/test/java/org/sonar/server/benchmark/PersistFileSourcesStepTest.java
index 4919aa890d4..d4bad3f9b50 100644
--- a/server/sonar-server-benchmarks/src/test/java/org/sonar/server/benchmark/PersistFileSourcesStepTest.java
+++ b/server/sonar-server-benchmarks/src/test/java/org/sonar/server/benchmark/PersistFileSourcesStepTest.java
@@ -33,8 +33,9 @@ import org.sonar.batch.protocol.Constants;
import org.sonar.batch.protocol.output.BatchReport;
import org.sonar.core.persistence.DbTester;
import org.sonar.server.computation.batch.BatchReportReaderRule;
-import org.sonar.server.computation.component.DbComponentsRefCache;
-import org.sonar.server.computation.component.DbComponentsRefCache.DbComponent;
+import org.sonar.server.computation.batch.TreeRootHolderRule;
+import org.sonar.server.computation.component.Component;
+import org.sonar.server.computation.component.DumbComponent;
import org.sonar.server.computation.step.PersistFileSourcesStep;
import org.sonar.server.db.DbClient;
import org.sonar.server.source.db.FileSourceDao;
@@ -49,12 +50,15 @@ public class PersistFileSourcesStepTest {
public static final int NUMBER_OF_LINES = 1000;
public static final String PROJECT_UUID = Uuids.create();
- DbComponentsRefCache dbComponentsRefCache = new DbComponentsRefCache();
-
@Rule
public DbTester dbTester = new DbTester();
+
@Rule
public Benchmark benchmark = new Benchmark();
+
+ @Rule
+ public TreeRootHolderRule treeRootHolder = new TreeRootHolderRule();
+
@Rule
public BatchReportReaderRule reportReader = new BatchReportReaderRule();
@@ -70,7 +74,7 @@ public class PersistFileSourcesStepTest {
long start = System.currentTimeMillis();
- PersistFileSourcesStep step = new PersistFileSourcesStep(dbClient, System2.INSTANCE, dbComponentsRefCache, reportReader);
+ PersistFileSourcesStep step = new PersistFileSourcesStep(dbClient, System2.INSTANCE, treeRootHolder, reportReader);
step.execute();
long end = System.currentTimeMillis();
@@ -92,17 +96,17 @@ public class PersistFileSourcesStepTest {
.setRef(1)
.setType(Constants.ComponentType.PROJECT);
- dbComponentsRefCache.addComponent(1, new DbComponent(1L, "PROJECT", PROJECT_UUID));
-
+ List<Component> components = new ArrayList<>();
for (int fileRef = 2; fileRef <= NUMBER_OF_FILES + 1; fileRef++) {
- generateFileReport(fileRef);
+ components.add(generateFileReport(fileRef));
project.addChildRef(fileRef);
}
+ treeRootHolder.setRoot(new DumbComponent(Component.Type.PROJECT, 1, PROJECT_UUID, "PROJECT", components.toArray(new Component[components.size()])));
reportReader.putComponent(project.build());
}
- private void generateFileReport(int fileRef) throws IOException {
+ private Component generateFileReport(int fileRef) throws IOException {
LineData lineData = new LineData();
for (int line = 1; line <= NUMBER_OF_LINES; line++) {
lineData.generateLineData(line);
@@ -113,14 +117,14 @@ public class PersistFileSourcesStepTest {
.setLines(NUMBER_OF_LINES)
.build());
- dbComponentsRefCache.addComponent(fileRef, new DbComponent((long) fileRef, "PROJECT:" + fileRef, Uuids.create()));
-
reportReader.putFileSourceLines(fileRef, lineData.lines);
reportReader.putCoverage(fileRef, lineData.coverages);
reportReader.putChangesets(lineData.changesetsBuilder.setComponentRef(fileRef).build());
reportReader.putSyntaxHighlighting(fileRef, lineData.highlightings);
reportReader.putSymbols(fileRef, lineData.symbols);
reportReader.putDuplications(fileRef, lineData.duplications);
+
+ return new DumbComponent(Component.Type.FILE, fileRef, Uuids.create(), "PROJECT:" + fileRef);
}
private static class LineData {