Skip to content
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
22 changes: 11 additions & 11 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -592,8 +592,8 @@ jobs:
- name: Run Plugin QA
run: |
mvn package -f its/plugin/plugins/consumer-plugin/pom.xml
mvn -f its/plugin/sonarlint-tests/pom.xml -DskipTests=false -Dsonar.runtimeVersion=LATEST_RELEASE -B -e -V verify surefire-report:report
mvn "-Dorchestrator.configUrl=$ORCHESTRATOR_CONFIG_URL" "-Dorchestrator.home=$ORCHESTRATOR_HOME" -f its/plugin/tests/pom.xml -DskipTests=false -Dsonar.runtimeVersion=LATEST_RELEASE -B -e -V verify surefire-report:report
mvn -f its/plugin/sonarlint-tests/pom.xml -DskipTests=false -B -e -V verify surefire-report:report
mvn "-Dorchestrator.configUrl=$ORCHESTRATOR_CONFIG_URL" "-Dorchestrator.home=$ORCHESTRATOR_HOME" -f its/plugin/tests/pom.xml -DskipTests=false -B -e -V verify surefire-report:report
env:
SONARSOURCE_QA: true
GITHUB_TOKEN: ${{ fromJSON(steps.secrets.outputs.vault).licenses_token }}
Expand Down Expand Up @@ -621,7 +621,7 @@ jobs:
- name: Run Fast Plugin QA
run: |
mvn package -f its/plugin/plugins/pom.xml
mvn "-Dorchestrator.configUrl=$ORCHESTRATOR_CONFIG_URL" "-Dorchestrator.home=$ORCHESTRATOR_HOME" -f its/plugin/fast-tests/pom.xml -DskipTests=false -Dsonar.runtimeVersion=LATEST_RELEASE -B -e -V verify surefire-report:report
mvn "-Dorchestrator.configUrl=$ORCHESTRATOR_CONFIG_URL" "-Dorchestrator.home=$ORCHESTRATOR_HOME" -f its/plugin/fast-tests/pom.xml -DskipTests=false -B -e -V verify surefire-report:report
env:
SONARSOURCE_QA: true
GITHUB_TOKEN: ${{ fromJSON(steps.secrets.outputs.vault).licenses_token }}
Expand Down Expand Up @@ -660,8 +660,8 @@ jobs:
- name: Run Plugin QA without Node
run: |
mvn package -f its/plugin/plugins/consumer-plugin/pom.xml
mvn -f its/plugin/sonarlint-tests/pom.xml -DskipTests=false -Dsonar.runtimeVersion=LATEST_RELEASE -B -e -V verify surefire-report:report
mvn "-Dorchestrator.configUrl=$ORCHESTRATOR_CONFIG_URL" "-Dorchestrator.home=$ORCHESTRATOR_HOME" -f its/plugin/tests/pom.xml -DskipTests=false -Dsonar.runtimeVersion=LATEST_RELEASE -B -e -V verify surefire-report:report
mvn -f its/plugin/sonarlint-tests/pom.xml -DskipTests=false -B -e -V verify surefire-report:report
mvn "-Dorchestrator.configUrl=$ORCHESTRATOR_CONFIG_URL" "-Dorchestrator.home=$ORCHESTRATOR_HOME" -f its/plugin/tests/pom.xml -DskipTests=false -B -e -V verify surefire-report:report
env:
SONARSOURCE_QA: true
SONARJS_ARTIFACT: multi
Expand Down Expand Up @@ -728,7 +728,7 @@ jobs:
- name: Run Fast Plugin QA without Node
run: |
mvn package -f its/plugin/plugins/pom.xml --projects !org.sonarsource.javascript:eslint-custom-rules-plugin,!org.sonarsource.javascript:eslint-custom-rules-plugin-legacy
mvn "-Dorchestrator.configUrl=$ORCHESTRATOR_CONFIG_URL" "-Dorchestrator.home=$ORCHESTRATOR_HOME" -f its/plugin/fast-tests/pom.xml -DskipTests=false -Dsonar.runtimeVersion=${{ matrix.sq-version }} -Dtest=!EslintCustomRulesTest,!EslintCustomRulesLegacyTest -B -e -V verify surefire-report:report
mvn "-Dorchestrator.configUrl=$ORCHESTRATOR_CONFIG_URL" "-Dorchestrator.home=$ORCHESTRATOR_HOME" -f its/plugin/fast-tests/pom.xml -DskipTests=false -Dtest=!EslintCustomRulesTest,!EslintCustomRulesLegacyTest -B -e -V verify surefire-report:report
env:
SONARSOURCE_QA: true
SONARJS_ARTIFACT: ${{ matrix.artifact }}
Expand Down Expand Up @@ -800,7 +800,7 @@ jobs:
fi

mvn package -f its/plugin/plugins/consumer-plugin/pom.xml
mvn "-Dorchestrator.configUrl=$ORCHESTRATOR_CONFIG_URL" "-Dorchestrator.home=$ORCHESTRATOR_HOME" -f its/plugin/tests/pom.xml -DskipTests=false -Dtest="$TEST_PATTERN" -Dsonar.runtimeVersion=LATEST_RELEASE -B -e -V verify surefire-report:report
mvn "-Dorchestrator.configUrl=$ORCHESTRATOR_CONFIG_URL" "-Dorchestrator.home=$ORCHESTRATOR_HOME" -f its/plugin/tests/pom.xml -DskipTests=false -Dtest="$TEST_PATTERN" -B -e -V verify surefire-report:report
env:
SONARSOURCE_QA: true
GITHUB_TOKEN: ${{ fromJSON(steps.secrets.outputs.vault).licenses_token }}
Expand All @@ -821,7 +821,7 @@ jobs:
- name: Run Plugin QA on Windows
shell: bash
run: |
mvn -f its/plugin/sonarlint-tests/pom.xml -DskipTests=false -Dsonar.runtimeVersion=LATEST_RELEASE -B -e -V verify surefire-report:report
mvn -f its/plugin/sonarlint-tests/pom.xml -DskipTests=false -B -e -V verify surefire-report:report
env:
SONARSOURCE_QA: true

Expand Down Expand Up @@ -864,7 +864,7 @@ jobs:
fi

mvn package -f its/plugin/plugins/pom.xml
mvn "-Dorchestrator.configUrl=$ORCHESTRATOR_CONFIG_URL" "-Dorchestrator.home=$ORCHESTRATOR_HOME" -f its/plugin/fast-tests/pom.xml -DskipTests=false -Dtest="$TEST_PATTERN" -Dsonar.runtimeVersion=LATEST_RELEASE -B -e -V verify surefire-report:report
mvn "-Dorchestrator.configUrl=$ORCHESTRATOR_CONFIG_URL" "-Dorchestrator.home=$ORCHESTRATOR_HOME" -f its/plugin/fast-tests/pom.xml -DskipTests=false -Dtest="$TEST_PATTERN" -B -e -V verify surefire-report:report
env:
SONARSOURCE_QA: true
GITHUB_TOKEN: ${{ fromJSON(steps.secrets.outputs.vault).licenses_token }}
Expand Down Expand Up @@ -910,7 +910,7 @@ jobs:
- name: Run Ruling Tests
run: |
cd its/ruling
mvn "-Dorchestrator.configUrl=$ORCHESTRATOR_CONFIG_URL" "-Dorchestrator.home=$ORCHESTRATOR_HOME" test -Dtest=JsTsRulingTest -DskipTests=false -Dsonar.runtimeVersion=LATEST_RELEASE -Dmaven.test.redirectTestOutputToFile=false -B -e -V
mvn "-Dorchestrator.configUrl=$ORCHESTRATOR_CONFIG_URL" "-Dorchestrator.home=$ORCHESTRATOR_HOME" test -Dtest=JsTsRulingTest -DskipTests=false -Dmaven.test.redirectTestOutputToFile=false -B -e -V
env:
SONARSOURCE_QA: true
# Match master: cap analyses independently of the container host CPU count.
Expand Down Expand Up @@ -946,7 +946,7 @@ jobs:
- name: Run CSS Ruling
run: |
cd its/ruling
mvn "-Dorchestrator.configUrl=$ORCHESTRATOR_CONFIG_URL" "-Dorchestrator.home=$ORCHESTRATOR_HOME" test -DskipTests=false -Dtest=CssRulingTest -Dsonar.runtimeVersion=LATEST_RELEASE -Dmaven.test.redirectTestOutputToFile=false -B -e -V
mvn "-Dorchestrator.configUrl=$ORCHESTRATOR_CONFIG_URL" "-Dorchestrator.home=$ORCHESTRATOR_HOME" test -DskipTests=false -Dtest=CssRulingTest -Dmaven.test.redirectTestOutputToFile=false -B -e -V
env:
SONARSOURCE_QA: true
MAVEN_ARGS: *ruling_maven_args
Expand Down
6 changes: 6 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ on:
description: Flag to enable the dry-run execution
default: false
required: false
skipJavascriptReleasabilityChecks:
type: boolean
description: Skip all releasability checks, including Quality Gate and Jira
default: false
required: false

jobs:
release:
Expand All @@ -26,3 +31,4 @@ jobs:
slackChannel: squad-corelang-releases
version: ${{ inputs.version }}
dryRun: ${{ inputs.dryRun == true }}
skipJavascriptReleasabilityChecks: ${{ inputs.skipJavascriptReleasabilityChecks == true }}
6 changes: 6 additions & 0 deletions its/plugin/fast-tests/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,12 @@
<version>1.5.0.1412</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.sonarsource.orchestrator</groupId>
<artifactId>sonar-orchestrator</artifactId>
<version>${sonar-orchestrator.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.sonarsource.api.plugin</groupId>
<artifactId>sonar-plugin-api</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,26 @@

import static com.sonarsource.scanner.integrationtester.utility.QualityProfileLoader.loadActiveRulesFromXmlProfile;

import com.sonar.orchestrator.config.Configuration;
import com.sonar.orchestrator.container.Edition;
import com.sonar.orchestrator.container.SonarDistribution;
import com.sonar.orchestrator.locator.FileLocation;
import com.sonar.orchestrator.locator.Location;
import com.sonar.orchestrator.locator.Locators;
import com.sonar.orchestrator.locator.MavenLocation;
import com.sonar.orchestrator.server.PackagingResolver;
import com.sonarsource.scanner.integrationtester.dsl.ActiveRule;
import com.sonarsource.scanner.integrationtester.dsl.EngineVersion;
import com.sonarsource.scanner.integrationtester.dsl.SonarProjectContext;
import com.sonarsource.scanner.integrationtester.dsl.SonarServerContext;
import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.StandardCopyOption;
import java.util.Arrays;
import java.util.List;
import java.util.zip.ZipFile;
import org.sonar.check.Rule;
import org.sonar.check.RuleProperty;
import org.sonar.css.CssLanguage;
Expand All @@ -45,12 +54,48 @@ public final class SonarScannerIntegrationHelper {
* Get the engine version based on the sonar.runtimeVersion system property.
* Defaults to LATEST_RELEASE if not specified.
*/
public static EngineVersion.Version getEngineVersion() {
public static synchronized EngineVersion.Version getEngineVersion() {
String runtimeVersion = System.getProperty("sonar.runtimeVersion", "LATEST_RELEASE");
if ("DEV".equals(runtimeVersion)) {
return EngineVersion.latestMasterBuild();
}
return EngineVersion.latestRelease();
if ("LATEST_RELEASE".equals(runtimeVersion)) {
return EngineVersion.latestRelease();
}
// The LTA engine is shipped inside the server ZIP, not published as a standalone artifact.
var configuration = Configuration.createEnv();
var packaging = new PackagingResolver(new Locators(configuration)).resolve(
new SonarDistribution().setEdition(Edition.ENTERPRISE_LW).setVersion(runtimeVersion)
);
var engineName = "scanner-enterprise-" + packaging.getVersion() + "-all.jar";
var engine = configuration
Comment on lines +57 to +71

@gitar-bot gitar-bot Bot Oct 23, 2026 •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Performance: LTA engine alias is re-resolved against Artifactory on every call

getEngineVersion() runs from the static SERVER_CONTEXT initializer of about 20 test classes, both through getContext() and directly. With the default DEV[2026.1], every call builds a new PackagingResolver and calls resolve(). That goes through locators.maven().resolveVersion(...) to DefaultArtifactory, which sends an api/search/versions HTTP request each time. Orchestrator caches the downloaded ZIP but not the alias-to-version lookup (DefaultArtifactory.java, PackagingResolver.java).

So each fast-QA JVM makes about 20 serialized network round trips, and the synchronized lock makes test classes wait on each other. If a new 2026.1 build is promoted during a run, different test classes in the same run can also get different scanner engines. Because the method is already synchronized, storing the result in a static field once fixes both problems.

Memoize the resolved engine for the JVM lifetime (method is already synchronized).:

private static EngineVersion.Version engineVersion;

public static synchronized EngineVersion.Version getEngineVersion() {
  if (engineVersion == null) {
    engineVersion = resolveEngineVersion();
  }
  return engineVersion;
}
// move the existing body into: private static EngineVersion.Version resolveEngineVersion()

Was this helpful? React with 👍 / 👎

.fileSystem()
.getCacheDir()
.resolve("sonarjs-scanner-engines")
.resolve(engineName);
if (!Files.exists(engine)) {
try (var zip = new ZipFile(packaging.getZip())) {
var entry = zip.getEntry(
"sonarqube-" + packaging.getVersion() + "/lib/scanner/" + engineName
);
if (entry == null) {
throw new IllegalStateException("Missing scanner engine in " + packaging.getZip());
}
Files.createDirectories(engine.getParent());
var temporaryEngine = Files.createTempFile(engine.getParent(), engineName, ".tmp");
try {
try (var input = zip.getInputStream(entry)) {
Files.copy(input, temporaryEngine, StandardCopyOption.REPLACE_EXISTING);
}
Files.move(temporaryEngine, engine, StandardCopyOption.REPLACE_EXISTING);
} finally {
Files.deleteIfExists(temporaryEngine);
}
} catch (IOException e) {
throw new IllegalStateException("Unable to extract the enterprise scanner engine", e);
}
}
return EngineVersion.localBuild(engine);
}

public static SonarServerContext getContext(
Expand All @@ -60,6 +105,7 @@ public static SonarServerContext getContext(
) {
var builder = SonarServerContext.builder()
.withProduct(SonarServerContext.Product.SERVER)
.withServerEdition(SonarServerContext.ServerEdition.ENTERPRISE)
.withEngineVersion(getEngineVersion());
for (var pluginLocation : pluginLocations) {
builder.withPlugin(pluginLocation);
Expand Down
10 changes: 10 additions & 0 deletions its/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,14 @@

<build>
<plugins>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<systemPropertyVariables>
<sonar.runtimeVersion>${sonar.runtimeVersion}</sonar.runtimeVersion>
</systemPropertyVariables>
</configuration>
</plugin>
<plugin>
<groupId>com.mycila</groupId>
<artifactId>license-maven-plugin</artifactId>
Expand Down Expand Up @@ -59,6 +67,8 @@
<properties>
<maven.deploy.skip>true</maven.deploy.skip>
<skipTests>true</skipTests>
<!-- Latest promoted SonarQube Server build from the maintenance line. -->
<sonar.runtimeVersion>DEV[2026.1]</sonar.runtimeVersion>
<!-- sonar scanner properties -->
<sonar.sources>src/main</sonar.sources>
<sonar.tests>src/test</sonar.tests>
Expand Down
Loading