Skip to content

TEST - Add Data Contract ODCS tests - #25588

Merged
pmbrull merged 25 commits into
mainfrom
odcs-31-test
Feb 4, 2026
Merged

pmbrull merged 25 commits into
mainfrom
odcs-31-test

Conversation

@pmbrull

@pmbrull pmbrull commented Jan 28, 2026 •

Copy link
Copy Markdown
Member

Describe your changes:

  • Main change has been adding contract validation in the BE when importing OM contracts, not only ODCS.
  • Added specific column validations as well, checking duplicates and mismatching types
  • If the contract was to fail due to JSON Schema validations, now that's going to be part of the check. E.g., contract with a super long name that breaks JSON check of length <256
  • Added more BE and playwrights

example:
image

Type of change:

  • Bug fix
  • Improvement
  • New feature
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation

Checklist:

  • I have read the CONTRIBUTING document.
  • My PR title is Fixes <issue-number>: <short explanation>
  • I have commented on my code, particularly in hard-to-understand areas.
  • For JSON Schema changes: I updated the migration scripts or explained why it is not needed.

Summary by Gitar

  • New E2E tests:
    • ODCSImportExport.spec.ts covers ODCS import/export workflows, SLA editing, and markdown rendering
    • ODCSImportExportPermissions.spec.ts validates RBAC for Data Consumer, Data Steward, EditAll, ViewOnly, and table owner roles
  • Backend enhancements:
    • Added comprehensive validation logic with new contractValidation.json schema
    • Enhanced DataContractService, DataContractRepository, and DataContractResource with validation endpoints and type compatibility mapping
    • Implemented type normalization for ODCS imports (STRING→VARCHAR, INT→BIGINT, NUMBER→DOUBLE) to ensure compatibility
    • Added 11 edge case tests in DataContractResourceIT.java for large schemas, type mismatches, duplicate columns
  • Frontend improvements:
    • Enhanced ODCSImportModal with comprehensive validation UI showing entity/constraint/schema errors
    • Added TypeScript types for contract validation
  • Test fixtures:
    • Added 10+ ODCS YAML samples in dataContracts.ts including valid/invalid contracts and markdown descriptions

This will update automatically on new commits.


@github-actions

github-actions Bot commented Jan 28, 2026 •

Copy link
Copy Markdown
Contributor

Jest test Coverage

UI tests summary

Lines Statements Branches Functions
Coverage: 65%
65.87% (55656/84497) 45.02% (28822/64027) 47.81% (8760/18321)

When schema validation detects type mismatches (e.g., expected INT, got STRING),
the UI now shows these as warnings in the success panel instead of hiding them.
The chip displays "Passed with Warnings" with a warning color scheme, and
each type mismatch is listed with a warning icon.

Co-Authored-By: Claude Opus 4.5 <[email protected]>
pmbrull and others added 10 commits January 30, 2026 08:43
- Changed parseOpenMetadataContent to check for 'name' field instead of 'entity'
- Made parse error panel format-aware: shows ODCS required fields (APIVersion,
  Kind, Status) for ODCS imports, and OM required field (name) for OM imports
- Added translation key for OM format required fields error message

Co-Authored-By: Claude Opus 4.5 <[email protected]>
The ODCS schema defines the role identifier field as 'role', not 'name'.
Using 'name' caused the parser to set role to null, which made the
export default to 'data-consumer'. Fixed all role definitions in test
fixtures to use the correct 'role' field.

Co-Authored-By: Claude Opus 4.5 <[email protected]>
The test was expecting 'data-consumer' in the exported YAML, but the
input ODCS_VALID_FULL_YAML contains roles 'data_admin' and 'analyst'.
Updated assertion to check for 'analyst' which matches the input.

Co-Authored-By: Claude Opus 4.5 <[email protected]>
@gitar-bot

gitar-bot Bot commented Feb 4, 2026 •

Copy link
Copy Markdown
Code Review ✅ Approved 0 resolved / 2 findings

No changes to review - diff is empty. This PR appears to have been merged or there are no new changes since the last review. Previous findings cannot be verified without diff content.

💡 Edge Case: Test assertion allows validation error but doesn't verify behavior

📄 openmetadata-integration-tests/src/test/java/org/openmetadata/it/tests/DataContractResourceIT.java

In testImportODCSWithVeryLongContractName, the test catches an OpenMetadataException and only checks that the message contains certain keywords. However, the comment suggests this behavior is uncertain ("This should either succeed or throw an appropriate validation error").

For a robust test, consider:

  1. Documenting the expected behavior explicitly (should it succeed with truncation, or fail validation?)
  2. If validation should fail, assert the specific exception type and HTTP status code
  3. If it should succeed, verify the name is handled correctly (truncated or stored as-is)

The current approach makes it unclear what the intended behavior is and may mask actual bugs where the wrong exception type is thrown.

💡 Quality: Temp file cleanup could fail if test throws before unlink

📄 openmetadata-ui/src/main/resources/ui/playwright/e2e/Pages/ODCSImportExport.spec.ts

Multiple tests download YAML files to /tmp/ and use fsModule.unlinkSync(tempPath) for cleanup inside the try block. If any assertion fails between saveAs(tempPath) and unlinkSync(tempPath), the temp file will not be cleaned up.

Consider moving the cleanup to the finally block with a conditional check:

finally {
  try {
    if (tempPath && fsModule.existsSync(tempPath)) {
      fsModule.unlinkSync(tempPath);
    }
  } catch { /* ignore cleanup errors */ }
  await table.delete(apiContext);
}

This ensures temp files are always cleaned up even when tests fail. This pattern should be applied to all 3 affected tests: 'Import ODCS, modify via UI...', 'Import ODCS, update description...', and 'Import ODCS with SLA, modify SLA...'.

Options

Auto-apply is off → Gitar will not commit updates to this branch.
Display: compact → Showing less information.

Comment with these commands to change:

Auto-apply Compact
gitar auto-apply:on         
gitar display:verbose         

Was this helpful? React with 👍 / 👎 | Gitar

@github-actions

github-actions Bot commented Feb 4, 2026

Copy link
Copy Markdown
Contributor

Changes have been cherry-picked to the 1.12.0 branch.

@sonarqubecloud

sonarqubecloud Bot commented Feb 4, 2026

Copy link
Copy Markdown

This branch was previously deployed

1 inactive deployment
test — 527fc016 Deployed Feb 4, 2026 by pmbrull via playwright-ci-postgresql (6, 6) #33024
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 To release Will cherry-pick this PR into the release branch

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants