Skip to content

MINOR - feat(dq): accept multiple testCaseStatus values on testCases/search/list - #31498

Merged
TeddyCr merged 3 commits into
open-metadata:mainfrom
TeddyCr:MINOR-DQSearch-List
Aug 14, 2026
Merged

TeddyCr merged 3 commits into
open-metadata:mainfrom
TeddyCr:MINOR-DQSearch-List

Conversation

@TeddyCr

@TeddyCr TeddyCr commented Aug 13, 2026

Copy link
Copy Markdown
Collaborator

Describe your changes:

Not applicable — MINOR change, no linked issue.

GET /api/v1/dataQuality/testCases/search/list bound testCaseStatus to a single String and built a single Elasticsearch term clause, so there was no way to ask for "Failed or Aborted" in one call — callers had to fire one request per status and merge/paginate the results client-side.

The parameter now accepts N values, matched as an OR:

Query Result
?testCaseStatus=Failed&testCaseStatus=Aborted Failed OR Aborted
?testCaseStatus=Failed,Aborted same
?testCaseStatus=failed,ABORTED same — matched case-insensitively, normalized to the canonical enum value
?testCaseStatus=Failed unchanged
?testCaseStatus=NotAStatus 400 — Invalid testCaseStatus 'NotAStatus'. Allowed values are [Success, Failed, Aborted, Queued]

Statuses OR each other; the status filter still ANDs with every other filter (testCaseType, entityLink, tags, …).

Type of change:

  • Improvement

High-level design:

Small change (2 main classes, 4 files), but it touches an API contract, so briefly:

  • Validation at the edge, not in the filter. TestCaseResource.validateTestCaseStatuses splits repeated params on commas, trims, de-duplicates, and resolves each value case-insensitively to a TestCaseStatus constant before handing a normalized comma-separated string down. Unknown values raise IllegalArgumentException, which CatalogGenericExceptionMapper already maps to a 400. SearchListFilter therefore stays a dumb query builder and the Elasticsearch terms clause always receives exact keyword values — no case_insensitive flag or index-side normalizer required.
  • term → terms. SearchListFilter.getTestCaseStatusCondition emits {"terms": {"testCaseResult.testCaseStatus": [...]}}. terms is an OR by definition and is equivalent to term for a single value, so single-status callers see no change.
  • Backward compatible. Existing clients — including the UI, which still sends one status — are unaffected. Two edge behaviors improve: testCaseStatus=failed used to be accepted and silently match nothing (the ES keyword field is case-sensitive) and now returns the Failed test cases; an unknown status used to return an empty list and now returns an actionable 400.
  • Deliberately not changed: the DB-backed GET /dataQuality/testCases list endpoint still takes a single status (status = :testCaseStatus in ListFilter), and the UI still sends one value. Both are straightforward follow-ups if wanted.

Tests:

Use cases covered

  • Filtering DQ test cases on several statuses at once via repeated query params (?testCaseStatus=Failed&testCaseStatus=Aborted)
  • The same filter expressed as a comma-separated value
  • The same filter in any casing (failed, ABORTED)
  • A single status keeps its existing behavior (regression)
  • An unknown status is rejected with a 400 naming the offending value and the allowed set
  • Blank/empty values are ignored rather than producing an impossible filter

Unit tests

  • I added unit tests for the new/changed logic.
  • File updated: openmetadata-service/src/test/java/org/openmetadata/service/jdbi3/SearchListFilterTest.java
    • added testMultipleTestCaseStatusesAreMatchedAsOr and testBlankTestCaseStatusesAreIgnored
    • updated testComplexGetCondition and testTestCaseConditionBuildsAllEntitySpecificFilters for the term → terms shape
  • mvn test -pl openmetadata-service -Dtest=SearchListFilterTest → 29/29 pass
  • Coverage (JaCoCo, mvn -Pstatic-code-analysis test -pl openmetadata-service -Dtest=SearchListFilterTest jacoco:report): 96% line coverage on SearchListFilter.java (253/263 lines) from this test class alone. TestCaseResource.java reports 0% here because it is a JAX-RS resource exercised by the integration tests below, not by unit tests.
  • RED-checked: reverting only the getTestCaseStatusCondition call makes 4 of the 29 fail — the old code built {"term": {…: "Failed,Aborted"}}, a term that matches nothing.

Backend integration tests

  • I added integration tests in openmetadata-integration-tests/ for the changed endpoint.
  • File updated: openmetadata-integration-tests/src/test/java/org/openmetadata/it/tests/TestCaseResourceIT.java
    • test_searchListByMultipleTestCaseStatuses_matchesAnyOfThem — creates three test cases on one table (Failed / Aborted / Success) and asserts the repeated-param, comma-separated, and lowercase forms all return the Failed + Aborted ones and exclude the Success one, and that a single status still narrows to that status
    • test_searchListByUnknownTestCaseStatus_returnsBadRequest — asserts a 400 (InvalidRequestException) naming the bad value
  • Run against real Postgres + Elasticsearch containers → 2/2 pass

Ingestion integration tests

  • Not applicable (no ingestion changes).

Playwright (UI) tests

  • Not applicable (no UI changes).

Manual testing performed

Verification was automated against real Postgres + Elasticsearch (the ITs above) rather than a hand-driven stack. To reproduce by hand on a local stack:

./docker/run_local_docker.sh -m ui -d mysql -s false -i true -r true
export OM=http://localhost:8585
export TOKEN=$(curl -s -X POST $OM/api/v1/users/login -H 'Content-Type: application/json' \
  -d "{\"email\":\"[email protected]\",\"password\":\"$(printf 'admin' | base64)\"}" | jq -r .accessToken)
tot() { curl -s -H "Authorization: Bearer $TOKEN" \
  "$OM/api/v1/dataQuality/testCases/search/list?limit=1&$1" | jq .paging.total; }

tot "testCaseStatus=Failed"                          # a
tot "testCaseStatus=Aborted"                         # b
tot "testCaseStatus=Failed&testCaseStatus=Aborted"   # must equal a + b (OR, not AND)
tot "testCaseStatus=Failed,Aborted"                  # same
tot "testCaseStatus=failed,aborted"                  # same (case-insensitive)

# contents, not just counts — must contain Failed and Aborted, never Success
curl -s -H "Authorization: Bearer $TOKEN" \
  "$OM/api/v1/dataQuality/testCases/search/list?limit=1000&testCaseStatus=Failed&testCaseStatus=Aborted" \
  | jq -r '.data[].testCaseResult.testCaseStatus' | sort | uniq -c

# 400 with an actionable message
curl -s -H "Authorization: Bearer $TOKEN" \
  "$OM/api/v1/dataQuality/testCases/search/list?testCaseStatus=NotAStatus" | jq -r .message

The Data Quality page (which still sends a single status) continues to filter correctly.

UI screen recording / screenshots:

Not applicable — backend only.

Checklist:

  • I have read the CONTRIBUTING document.
  • My PR title is Fixes <issue-number>: <short explanation> — N/A, MINOR change with no linked issue
  • My PR is linked to a GitHub issue via Fixes #<issue-number> above — N/A, MINOR change
  • I have commented on my code, particularly in hard-to-understand areas.
  • For JSON Schema changes: N/A — no schema changes, the TestCaseStatus enum is used as-is.
  • For UI changes: N/A — no UI changes.
  • I have added tests (unit / integration / Playwright as applicable) and listed them above.

Improvement:

  • I have added tests around the new logic.
  • For connector/ingestion changes: N/A — no connector or ingestion changes.

…search/list

`GET /v1/dataQuality/testCases/search/list` bound `testCaseStatus` to a single
String and built a single Elasticsearch `term` clause, so filtering on more than
one status was impossible. The parameter is now a `List<String>` that accepts
repeated params and/or comma separated values, is validated case-insensitively
against the `TestCaseStatus` enum, and is turned into a `terms` clause so the
statuses match as an OR.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
@TeddyCr
TeddyCr requested a review from a team as a code owner August 13, 2026 20:37
Copilot AI lite review requested due to automatic review settings August 13, 2026 20:37
@github-actions

Copy link
Copy Markdown
Contributor

❌ PR checklist incomplete

This PR cannot be merged until the following are addressed on its linked issue:

  • No GitHub issue is linked. Link an issue in the Development section of the PR (or add Fixes #12345 to the description). For a same-org cross-repo issue, add Fixes open-metadata/<repo>#123 to the description.

The fields live on the linked issue in the Shipping project (open the issue → right sidebar → Projects). After you set them, re-run this check (or push a commit) — issue/project changes do not re-trigger it automatically.

Maintainers can bypass this check by adding the skip-pr-checks label.

@github-actions github-actions Bot added Ingestion safe to test Add this label to run secure Github workflows on PRs labels Aug 13, 2026
@gitar-bot

gitar-bot Bot commented Aug 13, 2026

Copy link
Copy Markdown
Code Review ✅ Approved

Updates the testCaseStatus parameter on the data quality test case search endpoint to accept multiple comma-separated or repeated values, enabling case-insensitive OR filtering with edge validation. No issues found.

Options

Display: compact → Showing less information.

Comment with these commands to change the behavior for this request:

Compact
gitar display:verbose         

Was this helpful? React with 👍 / 👎 | Powered by Gitar — free for open source

@TeddyCr TeddyCr added the skip-pr-checks Bypass PR metadata validation check label Aug 13, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the Elasticsearch-backed Data Quality test case search endpoint (GET /api/v1/dataQuality/testCases/search/list) to support filtering by multiple testCaseStatus values in a single request, improving client efficiency and making status filtering case-insensitive with proper validation at the resource layer.

Changes:

  • Extend testCaseStatus query param handling to accept repeated and/or comma-separated values, normalize them case-insensitively to canonical TestCaseStatus values, and reject unknown statuses with a 400.
  • Update the ES query builder to emit a terms filter for testCaseResult.testCaseStatus (OR semantics) instead of a single term.
  • Add/adjust unit and integration tests to cover multi-status filtering, blank handling, and invalid status behavior.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.

File Description
openmetadata-service/src/main/java/org/openmetadata/service/resources/dqtests/TestCaseResource.java Accept testCaseStatus as a list, validate/normalize values, and pass the normalized status set into the search filter.
openmetadata-service/src/main/java/org/openmetadata/service/search/SearchListFilter.java Build the test-case status filter using an ES terms clause (OR) while preserving single-status behavior.
openmetadata-service/src/test/java/org/openmetadata/service/jdbi3/SearchListFilterTest.java Update expected query shapes for term → terms and add unit coverage for multi-status and blank status inputs.
openmetadata-integration-tests/src/test/java/org/openmetadata/it/tests/TestCaseResourceIT.java Add integration coverage for repeated/comma-separated/case-insensitive multi-status filtering and for unknown-status 400 behavior.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Copilot AI review requested due to automatic review settings August 14, 2026 04:27
@github-actions github-actions Bot added safe to test Add this label to run secure Github workflows on PRs and removed safe to test Add this label to run secure Github workflows on PRs labels Aug 14, 2026
Copilot AI review requested due to automatic review settings August 14, 2026 05:35
@github-actions github-actions Bot added safe to test Add this label to run secure Github workflows on PRs and removed safe to test Add this label to run secure Github workflows on PRs labels Aug 14, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated no new comments.

@sonarqubecloud

Copy link
Copy Markdown

Merged via the queue into open-metadata:main with commit 5722dfe Aug 14, 2026
143 of 150 checks passed
@TeddyCr
TeddyCr deleted the MINOR-DQSearch-List branch August 14, 2026 16:53
ShaileshParmar11 added a commit that referenced this pull request Aug 20, 2026
…search/list (#31498) (#31831)

`GET /v1/dataQuality/testCases/search/list` bound `testCaseStatus` to a single
String and built a single Elasticsearch `term` clause, so filtering on more than
one status was impossible. The parameter is now a `List<String>` that accepts
repeated params and/or comma separated values, is validated case-insensitively
against the `TestCaseStatus` enum, and is turned into a `terms` clause so the
statuses match as an OR.



(cherry picked from commit 5722dfe)

Co-authored-by: Teddy <[email protected]>
Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
Co-authored-by: Sriharsha Chintalapani <[email protected]>

This branch was previously deployed

1 inactive deployment
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Ingestion safe to test Add this label to run secure Github workflows on PRs skip-pr-checks Bypass PR metadata validation check

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants