Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MSONAR-212 Fix performance degradation in our ITs with [LATEST_RELEASE] & [DEV] versions of SQ #204

Merged
merged 2 commits into from
Mar 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import com.sonar.orchestrator.http.HttpResponse;
import com.sonar.orchestrator.junit5.OrchestratorExtension;
import com.sonar.orchestrator.version.Version;

import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
Expand All @@ -38,6 +39,7 @@
import java.util.regex.Pattern;
import java.util.stream.Collectors;
import javax.annotation.CheckForNull;

import org.apache.commons.lang.StringUtils;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
Expand All @@ -63,10 +65,12 @@ public abstract class AbstractMavenTest {

@RegisterExtension
public static final OrchestratorExtension ORCHESTRATOR = OrchestratorExtension.builderEnv()
.setSonarVersion(getSonarVersion())
.useDefaultAdminCredentialsForBuilds(true)
.keepBundledPlugins()
.build();
.setSonarVersion(getSonarVersion())
.useDefaultAdminCredentialsForBuilds(true)
.addBundledPluginToKeep("sonar-java-plugin")
.addBundledPluginToKeep("sonar-xml-plugin")
.addBundledPluginToKeep("sonar-html-plugin")
.build();

protected HttpConnector wsConnector;
protected WsClient wsClient;
Expand Down
18 changes: 9 additions & 9 deletions its/src/test/java/com/sonar/maven/it/suite/JavaTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
import static org.assertj.core.data.MapEntry.entry;
import static org.junit.jupiter.api.Assumptions.assumeTrue;

public class JavaTest extends AbstractMavenTest {
class JavaTest extends AbstractMavenTest {

@TempDir
public Path temp;
Expand All @@ -50,7 +50,7 @@ public void cleanup() {

// MSONAR-83
@Test
public void shouldPopulateLibraries() throws IOException {
void shouldPopulateLibraries() throws IOException {
File outputProps = temp.resolve("out.properties").toFile();
outputProps.createNewFile();

Expand All @@ -75,7 +75,7 @@ public void shouldPopulateLibraries() throws IOException {
}

@Test
public void read_default_from_plugins_config() throws Exception {
void read_default_from_plugins_config() throws Exception {
File outputProps = temp.resolve("out.properties").toFile();
outputProps.createNewFile();

Expand All @@ -96,7 +96,7 @@ public void read_default_from_plugins_config() throws Exception {
}

@Test
public void setJavaVersionCompilerConfiguration() throws IOException {
void setJavaVersionCompilerConfiguration() throws IOException {
File outputProps = temp.resolve("out.properties").toFile();
outputProps.createNewFile();

Expand All @@ -113,7 +113,7 @@ public void setJavaVersionCompilerConfiguration() throws IOException {
}

@Test
public void setJavaVersionProperties() throws IOException {
void setJavaVersionProperties() throws IOException {
File outputProps = temp.resolve("out.properties").toFile();
outputProps.createNewFile();

Expand All @@ -130,7 +130,7 @@ public void setJavaVersionProperties() throws IOException {
}

@Test
public void setJdkHomeFromCompilerExecutableConfiguration() throws IOException {
void setJdkHomeFromCompilerExecutableConfiguration() throws IOException {
File outputProps = temp.resolve("out.properties").toFile();
outputProps.createNewFile();

Expand All @@ -145,7 +145,7 @@ public void setJdkHomeFromCompilerExecutableConfiguration() throws IOException {
}

@Test
public void setJdkHomeFromGlobalToolchainsPlugin() throws IOException {
void setJdkHomeFromGlobalToolchainsPlugin() throws IOException {
File outputProps = temp.resolve("out.properties").toFile();
outputProps.createNewFile();

Expand All @@ -163,7 +163,7 @@ public void setJdkHomeFromGlobalToolchainsPlugin() throws IOException {
}

@Test
public void setJdkHomeFromCompilerToolchainsConfiguration() throws IOException {
void setJdkHomeFromCompilerToolchainsConfiguration() throws IOException {
// https://maven.apache.org/plugins/maven-compiler-plugin/compile-mojo.html#jdkToolchain requires Maven 3.3.1+
assumeTrue(getMavenVersion().compareTo(Version.create("3.3.1")) >= 0);

Expand All @@ -183,7 +183,7 @@ public void setJdkHomeFromCompilerToolchainsConfiguration() throws IOException {
}

@Test
public void takeFirstToolchainIfMultipleExecutions() throws IOException {
void takeFirstToolchainIfMultipleExecutions() throws IOException {
// https://maven.apache.org/plugins/maven-compiler-plugin/compile-mojo.html#jdkToolchain requires Maven 3.3.1+
assumeTrue(getMavenVersion().compareTo(Version.create("3.3.1")) >= 0);

Expand Down
54 changes: 27 additions & 27 deletions its/src/test/java/com/sonar/maven/it/suite/MavenTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@

import static org.assertj.core.api.Assertions.assertThat;

public class MavenTest extends AbstractMavenTest {
class MavenTest extends AbstractMavenTest {

private static final String MODULE_START_7_6 = "------------- Run sensors on module ";
private static final String MODULE_START = "------------- Scan ";
Expand All @@ -55,7 +55,7 @@ public void cleanup() {
* See MSONAR-129
*/
@Test
public void useUserPropertiesGlobalConfig() throws Exception {
void useUserPropertiesGlobalConfig() throws Exception {
BuildRunner runner = new BuildRunner(ORCHESTRATOR.getConfiguration());
MavenBuild build = MavenBuild.create(ItUtils.locateProjectPom("maven/maven-only-test-dir"))
.setGoals(cleanSonarGoal());
Expand All @@ -79,7 +79,7 @@ public void useUserPropertiesGlobalConfig() throws Exception {
* See MSONAR-129
*/
@Test
public void supportSonarHostURLParam() {
void supportSonarHostURLParam() {
BuildRunner runner = new BuildRunner(ORCHESTRATOR.getConfiguration());
MavenBuild build = MavenBuild.create(ItUtils.locateProjectPom("maven/maven-global-properties"))
// global property should take precedence
Expand All @@ -96,7 +96,7 @@ public void supportSonarHostURLParam() {
* See MSONAR-172
*/
@Test
public void supportSonarHostURLParamFromEnvironmentVariable() {
void supportSonarHostURLParamFromEnvironmentVariable() {
BuildRunner runner = new BuildRunner(ORCHESTRATOR.getConfiguration());
MavenBuild build = MavenBuild.create(ItUtils.locateProjectPom("maven/maven-only-test-dir"))
.setEnvironmentVariable("SONAR_HOST_URL", "http://from-env.org:9000")
Expand All @@ -112,7 +112,7 @@ public void supportSonarHostURLParamFromEnvironmentVariable() {
* See MSONAR-130
*/
@Test
public void structureWithRelativePaths() {
void structureWithRelativePaths() {
MavenBuild build = MavenBuild.create(ItUtils.locateProjectPom("maven/maven-structure-relative-paths"))
.setGoals(cleanSonarGoal());
ORCHESTRATOR.executeBuild(build);
Expand All @@ -122,22 +122,22 @@ public void structureWithRelativePaths() {
* See MSONAR-164
*/
@Test
public void flatStructure() {
void flatStructure() {
MavenBuild build = MavenBuild.create(ItUtils.locateProjectPom("maven/maven-flat-layout/parent"))
.setGoals(cleanSonarGoal());
ORCHESTRATOR.executeBuild(build);
}

@Test
public void aggregatorInheritParent() {
void aggregatorInheritParent() {
MavenBuild build = MavenBuild.create(ItUtils.locateProjectPom("maven/aggregator-inherit-parent"))
.setGoals(cleanSonarGoal());
ORCHESTRATOR.executeBuild(build);
assertThat(getMeasureAsInteger("org.sonarsource.maven.its:aggregator", "files")).isEqualTo(4); // 4 x pom.xml
}

@Test
public void aggregatorInheritParentAndSonarAttachedToPhase() {
void aggregatorInheritParentAndSonarAttachedToPhase() {
MavenBuild build = MavenBuild.create(ItUtils.locateProjectPom("maven/aggregator-inherit-parent-and-bind-to-verify"))
.setGoals("clean verify")
.setProperty("sonar.maven.it.mojoVersion", mojoVersion().toString());
Expand All @@ -146,7 +146,7 @@ public void aggregatorInheritParentAndSonarAttachedToPhase() {
}

@Test
public void shouldSupportJarWithoutSources() {
void shouldSupportJarWithoutSources() {
MavenBuild build = MavenBuild.create(ItUtils.locateProjectPom("maven/project-with-module-without-sources"))
.setGoals(cleanSonarGoal());
ORCHESTRATOR.executeBuild(build);
Expand All @@ -163,7 +163,7 @@ public void shouldSupportJarWithoutSources() {
* See SONAR-594
*/
@Test
public void shouldSupportJeeProjects() {
void shouldSupportJeeProjects() {
MavenBuild build = MavenBuild.create(ItUtils.locateProjectPom("maven/jee"))
.setGoals(cleanInstallSonarGoal());
ORCHESTRATOR.executeBuild(build);
Expand All @@ -182,7 +182,7 @@ public void shouldSupportJeeProjects() {
* See SONAR-222
*/
@Test
public void shouldSupportMavenExtensions() {
void shouldSupportMavenExtensions() {
MavenBuild build = MavenBuild.create(ItUtils.locateProjectPom("maven/maven-extensions"))
.setGoals(cleanSonarGoal());
ORCHESTRATOR.executeBuild(build);
Expand All @@ -194,7 +194,7 @@ public void shouldSupportMavenExtensions() {
* This test should be splitted. It checks multiple use-cases at the same time : SONAR-518, SONAR-519 and SONAR-593
*/
@Test
public void testBadMavenParameters() {
void testBadMavenParameters() {
// should not fail
MavenBuild build = MavenBuild.create(ItUtils.locateProjectPom("maven/maven-bad-parameters"))
.setGoals(cleanSonarGoal());
Expand All @@ -204,7 +204,7 @@ public void testBadMavenParameters() {
}

@Test
public void shouldAnalyzeMultiModules() {
void shouldAnalyzeMultiModules() {
MavenBuild build = MavenBuild.create(ItUtils.locateProjectPom("maven/modules-order"))
.setGoals(cleanSonarGoal());
ORCHESTRATOR.executeBuild(build);
Expand Down Expand Up @@ -232,7 +232,7 @@ public void shouldAnalyzeMultiModules() {
}

@Test
public void shouldEvaluateSourceVersionOnEachModule() {
void shouldEvaluateSourceVersionOnEachModule() {
MavenBuild build = MavenBuild.create(ItUtils.locateProjectPom("maven/modules-source-versions"))
.setGoals(cleanSonarGoal());
BuildResult buildResult = ORCHESTRATOR.executeBuild(build);
Expand All @@ -254,7 +254,7 @@ private String findScanSectionOfModule(String logs, String moduleName) {

// MSONAR-158
@Test
public void shouldAnalyzeMultiModulesAttachedToPhase() {
void shouldAnalyzeMultiModulesAttachedToPhase() {
MavenBuild build = MavenBuild.create(ItUtils.locateProjectPom("maven/attach-sonar-to-verify"))
.setGoals("clean verify")
.setProperty("sonar.maven.it.mojoVersion", mojoVersion().toString());
Expand All @@ -273,7 +273,7 @@ public void shouldAnalyzeMultiModulesAttachedToPhase() {
* See SONAR-2735
*/
@Test
public void shouldSupportDifferentDeclarationsForModules() {
void shouldSupportDifferentDeclarationsForModules() {
MavenBuild build = MavenBuild.create(ItUtils.locateProjectPom("maven/modules-declaration"))
.setGoals(cleanSonarGoal());
ORCHESTRATOR.executeBuild(build);
Expand Down Expand Up @@ -312,7 +312,7 @@ public void shouldSupportDifferentDeclarationsForModules() {
* See SONAR-3843
*/
@Test
public void should_support_shade_with_dependency_reduced_pom_with_clean_install_sonar_goals() {
void should_support_shade_with_dependency_reduced_pom_with_clean_install_sonar_goals() {
MavenBuild build = MavenBuild.create(ItUtils.locateProjectPom("maven/shade-with-dependency-reduced-pom"))
.setGoals(cleanInstallSonarGoal());
BuildResult result = ORCHESTRATOR.executeBuildQuietly(build);
Expand All @@ -325,7 +325,7 @@ public void should_support_shade_with_dependency_reduced_pom_with_clean_install_
* src/main/java is missing
*/
@Test
public void maven_project_with_only_test_dir() {
void maven_project_with_only_test_dir() {
// Need package to have test execution
MavenBuild build = MavenBuild.create(ItUtils.locateProjectPom("maven/maven-only-test-dir")).setGoals(cleanPackageSonarGoal());
ORCHESTRATOR.executeBuild(build);
Expand All @@ -338,7 +338,7 @@ public void maven_project_with_only_test_dir() {
* The property sonar.sources overrides the source dirs as declared in Maven
*/
@Test
public void override_sources() {
void override_sources() {
MavenBuild build = MavenBuild.create(ItUtils.locateProjectPom("maven/maven-override-sources")).setGoals(sonarGoal());
ORCHESTRATOR.executeBuild(build);

Expand All @@ -350,7 +350,7 @@ public void override_sources() {
* The property sonar.sources overrides the source dirs as declared in Maven
*/
@Test
public void override_sources_in_multi_module() {
void override_sources_in_multi_module() {
MavenBuild build = MavenBuild.create(ItUtils.locateProjectPom("maven/multi-modules-override-sources")).setGoals(sonarGoal());
ORCHESTRATOR.executeBuild(build);

Expand All @@ -365,7 +365,7 @@ public void override_sources_in_multi_module() {
* The property sonar.sources overrides the source dirs as declared in Maven
*/
@Test
public void override_sources_in_multi_module_aggregator() {
void override_sources_in_multi_module_aggregator() {
MavenBuild build = MavenBuild.create(ItUtils.locateProjectPom("maven/multi-module-aggregator"))
.setGoals(sonarGoal());
ORCHESTRATOR.executeBuild(build);
Expand All @@ -381,7 +381,7 @@ public void override_sources_in_multi_module_aggregator() {
* The property sonar.inclusions overrides the property sonar.sources
*/
@Test
public void inclusions_apply_to_source_dirs() {
void inclusions_apply_to_source_dirs() {
MavenBuild build = MavenBuild.create(ItUtils.locateProjectPom("maven/inclusions_apply_to_source_dirs")).setGoals(sonarGoal());
ORCHESTRATOR.executeBuild(build);

Expand All @@ -393,7 +393,7 @@ public void inclusions_apply_to_source_dirs() {
* The property sonar.sources has a typo -> fail, like in sonar-runner
*/
@Test
public void fail_if_bad_value_of_sonar_sources_property() {
void fail_if_bad_value_of_sonar_sources_property() {
MavenBuild build = MavenBuild.create(ItUtils.locateProjectPom("maven/maven-bad-sources-property")).setGoals(sonarGoal());
BuildResult result = ORCHESTRATOR.executeBuildQuietly(build);
assertThat(result.getLastStatus()).isNotEqualTo(0);
Expand All @@ -405,7 +405,7 @@ public void fail_if_bad_value_of_sonar_sources_property() {
* The property sonar.sources has a typo -> fail, like in sonar-runner
*/
@Test
public void fail_if_bad_value_of_sonar_tests_property() {
void fail_if_bad_value_of_sonar_tests_property() {
MavenBuild build = MavenBuild.create(ItUtils.locateProjectPom("maven/maven-bad-tests-property")).setGoals(sonarGoal());
BuildResult result = ORCHESTRATOR.executeBuildQuietly(build);
assertThat(result.getLastStatus()).isNotEqualTo(0);
Expand All @@ -415,7 +415,7 @@ public void fail_if_bad_value_of_sonar_tests_property() {

// MSONAR-91
@Test
public void shouldSkipModules() {
void shouldSkipModules() {
MavenBuild build = MavenBuild.create(ItUtils.locateProjectPom("exclusions/skip-one-module"))
.setGoals(cleanSonarGoal());
ORCHESTRATOR.executeBuild(build);
Expand All @@ -433,7 +433,7 @@ public void shouldSkipModules() {

// MSONAR-150
@Test
public void shouldSkipWithEnvVar() {
void shouldSkipWithEnvVar() {
MavenBuild build = MavenBuild.create(ItUtils.locateProjectPom("maven/maven-only-test-dir"))
.setGoals(cleanSonarGoal())
.setProperties("sonar.host.url", "invalid")
Expand All @@ -446,7 +446,7 @@ public void shouldSkipWithEnvVar() {
* MSONAR-141
*/
@Test
public void supportMavenEncryption() throws Exception {
void supportMavenEncryption() throws Exception {
wsClient.settings().set(new SetRequest().setKey("sonar.forceAuthentication").setValue("true"));
wsClient.users().create(new CreateRequest().setLogin("julien").setName("Julien").setPassword("123abc"));

Expand Down
4 changes: 2 additions & 2 deletions its/src/test/java/com/sonar/maven/it/suite/ProxyTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.io.TempDir;

public class ProxyTest extends AbstractMavenTest {
class ProxyTest extends AbstractMavenTest {
private Proxy proxy;
@TempDir
public Path temp;
Expand All @@ -58,7 +58,7 @@ public void after() throws Exception {
}

@Test
public void useActiveProxyInSettings() throws IOException, URISyntaxException, InterruptedException {
void useActiveProxyInSettings() throws IOException, URISyntaxException, InterruptedException {
Thread.sleep(2000);
Path proxyXml = Paths.get(this.getClass().getResource("/proxy-settings.xml").toURI());
Path proxyXmlPatched = temp.resolve("settings.xml");
Expand Down