aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-batch
diff options
context:
space:
mode:
authorJulien HENRY <julien.henry@sonarsource.com>2015-11-24 13:08:43 +0100
committerJulien HENRY <julien.henry@sonarsource.com>2015-11-24 13:09:15 +0100
commit0ef2119bf5961312426fe855b6e0beb82c46c297 (patch)
tree2ba7739cbc4ca5830dd14b4965bca57201975298 /sonar-batch
parentac6428a4a218bc311e3707b3d86c0d3c6ba67e4b (diff)
downloadsonarqube-0ef2119bf5961312426fe855b6e0beb82c46c297.tar.gz
sonarqube-0ef2119bf5961312426fe855b6e0beb82c46c297.zip
Remove perf tests from batch MT (take too much time)
Diffstat (limited to 'sonar-batch')
-rw-r--r--sonar-batch/src/test/java/org/sonar/batch/mediumtest/fs/RandomFsAccessMediumTest.java140
-rw-r--r--sonar-batch/src/test/java/org/sonar/batch/mediumtest/highlighting/HighlightingMediumTest.java48
2 files changed, 4 insertions, 184 deletions
diff --git a/sonar-batch/src/test/java/org/sonar/batch/mediumtest/fs/RandomFsAccessMediumTest.java b/sonar-batch/src/test/java/org/sonar/batch/mediumtest/fs/RandomFsAccessMediumTest.java
deleted file mode 100644
index 92f7257d19e..00000000000
--- a/sonar-batch/src/test/java/org/sonar/batch/mediumtest/fs/RandomFsAccessMediumTest.java
+++ /dev/null
@@ -1,140 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2014 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * SonarQube is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-package org.sonar.batch.mediumtest.fs;
-
-import com.google.common.collect.ImmutableMap;
-import java.io.File;
-import java.io.IOException;
-import java.nio.charset.StandardCharsets;
-import java.util.List;
-import org.apache.commons.io.FileUtils;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.TemporaryFolder;
-import org.sonar.batch.mediumtest.BatchMediumTester;
-import org.sonar.batch.mediumtest.Benchmark;
-import org.sonar.batch.mediumtest.TaskResult;
-import org.sonar.batch.protocol.output.BatchReport.Issue;
-import org.sonar.xoo.XooPlugin;
-import org.sonar.xoo.rule.XooRulesDefinition;
-
-import static org.assertj.core.api.Assertions.assertThat;
-
-public class RandomFsAccessMediumTest {
-
- @Rule
- public TemporaryFolder temp = new TemporaryFolder();
-
- @Rule
- public Benchmark bench = new Benchmark();
-
- public BatchMediumTester tester = BatchMediumTester.builder()
- .registerPlugin("xoo", new XooPlugin())
- .addDefaultQProfile("xoo", "Sonar Way")
- .addRules(new XooRulesDefinition())
- .addActiveRule("xoo", "RandomAccessIssue", null, "One issue per line", "MAJOR", null, "xoo")
- .build();
-
- @Before
- public void prepare() {
- tester.start();
- }
-
- @After
- public void stop() {
- tester.stop();
- }
-
- @Test
- public void testRandomFsAccessByAbsolutePath() throws IOException {
-
- File baseDir = temp.getRoot();
- File srcDir = prepareBigProject(baseDir);
-
- File paths = new File(baseDir, "paths.txt");
- int ISSUE_COUNT = 10000;
- for (int i = 0; i < ISSUE_COUNT; i++) {
- File xooFile = new File(srcDir, "sample" + (i / 10 + 1) + ".xoo");
- FileUtils.write(paths, xooFile.getAbsolutePath() + "\n", StandardCharsets.UTF_8, true);
- }
-
- long start = System.currentTimeMillis();
- TaskResult result = tester.newTask()
- .properties(ImmutableMap.<String, String>builder()
- .put("sonar.task", "scan")
- .put("sonar.projectBaseDir", baseDir.getAbsolutePath())
- .put("sonar.projectKey", "com.foo.project")
- .put("sonar.projectName", "Foo Project")
- .put("sonar.projectVersion", "1.0-SNAPSHOT")
- .put("sonar.projectDescription", "Description of Foo Project")
- .put("sonar.sources", "src")
- .put("sonar.xoo.randomAccessIssue.paths", paths.getAbsolutePath())
- .build())
- .start();
-
- List<Issue> issues = result.issuesFor(result.inputFile("src/sample1.xoo"));
- assertThat(issues).hasSize(10);
- bench.expectLessThanOrEqualTo("Time to create " + ISSUE_COUNT + " issues on random files using FileSystem query", System.currentTimeMillis() - start, 2000);
- }
-
- @Test
- public void testRandomFsAccessByRelativePath() throws IOException {
-
- File baseDir = temp.getRoot();
- prepareBigProject(baseDir);
-
- File paths = new File(baseDir, "paths.txt");
- int ISSUE_COUNT = 10000;
- for (int i = 0; i < ISSUE_COUNT; i++) {
- FileUtils.write(paths, "src/sample" + (i / 10 + 1) + ".xoo\n", StandardCharsets.UTF_8, true);
- }
-
- TaskResult result = tester.newTask()
- .properties(ImmutableMap.<String, String>builder()
- .put("sonar.task", "scan")
- .put("sonar.projectBaseDir", baseDir.getAbsolutePath())
- .put("sonar.projectKey", "com.foo.project")
- .put("sonar.projectName", "Foo Project")
- .put("sonar.projectVersion", "1.0-SNAPSHOT")
- .put("sonar.projectDescription", "Description of Foo Project")
- .put("sonar.sources", "src")
- .put("sonar.xoo.randomAccessIssue.paths", paths.getAbsolutePath())
- .build())
- .start();
-
- List<Issue> issues = result.issuesFor(result.inputFile("src/sample1.xoo"));
- assertThat(issues).hasSize(10);
-
- }
-
- private File prepareBigProject(File baseDir) throws IOException {
- File srcDir = new File(baseDir, "src");
- srcDir.mkdir();
-
- for (int i = 1; i <= 1000; i++) {
- File xooFile = new File(srcDir, "sample" + i + ".xoo");
- FileUtils.write(xooFile, "foo");
- }
- return srcDir;
- }
-
-}
diff --git a/sonar-batch/src/test/java/org/sonar/batch/mediumtest/highlighting/HighlightingMediumTest.java b/sonar-batch/src/test/java/org/sonar/batch/mediumtest/highlighting/HighlightingMediumTest.java
index 9672d2a4b5d..48194a7dcd8 100644
--- a/sonar-batch/src/test/java/org/sonar/batch/mediumtest/highlighting/HighlightingMediumTest.java
+++ b/sonar-batch/src/test/java/org/sonar/batch/mediumtest/highlighting/HighlightingMediumTest.java
@@ -19,28 +19,24 @@
*/
package org.sonar.batch.mediumtest.highlighting;
-import org.hamcrest.TypeSafeMatcher;
-import org.hamcrest.BaseMatcher;
-import org.hamcrest.Description;
-import org.hamcrest.Matcher;
-import org.junit.rules.ExpectedException;
import com.google.common.collect.ImmutableMap;
-
import java.io.File;
import java.io.IOException;
-
import org.apache.commons.io.FileUtils;
-import org.apache.commons.lang.StringUtils;
+import org.hamcrest.Description;
+import org.hamcrest.TypeSafeMatcher;
import org.junit.After;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
+import org.junit.rules.ExpectedException;
import org.junit.rules.TemporaryFolder;
import org.sonar.api.batch.fs.InputFile;
import org.sonar.api.batch.sensor.highlighting.TypeOfText;
import org.sonar.batch.mediumtest.BatchMediumTester;
import org.sonar.batch.mediumtest.TaskResult;
import org.sonar.xoo.XooPlugin;
+
import static org.assertj.core.api.Assertions.assertThat;
public class HighlightingMediumTest {
@@ -121,41 +117,7 @@ public class HighlightingMediumTest {
return e.getMessage().contains("Unable to highlight file");
}
});
-
- TaskResult result = tester.newTask()
- .properties(ImmutableMap.<String, String>builder()
- .put("sonar.projectBaseDir", baseDir.getAbsolutePath())
- .put("sonar.projectKey", "com.foo.project")
- .put("sonar.projectName", "Foo Project")
- .put("sonar.projectVersion", "1.0-SNAPSHOT")
- .put("sonar.projectDescription", "Description of Foo Project")
- .put("sonar.sources", "src")
- .build())
- .start();
- }
-
- @Test
- public void computeSyntaxHighlightingOnBigFile() throws IOException {
- File baseDir = temp.newFolder();
- File srcDir = new File(baseDir, "src");
- srcDir.mkdir();
-
- int nbFiles = 100;
- int ruleCount = 100000;
- int nblines = 1000;
- int linesize = ruleCount / nblines;
- for (int nb = 1; nb <= nbFiles; nb++) {
- File xooFile = new File(srcDir, "sample" + nb + ".xoo");
- File xoohighlightingFile = new File(srcDir, "sample" + nb + ".xoo.highlighting");
- FileUtils.write(xooFile, StringUtils.repeat(StringUtils.repeat("a", linesize) + "\n", nblines));
- StringBuilder sb = new StringBuilder(16 * ruleCount);
- for (int i = 0; i < ruleCount; i++) {
- sb.append(i).append(":").append(i + 1).append(":s\n");
- }
- FileUtils.write(xoohighlightingFile, sb.toString());
- }
- long start = System.currentTimeMillis();
TaskResult result = tester.newTask()
.properties(ImmutableMap.<String, String>builder()
.put("sonar.projectBaseDir", baseDir.getAbsolutePath())
@@ -166,8 +128,6 @@ public class HighlightingMediumTest {
.put("sonar.sources", "src")
.build())
.start();
- System.out.println("Duration: " + (System.currentTimeMillis() - start));
-
}
}