sivakumar-mahalingam opened a new issue, #4393: URL: https://github.com/apache/amoro/issues/4393
### What happened? AMS test classes share one AMS instance and one Derby database. Some tests change or delete shared state, so other test classes fail depending on execution order. This breaks CI for PRs that are unrelated to the failing tests (for example #4378 and #4392): 24 errors across `TestInternalIcebergCatalogService` and `TestInternalMixedCatalogService`. There are three root causes: 1. **`TestIcebergV3OptimizingPlanning`** extends `DerbyPersistence`, and its `@AfterEach` cleanup truncates the whole shared database. That deletes the catalogs the REST catalog tests need, so they fail with `Catalog internal_iceberg_catalog not exists` / `Catalog internal_mixed_iceberg_catalog not exists`. 2. **`TestInternalMixedCatalogService`**: if an earlier test leaves `test_ns` behind, the `listDatabases().isEmpty()` assertion fails and the nested setup fails with `failed create database` / `AlreadyExists`. 3. **`TestInternalIcebergCatalogService$CatalogPropertiesTest`**: the background catalog-scan task can read the old catalog metadata before `updateCatalog()` finishes and write it back afterward. The test then sees stale catalog properties. ### Affects Versions master ### What table formats are you seeing the problem on? _No response_ ### What engines are you seeing the problem on? _No response_ ### How to reproduce Run the AMS test suite: ``` ./mvnw test -pl amoro-ams ``` Whether the failures appear depends on test execution order and timing. They show up regularly in CI, for example in the `Build Amoro with JDK 11/17` jobs on #4378: https://github.com/apache/amoro/actions/runs/36305414429 ### Relevant log output ```shell [ERROR] TestInternalIcebergCatalogService$CatalogPropertiesTest.testCatalogProperties:99 » ObjectNotExists Catalog internal_iceberg_catalog not exists [ERROR] TestInternalIcebergCatalogService$NamespaceTests.testNamespaceExists:172 » NoSuchNamespace Catalog internal_iceberg_catalog not exists [ERROR] TestInternalIcebergCatalogService$NamespaceTests.testNamespaceOperations:133 » NoSuchNamespace Catalog internal_iceberg_catalog not exists [ERROR] TestInternalIcebergCatalogService$TableTests.setup:291 » ObjectNotExists Catalog internal_iceberg_catalog not exists [ERROR] TestInternalMixedCatalogService$CompatibilityCatalogTests.setupTest:332 » IllegalState failed create database [ERROR] TestInternalMixedCatalogService$TestDatabaseOperation.test:170 » NoSuchNamespace Catalog internal_mixed_iceberg_catalog not exists [ERROR] TestInternalMixedCatalogService$TestTableCommit.before:259 » NoSuchNamespace Catalog internal_mixed_iceberg_catalog not exists [ERROR] TestInternalMixedCatalogService$TestTableOperation.before:186 » NoSuchNamespace Catalog internal_mixed_iceberg_catalog not exists [ERROR] Tests run: 1183, Failures: 0, Errors: 24, Skipped: 19 ``` ### Anything else Proposed fix (test code only, no production changes): - `TestIcebergV3OptimizingPlanning`: delete only the rows for the table IDs the test created, rather than truncating the shared database. Initialize `DerbyPersistence` only when the class runs on its own. - `TestInternalMixedCatalogService`: before each test, drop any leftover tables and `test_ns`, and check whether `test_ns` exists instead of expecting the catalog to be empty. - `TestInternalIcebergCatalogService`: after the update, reload the catalog through REST and apply the update again if the background scan overwrote it (up to 3 attempts). The fix was first included in #4392. At the reviewer's request, it's being split into its own PR so it can be reviewed separately. ### Are you willing to submit a PR? - [x] Yes I am willing to submit a PR! ### Code of Conduct - [x] I agree to follow this project's Code of Conduct -- 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: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
