Add unit tests for JDBC query DAO SQL building#13800
Merged
wu-sheng merged 2 commits intoapache:masterfrom Apr 6, 2026
Merged
Conversation
Add unit tests for JDBCAlarmQueryDAO, JDBCLogQueryDAO, JDBCTraceQueryDAO, and JDBCTopologyQueryDAO to verify correct SQL query construction with various filter combinations.
This was referenced Apr 6, 2026
There was a problem hiding this comment.
Pull request overview
Adds unit-test coverage for JDBC storage DAOs’ SQL construction to guard against regressions in generated query strings across multiple filter combinations.
Changes:
- Add SQL-building unit tests for
JDBCAlarmQueryDAOandJDBCLogQueryDAOvia directbuildSQL(...)assertions. - Add SQL-capture tests for
JDBCTraceQueryDAOquery methods by interceptingjdbcClient.executeQuery(...). - Add SQL-capture tests for
JDBCTopologyQueryDAOservice/instance relation query variants to validate parentheses/OR chaining.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| oap-server/server-storage-plugin/storage-jdbc-hikaricp-plugin/src/test/java/org/apache/skywalking/oap/server/storage/plugin/jdbc/common/dao/JDBCTraceQueryDAOTest.java | Verifies generated SQL for trace queries (traceId, segmentId IN, traceId+instanceId IN with correct conjunction/parentheses). |
| oap-server/server-storage-plugin/storage-jdbc-hikaricp-plugin/src/test/java/org/apache/skywalking/oap/server/storage/plugin/jdbc/common/dao/JDBCTopologyQueryDAOTest.java | Verifies topology relation SQL filters and correct OR/parentheses structure for service/instance relations. |
| oap-server/server-storage-plugin/storage-jdbc-hikaricp-plugin/src/test/java/org/apache/skywalking/oap/server/storage/plugin/jdbc/common/dao/JDBCLogQueryDAOTest.java | Verifies log query SQL under various filters, ordering, tag joins, and limit/offset behavior. |
| oap-server/server-storage-plugin/storage-jdbc-hikaricp-plugin/src/test/java/org/apache/skywalking/oap/server/storage/plugin/jdbc/common/dao/JDBCAlarmQueryDAOTest.java | Verifies alarm query SQL under scope/keyword/duration/tag filters and limit/offset behavior. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
wu-sheng
approved these changes
Apr 6, 2026
Member
wu-sheng
left a comment
There was a problem hiding this comment.
It is great to see new UTs added to the coverage of more branches. Thanks!
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
JDBCAlarmQueryDAO,JDBCLogQueryDAO,JDBCTraceQueryDAO, andJDBCTopologyQueryDAOto verify correct SQL query construction with various filter combinations.Test plan