Skip to content
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

1505 avoid flakiness 2 with traces #941

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
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
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,12 @@ public void computeDiagnostics(String camelText, TextDocumentItem documentItem)
diagnostics.addAll(configurationPropertiesDiagnosticService.converToLSPDiagnostics(configurationPropertiesErrors));
diagnostics.addAll(camelKModelineDiagnosticService.compute(camelText, documentItem));
diagnostics.addAll(connectedModeDiagnosticService.compute(camelText, documentItem));
camelLanguageServer.getClient().publishDiagnostics(new PublishDiagnosticsParams(uri, diagnostics));
lastTriggeredDiagnostic.remove(uri);
if(!Thread.currentThread().isInterrupted()) {
camelLanguageServer.getClient().publishDiagnostics(new PublishDiagnosticsParams(uri, diagnostics));
lastTriggeredDiagnostic.remove(uri);
} else {
System.out.println("### Thread was interrupted (i.e. Future for diagnostic cancelled)");
}
});
lastTriggeredDiagnostic.put(uri, lastTriggeredComputation);
}
Expand All @@ -97,6 +101,7 @@ public void clear(String uri) {
CompletableFuture<Void> previousComputation = lastTriggeredDiagnostic.get(uri);
if (previousComputation != null) {
previousComputation.cancel(true);
lastTriggeredDiagnostic.remove(uri);
}
camelLanguageServer.getClient().publishDiagnostics(new PublishDiagnosticsParams(uri, Collections.emptyList()));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ public void showMessage(MessageParams messageParams) {

@Override
public void publishDiagnostics(PublishDiagnosticsParams diagnostics) {
System.out.println("Published Diagnostics " + diagnostics.getUri() +" "+ diagnostics.getDiagnostics().size());
AbstractCamelLanguageServerTest.this.lastPublishedDiagnostics = diagnostics;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ protected void testDiagnostic(String fileUnderTest, int expectedNumberOfError, S
protected void testDiagnostic(File file, int expectedNumberOfError, String extension) throws FileNotFoundException {
camelLanguageServer = initializeLanguageServer(new FileInputStream(file), extension);

createAwait().untilAsserted(() -> assertThat(lastPublishedDiagnostics).isNotNull());
createAwait().untilAsserted(() -> assertThat(lastPublishedDiagnostics.getDiagnostics()).isEmpty());

DidSaveTextDocumentParams params = new DidSaveTextDocumentParams(new TextDocumentIdentifier(DUMMY_URI+extension));
camelLanguageServer.getTextDocumentService().didSave(params);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,16 +142,22 @@ void testNoExceptionOnInvalidJavaFile() throws Exception {

@Test
void testValidationErrorClearedOnClose() throws Exception {
System.out.println("### Starting testValidationErrorClearedOnClose test ");
testDiagnostic("camel-with-endpoint-error", 1, ".xml");

System.out.println("### Will close");

DidCloseTextDocumentParams params = new DidCloseTextDocumentParams(new TextDocumentIdentifier(DUMMY_URI+".xml"));
camelLanguageServer.getTextDocumentService().didClose(params);

await().timeout(AWAIT_TIMEOUT).untilAsserted(() -> assertThat(lastPublishedDiagnostics.getDiagnostics()).isEmpty());
System.out.println("### didClose sent");

await().timeout(AWAIT_TIMEOUT.multipliedBy(2)).untilAsserted(() -> assertThat(lastPublishedDiagnostics.getDiagnostics()).isEmpty());
}

@Test
void testValidationErrorUpdatedOnChange() throws Exception {
System.out.println("### Starting testValidationErrorUpdatedOnChange test ");
testDiagnostic("camel-with-endpoint-error", 1, ".xml");

camelLanguageServer.getTextDocumentService().getOpenedDocument(DUMMY_URI+".xml").getText();
Expand Down
Loading