-
Notifications
You must be signed in to change notification settings - Fork 25.6k
Make EsqlSpecTestCase more resilient and re-enable some performance updates #136781
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
Open
craigtaverner
wants to merge
6
commits into
elastic:main
Choose a base branch
from
craigtaverner:esql_test_resilience
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+138
−29
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
7b6749d
Make EsqlSpecTestCase more resilient
craigtaverner f39fb57
Revert "Revert PR #134086 (#134738)"
craigtaverner c13c071
Merge branch 'main' into esql_test_resilience
craigtaverner 15c6458
Reapply "ESQL: Speed up MultiClusterSpecIT start up by 40% by paralle…
craigtaverner 56fd509
Merge branch 'main' into esql_test_resilience
craigtaverner 4a91ed7
Merge branch 'main' into esql_test_resilience
craigtaverner 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -51,6 +51,7 @@ | |
import java.util.Locale; | ||
import java.util.Map; | ||
import java.util.TreeMap; | ||
import java.util.concurrent.Callable; | ||
import java.util.stream.Collectors; | ||
import java.util.stream.IntStream; | ||
import java.util.stream.LongStream; | ||
|
@@ -122,23 +123,59 @@ protected EsqlSpecTestCase( | |
this.mode = randomFrom(Mode.values()); | ||
} | ||
|
||
private static boolean dataLoaded = false; | ||
private static class Protected { | ||
private volatile boolean completed = false; | ||
private volatile boolean started = false; | ||
private volatile Throwable failure = null; | ||
|
||
private void protectedBlock(Callable<Void> callable) { | ||
if (completed) { | ||
return; | ||
} | ||
// In case tests get run in parallel, we ensure only one setup is run, and other tests wait for this | ||
synchronized (this) { | ||
if (completed) { | ||
return; | ||
} | ||
if (started) { | ||
// Should only happen if a previous test setup failed, possibly with partial setup, let's fail fast the current test | ||
if (failure != null) { | ||
fail(failure, "Previous test setup failed: " + failure.getMessage()); | ||
} | ||
fail("Previous test setup failed with unknown error"); | ||
} | ||
started = true; | ||
try { | ||
callable.call(); | ||
completed = true; | ||
} catch (Throwable t) { | ||
failure = t; | ||
fail(failure, "Current test setup failed: " + failure.getMessage()); | ||
} | ||
} | ||
} | ||
|
||
private synchronized void reset() { | ||
completed = false; | ||
started = false; | ||
failure = null; | ||
} | ||
} | ||
|
||
private static final Protected INGEST = new Protected(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In the Views PR we use a separate VIEWS protector, semi-decoupling views from index creation. We could break the index parts into finer grained stuff too, but I see risks with that. |
||
protected static boolean testClustersOk = true; | ||
|
||
@Before | ||
public void setup() throws IOException { | ||
public void setup() { | ||
assumeTrue("test clusters were broken", testClustersOk); | ||
boolean supportsLookup = supportsIndexModeLookup(); | ||
boolean supportsSourceMapping = supportsSourceFieldMapping(); | ||
boolean supportsInferenceTestService = supportsInferenceTestService(); | ||
if (dataLoaded == false) { | ||
if (supportsInferenceTestService) { | ||
INGEST.protectedBlock(() -> { | ||
// Inference endpoints must be created before ingesting any datasets that rely on them (mapping of inference_id) | ||
if (supportsInferenceTestService()) { | ||
createInferenceEndpoints(adminClient()); | ||
} | ||
|
||
loadDataSetIntoEs(client(), supportsLookup, supportsSourceMapping, supportsInferenceTestService); | ||
dataLoaded = true; | ||
} | ||
loadDataSetIntoEs(client(), supportsIndexModeLookup(), supportsSourceFieldMapping(), supportsInferenceTestService()); | ||
return null; | ||
}); | ||
} | ||
|
||
@AfterClass | ||
|
@@ -147,15 +184,14 @@ public static void wipeTestData() throws IOException { | |
return; | ||
} | ||
try { | ||
dataLoaded = false; | ||
adminClient().performRequest(new Request("DELETE", "/*")); | ||
} catch (ResponseException e) { | ||
// 404 here just means we had no indexes | ||
if (e.getResponse().getStatusLine().getStatusCode() != 404) { | ||
throw e; | ||
} | ||
} | ||
|
||
INGEST.reset(); | ||
deleteInferenceEndpoints(adminClient()); | ||
} | ||
|
||
|
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
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.
NIT: you could use
PlainActionFuture
instead of anonymous listeners implementations here.