You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@iotdb.apache.org by "JackieTien97 (via GitHub)" <gi...@apache.org> on 2026/05/15 02:50:03 UTC

[PR] Speed up ITs by sharing the cluster across test methods [iotdb]

JackieTien97 opened a new pull request, #17682:
URL: https://github.com/apache/iotdb/pull/17682

   ## Motivation
   
   Most ITs under `integration-test/src/test/java/org/apache/iotdb/db/it/` use `@Before`/`@After` to start and stop the cluster on every test method. For a class with N tests this means N full cluster start/stop cycles (~5s each), which dominates wall time on management/syntax/auth-style suites where the actual test body finishes in tens of milliseconds.
   
   For example, `IoTDBSimpleQueryIT` has 36 tests; previously it spent roughly 36 × 5s ≈ 3 min just on cluster lifecycle. After this change the same suite finishes in ~14s.
   
   ## Changes
   
   Converted 37 ITs to start the cluster once per class:
   
   - `@Before` → `@BeforeClass public static void setUp()`
   - `@After` → `@AfterClass public static void tearDown()`
   - Each test wraps its body in `try { ... } finally { ... }` and cleans up the state it created (drop database / drop function / drop user / drop role / revoke privileges / drop trigger / drop template / etc.) via small static helpers like `dropFunctionQuietly`, `executeQuietly`, or `cleanupAfterTest` that swallow expected SQLExceptions.
   - Where setup populated shared seed data (e.g. trigger timeseries, schema fixtures), the seed runs once in `@BeforeClass`.
   - For `IoTDBMQTTServiceJsonIT` the cluster moves to `@BeforeClass`/`@AfterClass` while per-test MQTT connection setup stays in `@Before`/`@After` (each test still gets its own connection).
   
   ## Tests intentionally left on `@Before`/`@After`
   
   These have semantics that are incompatible with sharing a cluster across tests:
   
   - Tests that restart or kill nodes — `IoTDBRecoverIT`, `IoTDBRecoverUnclosedIT`, `IoTDBRestartIT`, `IoTDBRestartRatisIT`, `IoTDBVerifyConnectionIT`
   - Tests that initialize the cluster with different topologies/configs per method — `IoTDBLoadLastCacheIT` (parameterized), `IoTDBLoadTsFileIT`, `metric/IoTDBMetricIT`, `iotconsensusv2/IoTDBIoTConsensusV23C3DBasicITBase`
   - Tests that depend on a fresh global counter or accumulate global state — `quotas/IoTDBSpaceQuotaIT`, `audit/IoTDBAuditLogBasicIT`, `schema/IoTDBDeactivateTemplateIT`, `schema/IoTDBMetadataFetchIT`, `schema/IoTDBSchemaTemplateIT`, `IoTDBInsertWithQueryIT`, `aligned/IoTDBAlignedDataDeletionIT`
   - Tests that mutate root credentials and could brick the cluster on failure — `auth/IoTDBUserRenameIT`
   - Parameterized base class where `@BeforeClass` would run before `@Parameterized.BeforeParam` (cluster not yet up) — `schema/quota/IoTDBClusterQuotaIT`
   - Two-test classes whose tests both `CREATE USER user1` and assert "no data → empty" on the same path — `schema/regionscan/IoTDBActiveSchemaQueryIT`
   
   ## Verification
   
   Spotless and `mvn test-compile` pass on the integration-test module. Ran 4 batches of representative ITs locally:
   
   | Batch | Tests | Failures | Skipped |
   |---|---|---|---|
   | 1 (UDF + SyntaxId + ExecuteBatch) | 31 | 0 | 0 |
   | 2 (SimpleQuery + Aligned + Trigger + auth + StringLiteral + ...) | 85 | 0 | 2 (`@Ignore`) |
   | 3 (single-test ITs + LoadTsFileWithMod + SortedShowTimeseries) | 28 | 0 | 0 |
   | 4 (Grafana + REST + MQTT + auth) | 20 | 0 | 0 |
   | **Total** | **164** | **0** | **2** |


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@iotdb.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Speed up ITs by sharing the cluster across test methods [iotdb]

Posted by "sonarqubecloud[bot] (via GitHub)" <gi...@apache.org>.
sonarqubecloud[bot] commented on PR #17682:
URL: https://github.com/apache/iotdb/pull/17682#issuecomment-4456498862

   ## [![Quality Gate Passed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/qg-passed-20px.png 'Quality Gate Passed')](https://sonarcloud.io/dashboard?id=apache_iotdb&pullRequest=17682) **Quality Gate passed**  
   Issues  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0 New issues](https://sonarcloud.io/project/issues?id=apache_iotdb&pullRequest=17682&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/accepted-16px.png '') [0 Accepted issues](https://sonarcloud.io/project/issues?id=apache_iotdb&pullRequest=17682&issueStatuses=ACCEPTED)
   
   Measures  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_iotdb&pullRequest=17682&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0.0% Coverage on New Code](https://sonarcloud.io/component_measures?id=apache_iotdb&pullRequest=17682&metric=new_coverage&view=list)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0.0% Duplication on New Code](https://sonarcloud.io/component_measures?id=apache_iotdb&pullRequest=17682&metric=new_duplicated_lines_density&view=list)  
     
   <!-- sqra-placement-anchor -->
   [See analysis details on SonarQube Cloud](https://sonarcloud.io/dashboard?id=apache_iotdb&pullRequest=17682)
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@iotdb.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Speed up ITs by sharing the cluster across test methods [iotdb]

Posted by "sonarqubecloud[bot] (via GitHub)" <gi...@apache.org>.
sonarqubecloud[bot] commented on PR #17682:
URL: https://github.com/apache/iotdb/pull/17682#issuecomment-4464721062

   ## [![Quality Gate Passed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/qg-passed-20px.png 'Quality Gate Passed')](https://sonarcloud.io/dashboard?id=apache_iotdb&pullRequest=17682) **Quality Gate passed**  
   Issues  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0 New issues](https://sonarcloud.io/project/issues?id=apache_iotdb&pullRequest=17682&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/accepted-16px.png '') [0 Accepted issues](https://sonarcloud.io/project/issues?id=apache_iotdb&pullRequest=17682&issueStatuses=ACCEPTED)
   
   Measures  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_iotdb&pullRequest=17682&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0.0% Coverage on New Code](https://sonarcloud.io/component_measures?id=apache_iotdb&pullRequest=17682&metric=new_coverage&view=list)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0.0% Duplication on New Code](https://sonarcloud.io/component_measures?id=apache_iotdb&pullRequest=17682&metric=new_duplicated_lines_density&view=list)  
     
   <!-- sqra-placement-anchor -->
   [See analysis details on SonarQube Cloud](https://sonarcloud.io/dashboard?id=apache_iotdb&pullRequest=17682)
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@iotdb.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Speed up ITs by sharing the cluster across test methods [iotdb]

Posted by "codecov[bot] (via GitHub)" <gi...@apache.org>.
codecov[bot] commented on PR #17682:
URL: https://github.com/apache/iotdb/pull/17682#issuecomment-4456759932

   ## [Codecov](https://app.codecov.io/gh/apache/iotdb/pull/17682?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) Report
   :white_check_mark: All modified and coverable lines are covered by tests.
   :white_check_mark: Project coverage is 40.43%. Comparing base ([`556cd66`](https://app.codecov.io/gh/apache/iotdb/commit/556cd6628b5e39adfa56959a97099da1a8228572?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)) to head ([`74285a0`](https://app.codecov.io/gh/apache/iotdb/commit/74285a0f65679eca77948b41adbded88a5cb8afa?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)).
   :warning: Report is 5 commits behind head on master.
   
   <details><summary>Additional details and impacted files</summary>
   
   
   
   ```diff
   @@             Coverage Diff              @@
   ##             master   #17682      +/-   ##
   ============================================
   + Coverage     40.38%   40.43%   +0.04%     
     Complexity     2574     2574              
   ============================================
     Files          5178     5179       +1     
     Lines        349134   349237     +103     
     Branches      44665    44679      +14     
   ============================================
   + Hits         140988   141201     +213     
   + Misses       208146   208036     -110     
   ```
   </details>
   
   [:umbrella: View full report in Codecov by Sentry](https://app.codecov.io/gh/apache/iotdb/pull/17682?dropdown=coverage&src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).   
   :loudspeaker: Have feedback on the report? [Share it here](https://about.codecov.io/codecov-pr-comment-feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).
   <details><summary> :rocket: New features to boost your workflow: </summary>
   
   - :snowflake: [Test Analytics](https://docs.codecov.com/docs/test-analytics): Detect flaky tests, report on failures, and find test suite problems.
   </details>


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@iotdb.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Speed up ITs by sharing the cluster across test methods [iotdb]

Posted by "JackieTien97 (via GitHub)" <gi...@apache.org>.
JackieTien97 merged PR #17682:
URL: https://github.com/apache/iotdb/pull/17682


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@iotdb.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org