Skip to content

Add unit tests for Elasticsearch profiling query DAOs#13820

Merged
wu-sheng merged 1 commit into
apache:masterfrom
currenjin:feat/es-profiling-dao-tests
Apr 15, 2026
Merged

Add unit tests for Elasticsearch profiling query DAOs#13820
wu-sheng merged 1 commit into
apache:masterfrom
currenjin:feat/es-profiling-dao-tests

Conversation

@currenjin
Copy link
Copy Markdown
Contributor

What

Add unit test coverage for the isMergedTable guard condition and query construction in five Elasticsearch profiling query DAOs:

  • AsyncProfilerTaskQueryEsDAOgetTaskList() with merged table filter and serviceId filter, getById() with merged table + TASK_ID filter
  • AsyncProfilerTaskLogQueryEsDAOgetTaskLogList() with merged table, TASK_ID filter, and sort by OPERATION_TIME
  • PprofTaskQueryEsDAOgetTaskList() with merged table and serviceId, getById() with merged table + TASK_ID
  • PprofTaskLogQueryEsDAOgetTaskLogList() with merged table, TASK_ID, and sort
  • JFRDataQueryEsDAOgetByTaskIdAndInstancesAndEvent() with merged table, TASK_ID, EVENT_TYPE, and optional INSTANCE_ID filter

Why

When logicSharding=false (default in single-node deployments), all Record-type tables are merged into a single records-all physical index. Each query must include a TABLE_COLUMN/RECORD_TABLE_NAME filter to scope results to the correct logical table. These tests verify that the guard condition (isMergedTable) and the filter are wired correctly.

This follows the pattern established in ProfileTaskQueryEsDAOTest (introduced alongside the ProfileTaskQueryEsDAO.getById() fix).

How the tests work

  1. The LOGIC_INDICES_CATALOG static map in IndexController.LogicIndicesRegister is populated via reflection to simulate logicSharding=false for each DAO's index.
  2. ElasticSearchClient is mocked; ArgumentCaptor<Search> captures the query sent to ES.
  3. The captured Search object is serialized to JSON via Jackson and asserted to contain the expected field names.

@wu-sheng
Copy link
Copy Markdown
Member

Please resolve conficts.

@wu-sheng
Copy link
Copy Markdown
Member

Pure UT could be excluded from changes.

@wu-sheng wu-sheng added backend OAP backend related. test Test requirements about performance, feature or before release. labels Apr 15, 2026
@wu-sheng wu-sheng added this to the 10.5.0 milestone Apr 15, 2026
Add test coverage for the isMergedTable guard condition and query
construction in five ES profiling DAOs: AsyncProfilerTaskQueryEsDAO,
AsyncProfilerTaskLogQueryEsDAO, PprofTaskQueryEsDAO,
PprofTaskLogQueryEsDAO, and JFRDataQueryEsDAO. Each test verifies that
when logicSharding is disabled (all records merged to records-all),
the RECORD_TABLE_NAME filter is correctly included in queries.
@currenjin currenjin force-pushed the feat/es-profiling-dao-tests branch from 30450e3 to c4ddd6c Compare April 15, 2026 07:52
@wu-sheng wu-sheng merged commit 9e3dcf1 into apache:master Apr 15, 2026
416 of 420 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backend OAP backend related. test Test requirements about performance, feature or before release.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants