Skip to content

Commit

Permalink
SONARPY-2431: Enable parallel test execution (#2233)
Browse files Browse the repository at this point in the history
  • Loading branch information
Seppli11 committed Dec 13, 2024
1 parent 3839043 commit 538c939
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 200 deletions.
6 changes: 3 additions & 3 deletions .cirrus.yml
Original file line number Diff line number Diff line change
Expand Up @@ -167,8 +167,8 @@ ruling_task:
<<: *ONLY_SONARSOURCE_QA
eks_container:
<<: *QA_CONTAINER_DEFINITION
cpu: 4
memory: 8G
cpu: 16
memory: 32G
env:
CIRRUS_CLONE_DEPTH: 10
SONARSOURCE_QA: true
Expand All @@ -181,7 +181,7 @@ ruling_task:
- source cirrus-env QA
- source set_maven_build_version $BUILD_NUMBER
- cd its/ruling
- mvn verify -Dsonar.runtimeVersion=LATEST_RELEASE -Dmaven.test.redirectTestOutputToFile=false -B -e -V -Dtest=PythonRulingTest
- mvn verify -Dsonar.runtimeVersion=LATEST_RELEASE -Dmaven.test.redirectTestOutputToFile=false -B -e -V -Dtest=PythonRulingTest -Djunit.jupiter.execution.parallel.config.dynamic.factor=1
cleanup_before_cache_script: cleanup_maven_repository

pr_analysis_qa_task:
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@
package org.sonar.python.it;

import com.sonar.orchestrator.build.SonarScanner;
import com.sonar.orchestrator.version.Version;
import com.sonar.orchestrator.build.SonarScannerInstaller;
import com.sonar.orchestrator.config.Configuration;
import com.sonar.orchestrator.junit5.OrchestratorExtension;
import com.sonar.orchestrator.locator.FileLocation;
import java.io.File;
Expand All @@ -26,17 +29,21 @@
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;
import org.junit.jupiter.api.parallel.Execution;
import org.junit.jupiter.api.parallel.ExecutionMode;
import org.sonarsource.analyzer.commons.ProfileGenerator;

import static java.nio.charset.StandardCharsets.UTF_8;
import static org.assertj.core.api.Assertions.assertThat;
import static org.sonar.python.it.RulingHelper.getOrchestrator;

// Ruling test for bug rules, to ensure they are properly tested without slowing down the CI
@Execution(ExecutionMode.CONCURRENT)
class PythonRulingTest {


@RegisterExtension
public static final OrchestratorExtension ORCHESTRATOR = getOrchestrator();
public static final Configuration CONFIGURATION = ORCHESTRATOR.getConfiguration();

private static final String PROFILE_NAME = "rules";

Expand All @@ -52,6 +59,11 @@ static void prepare_quality_profile() {
ORCHESTRATOR.getServer().restoreProfile(FileLocation.of(iPythonProfileFile));
}

@BeforeAll
static void install_sonar_scanner() {
new SonarScannerInstaller(CONFIGURATION.locators()).install(Version.create(SonarScanner.DEFAULT_SCANNER_VERSION), CONFIGURATION.fileSystem().workspace());
}

@Test
void test_airflow() throws IOException {
SonarScanner build = buildWithCommonProperties("airflow");
Expand Down
3 changes: 3 additions & 0 deletions its/ruling/src/test/resources/junit-platform.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
junit.jupiter.execution.parallel.enabled = true
junit.jupiter.execution.parallel.config.strategy=dynamic
junit.jupiter.execution.parallel.config.dynamic.factor=0.5

0 comments on commit 538c939

Please sign in to comment.