Search in sources :

Example 76 with SonarScanner

use of com.sonar.orchestrator.build.SonarScanner in project sonarqube by SonarSource.

the class BootstrappingTest method analyzeProjectWith100FlatModules.

@Test
public void analyzeProjectWith100FlatModules() throws IOException {
    SonarScanner scanner = SonarScanner.create().setProperties("sonar.projectKey", "many-flat-modules", "sonar.projectName", "Many Flat Modules", "sonar.projectVersion", "1.0", "sonar.sources", "", "sonar.showProfiling", "true");
    scanner.setEnvironmentVariable("SONAR_RUNNER_OPTS", "-Xmx512m -server").setProjectDir(manyFlatModulesBaseDir);
    BuildResult result = orchestrator.executeBuild(scanner);
    // First analysis
    perfRule.assertDurationAround(MavenLogs.extractTotalTime(result.getLogs()), 22800L);
    result = orchestrator.executeBuild(scanner);
    // Second analysis is longer since we load project referential
    perfRule.assertDurationAround(MavenLogs.extractTotalTime(result.getLogs()), 27200L);
}
Also used : BuildResult(com.sonar.orchestrator.build.BuildResult) SonarScanner(com.sonar.orchestrator.build.SonarScanner) Test(org.junit.Test)

Example 77 with SonarScanner

use of com.sonar.orchestrator.build.SonarScanner in project sonarqube by SonarSource.

the class BootstrappingTest method analyzeProjectWith50NestedModules.

@Test
public void analyzeProjectWith50NestedModules() throws IOException {
    SonarScanner scanner = SonarScanner.create().setProperties("sonar.projectKey", "many-nested-modules", "sonar.projectName", "Many Nested Modules", "sonar.projectVersion", "1.0", "sonar.sources", "", "sonar.showProfiling", "true");
    scanner.setEnvironmentVariable("SONAR_RUNNER_OPTS", "-Xmx512m -server");
    scanner.setProjectDir(manyNestedModulesBaseDir);
    BuildResult result = orchestrator.executeBuild(scanner);
    // First analysis
    perfRule.assertDurationAround(MavenLogs.extractTotalTime(result.getLogs()), 8900L);
    result = orchestrator.executeBuild(scanner);
    // Second analysis
    perfRule.assertDurationAround(MavenLogs.extractTotalTime(result.getLogs()), 9300L);
}
Also used : BuildResult(com.sonar.orchestrator.build.BuildResult) SonarScanner(com.sonar.orchestrator.build.SonarScanner) Test(org.junit.Test)

Example 78 with SonarScanner

use of com.sonar.orchestrator.build.SonarScanner in project sonarqube by SonarSource.

the class HighlightingTest method computeSyntaxHighlightingOnBigFiles.

@Test
public void computeSyntaxHighlightingOnBigFiles() 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());
    }
    SonarScanner scanner = SonarScanner.create().setProperties("sonar.projectKey", "highlighting", "sonar.projectName", "highlighting", "sonar.projectVersion", "1.0", "sonar.sources", "src", "sonar.showProfiling", "true");
    scanner.setEnvironmentVariable("SONAR_RUNNER_OPTS", "-Xmx512m -server").setProjectDir(baseDir);
    BuildResult result = orchestrator.executeBuild(scanner);
    System.out.println("Total time: " + MavenLogs.extractTotalTime(result.getLogs()));
    perfRule.assertDurationAround(MavenLogs.extractTotalTime(result.getLogs()), 25700L);
    Properties prof = readProfiling(baseDir, "highlighting");
    perfRule.assertDurationAround(Long.valueOf(prof.getProperty("Xoo Highlighting Sensor")), 9700L);
}
Also used : BuildResult(com.sonar.orchestrator.build.BuildResult) Properties(java.util.Properties) File(java.io.File) SonarScanner(com.sonar.orchestrator.build.SonarScanner) Test(org.junit.Test)

Example 79 with SonarScanner

use of com.sonar.orchestrator.build.SonarScanner in project sonarqube by SonarSource.

the class MemoryTest method analyzeProjectWithManyModulesAndBigProperties.

// Property on root module is duplicated in each module so it may be big
@Test
public void analyzeProjectWithManyModulesAndBigProperties() throws IOException {
    File baseDir = temp.newFolder();
    prepareModule(baseDir, "moduleA", 1);
    prepareModule(baseDir, "moduleB", 1);
    prepareModule(baseDir, "moduleC", 1);
    FileUtils.write(new File(baseDir, "sonar-project.properties"), "sonar.modules=moduleA,moduleB,moduleC\n", true);
    FileUtils.write(new File(baseDir, "sonar-project.properties"), "sonar.myBigProp=" + Strings.repeat("A", 10000), true);
    SonarScanner scanner = SonarScanner.create().setProperties("sonar.projectKey", "big-module-tree", "sonar.projectName", "Big Module Tree", "sonar.projectVersion", "1.0", "sonar.sources", "", "sonar.showProfiling", "true");
    scanner.setEnvironmentVariable("SONAR_RUNNER_OPTS", "-Xmx512m -server").setProjectDir(baseDir);
    BuildResult result = orchestrator.executeBuild(scanner);
    perfRule.assertDurationAround(MavenLogs.extractTotalTime(result.getLogs()), 4847L);
    // Second execution with a property on server side
    orchestrator.getServer().getAdminWsClient().create(new PropertyCreateQuery("sonar.anotherBigProp", Strings.repeat("B", 1000), "big-module-tree"));
    result = orchestrator.executeBuild(scanner);
    perfRule.assertDurationAround(MavenLogs.extractTotalTime(result.getLogs()), 4620L);
}
Also used : BuildResult(com.sonar.orchestrator.build.BuildResult) PropertyCreateQuery(org.sonar.wsclient.services.PropertyCreateQuery) File(java.io.File) SonarScanner(com.sonar.orchestrator.build.SonarScanner) Test(org.junit.Test)

Example 80 with SonarScanner

use of com.sonar.orchestrator.build.SonarScanner in project sonar-web by SonarSource.

the class FileSuffixesTest method filesSuffixesHtmlPhp.

@Test
public void filesSuffixesHtmlPhp() {
    SonarScanner build = getSonarRunner().setProperty("sonar.web.file.suffixes", ".html,.php");
    orchestrator.executeBuild(build);
    assertThat(getAnalyzedFilesNumber()).isEqualTo(2);
}
Also used : SonarScanner(com.sonar.orchestrator.build.SonarScanner) Test(org.junit.Test)

Aggregations

SonarScanner (com.sonar.orchestrator.build.SonarScanner)84 Test (org.junit.Test)65 BuildResult (com.sonar.orchestrator.build.BuildResult)38 File (java.io.File)21 QualityGate (org.sonar.wsclient.qualitygate.QualityGate)8 JSONArray (org.json.simple.JSONArray)4 JSONObject (org.json.simple.JSONObject)4 Issue (org.sonar.wsclient.issue.Issue)4 Favorites (org.sonarqube.ws.Favorites)3 SearchRequest (org.sonarqube.ws.client.favorite.SearchRequest)3 Path (java.nio.file.Path)2 ArrayList (java.util.ArrayList)2 BeforeClass (org.junit.BeforeClass)2 SonarClient (org.sonar.wsclient.SonarClient)2 IssueClient (org.sonar.wsclient.issue.IssueClient)2 ImmutableMap (com.google.common.collect.ImmutableMap)1 WebTestSuite.createSonarScanner (com.sonar.it.web.WebTestSuite.createSonarScanner)1 BuildFailureException (com.sonar.orchestrator.build.BuildFailureException)1 SonarScannerInstaller (com.sonar.orchestrator.build.SonarScannerInstaller)1 FileSystem (com.sonar.orchestrator.config.FileSystem)1