Skip to content

Commit b637acd

Browse files
authored
MSONAR-212 Fix performance regression in our ITs with [LATEST_RELEASE] & [DEV] versions of SQ (#204)
1 parent 4b86947 commit b637acd

File tree

4 files changed

+46
-42
lines changed

4 files changed

+46
-42
lines changed

its/src/test/java/com/sonar/maven/it/suite/AbstractMavenTest.java

+8-4
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
import com.sonar.orchestrator.http.HttpResponse;
2929
import com.sonar.orchestrator.junit5.OrchestratorExtension;
3030
import com.sonar.orchestrator.version.Version;
31+
3132
import java.io.IOException;
3233
import java.nio.charset.StandardCharsets;
3334
import java.nio.file.Files;
@@ -38,6 +39,7 @@
3839
import java.util.regex.Pattern;
3940
import java.util.stream.Collectors;
4041
import javax.annotation.CheckForNull;
42+
4143
import org.apache.commons.lang.StringUtils;
4244
import org.junit.jupiter.api.AfterEach;
4345
import org.junit.jupiter.api.BeforeEach;
@@ -63,10 +65,12 @@ public abstract class AbstractMavenTest {
6365

6466
@RegisterExtension
6567
public static final OrchestratorExtension ORCHESTRATOR = OrchestratorExtension.builderEnv()
66-
.setSonarVersion(getSonarVersion())
67-
.useDefaultAdminCredentialsForBuilds(true)
68-
.keepBundledPlugins()
69-
.build();
68+
.setSonarVersion(getSonarVersion())
69+
.useDefaultAdminCredentialsForBuilds(true)
70+
.addBundledPluginToKeep("sonar-java-plugin")
71+
.addBundledPluginToKeep("sonar-xml-plugin")
72+
.addBundledPluginToKeep("sonar-html-plugin")
73+
.build();
7074

7175
protected HttpConnector wsConnector;
7276
protected WsClient wsClient;

its/src/test/java/com/sonar/maven/it/suite/JavaTest.java

+9-9
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
import static org.assertj.core.data.MapEntry.entry;
3939
import static org.junit.jupiter.api.Assumptions.assumeTrue;
4040

41-
public class JavaTest extends AbstractMavenTest {
41+
class JavaTest extends AbstractMavenTest {
4242

4343
@TempDir
4444
public Path temp;
@@ -50,7 +50,7 @@ public void cleanup() {
5050

5151
// MSONAR-83
5252
@Test
53-
public void shouldPopulateLibraries() throws IOException {
53+
void shouldPopulateLibraries() throws IOException {
5454
File outputProps = temp.resolve("out.properties").toFile();
5555
outputProps.createNewFile();
5656

@@ -75,7 +75,7 @@ public void shouldPopulateLibraries() throws IOException {
7575
}
7676

7777
@Test
78-
public void read_default_from_plugins_config() throws Exception {
78+
void read_default_from_plugins_config() throws Exception {
7979
File outputProps = temp.resolve("out.properties").toFile();
8080
outputProps.createNewFile();
8181

@@ -96,7 +96,7 @@ public void read_default_from_plugins_config() throws Exception {
9696
}
9797

9898
@Test
99-
public void setJavaVersionCompilerConfiguration() throws IOException {
99+
void setJavaVersionCompilerConfiguration() throws IOException {
100100
File outputProps = temp.resolve("out.properties").toFile();
101101
outputProps.createNewFile();
102102

@@ -113,7 +113,7 @@ public void setJavaVersionCompilerConfiguration() throws IOException {
113113
}
114114

115115
@Test
116-
public void setJavaVersionProperties() throws IOException {
116+
void setJavaVersionProperties() throws IOException {
117117
File outputProps = temp.resolve("out.properties").toFile();
118118
outputProps.createNewFile();
119119

@@ -130,7 +130,7 @@ public void setJavaVersionProperties() throws IOException {
130130
}
131131

132132
@Test
133-
public void setJdkHomeFromCompilerExecutableConfiguration() throws IOException {
133+
void setJdkHomeFromCompilerExecutableConfiguration() throws IOException {
134134
File outputProps = temp.resolve("out.properties").toFile();
135135
outputProps.createNewFile();
136136

@@ -145,7 +145,7 @@ public void setJdkHomeFromCompilerExecutableConfiguration() throws IOException {
145145
}
146146

147147
@Test
148-
public void setJdkHomeFromGlobalToolchainsPlugin() throws IOException {
148+
void setJdkHomeFromGlobalToolchainsPlugin() throws IOException {
149149
File outputProps = temp.resolve("out.properties").toFile();
150150
outputProps.createNewFile();
151151

@@ -163,7 +163,7 @@ public void setJdkHomeFromGlobalToolchainsPlugin() throws IOException {
163163
}
164164

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

@@ -183,7 +183,7 @@ public void setJdkHomeFromCompilerToolchainsConfiguration() throws IOException {
183183
}
184184

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

its/src/test/java/com/sonar/maven/it/suite/MavenTest.java

+27-27
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838

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

41-
public class MavenTest extends AbstractMavenTest {
41+
class MavenTest extends AbstractMavenTest {
4242

4343
private static final String MODULE_START_7_6 = "------------- Run sensors on module ";
4444
private static final String MODULE_START = "------------- Scan ";
@@ -55,7 +55,7 @@ public void cleanup() {
5555
* See MSONAR-129
5656
*/
5757
@Test
58-
public void useUserPropertiesGlobalConfig() throws Exception {
58+
void useUserPropertiesGlobalConfig() throws Exception {
5959
BuildRunner runner = new BuildRunner(ORCHESTRATOR.getConfiguration());
6060
MavenBuild build = MavenBuild.create(ItUtils.locateProjectPom("maven/maven-only-test-dir"))
6161
.setGoals(cleanSonarGoal());
@@ -79,7 +79,7 @@ public void useUserPropertiesGlobalConfig() throws Exception {
7979
* See MSONAR-129
8080
*/
8181
@Test
82-
public void supportSonarHostURLParam() {
82+
void supportSonarHostURLParam() {
8383
BuildRunner runner = new BuildRunner(ORCHESTRATOR.getConfiguration());
8484
MavenBuild build = MavenBuild.create(ItUtils.locateProjectPom("maven/maven-global-properties"))
8585
// global property should take precedence
@@ -96,7 +96,7 @@ public void supportSonarHostURLParam() {
9696
* See MSONAR-172
9797
*/
9898
@Test
99-
public void supportSonarHostURLParamFromEnvironmentVariable() {
99+
void supportSonarHostURLParamFromEnvironmentVariable() {
100100
BuildRunner runner = new BuildRunner(ORCHESTRATOR.getConfiguration());
101101
MavenBuild build = MavenBuild.create(ItUtils.locateProjectPom("maven/maven-only-test-dir"))
102102
.setEnvironmentVariable("SONAR_HOST_URL", "http://from-env.org:9000")
@@ -112,7 +112,7 @@ public void supportSonarHostURLParamFromEnvironmentVariable() {
112112
* See MSONAR-130
113113
*/
114114
@Test
115-
public void structureWithRelativePaths() {
115+
void structureWithRelativePaths() {
116116
MavenBuild build = MavenBuild.create(ItUtils.locateProjectPom("maven/maven-structure-relative-paths"))
117117
.setGoals(cleanSonarGoal());
118118
ORCHESTRATOR.executeBuild(build);
@@ -122,22 +122,22 @@ public void structureWithRelativePaths() {
122122
* See MSONAR-164
123123
*/
124124
@Test
125-
public void flatStructure() {
125+
void flatStructure() {
126126
MavenBuild build = MavenBuild.create(ItUtils.locateProjectPom("maven/maven-flat-layout/parent"))
127127
.setGoals(cleanSonarGoal());
128128
ORCHESTRATOR.executeBuild(build);
129129
}
130130

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

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

148148
@Test
149-
public void shouldSupportJarWithoutSources() {
149+
void shouldSupportJarWithoutSources() {
150150
MavenBuild build = MavenBuild.create(ItUtils.locateProjectPom("maven/project-with-module-without-sources"))
151151
.setGoals(cleanSonarGoal());
152152
ORCHESTRATOR.executeBuild(build);
@@ -163,7 +163,7 @@ public void shouldSupportJarWithoutSources() {
163163
* See SONAR-594
164164
*/
165165
@Test
166-
public void shouldSupportJeeProjects() {
166+
void shouldSupportJeeProjects() {
167167
MavenBuild build = MavenBuild.create(ItUtils.locateProjectPom("maven/jee"))
168168
.setGoals(cleanInstallSonarGoal());
169169
ORCHESTRATOR.executeBuild(build);
@@ -182,7 +182,7 @@ public void shouldSupportJeeProjects() {
182182
* See SONAR-222
183183
*/
184184
@Test
185-
public void shouldSupportMavenExtensions() {
185+
void shouldSupportMavenExtensions() {
186186
MavenBuild build = MavenBuild.create(ItUtils.locateProjectPom("maven/maven-extensions"))
187187
.setGoals(cleanSonarGoal());
188188
ORCHESTRATOR.executeBuild(build);
@@ -194,7 +194,7 @@ public void shouldSupportMavenExtensions() {
194194
* This test should be splitted. It checks multiple use-cases at the same time : SONAR-518, SONAR-519 and SONAR-593
195195
*/
196196
@Test
197-
public void testBadMavenParameters() {
197+
void testBadMavenParameters() {
198198
// should not fail
199199
MavenBuild build = MavenBuild.create(ItUtils.locateProjectPom("maven/maven-bad-parameters"))
200200
.setGoals(cleanSonarGoal());
@@ -204,7 +204,7 @@ public void testBadMavenParameters() {
204204
}
205205

206206
@Test
207-
public void shouldAnalyzeMultiModules() {
207+
void shouldAnalyzeMultiModules() {
208208
MavenBuild build = MavenBuild.create(ItUtils.locateProjectPom("maven/modules-order"))
209209
.setGoals(cleanSonarGoal());
210210
ORCHESTRATOR.executeBuild(build);
@@ -232,7 +232,7 @@ public void shouldAnalyzeMultiModules() {
232232
}
233233

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

255255
// MSONAR-158
256256
@Test
257-
public void shouldAnalyzeMultiModulesAttachedToPhase() {
257+
void shouldAnalyzeMultiModulesAttachedToPhase() {
258258
MavenBuild build = MavenBuild.create(ItUtils.locateProjectPom("maven/attach-sonar-to-verify"))
259259
.setGoals("clean verify")
260260
.setProperty("sonar.maven.it.mojoVersion", mojoVersion().toString());
@@ -273,7 +273,7 @@ public void shouldAnalyzeMultiModulesAttachedToPhase() {
273273
* See SONAR-2735
274274
*/
275275
@Test
276-
public void shouldSupportDifferentDeclarationsForModules() {
276+
void shouldSupportDifferentDeclarationsForModules() {
277277
MavenBuild build = MavenBuild.create(ItUtils.locateProjectPom("maven/modules-declaration"))
278278
.setGoals(cleanSonarGoal());
279279
ORCHESTRATOR.executeBuild(build);
@@ -312,7 +312,7 @@ public void shouldSupportDifferentDeclarationsForModules() {
312312
* See SONAR-3843
313313
*/
314314
@Test
315-
public void should_support_shade_with_dependency_reduced_pom_with_clean_install_sonar_goals() {
315+
void should_support_shade_with_dependency_reduced_pom_with_clean_install_sonar_goals() {
316316
MavenBuild build = MavenBuild.create(ItUtils.locateProjectPom("maven/shade-with-dependency-reduced-pom"))
317317
.setGoals(cleanInstallSonarGoal());
318318
BuildResult result = ORCHESTRATOR.executeBuildQuietly(build);
@@ -325,7 +325,7 @@ public void should_support_shade_with_dependency_reduced_pom_with_clean_install_
325325
* src/main/java is missing
326326
*/
327327
@Test
328-
public void maven_project_with_only_test_dir() {
328+
void maven_project_with_only_test_dir() {
329329
// Need package to have test execution
330330
MavenBuild build = MavenBuild.create(ItUtils.locateProjectPom("maven/maven-only-test-dir")).setGoals(cleanPackageSonarGoal());
331331
ORCHESTRATOR.executeBuild(build);
@@ -338,7 +338,7 @@ public void maven_project_with_only_test_dir() {
338338
* The property sonar.sources overrides the source dirs as declared in Maven
339339
*/
340340
@Test
341-
public void override_sources() {
341+
void override_sources() {
342342
MavenBuild build = MavenBuild.create(ItUtils.locateProjectPom("maven/maven-override-sources")).setGoals(sonarGoal());
343343
ORCHESTRATOR.executeBuild(build);
344344

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

@@ -365,7 +365,7 @@ public void override_sources_in_multi_module() {
365365
* The property sonar.sources overrides the source dirs as declared in Maven
366366
*/
367367
@Test
368-
public void override_sources_in_multi_module_aggregator() {
368+
void override_sources_in_multi_module_aggregator() {
369369
MavenBuild build = MavenBuild.create(ItUtils.locateProjectPom("maven/multi-module-aggregator"))
370370
.setGoals(sonarGoal());
371371
ORCHESTRATOR.executeBuild(build);
@@ -381,7 +381,7 @@ public void override_sources_in_multi_module_aggregator() {
381381
* The property sonar.inclusions overrides the property sonar.sources
382382
*/
383383
@Test
384-
public void inclusions_apply_to_source_dirs() {
384+
void inclusions_apply_to_source_dirs() {
385385
MavenBuild build = MavenBuild.create(ItUtils.locateProjectPom("maven/inclusions_apply_to_source_dirs")).setGoals(sonarGoal());
386386
ORCHESTRATOR.executeBuild(build);
387387

@@ -393,7 +393,7 @@ public void inclusions_apply_to_source_dirs() {
393393
* The property sonar.sources has a typo -> fail, like in sonar-runner
394394
*/
395395
@Test
396-
public void fail_if_bad_value_of_sonar_sources_property() {
396+
void fail_if_bad_value_of_sonar_sources_property() {
397397
MavenBuild build = MavenBuild.create(ItUtils.locateProjectPom("maven/maven-bad-sources-property")).setGoals(sonarGoal());
398398
BuildResult result = ORCHESTRATOR.executeBuildQuietly(build);
399399
assertThat(result.getLastStatus()).isNotEqualTo(0);
@@ -405,7 +405,7 @@ public void fail_if_bad_value_of_sonar_sources_property() {
405405
* The property sonar.sources has a typo -> fail, like in sonar-runner
406406
*/
407407
@Test
408-
public void fail_if_bad_value_of_sonar_tests_property() {
408+
void fail_if_bad_value_of_sonar_tests_property() {
409409
MavenBuild build = MavenBuild.create(ItUtils.locateProjectPom("maven/maven-bad-tests-property")).setGoals(sonarGoal());
410410
BuildResult result = ORCHESTRATOR.executeBuildQuietly(build);
411411
assertThat(result.getLastStatus()).isNotEqualTo(0);
@@ -415,7 +415,7 @@ public void fail_if_bad_value_of_sonar_tests_property() {
415415

416416
// MSONAR-91
417417
@Test
418-
public void shouldSkipModules() {
418+
void shouldSkipModules() {
419419
MavenBuild build = MavenBuild.create(ItUtils.locateProjectPom("exclusions/skip-one-module"))
420420
.setGoals(cleanSonarGoal());
421421
ORCHESTRATOR.executeBuild(build);
@@ -433,7 +433,7 @@ public void shouldSkipModules() {
433433

434434
// MSONAR-150
435435
@Test
436-
public void shouldSkipWithEnvVar() {
436+
void shouldSkipWithEnvVar() {
437437
MavenBuild build = MavenBuild.create(ItUtils.locateProjectPom("maven/maven-only-test-dir"))
438438
.setGoals(cleanSonarGoal())
439439
.setProperties("sonar.host.url", "invalid")
@@ -446,7 +446,7 @@ public void shouldSkipWithEnvVar() {
446446
* MSONAR-141
447447
*/
448448
@Test
449-
public void supportMavenEncryption() throws Exception {
449+
void supportMavenEncryption() throws Exception {
450450
wsClient.settings().set(new SetRequest().setKey("sonar.forceAuthentication").setValue("true"));
451451
wsClient.users().create(new CreateRequest().setLogin("julien").setName("Julien").setPassword("123abc"));
452452

its/src/test/java/com/sonar/maven/it/suite/ProxyTest.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
import org.junit.jupiter.api.Test;
4040
import org.junit.jupiter.api.io.TempDir;
4141

42-
public class ProxyTest extends AbstractMavenTest {
42+
class ProxyTest extends AbstractMavenTest {
4343
private Proxy proxy;
4444
@TempDir
4545
public Path temp;
@@ -58,7 +58,7 @@ public void after() throws Exception {
5858
}
5959

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

0 commit comments

Comments
 (0)