You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Test Case Failure When Accessing Singleton Resource and Embedded DB #4178
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.
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
Cause: org.postgresql.util.PSQLException: Connection to localhost:52153 refused. Check that the hostname and port are correct and that the postmaster is accepting TCP/IP connections.
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.
Activity
seongjinyoon commentedon Jan 27, 2026
@Xiao-zhen-Liu Please review the issue.
Xiao-zhen-Liu commentedon Jan 27, 2026
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.fix(backend): use dynamic DSLContext lookup to fix stale DB connectio…
fix(backend): use dynamic DSLContext lookup to fix stale DB connectio…
fix(backend): use dynamic DSLContext lookup to fix stale DB connectio…
fix(backend): use dynamic DSLContext lookup to fix stale DB connectio…