-
Notifications
You must be signed in to change notification settings - Fork 98
SONARPY-2462: Parallelize the qa_plugin tests #2248
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
Merged
Merged
Changes from 4 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
698e2b4
SONARPY-2462 implement a concurrent version of the OrchestratorExtension
Seppli11 206dd93
parallelize the tests
Seppli11 d8abd2e
ensure that all tests are executed
Seppli11 dbcef7f
make NotebookPluginTest pass
Seppli11 c6777f5
review fixes
Seppli11 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
82 changes: 82 additions & 0 deletions
82
...plugin-test/src/test/java/com/sonar/python/it/plugin/ConcurrentOrchestratorExtension.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,82 @@ | ||
| /* | ||
| * SonarQube Python Plugin | ||
| * Copyright (C) 2012-2024 SonarSource SA | ||
| * mailto:info AT sonarsource DOT com | ||
| * | ||
| * This program is free software; you can redistribute it and/or | ||
| * modify it under the terms of the Sonar Source-Available License Version 1, as published by SonarSource SA. | ||
| * | ||
| * This program is distributed in the hope that it will be useful, | ||
| * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | ||
| * See the Sonar Source-Available License for more details. | ||
| * | ||
| * You should have received a copy of the Sonar Source-Available License | ||
| * along with this program; if not, see https://sonarsource.com/license/ssal/ | ||
| */ | ||
| package com.sonar.python.it.plugin; | ||
|
|
||
| import com.sonar.orchestrator.Orchestrator; | ||
| import com.sonar.orchestrator.OrchestratorBuilder; | ||
| import com.sonar.orchestrator.build.SonarScanner; | ||
| import com.sonar.orchestrator.build.SonarScannerInstaller; | ||
| import com.sonar.orchestrator.config.Configuration; | ||
| import com.sonar.orchestrator.container.SonarDistribution; | ||
| import com.sonar.orchestrator.server.StartupLogWatcher; | ||
| import com.sonar.orchestrator.util.System2; | ||
| import com.sonar.orchestrator.version.Version; | ||
| import java.util.concurrent.CountDownLatch; | ||
| import java.util.concurrent.atomic.AtomicInteger; | ||
| import org.jetbrains.annotations.Nullable; | ||
| import org.junit.jupiter.api.extension.BeforeAllCallback; | ||
| import org.junit.jupiter.api.extension.ExtensionContext; | ||
|
|
||
| public class ConcurrentOrchestratorExtension extends Orchestrator implements BeforeAllCallback { | ||
| private static final AtomicInteger REQUESTED_ORCHESTRATORS_KEY = new AtomicInteger(); | ||
| private static final CountDownLatch IS_ORCHESTRATOR_READY = new CountDownLatch(1); | ||
|
|
||
| ConcurrentOrchestratorExtension(Configuration config, SonarDistribution distribution, @Nullable StartupLogWatcher startupLogWatcher) { | ||
| super(config, distribution, startupLogWatcher); | ||
| } | ||
|
|
||
| @Override | ||
| public void beforeAll(ExtensionContext context) throws InterruptedException { | ||
| if (REQUESTED_ORCHESTRATORS_KEY.getAndIncrement() == 0) { | ||
| start(); | ||
|
|
||
| new SonarScannerInstaller(getConfiguration().locators()).install(Version.create(SonarScanner.DEFAULT_SCANNER_VERSION), getConfiguration().fileSystem().workspace()); | ||
| IS_ORCHESTRATOR_READY.countDown(); | ||
|
|
||
| } else { | ||
| IS_ORCHESTRATOR_READY.await(); | ||
| } | ||
| } | ||
|
|
||
|
|
||
| public SonarScanner createSonarScanner() { | ||
| return SonarScanner.create(); | ||
| } | ||
|
|
||
| public static ConcurrentOrchestratorExtensionBuilder builderEnv() { | ||
| return new ConcurrentOrchestratorExtensionBuilder(Configuration.createEnv()); | ||
| } | ||
|
|
||
| public static ConcurrentOrchestratorExtensionBuilder builder(Configuration config) { | ||
| return new ConcurrentOrchestratorExtensionBuilder(config); | ||
| } | ||
|
|
||
| public static class ConcurrentOrchestratorExtensionBuilder extends OrchestratorBuilder<ConcurrentOrchestratorExtensionBuilder, ConcurrentOrchestratorExtension> { | ||
| ConcurrentOrchestratorExtensionBuilder(Configuration initialConfig) { | ||
| this(initialConfig, System2.INSTANCE); | ||
| } | ||
|
|
||
| ConcurrentOrchestratorExtensionBuilder(Configuration initialConfig, System2 system2) { | ||
| super(initialConfig, system2); | ||
| } | ||
|
|
||
| @Override | ||
| protected ConcurrentOrchestratorExtension build(Configuration finalConfig, SonarDistribution distribution, StartupLogWatcher startupLogWatcher) { | ||
| return new ConcurrentOrchestratorExtension(finalConfig, distribution, startupLogWatcher); | ||
| } | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems unused, do we need it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch. You're right, we don't need it. thx