You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@texera.apache.org by "aglinxinyuan (via GitHub)" <gi...@apache.org> on 2026/06/13 23:10:27 UTC
[I] add unit test coverage for PostgreSQLConnUtil and MySQLConnUtil [texera]
aglinxinyuan opened a new issue, #5695:
URL: https://github.com/apache/texera/issues/5695
### Task Summary
Add dedicated unit-specs for the two JDBC connection helpers in `common/workflow-operator/operator/source/sql/{postgresql,mysql}/`. Pin the JDBC URL composition (the only application-controlled logic in each method) without standing up a real DB.
## Background
Two thin JDBC wrappers in `common/workflow-operator/operator/source/sql/` currently lack a dedicated unit-spec. Each `connect(host, port, database, username, password)` method builds a JDBC URL string, calls `DriverManager.getConnection`, and flips the resulting Connection to read-only:
| Source class | URL format |
| --- | --- |
| `PostgreSQLConnUtil` | `jdbc:postgresql://{host}:{port}/{database}` |
| `MySQLConnUtil` | `jdbc:mysql://{host}:{port}/{database}?autoReconnect=true&useSSL=true` |
The URL string is application-logic worth pinning; an accidental edit (e.g. dropping `useSSL=true` from MySQL) would silently change connection security. The actual `DriverManager.getConnection` call needs no DB — when the host is unreachable, it throws `SQLException` early, and the URL has already been built and visible inside the exception.
## Behavior to pin
For each `connect` method:
| Surface | Contract |
| --- | --- |
| Invocation with a bogus host (e.g. `"unreachable.example.invalid"`) | throws `SQLException` (no driver class is loaded for `jdbc:postgresql://…` / `jdbc:mysql://…` in the unit-test classpath, or the driver throws "no suitable driver") |
| `PostgreSQLConnUtil.connect("h", "5432", "db", "u", "p")` | the SQLException's message or the constructed URL contains the substring `jdbc:postgresql://h:5432/db` |
| `MySQLConnUtil.connect("h", "3306", "db", "u", "p")` | the constructed URL substring includes `jdbc:mysql://h:3306/db`, `autoReconnect=true`, AND `useSSL=true` |
| Distinct host/port/database values | are interpolated into the right positions (e.g. swapping `host` and `database` produces a different URL) |
| Empty database name | does not crash the URL builder (the resulting URL `jdbc:postgresql://h:5432/` is still well-formed even if rejected by the driver) |
## Scope
- New spec files (one per source class):
- `PostgreSQLConnUtilSpec.scala`
- `MySQLConnUtilSpec.scala`
- No production-code changes.
- The harness uses `intercept[SQLException]` (or `RuntimeException` for `ClassNotFoundException` cases) and asserts on the *URL substring* visible in the exception message — the URL has already been built before the connection failure, so the substring is reachable.
- If the URL substring is not in the exception, consider registering a dummy `Driver` via `DriverManager.registerDriver` that captures the URL it was asked to open and throws — that gives the test full control without touching network.
### Task Type
- [ ] Refactor / Cleanup
- [ ] DevOps / Deployment / CI
- [x] Testing / QA
- [ ] Documentation
- [ ] Performance
- [ ] Other
--
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] add unit test coverage for PostgreSQLConnUtil and MySQLConnUtil [texera]
Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on issue #5695:
URL: https://github.com/apache/texera/issues/5695#issuecomment-4700068073
<!-- texera:template-compliance -->
👋 Thanks for opening this issue, @aglinxinyuan!
It looks like the issue description doesn't quite follow our template yet:
- This issue doesn't appear to use one of our templates (Bug, Feature, or Task). Please open it using a template so the required details are captured.
Filling out the template helps reviewers understand and triage your contribution faster. Please edit the description to complete it. This message will disappear automatically once the template is followed.
You can find the template prompts by editing the description, or see [CONTRIBUTING.md](https://github.com/apache/texera/blob/main/CONTRIBUTING.md) for the full contribution flow.
--
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] add unit test coverage for PostgreSQLConnUtil and MySQLConnUtil [texera]
Posted by "aglinxinyuan (via GitHub)" <gi...@apache.org>.
aglinxinyuan closed issue #5695: add unit test coverage for PostgreSQLConnUtil and MySQLConnUtil
URL: https://github.com/apache/texera/issues/5695
--
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