Skip to content

Commit

Permalink
parallelize the tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Seppli11 committed Dec 13, 2024
1 parent 4fba005 commit 4679dc7
Show file tree
Hide file tree
Showing 16 changed files with 19 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
package com.sonar.python.it.plugin;

import com.sonar.orchestrator.build.SonarScanner;
import com.sonar.orchestrator.junit5.OrchestratorExtension;
import java.io.File;
import java.util.List;
import org.junit.jupiter.api.Test;
Expand All @@ -33,7 +32,7 @@ class BanditReportTest {
private static final String PROJECT = "bandit_project";

@RegisterExtension
public static final OrchestratorExtension ORCHESTRATOR = TestsUtils.ORCHESTRATOR;
public static final ConcurrentOrchestratorExtension ORCHESTRATOR = TestsUtils.ORCHESTRATOR;

@Test
void import_report() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
package com.sonar.python.it.plugin;

import com.sonar.orchestrator.build.SonarScanner;
import com.sonar.orchestrator.junit5.OrchestratorExtension;
import java.io.File;
import org.assertj.core.data.Offset;
import org.junit.jupiter.api.BeforeAll;
Expand All @@ -41,7 +40,7 @@ class CPDTest {
private static final String DUPLICATED_LINES_DENSITY = "duplicated_lines_density";

@RegisterExtension
public static final OrchestratorExtension ORCHESTRATOR = TestsUtils.ORCHESTRATOR;
public static final ConcurrentOrchestratorExtension ORCHESTRATOR = TestsUtils.ORCHESTRATOR;

@BeforeAll
static void startServer() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
import com.google.common.collect.ImmutableMap.Builder;
import com.sonar.orchestrator.build.BuildResult;
import com.sonar.orchestrator.build.SonarScanner;
import com.sonar.orchestrator.junit5.OrchestratorExtension;
import java.io.File;
import java.util.HashMap;
import java.util.Map;
Expand All @@ -33,7 +32,7 @@ class CoverageTest {

private static final String COVERAGE_PROJECT = "projects/coverage_project";
@RegisterExtension
public static final OrchestratorExtension ORCHESTRATOR = TestsUtils.ORCHESTRATOR;
public static final ConcurrentOrchestratorExtension ORCHESTRATOR = TestsUtils.ORCHESTRATOR;

private static final String PROJECT_KEY = "coverage_project";
private static final String LINES_TO_COVER = "lines_to_cover";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
package com.sonar.python.it.plugin;

import com.sonar.orchestrator.build.SonarScanner;
import com.sonar.orchestrator.junit5.OrchestratorExtension;
import java.io.File;
import java.util.List;
import org.junit.jupiter.api.BeforeAll;
Expand All @@ -33,7 +32,7 @@
class CustomRulesExampleTest {

@RegisterExtension
public static final OrchestratorExtension orchestrator = TestsUtils.ORCHESTRATOR;
public static final ConcurrentOrchestratorExtension orchestrator = TestsUtils.ORCHESTRATOR;

private static final String PROJECT_KEY = "custom-rules";
private static final String PROJECT_NAME = "Custom Rules";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
package com.sonar.python.it.plugin;

import com.sonar.orchestrator.build.SonarScanner;
import com.sonar.orchestrator.junit5.OrchestratorExtension;
import java.io.File;
import java.util.List;
import org.junit.jupiter.api.BeforeAll;
Expand All @@ -33,7 +32,7 @@
class CustomRulesTest {

@RegisterExtension
public static final OrchestratorExtension orchestrator = TestsUtils.ORCHESTRATOR;
public static final ConcurrentOrchestratorExtension orchestrator = TestsUtils.ORCHESTRATOR;

private static final String PROJECT_KEY = "custom-rules";
private static final String PROJECT_NAME = "Custom Rules";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
package com.sonar.python.it.plugin;

import com.sonar.orchestrator.build.SonarScanner;
import com.sonar.orchestrator.junit5.OrchestratorExtension;
import java.io.File;
import java.util.List;
import org.junit.jupiter.api.Test;
Expand All @@ -33,7 +32,7 @@ class Flake8ReportTest {
private static final String PROJECT = "flake8_project";

@RegisterExtension
public static final OrchestratorExtension ORCHESTRATOR = TestsUtils.ORCHESTRATOR;
public static final ConcurrentOrchestratorExtension ORCHESTRATOR = TestsUtils.ORCHESTRATOR;

@Test
void import_report() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@

import com.sonar.orchestrator.build.BuildResult;
import com.sonar.orchestrator.build.SonarScanner;
import com.sonar.orchestrator.junit5.OrchestratorExtension;
import java.io.File;
import org.assertj.core.data.Offset;
import org.junit.jupiter.api.BeforeAll;
Expand Down Expand Up @@ -56,7 +55,7 @@ class MetricsTest {
private static final Offset<Double> OFFSET = Offset.offset(0.01d);

@RegisterExtension
public static final OrchestratorExtension orchestrator = TestsUtils.ORCHESTRATOR;
public static final ConcurrentOrchestratorExtension orchestrator = TestsUtils.ORCHESTRATOR;

private static BuildResult buildResult;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
package com.sonar.python.it.plugin;

import com.sonar.orchestrator.build.SonarScanner;
import com.sonar.orchestrator.junit5.OrchestratorExtension;
import java.io.File;
import java.util.List;
import org.junit.jupiter.api.Test;
Expand All @@ -33,7 +32,7 @@ class MypyReportTest {
private static final String PROJECT = "mypy_project";

@RegisterExtension
public static final OrchestratorExtension ORCHESTRATOR = TestsUtils.ORCHESTRATOR;
public static final ConcurrentOrchestratorExtension ORCHESTRATOR = TestsUtils.ORCHESTRATOR;

@Test
void import_report() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
package com.sonar.python.it.plugin;

import com.sonar.orchestrator.build.SonarScanner;
import com.sonar.orchestrator.junit5.OrchestratorExtension;
import java.io.File;
import java.util.List;
import org.junit.jupiter.api.BeforeAll;
Expand All @@ -34,7 +33,7 @@ class NoSonarTest {
private static final String PROFILE_NAME = "nosonar";

@RegisterExtension
public static final OrchestratorExtension ORCHESTRATOR = TestsUtils.ORCHESTRATOR;
public static final ConcurrentOrchestratorExtension ORCHESTRATOR = TestsUtils.ORCHESTRATOR;

@BeforeAll
static void startServer() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
package com.sonar.python.it.plugin;

import com.sonar.orchestrator.build.SonarScanner;
import com.sonar.orchestrator.junit5.OrchestratorExtension;
import java.io.File;
import java.util.List;
import org.junit.jupiter.api.BeforeAll;
Expand All @@ -33,7 +32,7 @@ class NotebookPluginTest {
private static final String PROJECT_KEY = "ipynb_json_project";

@RegisterExtension
public static final OrchestratorExtension ORCHESTRATOR = TestsUtils.ORCHESTRATOR;
public static final ConcurrentOrchestratorExtension ORCHESTRATOR = TestsUtils.ORCHESTRATOR;

@BeforeAll
static void startServer() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@

import com.sonar.orchestrator.build.BuildResult;
import com.sonar.orchestrator.build.SonarScanner;
import com.sonar.orchestrator.junit5.OrchestratorExtension;
import java.io.File;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;
Expand All @@ -32,7 +31,7 @@ class PylintReportTest {
private static final String LEGACY_PROPERTY = "sonar.python.pylint.reportPath";

@RegisterExtension
public static final OrchestratorExtension ORCHESTRATOR = TestsUtils.ORCHESTRATOR;
public static final ConcurrentOrchestratorExtension ORCHESTRATOR = TestsUtils.ORCHESTRATOR;

@Test
void import_report() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
*/
package com.sonar.python.it.plugin;

import com.sonar.orchestrator.Orchestrator;
import com.sonar.orchestrator.build.SonarScanner;
import java.io.File;
import java.util.Comparator;
Expand All @@ -34,7 +33,7 @@ class RuffReportTest {
private final String PROJECT = "ruff_project";

@RegisterExtension
public static final Orchestrator ORCHESTRATOR = TestsUtils.ORCHESTRATOR;
public static final ConcurrentOrchestratorExtension ORCHESTRATOR = TestsUtils.ORCHESTRATOR;

@Test
void import_report() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
import com.google.common.collect.Maps;
import com.sonar.orchestrator.build.BuildResult;
import com.sonar.orchestrator.build.SonarScanner;
import com.sonar.orchestrator.junit5.OrchestratorExtension;
import java.io.File;
import java.util.HashMap;
import java.util.Map;
Expand All @@ -42,7 +41,7 @@ class TestReportTest {
public static final String TEST_EXECUTION_TIME = "test_execution_time";

@RegisterExtension
public static final OrchestratorExtension ORCHESTRATOR = TestsUtils.ORCHESTRATOR;
public static final ConcurrentOrchestratorExtension ORCHESTRATOR = TestsUtils.ORCHESTRATOR;

private static SonarScanner createBuild(String projectKey, String testReportPath) {
return SonarScanner.create()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
package com.sonar.python.it.plugin;

import com.sonar.orchestrator.build.SonarScanner;
import com.sonar.orchestrator.junit5.OrchestratorExtension;
import java.io.File;
import java.util.List;
import org.junit.jupiter.api.BeforeAll;
Expand All @@ -33,7 +32,7 @@
class TestRulesTest {

@RegisterExtension
public static final OrchestratorExtension orchestrator = TestsUtils.ORCHESTRATOR;
public static final ConcurrentOrchestratorExtension orchestrator = TestsUtils.ORCHESTRATOR;
private static final String PROJECT_KEY = "test-rules";
private static final String PROJECT_NAME = "Test Rules";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
*/
package com.sonar.python.it.plugin;

import com.sonar.orchestrator.junit5.OrchestratorExtension;
import com.sonar.orchestrator.locator.FileLocation;
import java.io.File;
import java.util.ArrayList;
Expand Down Expand Up @@ -46,7 +45,7 @@ public final class TestsUtils {

public static final FileLocation PLUGIN_LOCATION = FileLocation.byWildcardMavenFilename(new File("../../../sonar-python-plugin/target"), "sonar-python-plugin-*.jar");

public static final OrchestratorExtension ORCHESTRATOR = OrchestratorExtension.builderEnv()
public static final ConcurrentOrchestratorExtension ORCHESTRATOR = ConcurrentOrchestratorExtension.builderEnv()
.useDefaultAdminCredentialsForBuilds(true)
.setSonarVersion(System.getProperty(SQ_VERSION_PROPERTY, DEFAULT_SQ_VERSION))
.addPlugin(PLUGIN_LOCATION)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
junit.jupiter.execution.parallel.enabled = true
junit.jupiter.execution.parallel.mode.classes.default = concurrent
junit.jupiter.execution.parallel.config.strategy=dynamic
junit.jupiter.execution.parallel.config.dynamic.factor=0.5

0 comments on commit 4679dc7

Please sign in to comment.