use of com.sonar.orchestrator.build.BuildResult in project sonarqube by SonarSource.
the class QualityGateTest method test_status_warning.
@Test
public void test_status_warning() throws IOException {
QualityGate simple = qgClient().create("SimpleWithLowThreshold");
qgClient().setDefault(simple.id());
qgClient().createCondition(NewCondition.create(simple.id()).metricKey("ncloc").operator("GT").warningThreshold("10"));
try {
SonarScanner build = SonarScanner.create(projectDir("qualitygate/xoo-sample"));
BuildResult buildResult = orchestrator.executeBuild(build);
verifyQGStatusInPostTask(buildResult, TASK_STATUS_SUCCESS, QG_STATUS_WARN);
assertThat(getGateStatusMeasure().getValue()).isEqualTo("WARN");
} finally {
qgClient().unsetDefault();
qgClient().destroy(simple.id());
}
}
use of com.sonar.orchestrator.build.BuildResult in project sonarqube by SonarSource.
the class QualityGateTest method status_ok_if_empty_gate.
@Test
public void status_ok_if_empty_gate() throws IOException {
QualityGate empty = qgClient().create("Empty");
qgClient().setDefault(empty.id());
try {
SonarScanner build = SonarScanner.create(projectDir("qualitygate/xoo-sample"));
BuildResult buildResult = orchestrator.executeBuild(build);
verifyQGStatusInPostTask(buildResult, TASK_STATUS_SUCCESS, QG_STATUS_OK);
assertThat(getGateStatusMeasure().getValue()).isEqualTo("OK");
} finally {
qgClient().unsetDefault();
qgClient().destroy(empty.id());
}
}
use of com.sonar.orchestrator.build.BuildResult in project sonarqube by SonarSource.
the class QualityGateTest method do_not_compute_status_if_no_gate.
@Test
public void do_not_compute_status_if_no_gate() throws IOException {
SonarScanner build = SonarScanner.create(projectDir("qualitygate/xoo-sample"));
BuildResult buildResult = orchestrator.executeBuild(build);
verifyQGStatusInPostTask(buildResult, TASK_STATUS_SUCCESS, QG_STATUS_NO_QG);
assertThat(getGateStatusMeasure()).isNull();
}
use of com.sonar.orchestrator.build.BuildResult in project sonarqube by SonarSource.
the class QualityGateTest method use_server_settings_instead_of_default_gate.
@Test
public void use_server_settings_instead_of_default_gate() throws IOException {
QualityGate alert = qgClient().create("AlertWithLowThreshold");
qgClient().createCondition(NewCondition.create(alert.id()).metricKey("ncloc").operator("GT").warningThreshold("10"));
QualityGate error = qgClient().create("ErrorWithLowThreshold");
qgClient().createCondition(NewCondition.create(error.id()).metricKey("ncloc").operator("GT").errorThreshold("10"));
qgClient().setDefault(alert.id());
associateQualityGateToProject(error.id(), PROJECT_KEY);
try {
SonarScanner build = SonarScanner.create(projectDir("qualitygate/xoo-sample"));
BuildResult buildResult = orchestrator.executeBuild(build);
verifyQGStatusInPostTask(buildResult, TASK_STATUS_SUCCESS, QG_STATUS_ERROR);
assertThat(getGateStatusMeasure().getValue()).isEqualTo("ERROR");
} finally {
qgClient().unsetDefault();
qgClient().destroy(alert.id());
qgClient().destroy(error.id());
}
}
use of com.sonar.orchestrator.build.BuildResult 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);
}
Aggregations