Search in sources :

Example 51 with BuildResult

use of com.sonar.orchestrator.build.BuildResult 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 52 with BuildResult

use of com.sonar.orchestrator.build.BuildResult 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 53 with BuildResult

use of com.sonar.orchestrator.build.BuildResult 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)

Aggregations

BuildResult (com.sonar.orchestrator.build.BuildResult)53 Test (org.junit.Test)49 SonarScanner (com.sonar.orchestrator.build.SonarScanner)38 File (java.io.File)12 QualityGate (org.sonar.wsclient.qualitygate.QualityGate)7 JSONArray (org.json.simple.JSONArray)4 JSONObject (org.json.simple.JSONObject)4 Issue (org.sonar.wsclient.issue.Issue)3 Path (java.nio.file.Path)2 ArrayList (java.util.ArrayList)2 BuildFailureException (com.sonar.orchestrator.build.BuildFailureException)1 SonarScannerInstaller (com.sonar.orchestrator.build.SonarScannerInstaller)1 FileSystem (com.sonar.orchestrator.config.FileSystem)1 AbapCheck (it.plugins.checks.AbapCheck)1 CCheck (it.plugins.checks.CCheck)1 Check (it.plugins.checks.Check)1 CobolCheck (it.plugins.checks.CobolCheck)1 CppCheck (it.plugins.checks.CppCheck)1 FlexCheck (it.plugins.checks.FlexCheck)1 GroovyCheck (it.plugins.checks.GroovyCheck)1