You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@texera.apache.org by "seongjinyoon (via GitHub)" <gi...@apache.org> on 2026/01/27 00:05:23 UTC
[I] Test Case Failure When Accessing Singleton Resource and Embedded DB [texera]
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: notifications-unsubscribe@texera.apache.org.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] Test Case Failure When Accessing Singleton Resource and Embedded DB [texera]
Posted by "Xiao-zhen-Liu (via GitHub)" <gi...@apache.org>.
Xiao-zhen-Liu commented on issue #4178:
URL: https://github.com/apache/texera/issues/4178#issuecomment-3808136469
The description is accurate. A related PR is #3782.
Also want to note for "How to reproduce?", currently there are no unit tests that will trigger this error because none of them access the singleton resources (e.g., `WorkflowAccessResource`.) Once you add such unit tests, the issue will appear.
--
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: notifications-unsubscribe@texera.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] Test Case Failure When Accessing Singleton Resource and Embedded DB [texera]
Posted by "seongjinyoon (via GitHub)" <gi...@apache.org>.
seongjinyoon commented on issue #4178:
URL: https://github.com/apache/texera/issues/4178#issuecomment-3802397714
@Xiao-zhen-Liu Please review the issue.
--
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: notifications-unsubscribe@texera.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] Test Case Failure When Accessing Singleton Resource and Embedded DB [texera]
Posted by "Xiao-zhen-Liu (via GitHub)" <gi...@apache.org>.
Xiao-zhen-Liu closed issue #4178: Test Case Failure When Accessing Singleton Resource and Embedded DB
URL: https://github.com/apache/texera/issues/4178
--
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: notifications-unsubscribe@texera.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org