The GitHub Actions job "Required Checks" on 
texera.git/gh-readonly-queue/main/pr-6722-d444fe0fc9beec61db17033d4c600a9677fd31db
 has failed.
Run started by GitHub user aglinxinyuan (triggered by aglinxinyuan).

Head commit for run:
50682cdb14772ccb2575eae9913c42d465e2d7e8 / Eugene Gu <[email protected]>
test(workflow-operator): add unit test coverage for AsterixDBConnUtil (#6722)

### What changes were proposed in this PR?

Add `AsterixDBConnUtilSpec`, unit test coverage for `AsterixDBConnUtil`
— the HTTP-based connection utility behind the AsterixDB source
operator. It previously had no tests.

Since the utility talks plain HTTP via Unirest, the spec exercises it
end-to-end against an in-process JDK `HttpServer` stub standing in for
an AsterixDB instance (the same pattern as `LiteLLMProxyAuthSpec`; no
new dependencies, no production-code changes). The stub serves the two
endpoints the utility touches: `/admin/version` with a hit counter and
configurable status/body, and `/query/service` with a swappable
statement-based responder that records every decoded form field, which
is what makes cache reuse and the outgoing `format` field observable.

The 32 characterization tests cover: per-host version-cache population
and reuse (`/admin/version` probed exactly once per host, pre-seeded
entries skip the probe); the version-dependent `format` field (`"csv"`
for 0.9.5 vs `"text/csv"` otherwise, pinned as an exact-equality check,
including caller-supplied formats); the `results` iterator on HTTP 200
and the strict `== 200` status check (201/204 are routed to the error
path); the non-200 `RuntimeException` embedding status and body, plus
the current failure modes for malformed responses (a bare NPE on a
non-JSON body due to Unirest's null body on parse failure, and a
`JSONException` on a 200 body without `results`);
`updateAsterixDBVersionMapping`'s status-only tolerance (silent on
non-200, throws on a 200 with an unexpected body shape); and
`fetchDataTypeFields` recursive flattening (dot-prefixed parent naming,
two-level nesting, empty-metadata tolerance, silent drop of nested
fields with missing child metadata, the exact `Try` tolerance boundary
where a field row missing `FieldType` escapes uncaught, the
case-sensitive `contains("type")` recursion heuristic, and
first-row-only consumption of multi-row results). The statement form
field is also verified to round-trip special characters and non-ASCII
text intact.

The mutable singleton version cache is reset before each test and
cleared after the suite. Tests pin current behavior, including the
`NoSuchElementException` thrown when the version probe fails before a
query; behavior changes to those failure modes belong in follow-up fixes
that flip the corresponding pins.

### Any related issues, documentation, discussions?

Closes #6721.

### How was this PR tested?

This PR only adds tests. `sbt "WorkflowOperator/testOnly *ConnUtilSpec"`
runs all three ConnUtil suites: 44 tests, all passing (AsterixDB 32 +
MySQL 8 + PostgreSQL 4). `sbt "WorkflowOperator/Test/scalafmtCheck"`
passes. Exception types asserted for the malformed-response cases were
first observed against the real Unirest behavior, then pinned.

### Was this PR authored or co-authored using generative AI tooling?

Co-authored by: Claude Code

---------

Signed-off-by: Xinyuan Lin <[email protected]>
Co-authored-by: Xinyuan Lin <[email protected]>
Co-authored-by: Copilot Autofix powered by AI 
<[email protected]>

Report URL: https://github.com/apache/texera/actions/runs/29881040418

With regards,
GitHub Actions via GitBox

Reply via email to