-
Notifications
You must be signed in to change notification settings - Fork 64
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
Add coverage for NeuralSearch class #898
Conversation
Signed-off-by: Daniel Widdis <[email protected]>
@dbwiddis can you check why gradle check is failing? |
Unrelated to my PR:
I can keep force-pushing until it's green but generally it's easier for repo maintainers to retry just the failed tests. |
@dbwiddis can you add
HybridQueryWeightTests and HybridQueryPhaseSearcherTests classes and add it into your PR ? |
Looking into the log, it seems it's timing out and it's likely related to thread locking. Multiple threads show
This makes me suspect some interaction with this PR which does mock a when(threadPool.executor(anyString())).thenReturn(executorService); I expected that mock to be isolated only to this test, and of course when run in isolation the test passes. However, looking at the plugin neural-search/src/main/java/org/opensearch/neuralsearch/plugin/NeuralSearch.java Line 101 in f58d989
That leads to this line: neural-search/src/main/java/org/opensearch/neuralsearch/executors/HybridQueryExecutor.java Line 60 in f58d989
That sets the value of a neural-search/src/main/java/org/opensearch/neuralsearch/executors/HybridQueryExecutor.java Line 31 in f58d989
I could replace the mock with a real thread pool and executor, somewhat like this pattern we use in Flow Framework and that I've carried over into ML Commons in a few places, and shut it down (the correct way to avoid the thread leak scope alert) public class ProcessNodeTests extends OpenSearchTestCase {
private static TestThreadPool testThreadPool;
@BeforeClass
public static void setup() {
testThreadPool = new TestThreadPool(
ProcessNodeTests.class.getName(),
new ScalingExecutorBuilder(
PROVISION_WORKFLOW_THREAD_POOL,
1,
Math.max(1, OpenSearchExecutors.allocatedProcessors(Settings.EMPTY) - 1),
TimeValue.timeValueMinutes(5),
FLOW_FRAMEWORK_THREAD_POOL_PREFIX + PROVISION_WORKFLOW_THREAD_POOL
)
);
}
@AfterClass
public static void cleanup() {
ThreadPool.terminate(testThreadPool, 500, TimeUnit.MILLISECONDS);
} But this works because the static variable is confined to this class and used only within this test. If I used this pattern in this test, it would still initialize the I could leave it running for the entire duration of the test suite, but This still doesn't solve the underlying problem: there is no way to ever execute Putting aside the question of whether a static object initialized by a different class is even a good idea at all (which I don't think it is), at this point I would prefer to just remove the perfunctory test of |
TLDR: I'll push a commit removing the coverage for |
Signed-off-by: Daniel Widdis <[email protected]>
Signed-off-by: Daniel Widdis <[email protected]>
OpenSearch has a direct executor service that simulates the (Runnable::run) default behavior of the non-initialized taskExecutor, so I used that. |
@martin-gaievski can you review this PR? |
481a347
into
opensearch-project:main
* Add coverage for NeuralSearch class Signed-off-by: Daniel Widdis <[email protected]> (cherry picked from commit 481a347)
* Add coverage for NeuralSearch class Signed-off-by: Daniel Widdis <[email protected]> (cherry picked from commit 481a347) Co-authored-by: Daniel Widdis <[email protected]>
Description
Adds test coverage for the main plugin class file
Related Issues
Part of #429
Check List
--signoff
.By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.