Skip to content

Fixes 5970: migrate Oracle CLI E2E to v2 and fix the foreign-key bug it found - #34302

Merged
Khairajani merged 8 commits into
mainfrom
feat/cli-e2e-v2-oracle
Oct 1, 2026
Merged

Khairajani merged 8 commits into
mainfrom
feat/cli-e2e-v2-oracle

Conversation

@Khairajani

@Khairajani Khairajani commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

Describe your changes:

Fixes open-metadata/openmetadata-collate#5970

Migrates the Oracle CLI E2E coverage to the v2 framework from #27949, and fixes a connector bug that the migration exposed.

The v1 test (cli_e2e/test_cli_oracle.py) and its py-cli-e2e-tests.yml matrix entry are unchanged and keep running, per the stability-window rule the MySQL and BigQuery migrations followed.

Type of change:

  • Bug fix
  • Improvement

High-level design:

1. Bug: every Oracle foreign key was silently dropped

Two Oracle code paths disagreed about identifier case:

Path Reports Result
get_table_names CUSTOMERS (dictionary name, verbatim) Table entity created as …schema.CUSTOMERS
get_foreign_keys customers (via normalize_name) FK points at …schema.customers

common_db_source._get_foreign_constraints looks the referred table up by exact FQN, so it never matched. The constraint was discarded with no error, no warning, and a reported 100% workflow success — tableConstraints came back empty for every Oracle table.

The fix is one line: report referred_table in the same case get_table_names uses.

remote_table = row[3]

get_table_names returns row[0] as stored, so taking row[3] as stored matches it by construction — in both identifier modes, and for tables created with quoted lowercase or mixed-case names.

test_oracle_constraint_reflection.py asserted the normalised referred_table and so pinned the behaviour this fixes; its expectation is updated. That is the only pre-existing assertion this PR changes.

No FQN changes. Table names are untouched, so no entity is renamed, no curated metadata is orphaned, and no migration or reindex is needed. Fixing the mismatch from the other side — normalising table names — would have renamed every existing Oracle table and is deliberately not done here.

test_oracle_foreign_key_case.py covers this in PR CI, parametrised over both identifier modes. It fails against the unfixed implementation.

2. Oracle v2 E2E suite

ingestion/tests/cli_e2e_v2/oracle/ follows the mysql/ and postgres/ references and covers everything the v1 Oracle path actually exercises: catalog equality under strict inventory matching, stored-procedure bodies, foreign keys, mark-deleted, repeat-ingest UUID stability, profiler metrics, view lineage, PII classification, sample values (original, updated, replacement), six filter scenarios including exclude precedence at table and schema level, and fixture safety.

The v1 tests not carried over exercise nothing: test_usage has an empty body, test_schema_filter_excludes is a bare pass, and test_profiler_with_time_partition and test_data_quality both guard themselves off because Oracle defines no hook for them.

Three things differ from the MySQL reference, all forced by Oracle:

  • The source is owned by the fixture via testcontainers (gvenzl/oracle-free, digest-pinned), so the E2E_ORACLE_* CI secrets v1 needed are no longer required.
  • A schema is a user, so each test creates one and drops it CASCADE.
  • Every invocation is schema-scoped. The connector reads the DBA_ dictionary views, and oracleConnectionType takes a service name or a databaseSchema but never both — so unlike MySQL there is no connection-level scope to lean on.

expected.py encodes OM's real naming rather than an idealised one: database default, schema lowercase, tables and procedures UPPERCASE, views and columns lowercase. The table/view split is pre-existing and costs users nothing, so this PR does not "fix" it.

error.containment is declared unsupported in the connector inventory with its reason: Oracle keeps dictionary metadata for invalid views, so the reference induction produces no ingestion error. Verified that neither dropping a selected column nor dropping the base table makes a view fail reflection.

Tests:

23 E2E tests against a real Oracle, green on two cold-container runs. 58 Oracle unit tests in PR CI, including test_oracle_foreign_key_case.py, which fails against the unfixed implementation. Rebased on main after #33946; the README follows the per-connector layout that PR introduced.

🤖 Generated with Claude Code

Adds ingestion/tests/cli_e2e_v2/oracle/ following the mysql reference, and
enables oracle in the v2 CI matrix and the Validate connector allowlist.

Coverage: catalog equality under STRICT inventory matching (tables, views,
columns, types, descriptions, procedures), stored-procedure bodies, foreign
keys, mark-deleted on re-ingest, repeat-ingest UUID stability, and three
filter scenarios. 8 contracts, all passing against a real Oracle in ~3min.

The source is owned by the fixture via testcontainers (gvenzl/oracle-free,
digest-pinned), so the E2E_ORACLE_* CI secrets the v1 path needed are no
longer required. A schema is an Oracle user, so each test creates one and
drops it CASCADE. Every invocation is schema-scoped by default: the connector
reads the DBA_ dictionary views, and oracleConnectionType accepts a service
name or a databaseSchema but never both, so there is no connection-level
scope to lean on as there is for MySQL.

Fixes a bug the migration surfaced: get_table_names was the only Oracle
object path not applying normalize_name, while get_view_names_dialect,
get_mview_names_dialect, get_columns and get_foreign_keys all do. Tables were
therefore ingested with the dictionary's uppercase name while the FK
reflection reported referred_table in lowercase. The two never matched, so
tableConstraints came back empty for every Oracle table and foreign keys were
lost with no error, no warning and a reported 100% workflow success.

This changes Oracle table FQNs from schema.TABLE to schema.table. Existing
Oracle deployments will need to reindex, and the release notes should call it
out. Stored procedure names are still uppercase, because that path reads the
dictionary directly; it is not implicated in the foreign-key bug and is left
for a follow-up rather than widening this change.

error.containment is declared unsupported in the connector inventory with its
reason: Oracle retains dictionary metadata for invalid views, so the reference
induction produces no ingestion error. Verified live that neither dropping a
selected column nor dropping the base table makes a view fail reflection.

The v1 path in ingestion/tests/cli_e2e/test_cli_oracle.py is retained; it
should be removed only after the v2 suite has been green for the agreed
stability window.
Mirrors mysql/test_fixture_safety.py for the parts that apply to Oracle.
DROP USER ... CASCADE is the most destructive statement in this suite and is
built by interpolating a generated identifier, so it is worth pinning that it
removes exactly what it owns.

Covers: a source mutates and drops only its own schema while a live sibling is
untouched by its teardown; cross-schema names are not addressable through the
owned-source API; the ingestion account can read the seeded data and the DBA_
dictionary but cannot update or drop; a workflow cannot be built against an
environment that is not the fixture's own instance, an empty source tuple or a
closed source; a failure partway through setup leaves no Oracle user behind;
and neither the instance nor the source repr carries a password or a
connection URL.

The seed-failure case compares the dba_users set before and after rather than
a captured schema name: the failure is raised inside __enter__, so the context
body never runs and no name is handed out. The set comparison is also the
stronger assertion, catching a leaked user under any name.

Also documents that an OSS checkout cannot be put first on PYTHONPATH when the
virtualenv holds a Collate build, whose metadata entry point (collate_cmd)
does not exist in the OSS tree. Shadowing it makes every CLI invocation die at
import before writing a status file, which surfaces as "CLI status is missing
or malformed" rather than an import error.

Verified by two full live runs from cold containers, 13 passed each, with no
leftover containers.
OracleConnection defaults supportsProfiler and supportsLineageExtraction to
true, but this slice declares no profile.* or lineage.* contract. Listing
those capabilities is inert, since capabilities only gate `unsupported`
entries, and reads as a coverage claim the suite does not make. They belong
here alongside their contracts.
@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

Copy link
Copy Markdown
Contributor

Hi there 👋 Thanks for your contribution!

The OpenMetadata team will review the PR shortly! Once it has been labeled as safe to test, the CI workflows
will start executing and we'll be able to make sure everything is working as expected.

Let us know if you need any help!

@github-actions

github-actions Bot commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

✅ Playwright Results — workflow succeeded

Validated commit 60ac99720f569b041c66b9b4a089fddb697447c6 in Playwright run 36845647525, attempt 1.

✅ 615 passed · ❌ 0 failed · 🟡 0 flaky · ⏭️ 0 skipped · 🧰 0 lifecycle flaky

Performance

Blocking targets: ✅ met · Optimization targets: 🟡 in progress

Shard-job maxima below are not the full workflow wall time; the linked run includes build, fixture, planning, and reporting.

🕒 Full workflow signal wall (to summary) 49m 0s

⏱️ Max setup 4m 42s · max shard execution 16m 22s · max shard-job elapsed before upload 20m 38s · reporting 4s

🌐 248.98 requests/attempt · 2.22 app boots/UI scenario · 34.11% common-shard skew

Optimization targets still in progress:

  • Common shard skew was 34.11% (convergence target: at most 15%).
  • Browser traffic was 248.98 requests per attempt (convergence target: fewer than 200).
  • Application boot ratio was 2.22 per UI scenario (1426 boots / 643 scenarios; convergence target: at most 1).
Shard Passed Failed Flaky Skipped Lifecycle failed Lifecycle flaky
✅ Shard chromium-01 127 0 0 0 0 0
✅ Shard chromium-02 139 0 0 0 0 0
✅ Shard chromium-03 127 0 0 0 0 0
✅ Shard data-asset-rules-01 65 0 0 0 0 0
✅ Shard domain-isolation-01 16 0 0 0 0 0
✅ Shard global-state-01 34 0 0 0 0 0
✅ Shard ingestion-01 28 0 0 0 0 0
✅ Shard ingestion-02 37 0 0 0 0 0
✅ Shard reindex-01 2 0 0 0 0 0
✅ Shard search-01 11 0 0 0 0 0
✅ Shard search-rbac-01 29 0 0 0 0 0

📦 Download artifacts

How to debug locally
# Download playwright-test-results-<shard> artifact and unzip
npx playwright show-trace path/to/trace.zip    # view trace

… fix

Closes the gap between the v2 Oracle suite and what the v1 path actually
exercises, so the migration replaces v1 rather than reducing it.

Adds profiler metrics, view lineage (table and column level), PII
auto-classification with negative assertions, persisted sample values and
their replacement on re-ingest, and the include+exclude filter mix. Together
with the existing cases, every v1 Oracle behaviour that exercises something is
now covered. The v1 tests that remain uncovered exercise nothing: test_usage
has an empty body, test_schema_filter_excludes is a bare pass, and
test_profiler_with_time_partition and test_data_quality both guard themselves
off because Oracle defines no hook for them.

Profiling samples the full table rather than v1's profileSample=1 workaround,
which existed because v1 ran against a shared instance where sampling did not
reliably reach the seeded rows. An owned source with a declared baseline is
small enough to profile whole.

Two fixes for the retained v1 path and for CI coverage of the connector change:

- test_cli_oracle.py expected e2e_oracle.default.admin.ADMIN_EMP. Now that
  get_table_names normalises, the table is stored as admin_emp, and the base
  class uses that FQN for lineage, sample data, profile and the mark-deleted
  assertion, so the v1 suite this PR keeps would have started failing. The
  ADMIN_EMP include filter still matches because filter patterns compile with
  re.IGNORECASE.
- test_oracle_table_name_normalization.py covers get_table_names in PR CI,
  which the v2 E2E suite cannot do while py-cli-e2e-tests-v2.yml is
  workflow_dispatch only. It pins both identifier-case modes and the pairing
  with get_foreign_keys' referred_table, and fails against the unnormalised
  implementation.

19 E2E tests pass against a real Oracle; 56 Oracle unit tests pass.
@github-actions

Copy link
Copy Markdown
Contributor

Hi there 👋 Thanks for your contribution!

The OpenMetadata team will review the PR shortly! Once it has been labeled as safe to test, the CI workflows
will start executing and we'll be able to make sure everything is working as expected.

Let us know if you need any help!

Replaces the previous approach of normalising table names, which fixed the
same bug but renamed every existing Oracle table's FQN.

get_table_names returns the data dictionary name verbatim, so a table is
stored as schema.CUSTOMERS, while get_foreign_keys reported referred_table
through normalize_name as customers. common_db_source looks the referred table
up by exact FQN, so it never matched: the constraint was discarded with no
error, no warning and a reported 100% workflow success, leaving
tableConstraints empty for every Oracle table.

Reporting referred_table in the same case get_table_names uses fixes the
mismatch without moving any FQN, so nothing is renamed, no curated metadata is
orphaned and no migration or reindex is needed. denormalize_name is the
inverse of normalize_name and is rebound to identity under
preserveIdentifierCase, so both identifier modes stay consistent.

test_cli_oracle.py is left untouched as a result, and the v2 expectations
encode OM's real naming: tables and procedures uppercase, views and columns
lowercase. That split is pre-existing and costs users nothing.

Sample tests scope their filter with an uppercase pattern: the metadata
pipeline matches tableFilterPattern case-insensitively but the
auto-classification path does not, so a lowercase pattern selects nothing and
no sample data is written.
# Conflicts:
#	ingestion/tests/cli_e2e_v2/README.md
@github-actions

Copy link
Copy Markdown
Contributor

Hi there 👋 Thanks for your contribution!

The OpenMetadata team will review the PR shortly! Once it has been labeled as safe to test, the CI workflows
will start executing and we'll be able to make sure everything is working as expected.

Let us know if you need any help!

# Conflicts:
#	.github/workflows/py-cli-e2e-tests-v2.yml
#	ingestion/tests/cli_e2e_v2/README.md
@gitar-bot

gitar-bot Bot commented Oct 1, 2026

Copy link
Copy Markdown
Code Review ✅ Approved 4 closed / 4 findings

🟡 Medium risk · Oracle ingestion now preserves previously dropped foreign-key relationships in metadata.

Migrates Oracle CLI E2E to v2 framework and fixes a connector bug where foreign keys were silently dropped due to identifier case mismatch between get_table_names and get_foreign_keys. The fix reports referred_table verbatim to match table name case, restoring constraint discovery without renaming entities. Comprehensive v2 test suite covers 23 scenarios including foreign keys, stored procedures, filtering, and profiler metrics against a real Oracle instance.

✅ 4 closed
✅ Bug: Retained v1 Oracle E2E still expects uppercase ADMIN_EMP FQN

📄 ingestion/src/metadata/ingestion/source/database/oracle/utils.py:379
The PR keeps cli_e2e/test_cli_oracle.py and its py-cli-e2e-tests.yml matrix entry running for the stability window. That test still hardcodes fqn_created_table()/_fqn_deleted_table() as e2e_oracle.default.admin.ADMIN_EMP. Once get_table_names normalises names, the table is stored as admin_emp. The base class uses that FQN in retrieve_lineage, retrieve_sample_data, retrieve_profile and the mark-deleted assertion, so the v1 suite you are keeping will start failing. Change the v1 expectations to admin_emp in this PR. The ADMIN_EMP table include filter still works because filters use re.IGNORECASE.

✅ Quality: Connector fix has no unit test that runs in PR CI

📄 ingestion/src/metadata/ingestion/source/database/oracle/utils.py:379 📄 .github/workflows/py-cli-e2e-tests-v2.yml:24-30
The only coverage for the get_table_names normalisation is the new v2 E2E suite. py-cli-e2e-tests-v2.yml only runs on workflow_dispatch, and no Oracle unit test calls get_table_names. A later revert of self.normalize_name(row[0]) would bring back the silent FK drop without any PR check failing. Add a pytest unit test with a mocked cursor. It should check that get_table_names returns lowercased names by default and verbatim names when the preserve-case normalize_name is bound.

✅ Edge Case: FQN case change orphans curated metadata; a reindex won't fix it

📄 ingestion/src/metadata/ingestion/source/database/oracle/utils.py:374-379
Tables are now emitted as schema.table instead of schema.TABLE, so OM gets a new FQN (and new fqnHash) for every existing Oracle table. On the next run with markDeletedTables, the old uppercase entities get soft-deleted and new empty ones are created. Their descriptions, tags, owners, glossary terms, lineage, data-quality test cases and profiles stay on the deleted entities. The PR description says a search reindex is the remedy, but a reindex only rebuilds the search index and does not move entity data. Ship a server/data migration that renames existing Oracle table FQNs to lowercase. If that isn't possible, gate the new behaviour behind a flag and document it as a breaking change with the metadata-loss impact.

✅ Edge Case: Round-trip uppercases quoted lowercase tables, breaking their FKs

📄 ingestion/src/metadata/ingestion/source/database/oracle/utils.py:538
denormalize_name(normalize_name(x)) does not always give back x. Take a table created with a quoted lowercase name such as "customers". The dictionary stores it as customers and get_table_names returns customers unchanged. SQLAlchemy's normalize_name turns it into quoted_name('customers', quote=True). denormalize_name does not look at the quote flag: it only sees an all-lowercase name that needs no quoting, so it uppercases it to CUSTOMERS. The FK then points at schema.CUSTOMERS, which does not exist, and the exact-FQN lookup drops it silently. That is the same bug this PR fixes. It is also a regression: the old normalize_name(row[3]) returned customers and matched. get_table_names returns row[0] as stored, so the fix is to pass the dictionary value through as-is in both identifier modes. It would help to add a unit-test case with a lowercase quoted referred table.

Review coverage

📋 Rules No rules evaluated

🧪 Functional validation Not enabled · Set up

🤖 Auto-approval Not enabled · Set up

Options

Display: compact → Counting what did not apply, without listing it.

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

@sonarqubecloud

sonarqubecloud Bot commented Oct 1, 2026

Copy link
Copy Markdown

@Khairajani
Khairajani enabled auto-merge October 1, 2026 11:22
@Khairajani
Khairajani added this pull request to the merge queue Oct 1, 2026
Merged via the queue into main with commit 3b1c13f Oct 1, 2026
131 of 133 checks passed
@Khairajani
Khairajani deleted the feat/cli-e2e-v2-oracle branch October 1, 2026 15:06
Khairajani added a commit that referenced this pull request Oct 6, 2026
Backport of #34302 to 2.0, connector fix and unit tests only.

get_table_names returns the data dictionary name verbatim, so a table is
stored as schema.CUSTOMERS, while get_foreign_keys reported referred_table
through normalize_name as customers. common_db_source looks the referred table
up by exact FQN, so it never matched: the constraint was discarded with no
error, no warning and a reported 100% workflow success, leaving
tableConstraints empty for every Oracle table.

Taking row[3] as stored matches get_table_names by construction, in both
identifier modes and for tables created with quoted lowercase or mixed-case
names. No FQN changes, so nothing is renamed and no migration is needed.

test_oracle_constraint_reflection.py asserted the normalised referred_table and
so pinned the behaviour this fixes; its expectation is updated.

The v2 E2E suite from #34302 is not backported: ingestion/tests/cli_e2e_v2 does
not exist on 2.0, since the framework from #27949 was never backported.

Two pre-existing failures in test_oracle.py on 2.0, both about stored-procedure
schema casing, are unaffected: they fail identically with and without this
change.

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

safe to test Add this label to run secure Github workflows on PRs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants