Skip to content

Commit

Permalink
Update to SLCORE 10.0.1, fix shutdown of backend (#338)
Browse files Browse the repository at this point in the history
* Update to SLCORE 10.0.1, fix shutdown of backend

* Try to make test assertion less susceptible to race conditions
  • Loading branch information
jblievremont authored Mar 12, 2024
1 parent 3064802 commit da52577
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 16 deletions.
6 changes: 3 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@
</parent>
<groupId>org.sonarsource.sonarlint.ls</groupId>
<artifactId>sonarlint-language-server</artifactId>
<version>3.5-SNAPSHOT</version>
<version>3.4.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>SonarLint Language Server</name>
<description>SonarLint Language Server</description>
<organization>
<name>SonarSource</name>
<url>http://www.sonarsource.com/</url>
<url>https://www.sonarsource.com/</url>
</organization>
<issueManagement>
<system>JIRA</system>
Expand All @@ -24,7 +24,7 @@

<properties>
<jdk.min.version>17</jdk.min.version>
<sonarlint.core.version>10.0.0.77144</sonarlint.core.version>
<sonarlint.core.version>10.0.1.77184</sonarlint.core.version>
<!-- Version used by Xodus -->
<kotlin.version>1.6.10</kotlin.version>
<!-- analyzers used for tests -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,6 @@ private static Duration getTimeoutProperty(String propertyName) {
}

public void shutdown() {
backendService.shutdown();
try {
backendService.shutdown().get(10, TimeUnit.SECONDS);
} catch (ExecutionException | TimeoutException e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,8 @@ public static void stopServer() throws Exception {
System.clearProperty(SonarLintTelemetry.DISABLE_PROPERTY_KEY);
try {
if (lsProxy != null) {
lsProxy.shutdown().join();
// 20 seconds should be way enough time for the backend to stop
lsProxy.shutdown().get(20, SECONDS);
lsProxy.exit();
}
} finally {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
import java.util.List;
import java.util.Map;
import java.util.UUID;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.ExecutionException;
import mockwebserver3.MockResponse;
Expand Down Expand Up @@ -59,7 +58,6 @@
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.TestInfo;
import org.junit.jupiter.api.extension.RegisterExtension;
import org.sonar.api.utils.DateUtils;
import org.sonar.scanner.protocol.Constants.Severity;
Expand Down Expand Up @@ -1222,7 +1220,6 @@ void change_issue_status_permission_check() throws ExecutionException, Interrupt
@Test
void change_issue_status_permission_check_exceptionally() throws ExecutionException, InterruptedException {
addConfigScope(CONNECTION_ID, "myProject", folder1BaseDir.toUri().toString());
awaitUntilAsserted(() -> assertThat(client.logs.stream().anyMatch(messageParams -> messageParams.getMessage().contains("Synchronizing project branches for project 'myProject'"))).isTrue());

var issueKey = "malformed issue UUID";
var result = lsProxy.checkIssueStatusChangePermitted(new SonarLintExtendedLanguageServer.CheckIssueStatusChangePermittedParams(folder1BaseDir.toUri().toString(), issueKey)).get();
Expand Down Expand Up @@ -1413,9 +1410,9 @@ void shouldReportTaintIssues() {


@Test
void test_binding_suggestion_for_client() throws Exception {
void should_automatically_suggest_bindings_to_client() throws Exception {
client.suggestBindingLatch = new CountDownLatch(1);
var basedir = Paths.get("path/to/base").toAbsolutePath();
var basedir = Paths.get("path/to/base/auto-suggest").toAbsolutePath();
var workspaceUri = basedir.toUri().toString();
addedConfigScopeIds.add(workspaceUri);
var workspaceFolder = new WorkspaceFolder(workspaceUri);
Expand All @@ -1433,8 +1430,8 @@ void test_binding_suggestion_for_client() throws Exception {


@Test
void getBindingSuggestions() throws ExecutionException, InterruptedException {
var basedir = Paths.get("path/to/base").toAbsolutePath();
void should_allow_client_to_explicitly_ask_for_binding_suggestions() throws ExecutionException, InterruptedException {
var basedir = Paths.get("path/to/base/explicit-request").toAbsolutePath();
var workspaceUri = basedir.toUri().toString();
addedConfigScopeIds.add(workspaceUri);
var workspaceFolder = new WorkspaceFolder(workspaceUri, "foo-bar");
Expand All @@ -1443,9 +1440,11 @@ void getBindingSuggestions() throws ExecutionException, InterruptedException {
lsProxy.getWorkspaceService().didChangeWorkspaceFolders(new DidChangeWorkspaceFoldersParams(
new WorkspaceFoldersChangeEvent(List.of(workspaceFolder), Collections.emptyList())));
foldersToRemove.add(workspaceUri);
var result = lsProxy.getBindingSuggestion(new GetBindingSuggestionParams(workspaceUri, CONNECTION_ID)).get();
assertThat(result).isNotNull();
assertThat(result.getSuggestions()).hasSize(1);
// Availability of binding suggestions for the added folder can take some time
awaitUntilAsserted(() -> {
var result = lsProxy.getBindingSuggestion(new GetBindingSuggestionParams(workspaceUri, CONNECTION_ID)).get();
assertThat(result).isNotNull();
assertThat(result.getSuggestions()).hasSize(1);
});
}

}

0 comments on commit da52577

Please sign in to comment.