-
Notifications
You must be signed in to change notification settings - Fork 715
test: add pytest for queries and assert hits #8241
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
Conversation
PR Reviewer Guide 🔍(Review updated until commit e79f915)Here are some key observations to aid the review process:
|
PR Code Suggestions ✨Latest suggestions up to e79f915
Previous suggestionsSuggestions up to commit 4531a4b
|
|
Persistent review updated to latest commit e79f915 |
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.
Greptile Summary
This PR enhances the existing test suite for OpenObserve's search API by adding 5 comprehensive end-to-end validation tests that go beyond basic HTTP status code checks to validate actual query result correctness. The changes are made exclusively to tests/api-testing/tests/test_search.py, adding 252 lines of new test code.
The new tests validate critical SQL query functionality:
- WHERE condition validation: Ensures all returned hits actually match the WHERE clause filter (
kubernetes_container_name = 'vector') - match_all search validation: Verifies that when using match_all queries, at least some results contain the expected search term
- Timestamp ordering validation: Confirms that
ORDER BY _timestamp DESCactually returns results in descending chronological order - LIMIT clause validation: Checks that
LIMIT 3actually restricts results to 3 or fewer hits - CTE query validation: Validates Common Table Expression queries return expected filtered results (
level = 'info')
These tests follow a consistent pattern: they execute SQL queries against the search API, parse the JSON response, and perform detailed assertions on the returned data structure. Each test includes proper error handling for empty result sets, informative console logging for debugging, and meaningful assertions that validate data correctness rather than just API availability. This addresses a critical gap in the existing test suite, which only validated HTTP response codes (200/400) without ensuring the returned data was actually correct.
The implementation integrates seamlessly with the existing test infrastructure, using the same session management, base URL configuration, and time range handling patterns as the current tests. This systematic approach to improving test quality is essential for a search and analytics platform where data accuracy is paramount.
Confidence score: 4/5
- This PR is safe to merge with minimal risk as it only adds test cases without modifying production code
- Score reflects well-structured test additions that follow existing patterns and improve test coverage significantly
- No files require special attention as this is purely additive test code with consistent implementation patterns
1 file reviewed, 1 comment
…erve into pytest-query-results
PR Type
Tests
Description
Add end-to-end SQL query validation tests
Verify WHERE, match_all, ORDER BY semantics
Enforce LIMIT and result consistency checks
Validate CTE filtering and fields presence
Diagram Walkthrough
File Walkthrough
test_search.py
Add comprehensive E2E SQL query teststests/api-testing/tests/test_search.py