seongjinyoon opened a new issue, #4178: URL: https://github.com/apache/texera/issues/4178
### What happened? **Problem:** In Texera, we maintain two primary types of test cases:`Unit Tests` and `End-to-End Tests`. These tests differ in how they handle resources: | | Unit Test | End to End Test | | :--- | :---: | ---: | | **Singleton Resource** | ✅ | ❌ | | **Embedded DB** | ❌ | ✅ | However, issues arise when writing unit tests that access both Singleton Resources (such as `SqlServer`) and Embedded DBs (such as `MockTexeraDB`). These tests pass when running a single test class but fail when run together with other test classes (e.g., `sbt test`). **Cause:** Each test class creates its own `EmbeddedPostgres` on a random port and replaces the `SqlServer` singleton. The problem occurs when resource classes store the database connection once and reuse it. Example: https://github.com/apache/texera/blob/850fd8517673626d62808487fa8994be5c1df906/amber/src/main/scala/org/apache/texera/web/resource/dashboard/user/workflow/WorkflowAccessResource.scala#L47-L49 When **Test Class A** runs first, this connection is initialized with Port A. When **Test Class A** finishes, its database shuts down. When **Test Class B** starts a new database on Port B, the saved connection still points to Port A (dead), causing "Connection refused" errors. **Solution:** Change so the connection is looked up fresh each time (dynamic lookup) instead of being cached. ### How to reproduce? Run any two test classes that use `MockTexeraDB`, where they accesses a resource that uses a cached context. ### Version 1.1.0-incubating (Pre-release/Master) ### Commit Hash (Optional) _No response_ ### What browsers are you seeing the problem on? _No response_ ### Relevant log output ```shell ``` -- 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]
