-
Notifications
You must be signed in to change notification settings - Fork 11
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
integ tests for exporter n reader #267
base: main
Are you sure you want to change the base?
integ tests for exporter n reader #267
Conversation
Signed-off-by: Kishore Kumaar Natarajan <[email protected]>
Signed-off-by: Kishore Kumaar Natarajan <[email protected]>
Thanks! These cases make the exporter tests much more complete. I have several suggestions:
|
Signed-off-by: Kishore Kumaar Natarajan <[email protected]>
ccfd35f
to
2a56543
Compare
Signed-off-by: Kishore Kumaar Natarajan <[email protected]>
Signed-off-by: Kishore Kumaar Natarajan <[email protected]>
Added these changes and also added a step to check topqueries-* is green |
Signed-off-by: Kishore Kumaar Natarajan <[email protected]>
Signed-off-by: Kishore Kumaar Natarajan <[email protected]>
Signed-off-by: Kishore Kumaar Natarajan <[email protected]>
Signed-off-by: Kishore Kumaar Natarajan <[email protected]>
Signed-off-by: Kishore Kumaar Natarajan <[email protected]>
7930dcc
to
779bb3f
Compare
Signed-off-by: Kishore Kumaar Natarajan <[email protected]>
Signed-off-by: Kishore Kumaar Natarajan <[email protected]>
Signed-off-by: Kishore Kumaar Natarajan <[email protected]>
Signed-off-by: Kishore Kumaar Natarajan <[email protected]>
Signed-off-by: Kishore Kumaar Natarajan <[email protected]>
Signed-off-by: Kishore Kumaar Natarajan <[email protected]>
Signed-off-by: Kishore Kumaar Natarajan <[email protected]>
Signed-off-by: Kishore Kumaar Natarajan <[email protected]>
Signed-off-by: Kishore Kumaar Natarajan <[email protected]>
Signed-off-by: Kishore Kumaar Natarajan <[email protected]>
Signed-off-by: Kishore Kumaar Natarajan <[email protected]>
Signed-off-by: Kishore Kumaar Natarajan <[email protected]>
Signed-off-by: Kishore Kumaar Natarajan <[email protected]>
Signed-off-by: Kishore Kumaar Natarajan <[email protected]>
Signed-off-by: Kishore Kumaar Natarajan <[email protected]>
Signed-off-by: Kishore Kumaar Natarajan <[email protected]>
Signed-off-by: Kishore Kumaar Natarajan <[email protected]>
Signed-off-by: Kishore Kumaar Natarajan <[email protected]>
Signed-off-by: Kishore Kumaar Natarajan <[email protected]>
Signed-off-by: Kishore Kumaar Natarajan <[email protected]>
Signed-off-by: Kishore Kumaar Natarajan <[email protected]>
Signed-off-by: Kishore Kumaar Natarajan <[email protected]>
Signed-off-by: Kishore Kumaar Natarajan <[email protected]>
Signed-off-by: Kishore Kumaar Natarajan <[email protected]>
Signed-off-by: Kishore Kumaar Natarajan <[email protected]>
Signed-off-by: Kishore Kumaar Natarajan <[email protected]>
Triggering the tests again to make sure they are not flaky |
} | ||
|
||
private void createIndexTemplate() throws IOException { |
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.
Why do we need to create an index template here? Index template should be created by the exporter.
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.
Removed
Response response = client().performRequest(request); | ||
Assert.assertEquals(200, response.getStatusLine().getStatusCode()); | ||
setLatencyWindowSize("1m"); | ||
createIndexTemplate(); | ||
waitForWindowToPass(10); |
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.
I don't think we need this waitForWindowToPass(10);
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.
Added because giving some time to create the document
checkQueryInsightsIndexTemplate(); | ||
disableLocalIndexExporter(); | ||
reEnableLocalIndexExporter(); | ||
setLocalIndexToDebug(); |
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.
What's the usage of this function? For debugging only?
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.
To check whether it is able to change from local to debug
import org.junit.Assert; | ||
import org.opensearch.client.Request; | ||
import org.opensearch.client.Response; | ||
import org.opensearch.client.ResponseException; | ||
import org.opensearch.plugin.insights.QueryInsightsRestTestCase; | ||
|
||
/** Rest Action tests for query */ | ||
/** Rest Action tests for query */ | ||
public class QueryInsightsExporterIT extends QueryInsightsRestTestCase { |
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.
Overall, both of the tests only check the "happy path", but we also need to check for example:
- Edge cases with invalid date parameters
- Error handling with malformed requests
- Filtering functionality with the id parameter (which exists in LocalIndexReader.java)
- Other filtering and types.
- Detailed Response structure validation
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.
Also:
- Date ranges spanning multiple indices
- Very large date ranges
waitForWindowToPass(10); | ||
performSearch(); | ||
|
||
waitForWindowToPass(70); |
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.
These hardcoded sleep values make the test potentially flaky. Why 10 seconds? Why 70 seconds? Can we add some explainations for future debugging?
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.
Added Explanation
assertTrue("Expected search results for title='Test Document'", responseContent.contains("\"Test Document\"")); | ||
} | ||
|
||
private void createDocument() throws IOException { |
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.
A lot of these functions are duplicated between Exporter tests and Reader tests, can we make combine them into one to reduce code duplication?
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.
Move all common utility methods into QueryInsightsRestTestCase
|
||
try { | ||
client().performRequest(new Request("DELETE", "/top_queries")); | ||
} catch (ResponseException ignored) {} |
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.
We should at least log something here instead of silently ignoring the errors
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.
Added Logger
} | ||
|
||
private void cleanup(String fullIndexName) throws IOException, InterruptedException { | ||
Thread.sleep(10000); |
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.
In exporter it sleeps 3 seconds but in here it's 10 seconds, why's the difference?
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.
I think 10 seconds is needed for reader otherwise it is not able to find the Local Index (only for Reader)
String fetchResponseContent = new String(fetchResponse.getEntity().getContent().readAllBytes(), StandardCharsets.UTF_8); | ||
assertTrue( | ||
"Expected title field with value 'Test Document' in query insights data in local Indices", | ||
fetchResponseContent.contains("\"Test Document\"") |
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.
Can you check more detailed content/fields instead of this simple contains
?
Maybe parse it to JSON format first to validate the structure.
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.
Updated the code
import org.opensearch.plugin.insights.QueryInsightsRestTestCase; | ||
|
||
public class QueryInsightsReaderIT extends QueryInsightsRestTestCase { | ||
public void testQueryInsightsReaderSettings() throws IOException, InterruptedException { |
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 function doesn't do what the name suggest. We should rename 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.
Changed to testQueryInsightsHistoricalTopQueriesRead
Signed-off-by: Kishore Kumaar Natarajan <[email protected]>
Signed-off-by: Kishore Kumaar Natarajan <[email protected]>
67582ac
to
f96251f
Compare
Description
This PR improves the QueryInsightsExporterIT test by adding the following updates:
Issues Resolved
Closes [#233]
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.