World's most powerful open data catalog for building a high-performance, geo-distributed and federated metadata lake.
Java ai-catalogdata-catalogdatalakefederated-querylakehousemetadatametalakemodel-catalogopendatacatalogskycomputingstratosphere
[#12418] improvement(test): Add multi-node entity cache consistency tests (#12460)
Qi Yu8494a3b6215b
diff --git a/.github/workflows/multi-instance-consistency-test.yml b/.github/workflows/multi-instance-consistency-test.ymlindex 7899e3dcec..a7c854f23c 100644--- a/.github/workflows/multi-instance-consistency-test.yml+++ b/.github/workflows/multi-instance-consistency-test.yml@@ -1,12 +1,16 @@name: Multi-Instance Consistency Test-# Verifies that authorization state (owners, roles, role privileges, user-role-# grants) propagates correctly between two Gravitino instances backed by the-# same MySQL entity store. Both instances run with the entity cache disabled-# and authorization enabled, so the only consistency contracts under test are-# the JcasbinAuthorizer caches and the JcasbinChangePoller invalidation paths.+# Verifies that entity and authorization caches propagate changes correctly+# between two Gravitino instances backed by the same MySQL entity store. The+# entity test warms one instance, mutates the other, and then re-reads the+# target until it converges or the convergence deadline expires.#-# The test plan and assertions live in dev/ci/test_multi_instance_consistency.sh.+# The entity test opens with a stale-read control that requires the target to+# serve a cached value before the poller runs. If that control fails, the cache+# is not actually caching and the remaining assertions prove nothing, so treat+# a failure there as a configuration problem rather than a propagation bug.+#+# The test plans and assertions live in the two test scripts under dev/ci/.on:workflow_dispatch:@@ -34,6 +38,23 @@ jobs:--health-interval=5s--health-timeout=3s--health-retries=20+ kafka:+ image: apache/kafka:3.9.1+ env:+ KAFKA_PROCESS_ROLES: broker,controller+ KAFKA_NODE_ID: 1+ KAFKA_CONTROLLER_QUORUM_VOTERS: 1@localhost:9093+ KAFKA_CONTROLLER_LISTENER_NAMES: CONTROLLER+ KAFKA_LISTENERS: PLAINTEXT://:9092,CONTROLLER://:9093+ KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://localhost:9092+ KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR: 1+ ports:+ - 9092:9092+ options: >-+ --health-cmd="/opt/kafka/bin/kafka-topics.sh --bootstrap-server localhost:9092 --list"+ --health-interval=5s+ --health-timeout=10s+ --health-retries=20steps:- uses: actions/checkout@v4@@ -50,7 +71,7 @@ jobs:run: |# Keep in sync with the latest schema file under scripts/mysql/ when the version bumps.mysql -h 127.0.0.1 -P 3306 -ugravitino -pgravitino gravitino \- < scripts/mysql/schema-1.3.0-mysql.sql+ < scripts/mysql/schema-2.0.0-mysql.sql- name: Build Gravitino distributionrun: ./gradlew compileDistribution -PskipWeb=true -x test@@ -58,8 +79,26 @@ jobs:- name: Stage and start two instances (A=8090, B=8190)run: bash dev/ci/setup_multi_instance.sh- - name: Run multi-instance consistency tests- id: consistency+ - name: Run multi-instance entity cache consistency tests+ id: entity-cache-consistency+ env:+ INSTANCE_A: http://localhost:8090+ INSTANCE_B: http://localhost:8190+ INSTANCE_B_HOME: distribution/package-b+ ADMIN_USER: admin+ KAFKA_BOOTSTRAP_SERVERS: localhost:9092+ # Convergence budget for every other case. A healthy node converges in+ # about a second and never spends this, so a generous value buys+ # resilience to CI scheduling hiccups at no cost on green runs.+ AWAIT_TIMEOUT_SECS: 30+ # Every cacheable entity type must expose a warm stale value in at+ # least one round before its target converges through the change log.+ PER_TYPE_STALE_CONTROL_ROUNDS: 3+ RUN_RESTART_TEST: true+ run: bash dev/ci/test_multi_instance_entity_cache_consistency.sh++ - name: Run multi-instance authorization consistency tests+ id: authorization-consistencyenv:INSTANCE_A: http://localhost:8090INSTANCE_B: http://localhost:8190diff --git a/dev/ci/setup_multi_instance.sh b/dev/ci/setup_multi_instance.shindex 8482d41def..c8aa3a5f95 100755--- a/dev/ci/setup_multi_instance.sh+++ b/dev/ci/setup_multi_instance.sh@@ -41,6 +41,12 @@ curl -fsSL "${JDBC_URL}" -o "${JDBC_JAR}"EXPECTED_SHA1="$(curl -fsSL "${JDBC_URL}.sha1")"echo "${EXPECTED_SHA1} ${JDBC_JAR}" | sha1sum --check+# The entity-cache consistency test uses an Iceberg JDBC catalog. Catalogs have+# isolated class loaders, so the driver must also be present in the catalog's+# own libs directory before the distribution is copied for instance B.+mkdir -p distribution/package/catalogs/lakehouse-iceberg/libs+cp "${JDBC_JAR}" distribution/package/catalogs/lakehouse-iceberg/libs/+# ---------------------------------------------------------------------------# 2. Copy distribution to get two independent instances.# ---------------------------------------------------------------------------@@ -70,7 +76,9 @@ subs = [(r'^gravitino\.entity\.store\.relational\.jdbcPassword\s*=.*$','gravitino.entity.store.relational.jdbcPassword = gravitino'),(r'^gravitino\.cache\.enabled\s*=.*$',- 'gravitino.cache.enabled = false'),+ 'gravitino.cache.enabled = true'),+ (r'^gravitino\.entityChangeLog\.pollIntervalSecs\s*=.*$',+ 'gravitino.entityChangeLog.pollIntervalSecs = 1'),(r'^gravitino\.authorization\.enable\s*=.*$','gravitino.authorization.enable = true'),(r'^gravitino\.authorization\.serviceAdmins\s*=.*$',@@ -135,8 +143,8 @@ patch_pid_grep distribution/package-b/bin/gravitino.sh# ---------------------------------------------------------------------------# 5. Start both instances and wait until they are ready.# ----------------------------------------------------------------------------distribution/package/bin/gravitino.sh start-distribution/package-b/bin/gravitino.sh start+GRAVITINO_DEBUG_OPTS= distribution/package/bin/gravitino.sh start+GRAVITINO_DEBUG_OPTS= distribution/package-b/bin/gravitino.sh startwait_ready() {local url=$1diff --git a/dev/ci/test_multi_instance_consistency.sh b/dev/ci/test_multi_instance_consistency.shindex bc670d8ed3..3efc709598 100755--- a/dev/ci/test_multi_instance_consistency.sh+++ b/dev/ci/test_multi_instance_consistency.sh@@ -24,7 +24,8 @@## A. metadataIdCache / ownerRelCache are eventually consistent across instances# via the JcasbinChangePoller (default poll interval = 3s).-# → set owner on A, read it back on B.+# → warm the old owner through an owner-gated operation on B, set a new+# owner on A, then verify the new owner on B.## B. The new owner can actually exercise owner privileges on the *other* instance# after the poll cycle, and the old owner is rejected.@@ -44,18 +45,21 @@# → grant CREATE_ROLE on the same role on A; user can immediately use it on B.## S. ownerRelCache handles GROUP-type owners, not just USER-type.-# → setOwner(TAG, type=GROUP) on A; B reads back the GROUP owner after poll.+# → warm a USER owner on B, setOwner(TAG, type=GROUP) on A, then verify+# that the former USER owner is rejected and B reads back the GROUP.#-# T. metadataIdCache is invalidated when an entity is deleted and re-created-# under the same name (new entity ID in the DB).+# T. metadataIdCache / ownerRelCache are invalidated when an entity is deleted+# and re-created under the same name (new entity ID in the DB).# → set owner of tag T to bob; delete T on A; re-create T on A (new ID,# owner = alice); B must NOT return bob as the owner of the new T.#-# U. User role-list metadata read-back (not just enforcement).-# → grant/revoke a role on A; GET /users/{user} on B immediately shows the-# updated role list (userRoleCache is version-validated per request).+# U. User-role grant/revoke with explicit target-cache prewarming plus+# metadata read-back.+# → a denied operation first warms B's empty userRoleCache; grant/revoke+# on A changes enforcement immediately, and GET /users/{user} on B+# independently shows the updated role list.#-# V. Role privilege metadata read-back (not just enforcement).+# V. Role privilege metadata read-back (Phase E covers loadedRoles enforcement).# → swap privileges on a role on A; GET /roles/{role} on B shows the new# set and no longer shows the removed privilege.#@@ -282,10 +286,17 @@ EOF)"expect "create role $ROLE_NAME with MANAGE_USERS on metalake" 200-# ---- A. owner read-back propagates (eventual ~3s) --------------------------+# ---- A. warm owner-cache invalidation (eventual ~3s) ------------------------section "A. Owner read-back propagates from A → B (eventual, ~${POLL_WAIT_SECS}s)"-# admin is current owner → admin transfers to jack+section "A. Warm owner cache invalidates from A → B (eventual, ~${POLL_WAIT_SECS}s)"+# PUT /owners is owner-gated and therefore resolves both the metadata ID and+# owner through JcasbinAuthorizer. GET /owners alone would read live metadata+# and would not prove that either authorizer cache was warm.+api "$INSTANCE_B" "$ADMIN_USER" PUT "/api/metalakes/$METALAKE/owners/METALAKE/$METALAKE" \+ "{\"name\":\"$ADMIN_USER\",\"type\":\"USER\"}"+expect "B: admin re-asserts ownership (explicitly warms B's old owner cache)" 200++# admin is current owner → admin transfers to jack on A.api "$INSTANCE_A" "$ADMIN_USER" PUT "/api/metalakes/$METALAKE/owners/METALAKE/$METALAKE" \"{\"name\":\"$USER_JACK\",\"type\":\"USER\"}"expect "A: admin (owner) → setOwner = $USER_JACK" 200@@ -293,10 +304,20 @@ expect "A: admin (owner) → setOwner = $USER_JACK" 200echo " ...sleeping ${POLL_WAIT_SECS}s for the change poller on B"sleep "$POLL_WAIT_SECS"-api "$INSTANCE_B" "$ADMIN_USER" GET "/api/metalakes/$METALAKE/owners/METALAKE/$METALAKE"-expect "B: GET owner now reports $USER_JACK" 200 "\"name\"[^}]*\"$USER_JACK\""+api "$INSTANCE_B" "$USER_JACK" PUT "/api/metalakes/$METALAKE/owners/METALAKE/$METALAKE" \+ "{\"name\":\"$USER_JACK\",\"type\":\"USER\"}"+expect "B: $USER_JACK is accepted after invalidating cached admin ownership" 200++api "$INSTANCE_B" "$ADMIN_USER" PUT "/api/metalakes/$METALAKE/owners/METALAKE/$METALAKE" \+ "{\"name\":\"$ADMIN_USER\",\"type\":\"USER\"}"+expect "B: admin (former owner cached before the change) is rejected" 403++# Explicitly warm jack immediately before the next mutation.+api "$INSTANCE_B" "$USER_JACK" PUT "/api/metalakes/$METALAKE/owners/METALAKE/$METALAKE" \+ "{\"name\":\"$USER_JACK\",\"type\":\"USER\"}"+expect "B: $USER_JACK re-asserts ownership (warms B before jack → alice)" 200-# jack is now owner → jack transfers to alice+# jack is now owner → jack transfers to alice on A.api "$INSTANCE_A" "$USER_JACK" PUT "/api/metalakes/$METALAKE/owners/METALAKE/$METALAKE" \"{\"name\":\"$USER_ALICE\",\"type\":\"USER\"}"expect "A: $USER_JACK (owner) → setOwner = $USER_ALICE" 200@@ -304,16 +325,19 @@ expect "A: $USER_JACK (owner) → setOwner = $USER_ALICE" 200echo " ...sleeping ${POLL_WAIT_SECS}s for the change poller on B"sleep "$POLL_WAIT_SECS"-api "$INSTANCE_B" "$ADMIN_USER" GET "/api/metalakes/$METALAKE/owners/METALAKE/$METALAKE"-expect "B: GET owner now reports $USER_ALICE" 200 "\"name\"[^}]*\"$USER_ALICE\""+api "$INSTANCE_B" "$USER_ALICE" PUT "/api/metalakes/$METALAKE/owners/METALAKE/$METALAKE" \+ "{\"name\":\"$USER_ALICE\",\"type\":\"USER\"}"+expect "B: $USER_ALICE is accepted after invalidating cached jack ownership" 200++api "$INSTANCE_B" "$USER_JACK" PUT "/api/metalakes/$METALAKE/owners/METALAKE/$METALAKE" \+ "{\"name\":\"$USER_JACK\",\"type\":\"USER\"}"+expect "B: $USER_JACK (the explicitly cached former owner) is rejected" 403# ---- B. enforcement on B reflects the owner change -------------------------section "B. Authz enforcement on B reflects the new owner (no extra wait)"-# alice is the current owner — re-setting (alice → alice) is a no-op write that requires-# the caller to be the current owner. If B's ownerRelCache is invalidated, this works.-# Note: this is also B's *first* isOwner check for $METALAKE, so its ownerRelCache-# entry is being populated cold from the DB here.+# Alice is the current owner. This is a post-propagation sanity check; Phase A+# already proved invalidation from an explicitly warm old entry.api "$INSTANCE_B" "$USER_ALICE" PUT "/api/metalakes/$METALAKE/owners/METALAKE/$METALAKE" \"{\"name\":\"$USER_ALICE\",\"type\":\"USER\"}"expect "B: $USER_ALICE (current owner) re-asserts ownership" 200@@ -325,19 +349,19 @@ expect "B: $USER_JACK (former owner) is rejected with 403" 403# ---- B'. WARM-cache invalidation: critical scenario ------------------------#-# Phases A/B above only exercise *cold* cache fills on B: when B's first-# isOwner check happens, the new owner is already in the DB, so the cache-# is correctly populated. They do NOT prove that an already-cached entry on-# B (with the stale owner) gets invalidated when A changes the owner.-#-# This phase forces that scenario:-# 1. B's ownerRelCache currently holds alice (warmed by Phase B above).+# This phase repeats the critical scenario with a prewarm immediately adjacent+# to the mutation, so the test does not depend on state left by another phase:+# 1. Explicitly warm alice in B's metadataIdCache / ownerRelCache.# 2. Change owner on A back to jack.# 3. Wait one poll cycle.# 4. On B, do an isOwner-gated operation as jack — must succeed if and# only if the poller invalidated B's alice entry. As alice — must fail.#section "B'. Warm-cache invalidation on owner change (eventual, ~${POLL_WAIT_SECS}s)"+api "$INSTANCE_B" "$USER_ALICE" PUT "/api/metalakes/$METALAKE/owners/METALAKE/$METALAKE" \+ "{\"name\":\"$USER_ALICE\",\"type\":\"USER\"}"+expect "B: $USER_ALICE re-asserts ownership (explicit prewarm before A changes it)" 200+api "$INSTANCE_A" "$USER_ALICE" PUT "/api/metalakes/$METALAKE/owners/METALAKE/$METALAKE" \"{\"name\":\"$USER_JACK\",\"type\":\"USER\"}"expect "A: $USER_ALICE (owner) transfers owner back to $USER_JACK" 200@@ -384,6 +408,11 @@ expect "B: $USER_BOB addUser succeeds immediately after grant" 200# ---- D. revoke role on A → user denied on B IMMEDIATELY --------------------section "D. Revoke role on A — effective on B without poll wait"+# Do not rely on Phase C's final assertion as an implicit warm-up.+api "$INSTANCE_B" "$USER_BOB" POST "/api/metalakes/$METALAKE/users" \+ "{\"name\":\"revoke_prewarm_${SUFFIX}\"}"+expect "B: $USER_BOB addUser succeeds (explicitly warms userRoleCache before revoke)" 200+api "$INSTANCE_A" "$USER_ALICE" PUT \"/api/metalakes/$METALAKE/permissions/users/$USER_BOB/revoke/" \"{\"roleNames\":[\"$ROLE_NAME\"]}"@@ -642,7 +671,7 @@ api "$INSTANCE_A" "$USER_ALICE" POST "/api/metalakes/$METALAKE/groups" \"{\"name\":\"$GROUP_NAME\"}"expect "A: create group $GROUP_NAME" 200-api "$INSTANCE_B" "$ADMIN_USER" GET "/api/metalakes/$METALAKE/groups/$GROUP_NAME"+api "$INSTANCE_B" "$USER_ALICE" GET "/api/metalakes/$METALAKE/groups/$GROUP_NAME"expect "B: GET group $GROUP_NAME visible immediately" 200 "\"name\"[^}]*\"$GROUP_NAME\""api "$INSTANCE_A" "$USER_ALICE" PUT \@@ -650,7 +679,7 @@ api "$INSTANCE_A" "$USER_ALICE" PUT \"{\"roleNames\":[\"$ROLE_ALLOW\"]}"expect "A: grant $ROLE_ALLOW to group $GROUP_NAME" 200-api "$INSTANCE_B" "$ADMIN_USER" GET "/api/metalakes/$METALAKE/groups/$GROUP_NAME"+api "$INSTANCE_B" "$USER_ALICE" GET "/api/metalakes/$METALAKE/groups/$GROUP_NAME"expect "B: GET group shows $ROLE_ALLOW in roles" 200 "\"roles\"[^]]*\"$ROLE_ALLOW\""api "$INSTANCE_A" "$USER_ALICE" PUT \@@ -661,7 +690,7 @@ expect "A: revoke $ROLE_ALLOW from group $GROUP_NAME" 200api "$INSTANCE_A" "$USER_ALICE" DELETE "/api/metalakes/$METALAKE/groups/$GROUP_NAME"expect "A: delete group $GROUP_NAME" 200-api "$INSTANCE_B" "$ADMIN_USER" GET "/api/metalakes/$METALAKE/groups/$GROUP_NAME"+api "$INSTANCE_B" "$USER_ALICE" GET "/api/metalakes/$METALAKE/groups/$GROUP_NAME"expect "B: GET group returns 404 after deletion" 404# ---- N. setOwner propagation for non-METALAKE entities (TAG) ---------------@@ -673,7 +702,14 @@ api "$INSTANCE_A" "$USER_ALICE" POST "/api/metalakes/$METALAKE/tags" \"{\"name\":\"$TAG_NAME\",\"comment\":\"phase N tag\",\"properties\":{}}"expect "A: $USER_ALICE creates tag $TAG_NAME (alice = metalake owner)" 200-# Transfer tag ownership to bob on A. alice is metalake owner so this is allowed.+# Warm B's authorizer caches with the old tag owner. This owner-gated PUT loads+# both metadataIdCache(TAG name → ID) and ownerRelCache(ID → alice).+api "$INSTANCE_B" "$USER_ALICE" PUT \+ "/api/metalakes/$METALAKE/owners/TAG/$TAG_NAME" \+ "{\"name\":\"$USER_ALICE\",\"type\":\"USER\"}"+expect "B: $USER_ALICE re-asserts tag ownership (explicit prewarm)" 200++# Transfer tag ownership to bob on A. Alice is metalake owner, so this is allowed.api "$INSTANCE_A" "$USER_ALICE" PUT \"/api/metalakes/$METALAKE/owners/TAG/$TAG_NAME" \"{\"name\":\"$USER_BOB\",\"type\":\"USER\"}"@@ -682,10 +718,15 @@ expect "A: setOwner(TAG $TAG_NAME) = $USER_BOB" 200echo " ...sleeping ${POLL_WAIT_SECS}s for the change poller"sleep "$POLL_WAIT_SECS"-# GET owner on a TAG requires LOAD_TAG (METALAKE::OWNER || TAG::OWNER || ANY_APPLY_TAG),-# so the GET is done as $USER_ALICE (metalake owner) rather than admin.+# If B retained cached alice ownership, bob would be rejected. Bob's success+# therefore proves that the owner-gated path reloaded the new owner.+api "$INSTANCE_B" "$USER_BOB" PUT \+ "/api/metalakes/$METALAKE/owners/TAG/$TAG_NAME" \+ "{\"name\":\"$USER_BOB\",\"type\":\"USER\"}"+expect "B: $USER_BOB (new tag owner) is accepted after B invalidates alice" 200+api "$INSTANCE_B" "$USER_ALICE" GET "/api/metalakes/$METALAKE/owners/TAG/$TAG_NAME"-expect "B: GET owner(TAG $TAG_NAME) = $USER_BOB" 200 "\"name\"[^}]*\"$USER_BOB\""+expect "B: metadata read-back also reports $USER_BOB" 200 "\"name\"[^}]*\"$USER_BOB\""# Enforcement: bob (now TAG owner) can DELETE the tag on B (TAG::OWNER required).api "$INSTANCE_B" "$USER_BOB" DELETE "/api/metalakes/$METALAKE/tags/$TAG_NAME"@@ -791,6 +832,11 @@ expect "B: metalake owner $USER_ALICE still has METALAKE-scope privileges (cache# ---- Q. several setOwner calls within one poll window — convergence --------section "Q. Burst of setOwner calls on A — B converges to the final state"+# Explicitly warm alice as the old owner on B before the first mutation.+api "$INSTANCE_B" "$USER_ALICE" PUT "/api/metalakes/$METALAKE/owners/METALAKE/$METALAKE" \+ "{\"name\":\"$USER_ALICE\",\"type\":\"USER\"}"+expect "B: $USER_ALICE re-asserts ownership (prewarms B before owner burst)" 200+# Sequence (no inter-step wait so the poller batches them in one cycle):# alice → bob → jack → aliceapi "$INSTANCE_A" "$USER_ALICE" PUT "/api/metalakes/$METALAKE/owners/METALAKE/$METALAKE" \@@ -823,6 +869,10 @@ expect "B: $USER_JACK (intermediate owner during burst) rejected" 403section "R. Re-granting an already-held role is idempotent"# bob still holds $ROLE_ALLOW from K (we revoked the other role in O).+api "$INSTANCE_B" "$USER_BOB" POST "/api/metalakes/$METALAKE/users" \+ "{\"name\":\"r_prewarm_${SUFFIX}\"}"+expect "B: $USER_BOB addUser succeeds (prewarms existing $ROLE_ALLOW binding)" 200+api "$INSTANCE_A" "$USER_ALICE" PUT \"/api/metalakes/$METALAKE/permissions/users/$USER_BOB/grant/" \"{\"roleNames\":[\"$ROLE_ALLOW\"]}"@@ -844,12 +894,10 @@ expect "B: $USER_BOB addUser denied after single revoke (no duplicate binding le# ---- S. GROUP-type owner: ownerRelCache with GROUP principal ----------------section "S. GROUP as owner type — tag owned by a group propagates to B (eventual, ~${POLL_WAIT_SECS}s)"-# ownerRelCache stores both USER and GROUP owners. Only USER-type has been-# tested in the phases above. This phase confirms GROUP-type entries are also-# propagated correctly by the JcasbinChangePoller.-# (Simple authenticator cannot enforce group-derived requests, so we verify the-# metadata read-back only — the owner is stored and visible on B as a GROUP.)+section "S. GROUP owner invalidates a warm USER owner on B (eventual, ~${POLL_WAIT_SECS}s)"+# Simple authenticator cannot submit group-derived principals, but it can prove+# invalidation: warm bob as the USER owner on B, replace bob with a GROUP on A,+# then require B to reject the formerly cached USER owner.api "$INSTANCE_A" "$USER_ALICE" POST "/api/metalakes/$METALAKE/groups" \"{\"name\":\"$GROUP_S\"}"expect "A: create group $GROUP_S for owner test" 200@@ -858,6 +906,17 @@ api "$INSTANCE_A" "$USER_ALICE" POST "/api/metalakes/$METALAKE/tags" \"{\"name\":\"$TAG_S\",\"comment\":\"phase S\",\"properties\":{}}"expect "A: $USER_ALICE creates tag $TAG_S" 200+api "$INSTANCE_A" "$USER_ALICE" PUT "/api/metalakes/$METALAKE/owners/TAG/$TAG_S" \+ "{\"name\":\"$USER_BOB\",\"type\":\"USER\"}"+expect "A: setOwner(TAG $TAG_S) = USER $USER_BOB" 200++echo " ...sleeping ${POLL_WAIT_SECS}s before explicitly warming B"+sleep "$POLL_WAIT_SECS"++api "$INSTANCE_B" "$USER_BOB" PUT "/api/metalakes/$METALAKE/owners/TAG/$TAG_S" \+ "{\"name\":\"$USER_BOB\",\"type\":\"USER\"}"+expect "B: $USER_BOB re-asserts tag ownership (explicit USER-owner prewarm)" 200+api "$INSTANCE_A" "$USER_ALICE" PUT "/api/metalakes/$METALAKE/owners/TAG/$TAG_S" \"{\"name\":\"$GROUP_S\",\"type\":\"GROUP\"}"expect "A: setOwner(TAG $TAG_S) = GROUP $GROUP_S" 200@@ -865,8 +924,12 @@ expect "A: setOwner(TAG $TAG_S) = GROUP $GROUP_S" 200echo " ...sleeping ${POLL_WAIT_SECS}s for the change poller"sleep "$POLL_WAIT_SECS"+api "$INSTANCE_B" "$USER_BOB" PUT "/api/metalakes/$METALAKE/owners/TAG/$TAG_S" \+ "{\"name\":\"$USER_BOB\",\"type\":\"USER\"}"+expect "B: cached former USER owner $USER_BOB is rejected after GROUP change" 403+api "$INSTANCE_B" "$USER_ALICE" GET "/api/metalakes/$METALAKE/owners/TAG/$TAG_S"-expect "B: GET owner(TAG $TAG_S) = GROUP $GROUP_S (type GROUP propagated)" 200 \+expect "B: metadata read-back reports GROUP $GROUP_S" 200 \"\"name\"[^}]*\"$GROUP_S\""# alice is metalake owner and can delete the tag regardless of its object owner.@@ -883,14 +946,10 @@ section "T. Stale-owner safety on tag delete+re-create (eventual, ~${POLL_WAIT_S# allow the old owner (bob) to exercise ownership on the new entity.## Two separate paths are exercised:-# 1. GET /owners (OwnerManager.getOwner) does a live DB lookup — bypasses-# the JcasbinAuthorizer caches — so it always returns the new owner (alice).-# 2. Enforcement (isOwner inside hasSetOwnerPermission) reads metadataIdCache-# → ownerRelCache. Tags do not write to entity_change_log, so-# metadataIdCache[name] may still hold the old entity ID. However, the-# owner_meta soft-delete IS propagated via the owner_meta poll path, so-# ownerRelCache[old_id] is invalidated → live DB returns no owner for the-# deleted entity → bob is correctly denied.+# 1. An owner-gated PUT on B explicitly warms metadataIdCache and ownerRelCache+# with the old tag ID and bob owner before the mutation.+# 2. After delete plus same-name re-create on A, enforcement must reject bob;+# GET /owners is retained only as an independent live-metadata sanity check.api "$INSTANCE_A" "$USER_ALICE" POST "/api/metalakes/$METALAKE/tags" \"{\"name\":\"$TAG_T\",\"comment\":\"phase T\",\"properties\":{}}"expect "A: create tag $TAG_T (owner = alice as creator)" 200@@ -899,12 +958,12 @@ api "$INSTANCE_A" "$USER_ALICE" PUT "/api/metalakes/$METALAKE/owners/TAG/$TAG_T""{\"name\":\"$USER_BOB\",\"type\":\"USER\"}"expect "A: setOwner(TAG $TAG_T) = $USER_BOB" 200-echo " ...sleeping ${POLL_WAIT_SECS}s so B caches bob as owner of $TAG_T"+echo " ...sleeping ${POLL_WAIT_SECS}s before explicitly warming B"sleep "$POLL_WAIT_SECS"-api "$INSTANCE_B" "$USER_ALICE" GET "/api/metalakes/$METALAKE/owners/TAG/$TAG_T"-expect "B: GET owner(TAG $TAG_T) = $USER_BOB (pre-delete baseline)" 200 \- "\"name\"[^}]*\"$USER_BOB\""+api "$INSTANCE_B" "$USER_BOB" PUT "/api/metalakes/$METALAKE/owners/TAG/$TAG_T" \+ "{\"name\":\"$USER_BOB\",\"type\":\"USER\"}"+expect "B: $USER_BOB re-asserts old tag ownership (explicit cache prewarm)" 200# Delete the tag on A — should signal the poller to invalidate B's metadataIdCache.api "$INSTANCE_A" "$USER_ALICE" DELETE "/api/metalakes/$METALAKE/tags/$TAG_T"@@ -918,13 +977,13 @@ expect "A: re-create tag $TAG_T (new entity ID, new owner = alice)" 200echo " ...sleeping ${POLL_WAIT_SECS}s for poller to propagate delete+re-create"sleep "$POLL_WAIT_SECS"-# B's ownerRelCache had bob for the OLD tag ID. After invalidation the new-# tag (different ID) must be resolved fresh from the DB → owner = alice.+# Live metadata read-back must show the re-created tag's owner.api "$INSTANCE_B" "$USER_ALICE" GET "/api/metalakes/$METALAKE/owners/TAG/$TAG_T"expect "B: GET owner(re-created TAG $TAG_T) = $USER_ALICE (no stale bob owner)" 200 \"\"name\"[^}]*\"$USER_ALICE\""-# Enforcement: bob was owner of the old tag; must be rejected for the new one.+# Enforcement is the cache assertion: bob was loaded as owner of the old tag+# immediately before deletion and must be rejected for the new entity ID.api "$INSTANCE_B" "$USER_BOB" PUT "/api/metalakes/$METALAKE/owners/TAG/$TAG_T" \"{\"name\":\"$USER_BOB\",\"type\":\"USER\"}"expect "B: $USER_BOB (old tag owner, stale) rejected for re-created $TAG_T" 403@@ -935,9 +994,9 @@ expect "A: delete re-created tag $TAG_T" 200# ---- U. user role-list metadata read-back on B -----------------------------section "U. User role-list read-back on B — GET /users/{user} reflects grant/revoke from A"-# Phases C/D verify enforcement (can the user DO X?). This phase verifies the-# metadata layer: GET /users/{user} on B returns the up-to-date role list.-# userRoleCache is per-request version-validated so no poll wait is needed.+# This phase verifies both paths: an explicit denied operation warms B's empty+# userRoleCache before the grant, while GET /users/{user} checks metadata+# read-back. Version validation makes both grant and revoke immediate.api "$INSTANCE_A" "$USER_ALICE" POST "/api/metalakes/$METALAKE/roles" "$(cat <<EOF{"name":"$ROLE_U","properties":{},"securableObjects":[{"fullName":"$METALAKE","type":"METALAKE",@@ -946,11 +1005,22 @@ EOF)"expect "A: create role $ROLE_U" 200+api "$INSTANCE_B" "$USER_ALICE" GET "/api/metalakes/$METALAKE/users/$USER_BOB"+expect_absent "B: pre-grant role list does not contain $ROLE_U" 200 "\"$ROLE_U\""++api "$INSTANCE_B" "$USER_BOB" POST "/api/metalakes/$METALAKE/users" \+ "{\"name\":\"u_before_grant_${SUFFIX}\"}"+expect "B: $USER_BOB denied before $ROLE_U grant (explicit userRoleCache prewarm)" 403+api "$INSTANCE_A" "$USER_ALICE" PUT \"/api/metalakes/$METALAKE/permissions/users/$USER_BOB/grant/" \"{\"roleNames\":[\"$ROLE_U\"]}"expect "A: grant $ROLE_U to $USER_BOB" 200+api "$INSTANCE_B" "$USER_BOB" POST "/api/metalakes/$METALAKE/users" \+ "{\"name\":\"u_after_grant_${SUFFIX}\"}"+expect "B: $USER_BOB addUser succeeds immediately after $ROLE_U grant" 200+api "$INSTANCE_B" "$USER_ALICE" GET "/api/metalakes/$METALAKE/users/$USER_BOB"expect "B: GET user $USER_BOB — $ROLE_U appears in roles list after grant" 200 \"\"$ROLE_U\""@@ -960,6 +1030,10 @@ api "$INSTANCE_A" "$USER_ALICE" PUT \"{\"roleNames\":[\"$ROLE_U\"]}"expect "A: revoke $ROLE_U from $USER_BOB" 200+api "$INSTANCE_B" "$USER_BOB" POST "/api/metalakes/$METALAKE/users" \+ "{\"name\":\"u_after_revoke_${SUFFIX}\"}"+expect "B: $USER_BOB denied immediately after $ROLE_U revoke" 403+api "$INSTANCE_B" "$USER_ALICE" GET "/api/metalakes/$METALAKE/users/$USER_BOB"expect_absent "B: GET user $USER_BOB — $ROLE_U absent from roles list after revoke" 200 \"\"$ROLE_U\""@@ -970,9 +1044,8 @@ expect "A: delete role $ROLE_U" 200# ---- V. role privilege metadata read-back on B -----------------------------section "V. Role privilege read-back on B — GET /roles/{role} reflects privilege changes from A"-# Complements Phase E (enforcement) with a metadata-layer check: after the-# privilege set on a role changes on A, GET /roles/{role} on B must show the-# updated list. loadedRoles is per-request version-validated, so this is immediate.+# Complements Phase E's explicitly warm enforcement check with a metadata-layer+# check: GET /roles/{role} on B must show the updated privilege list.api "$INSTANCE_A" "$USER_ALICE" POST "/api/metalakes/$METALAKE/roles" "$(cat <<EOF{"name":"$ROLE_V","properties":{},"securableObjects":[{"fullName":"$METALAKE","type":"METALAKE",@@ -1016,6 +1089,11 @@ EOF)"expect "B: $USER_ALICE creates role $ROLE_W on B" 200+# Warm A's empty userRoleCache entry immediately before B grants the role.+api "$INSTANCE_A" "$USER_BOB" POST "/api/metalakes/$METALAKE/users" \+ "{\"name\":\"w_bi_prewarm_${SUFFIX}\"}"+expect "A: $USER_BOB denied before reverse-direction grant (prewarms A)" 403+api "$INSTANCE_B" "$USER_ALICE" PUT \"/api/metalakes/$METALAKE/permissions/users/$USER_BOB/grant/" \"{\"roleNames\":[\"$ROLE_W\"]}"diff --git a/dev/ci/test_multi_instance_entity_cache_consistency.sh b/dev/ci/test_multi_instance_entity_cache_consistency.shnew file mode 100755index 0000000000..2eea4cd43c--- /dev/null+++ b/dev/ci/test_multi_instance_entity_cache_consistency.sh@@ -0,0 +1,1654 @@+#!/usr/bin/env bash+#+# Licensed to the Apache Software Foundation (ASF) under one+# or more contributor license agreements. See the NOTICE file+# distributed with this work for additional information+# regarding copyright ownership. The ASF licenses this file+# to you under the Apache License, Version 2.0 (the+# "License"); you may not use this file except in compliance+# with the License. You may obtain a copy of the License at+#+# http://www.apache.org/licenses/LICENSE-2.0+#+# Unless required by applicable law or agreed to in writing,+# software distributed under the License is distributed on an+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY+# KIND, either express or implied. See the License for the+# specific language governing permissions and limitations+# under the License.+#+# Real-process entity-cache consistency test. Both Gravitino instances use the+# same relational entity store, but each owns an independent local cache.+# Every consistency case follows the same sequence:+#+# 1. Load the old entity through the target instance to warm its cache.+# 2. Alter, rename, disable, or drop it through the other instance.+# 3. Re-read through the target until it converges, or until the deadline.+# 4. Assert that the stale value is gone.+#+# Step 3 retries instead of sleeping for a fixed interval. Every consistency+# assertion here is positive ("the target eventually converges"), so retrying+# can only remove timing flakiness, never mask a regression: a cache that is+# never invalidated still fails when the deadline expires. The exceptions are+# the stale-read controls, which assert a *negative* and therefore read at a+# fixed instant across several rounds.+#+# The stale-read controls are what make the rest of the suite meaningful.+# Without them, a run with the entity cache switched off for one entity type+# would pass that type's convergence cases while proving nothing, because "B+# serves the new value" is also what an uncached B does. Every cacheable type+# therefore has a repeated negative control that proves the target really held+# a stale copy first; a reverse TAG control proves the same for node A.+#+# Assertions on externally backed entities need care. For Iceberg tables/views/+# schemas and Kafka topics, a load merges live catalog state with the stored+# entity (see TableOperationDispatcher#internalLoadTable), and name, comment and+# properties all come from the *catalog* side, which no Gravitino cache serves.+# Those fields would converge even with the cache disabled and the poller+# stopped. The audit block is the opposite: EntityCombined*#auditInfo() merges+# the entity's audit over the catalog's with overwrite=true, so+# audit.lastModifiedTime is served from the entity cache alone. Externally+# backed cases use it whenever the operation preserves a reliable audit block,+# and treat name/comment/properties as an end-to-end check only.+#+# Two properties of that field drive how the cases are written. It is null until+# the first alter (creation sets only creator and createTime), so each such+# section primes it once before the case starts. And it is unreliable across a+# same-name recreate: tables, views, and schemas can reload with an empty audit+# block. Those recreate scenarios are external-backend E2E checks, not cache+# assertions; the type-level alter controls prove their entity caches instead.+#+# Covered cache entity types and mutations:+# METALAKE alter, rename, disable/enable, drop+# CATALOG alter, rename, disable/enable, drop+# SCHEMA alter, rapid alters, cascade drop, multi-level hierarchy+# TABLE alter (rename/drop/recreate are external-backend E2E only; see their notes)+# TOPIC alter (drop is external-backend E2E only)+# VIEW alter (rename/drop/recreate are external-backend E2E only)+# FILESET alter, rename, drop+# TAG alter, rename, drop+# POLICY alter, rename, disable/enable, drop+# JOB status alter through cancellation+#+# Dedicated edge cases cover A-to-B and B-to-A propagation, drop plus recreate+# with the same name inside one poll window, several updates inside one poll+# window, cross-type batched changes, recursive invalidation, and restart at a+# change-log high-water mark.+#+# Kafka supplies the external topic backend. Iceberg's JDBC backend supplies+# schemas, tables, views, and hierarchical schemas; the managed fileset catalog+# supplies schema-level cascade behavior.++set -uo pipefail++INSTANCE_A="${INSTANCE_A:-http://localhost:8090}"+INSTANCE_B="${INSTANCE_B:-http://localhost:8190}"+INSTANCE_B_HOME="${INSTANCE_B_HOME:-distribution/package-b}"+ADMIN_USER="${ADMIN_USER:-admin}"+KAFKA_BOOTSTRAP_SERVERS="${KAFKA_BOOTSTRAP_SERVERS:-localhost:9092}"+# Upper bound for convergence. Generous on purpose: a correct node converges in+# about one poll interval and never reaches this, while a broken one has to burn+# the whole budget before failing. Raising it costs nothing on a healthy run.+AWAIT_TIMEOUT_SECS="${AWAIT_TIMEOUT_SECS:-20}"+AWAIT_INTERVAL_SECS="${AWAIT_INTERVAL_SECS:-0.2}"+# Rounds of the stale-read control. Each round reads B within milliseconds of+# the mutation on A, so a warm cache is observed with probability ~(1 - rtt/poll+# interval); several rounds make a false alarm negligible while still failing+# hard when no round ever sees a stale value.+STALE_CONTROL_ROUNDS="${STALE_CONTROL_ROUNDS:-5}"+# Each cacheable entity type gets its own warm-cache proof. Repeating the+# immediate stale read makes the proof tolerant of the poller occasionally+# winning the mutation/read race without allowing a cold or bypassed cache to+# pass: a cold target observes the new value in every round.+PER_TYPE_STALE_CONTROL_ROUNDS="${PER_TYPE_STALE_CONTROL_ROUNDS:-3}"+RUN_RESTART_TEST="${RUN_RESTART_TEST:-false}"++SUFFIX="$(date +%s)_$$"+MAIN_METALAKE="entity_cache_${SUFFIX}"+LIFECYCLE_METALAKE="metalake_cache_${SUFFIX}"+RENAMED_METALAKE="metalake_cache_renamed_${SUFFIX}"+RECREATE_METALAKE="metalake_recreate_${SUFFIX}"+LIFECYCLE_CATALOG="catalog_cache_${SUFFIX}"+RENAMED_CATALOG="catalog_cache_renamed_${SUFFIX}"+RECREATE_CATALOG="catalog_recreate_${SUFFIX}"+ICEBERG_CATALOG="iceberg_cache_${SUFFIX}"+FILESET_CATALOG="fileset_cache_${SUFFIX}"+KAFKA_CATALOG="kafka_cache_${SUFFIX}"+SCHEMA_NAME="schema_cache_${SUFFIX}"+FILESET_SCHEMA="fileset_schema_${SUFFIX}"+TABLE_NAME="table_cache_${SUFFIX}"+RENAMED_TABLE="table_cache_renamed_${SUFFIX}"+RECREATE_TABLE="table_recreate_${SUFFIX}"+VIEW_NAME="view_cache_${SUFFIX}"+RENAMED_VIEW="view_cache_renamed_${SUFFIX}"+FILESET_NAME="fileset_entity_${SUFFIX}"+RENAMED_FILESET="fileset_entity_renamed_${SUFFIX}"+RECREATE_FILESET="fileset_recreate_${SUFFIX}"+TOPIC_NAME="topic_cache_${SUFFIX}"+TAG_NAME="tag_cache_${SUFFIX}"+RENAMED_TAG="tag_cache_renamed_${SUFFIX}"+RECREATE_TAG="tag_recreate_${SUFFIX}"+LATEST_TAG="tag_latest_${SUFFIX}"+POLICY_NAME="policy_cache_${SUFFIX}"+RENAMED_POLICY="policy_cache_renamed_${SUFFIX}"+JOB_TEMPLATE="job_cache_${SUFFIX}"+CASCADE_SCHEMA="cascade_schema_${SUFFIX}"+CASCADE_FILESET="cascade_fileset_${SUFFIX}"+HIER_PARENT="parent_cache_${SUFFIX}"+HIER_CHILD="${HIER_PARENT}:child"+HIER_GRANDCHILD="${HIER_CHILD}:grandchild"+HIER_SIBLING="${HIER_PARENT}:sibling"+HIER_TABLE="hier_grandchild_table_${SUFFIX}"+HIER_VIEW="hier_sibling_view_${SUFFIX}"+REVERSE_TAG="reverse_tag_${SUFFIX}"+RENAMED_REVERSE_TAG="reverse_tag_renamed_${SUFFIX}"+REVERSE_FILESET="reverse_fileset_${SUFFIX}"+RENAMED_REVERSE_FILESET="reverse_fileset_renamed_${SUFFIX}"+REVERSE_POLICY="reverse_policy_${SUFFIX}"+BURST_TAG="burst_tag_${SUFFIX}"+BURST_POLICY="burst_policy_${SUFFIX}"+BURST_FILESET="burst_fileset_${SUFFIX}"+RESTART_TAG="restart_tag_${SUFFIX}"++PASS=0+FAIL=0+CONSISTENCY_CASES=0+CACHE_PROOF_CASES=0+EXPECTED_CACHE_PROOF_CASES=11+FAILED_TESTS=()+CACHE_PROOFS=()+HTTP_CODE=""+RESPONSE_BODY=""+JOB_ID=""+JOB_SCRIPT=""+CASE_PREWARMED=true+CASE_MUTATION_STARTED=true++auth_header() {+ printf 'Basic %s' "$(jq -rn --arg credentials "$1:" '$credentials | @base64')"+}++# api <base_url> <method> <path> [body_json]+# Writes the response status and body to HTTP_CODE and RESPONSE_BODY.+api() {+ local base="$1" method="$2" path="$3" body="${4:-}"+ local tmp+ tmp="$(mktemp -t gravitino_entity_cache_api.XXXX)"+ if [[ -n "$body" ]]; then+ HTTP_CODE=$(curl -sS --connect-timeout 10 --max-time 60 \+ -o "$tmp" -w '%{http_code}' \+ -H "Authorization: $(auth_header "$ADMIN_USER")" \+ -H 'Accept: application/vnd.gravitino.v1+json' \+ -H 'Content-Type: application/json' \+ -X "$method" --data "$body" "${base}${path}" || echo 000)+ else+ HTTP_CODE=$(curl -sS --connect-timeout 10 --max-time 60 \+ -o "$tmp" -w '%{http_code}' \+ -H "Authorization: $(auth_header "$ADMIN_USER")" \+ -H 'Accept: application/vnd.gravitino.v1+json' \+ -X "$method" "${base}${path}" || echo 000)+ fi+ RESPONSE_BODY="$(<"$tmp")"+ rm -f "$tmp"+}++pass() {+ PASS=$((PASS + 1))+ printf ' \033[32m✓\033[0m %s\n' "$1"+}++fail() {+ FAIL=$((FAIL + 1))+ FAILED_TESTS+=("$1")+ printf ' \033[31m✗\033[0m %s\n' "$1"+}++body_snippet() {+ printf '%s' "$RESPONSE_BODY" | tr '\n' ' ' | cut -c1-240+}++expect_http() {+ local desc="$1" expected="$2"+ if [[ "$HTTP_CODE" == "$expected" ]]; then+ pass "$desc"+ else+ fail "$desc — expected HTTP $expected, got $HTTP_CODE. Body: $(body_snippet)"+ fi+}++expect_value() {+ local desc="$1" filter="$2" expected="$3"+ local actual+ if [[ "$HTTP_CODE" != "200" ]]; then+ fail "$desc — expected HTTP 200, got $HTTP_CODE. Body: $(body_snippet)"+ return+ fi+ if ! actual=$(printf '%s' "$RESPONSE_BODY" | jq -r "$filter" 2>/dev/null); then+ fail "$desc — response does not contain $filter. Body: $(body_snippet)"+ return+ fi+ if [[ "$actual" == "null" ]]; then+ fail "$desc — response does not contain $filter. Body: $(body_snippet)"+ return+ fi+ if [[ "$actual" == "$expected" ]]; then+ pass "$desc"+ else+ fail "$desc — expected '$expected', got '$actual'. Body: $(body_snippet)"+ fi+}++expect_one_of() {+ local desc="$1" filter="$2"+ shift 2+ local actual expected+ if [[ "$HTTP_CODE" != "200" ]]; then+ fail "$desc — expected HTTP 200, got $HTTP_CODE. Body: $(body_snippet)"+ return+ fi+ if ! actual=$(printf '%s' "$RESPONSE_BODY" | jq -r "$filter" 2>/dev/null); then+ fail "$desc — response does not contain $filter. Body: $(body_snippet)"+ return+ fi+ if [[ "$actual" == "null" ]]; then+ fail "$desc — response does not contain $filter. Body: $(body_snippet)"+ return+ fi+ for expected in "$@"; do+ if [[ "$actual" == "$expected" ]]; then+ pass "$desc"+ return+ fi+ done+ fail "$desc — got unexpected value '$actual'. Body: $(body_snippet)"+}++section() {+ printf '\n\033[1m== %s ==\033[0m\n' "$1"+}++# Matchers used by the await_* helpers. Each inspects the HTTP_CODE and+# RESPONSE_BODY left behind by the most recent api() call and returns success+# when the target has converged. They deliberately mirror the expect_* rules+# (non-200 and a null filter result both count as "not yet") so that a matcher+# never reports converged where the matching expect_* would fail.+matches_http() {+ [[ "$HTTP_CODE" == "$1" ]]+}++matches_one_of() {+ [[ "$HTTP_CODE" == "200" ]] || return 1+ local filter="$1" actual expected+ shift+ actual=$(printf '%s' "$RESPONSE_BODY" | jq -r "$filter" 2>/dev/null) || return 1+ [[ "$actual" == "null" ]] && return 1+ for expected in "$@"; do+ [[ "$actual" == "$expected" ]] && return 0+ done+ return 1+}++matches_value() {+ matches_one_of "$1" "$2"+}++matches_changed() {+ [[ "$HTTP_CODE" == "200" ]] || return 1+ local actual+ actual=$(printf '%s' "$RESPONSE_BODY" | jq -r "$1" 2>/dev/null) || return 1+ [[ "$actual" != "null" && "$actual" != "$2" ]]+}++# await_loop <base> <path> <matcher> [matcher args...]+# Re-issues the GET until <matcher> succeeds or the deadline expires. The final+# response is left in HTTP_CODE/RESPONSE_BODY either way, so the caller's+# expect_* reports a pass on convergence and a real failure message — with the+# actual body — on timeout. Reporting stays entirely in the expect_* helpers.+await_loop() {+ local base="$1" path="$2" matcher="$3"+ shift 3+ local attempts attempt+ attempts=$(awk -v timeout="$AWAIT_TIMEOUT_SECS" -v interval="$AWAIT_INTERVAL_SECS" \+ 'BEGIN { n = int(timeout / interval); if (n < 1) n = 1; print n }')+ for ((attempt = 0; attempt < attempts; attempt++)); do+ api "$base" GET "$path"+ if "$matcher" "$@"; then+ return 0+ fi+ sleep "$AWAIT_INTERVAL_SECS"+ done+ return 1+}++await_value() {+ local desc="$1" base="$2" path="$3" filter="$4" expected="$5"+ await_loop "$base" "$path" matches_value "$filter" "$expected"+ expect_value "$desc" "$filter" "$expected"+}++await_http() {+ local desc="$1" base="$2" path="$3" expected="$4"+ await_loop "$base" "$path" matches_http "$expected"+ expect_http "$desc" "$expected"+}++await_one_of() {+ local desc="$1" base="$2" path="$3" filter="$4"+ shift 4+ await_loop "$base" "$path" matches_one_of "$filter" "$@"+ expect_one_of "$desc" "$filter" "$@"+}++# Asserts that a field moved away from a previously captured value. Used for+# audit timestamps, where the point is that the target stopped serving the+# cached entity rather than that it reached one specific new value.+await_changed() {+ local desc="$1" base="$2" path="$3" filter="$4" stale="$5"+ local actual+ # An empty or null baseline would make "the value moved" trivially true, which+ # would turn this assertion into a silent pass. Fail loudly instead: it means+ # the probe field is missing from the response, not that the cache is correct.+ if [[ -z "$stale" || "$stale" == "null" ]]; then+ fail "$desc — no baseline captured for $filter, cannot prove the cached entity was dropped"+ return+ fi+ if await_loop "$base" "$path" matches_changed "$filter" "$stale"; then+ pass "$desc"+ return+ fi+ if [[ "$HTTP_CODE" != "200" ]]; then+ fail "$desc — expected HTTP 200, got $HTTP_CODE. Body: $(body_snippet)"+ return+ fi+ actual=$(printf '%s' "$RESPONSE_BODY" | jq -r "$filter" 2>/dev/null)+ fail "$desc — $filter still serves the cached value '$stale' (got '$actual'). Body: $(body_snippet)"+}++# Reads a single field, for capturing a baseline rather than asserting on it.+read_field() {+ local base="$1" path="$2" filter="$3"+ api "$base" GET "$path"+ printf '%s' "$RESPONSE_BODY" | jq -r "$filter" 2>/dev/null+}++record_cache_proof() {+ CACHE_PROOF_CASES=$((CACHE_PROOF_CASES + 1))+ CACHE_PROOFS+=("$1")+ pass "$1: target served a warm stale entry before change-log invalidation"+}++# stale_value_control <description> <direction> <source> <target> <method>+# <mutation_path> <read_path> <filter> <original_value> <body_template>+# <probe_prefix>+#+# Proves that a native entity type is really cached on the target node. The+# body template must contain __VALUE__; the last round restores original_value+# so the regular lifecycle cases can retain their simple, readable baselines.+stale_value_control() {+ local desc="$1" direction="$2" source="$3" target="$4" method="$5"+ local mutation_path="$6" read_path="$7" filter="$8" original_value="$9"+ local body_template="${10}" probe_prefix="${11}"+ local current_value="$original_value" new_value body observed round+ local stale_observed=0++ consistency_case "$desc"+ for round in $(seq 1 "$PER_TYPE_STALE_CONTROL_ROUNDS"); do+ if ((round == PER_TYPE_STALE_CONTROL_ROUNDS)); then+ new_value="$original_value"+ else+ new_value="${probe_prefix}-v${round}"+ fi++ prewarm_value "${direction} round ${round}: target caches ${current_value}" \+ "$target" "$read_path" "$filter" "$current_value"+ body="${body_template//__VALUE__/$new_value}"+ api "$source" "$method" "$mutation_path" "$body"+ expect_http "${direction} round ${round}: source changes value to ${new_value}" 200+ CASE_MUTATION_STARTED=true++ observed=$(read_field "$target" "$read_path" "$filter")+ if [[ "$observed" == "$current_value" ]]; then+ stale_observed=$((stale_observed + 1))+ printf ' %s round %d: target still served cached %s\n' \+ "$direction" "$round" "$current_value"+ else+ printf ' %s round %d: target already served %s (poller won the race)\n' \+ "$direction" "$round" "$observed"+ fi++ await_value "${direction} round ${round}: target converges on ${new_value}" \+ "$target" "$read_path" "$filter" "$new_value"+ current_value="$new_value"+ done++ if ((stale_observed > 0)); then+ record_cache_proof "$direction $desc"+ else+ fail "$direction $desc never served a stale value in ${PER_TYPE_STALE_CONTROL_ROUNDS} rounds — the target may be cold or bypassing this entity cache"+ fi+}++# stale_changed_control <description> <direction> <source> <target> <method>+# <mutation_path> <read_path> <audit_filter> <body_template> <probe_prefix>+# <final_value>+#+# Externally backed fields come from the catalog and can change while the+# Gravitino entity cache is cold. This variant observes an entity-store audit+# field instead: the immediate read must retain the old audit in at least one+# round, and every round must later move after the poller invalidates the key.+stale_changed_control() {+ local desc="$1" direction="$2" source="$3" target="$4" method="$5"+ local mutation_path="$6" read_path="$7" audit_filter="$8"+ local body_template="$9" probe_prefix="${10}" final_value="${11}"+ local baseline new_value body observed round+ local stale_observed=0++ consistency_case "$desc"+ for round in $(seq 1 "$PER_TYPE_STALE_CONTROL_ROUNDS"); do+ prewarm_http "${direction} round ${round}: target loads the entity before mutation" \+ "$target" "$read_path" 200+ baseline=$(read_field "$target" "$read_path" "$audit_filter")+ if [[ -z "$baseline" || "$baseline" == "null" ]]; then+ fail "${direction} $desc round ${round}: no audit baseline at ${audit_filter}"+ CASE_MUTATION_STARTED=true+ continue+ fi++ if ((round == PER_TYPE_STALE_CONTROL_ROUNDS)); then+ new_value="$final_value"+ else+ new_value="${probe_prefix}-v${round}"+ fi+ body="${body_template//__VALUE__/$new_value}"+ api "$source" "$method" "$mutation_path" "$body"+ expect_http "${direction} round ${round}: source changes the external entity" 200+ CASE_MUTATION_STARTED=true++ observed=$(read_field "$target" "$read_path" "$audit_filter")+ if [[ "$observed" == "$baseline" ]]; then+ stale_observed=$((stale_observed + 1))+ printf ' %s round %d: target still served cached audit %s\n' \+ "$direction" "$round" "$baseline"+ else+ printf ' %s round %d: target audit already moved to %s (poller won the race)\n' \+ "$direction" "$round" "$observed"+ fi++ await_changed "${direction} round ${round}: target reloads the changed entity" \+ "$target" "$read_path" "$audit_filter" "$baseline"+ done++ if ((stale_observed > 0)); then+ record_cache_proof "$direction $desc"+ else+ fail "$direction $desc never served a stale audit in ${PER_TYPE_STALE_CONTROL_ROUNDS} rounds — the target may be cold or bypassing this entity cache"+ fi+}++consistency_case() {+ CONSISTENCY_CASES=$((CONSISTENCY_CASES + 1))+ CASE_PREWARMED=false+ CASE_MUTATION_STARTED=false+ printf '\n \033[1m[consistency case %d]\033[0m %s\n' "$CONSISTENCY_CASES" "$1"+}++restart_case() {+ CONSISTENCY_CASES=$((CONSISTENCY_CASES + 1))+ CASE_PREWARMED=true+ CASE_MUTATION_STARTED=false+ printf '\n \033[1m[restart case %d]\033[0m %s\n' "$CONSISTENCY_CASES" "$1"+}++prewarm_value() {+ local desc="$1" base="$2" path="$3" filter="$4" expected="$5"+ api "$base" GET "$path"+ expect_value "$desc" "$filter" "$expected"+ CASE_PREWARMED=true+}++prewarm_http() {+ local desc="$1" base="$2" path="$3" expected="$4"+ api "$base" GET "$path"+ expect_http "$desc" "$expected"+ CASE_PREWARMED=true+}++prewarm_one_of() {+ local desc="$1" base="$2" path="$3" filter="$4"+ shift 4+ api "$base" GET "$path"+ expect_one_of "$desc" "$filter" "$@"+ CASE_PREWARMED=true+}++ensure_case_prewarmed() {+ if [[ "$CASE_MUTATION_STARTED" == "false" ]]; then+ if [[ "$CASE_PREWARMED" != "true" ]]; then+ fail "consistency case mutated its source before explicitly prewarming the target cache"+ return 1+ fi+ CASE_MUTATION_STARTED=true+ fi+}++mutate_a() {+ local desc="$1" method="$2" path="$3" body="${4:-}"+ ensure_case_prewarmed || return+ api "$INSTANCE_A" "$method" "$path" "$body"+ expect_http "$desc" 200+}++mutate_b() {+ local desc="$1" method="$2" path="$3" body="${4:-}"+ ensure_case_prewarmed || return+ api "$INSTANCE_B" "$method" "$path" "$body"+ expect_http "$desc" 200+}++wait_ready() {+ local url="$1"+ local attempt+ for attempt in $(seq 1 60); do+ if curl -fsS --connect-timeout 2 --max-time 5 "$url/api/version" >/dev/null 2>&1; then+ return 0+ fi+ sleep 2+ done+ return 1+}++cleanup() {+ if [[ -n "$JOB_ID" ]]; then+ api "$INSTANCE_A" POST "/api/metalakes/${MAIN_METALAKE}/jobs/runs/${JOB_ID}" >/dev/null 2>&1 || true+ fi+ api "$INSTANCE_A" DELETE "/api/metalakes/${MAIN_METALAKE}?force=true" >/dev/null 2>&1 || true+ api "$INSTANCE_A" DELETE "/api/metalakes/${LIFECYCLE_METALAKE}?force=true" >/dev/null 2>&1 || true+ api "$INSTANCE_A" DELETE "/api/metalakes/${RENAMED_METALAKE}?force=true" >/dev/null 2>&1 || true+ api "$INSTANCE_A" DELETE "/api/metalakes/${RECREATE_METALAKE}?force=true" >/dev/null 2>&1 || true+ if [[ -n "$JOB_SCRIPT" ]]; then+ rm -f "$JOB_SCRIPT"+ fi+}+trap cleanup EXIT++section "Preflight"+for command_name in curl jq; do+ if command -v "$command_name" >/dev/null 2>&1; then+ pass "$command_name is available"+ else+ fail "$command_name is required"+ fi+done++if [[ "$PER_TYPE_STALE_CONTROL_ROUNDS" =~ ^[0-9]+$ ]] \+ && ((PER_TYPE_STALE_CONTROL_ROUNDS >= 2)); then+ pass "per-type stale control runs at least twice"+else+ fail "PER_TYPE_STALE_CONTROL_ROUNDS must be an integer >= 2"+fi++api "$INSTANCE_A" GET /api/version+expect_http "instance A is reachable" 200+api "$INSTANCE_B" GET /api/version+expect_http "instance B is reachable" 200+if ((FAIL > 0)); then+ printf '\nPreflight failed; entity-cache scenarios were not executed.\n'+ exit 1+fi++section "METALAKE cache: alter, rename, disable/enable, and drop"+mutate_a "create lifecycle metalake on A" POST /api/metalakes \+ "{\"name\":\"${LIFECYCLE_METALAKE}\",\"comment\":\"metalake-old\",\"properties\":{}}"++stale_value_control "METALAKE cache residency" "METALAKE A -> B" \+ "$INSTANCE_A" "$INSTANCE_B" PUT \+ "/api/metalakes/${LIFECYCLE_METALAKE}" \+ "/api/metalakes/${LIFECYCLE_METALAKE}" \+ '.metalake.comment' metalake-old \+ '{"updates":[{"@type":"updateComment","newComment":"__VALUE__"}]}' \+ metalake-proof++consistency_case "METALAKE alter propagates A -> B"+prewarm_value "B caches the old metalake before A alters it" "$INSTANCE_B" \+ "/api/metalakes/${LIFECYCLE_METALAKE}" '.metalake.comment' metalake-old+mutate_a "alter metalake comment on A" PUT "/api/metalakes/${LIFECYCLE_METALAKE}" \+ '{"updates":[{"@type":"updateComment","newComment":"metalake-new"}]}'+await_value "B sees altered metalake" "$INSTANCE_B" \+ "/api/metalakes/${LIFECYCLE_METALAKE}" '.metalake.comment' metalake-new++consistency_case "METALAKE rename invalidates the old name on B"+prewarm_value "B caches the pre-rename metalake" "$INSTANCE_B" \+ "/api/metalakes/${LIFECYCLE_METALAKE}" '.metalake.comment' metalake-new+mutate_a "rename metalake on A" PUT "/api/metalakes/${LIFECYCLE_METALAKE}" \+ "{\"updates\":[{\"@type\":\"rename\",\"newName\":\"${RENAMED_METALAKE}\"}]}"+# Authorization resolves the missing metalake before dispatching the load, so+# a missing top-level name is surfaced as forbidden rather than not found.+await_http "B no longer serves the old metalake name" "$INSTANCE_B" \+ "/api/metalakes/${LIFECYCLE_METALAKE}" 403+await_value "B loads the renamed metalake" "$INSTANCE_B" \+ "/api/metalakes/${RENAMED_METALAKE}" '.metalake.name' "$RENAMED_METALAKE"++consistency_case "METALAKE disable blocks operations through B"+prewarm_value "B caches the enabled metalake before A disables it" "$INSTANCE_B" \+ "/api/metalakes/${RENAMED_METALAKE}" '.metalake.properties["in-use"]' true+prewarm_http "B warms an operation under the enabled metalake" "$INSTANCE_B" \+ "/api/metalakes/${RENAMED_METALAKE}/catalogs" 200+mutate_a "disable metalake on A" PATCH "/api/metalakes/${RENAMED_METALAKE}" '{"inUse":false}'+await_value "B sees disabled metalake state" "$INSTANCE_B" \+ "/api/metalakes/${RENAMED_METALAKE}" '.metalake.properties["in-use"]' false+await_http "B rejects an operation under the disabled metalake" "$INSTANCE_B" \+ "/api/metalakes/${RENAMED_METALAKE}/catalogs" 409++consistency_case "METALAKE enable restores operations through B"+prewarm_value "B caches the disabled metalake before A enables it" "$INSTANCE_B" \+ "/api/metalakes/${RENAMED_METALAKE}" '.metalake.properties["in-use"]' false+prewarm_http "B warms the disabled operation state" "$INSTANCE_B" \+ "/api/metalakes/${RENAMED_METALAKE}/catalogs" 409+mutate_a "enable metalake on A" PATCH "/api/metalakes/${RENAMED_METALAKE}" '{"inUse":true}'+await_value "B sees enabled metalake state" "$INSTANCE_B" \+ "/api/metalakes/${RENAMED_METALAKE}" '.metalake.properties["in-use"]' true+await_http "B accepts an operation under the re-enabled metalake" "$INSTANCE_B" \+ "/api/metalakes/${RENAMED_METALAKE}/catalogs" 200++consistency_case "METALAKE drop invalidates B"+prewarm_value "B caches the enabled metalake before A drops it" "$INSTANCE_B" \+ "/api/metalakes/${RENAMED_METALAKE}" '.metalake.properties["in-use"]' true+mutate_a "drop metalake on A" DELETE "/api/metalakes/${RENAMED_METALAKE}?force=true"+await_http "B no longer serves the dropped metalake" "$INSTANCE_B" \+ "/api/metalakes/${RENAMED_METALAKE}" 403++section "METALAKE edge case: drop and recreate the same name in one poll window"+mutate_a "create recreate-probe metalake on A" POST /api/metalakes \+ "{\"name\":\"${RECREATE_METALAKE}\",\"comment\":\"metalake-generation-1\",\"properties\":{}}"++consistency_case "METALAKE drop plus same-name recreate evicts the old generation"+prewarm_value "B caches the first metalake generation" "$INSTANCE_B" \+ "/api/metalakes/${RECREATE_METALAKE}" '.metalake.comment' metalake-generation-1+mutate_a "drop first metalake generation on A" DELETE "/api/metalakes/${RECREATE_METALAKE}?force=true"+mutate_a "recreate the same metalake name on A" POST /api/metalakes \+ "{\"name\":\"${RECREATE_METALAKE}\",\"comment\":\"metalake-generation-2\",\"properties\":{}}"+await_value "B loads the second metalake generation" "$INSTANCE_B" \+ "/api/metalakes/${RECREATE_METALAKE}" '.metalake.comment' metalake-generation-2++section "Shared test metalake"+mutate_a "create shared test metalake" POST /api/metalakes \+ "{\"name\":\"${MAIN_METALAKE}\",\"comment\":\"entity cache test\",\"properties\":{}}"+api "$INSTANCE_B" GET "/api/metalakes/${MAIN_METALAKE}"+expect_value "B loads shared test metalake" '.metalake.name' "$MAIN_METALAKE"++# ---------------------------------------------------------------------------+# Stale-read control.+#+# Every other case asserts that B eventually serves the new value. That is also+# what B does with no cache at all, so on its own the suite cannot tell "the+# poller invalidated a warm entry" from "there was never an entry to+# invalidate". This section closes that gap by asserting the negative: B must+# serve the *old* value when read immediately after the mutation on A.+#+# A single round would be racy, because the poller can fire between the mutation+# and the read. Instead each round records whether it observed the stale value+# and the section requires at least one hit across STALE_CONTROL_ROUNDS. With a+# one-second poll interval and a read issued milliseconds after the mutation,+# missing every round is vanishingly unlikely when the cache works — while a+# disabled or non-caching B misses every round by construction and fails here.+#+# This runs before the rest of the suite so a misconfigured deployment (cache+# off, wrong poll interval) fails immediately rather than passing 50-odd cases+# that prove nothing.+# ---------------------------------------------------------------------------+section "Stale-read control: B must serve a cached value before the poller runs"+CONTROL_TAG="control_tag_${SUFFIX}"+mutate_a "create stale-read control tag on A" POST "/api/metalakes/${MAIN_METALAKE}/tags" \+ "{\"name\":\"${CONTROL_TAG}\",\"comment\":\"control-v0\",\"properties\":{}}"++STALE_OBSERVED=0+for round in $(seq 1 "$STALE_CONTROL_ROUNDS"); do+ old_value="control-v$((round - 1))"+ new_value="control-v${round}"++ # Warm B with the current value, so B holds a cache entry to invalidate.+ api "$INSTANCE_B" GET "/api/metalakes/${MAIN_METALAKE}/tags/${CONTROL_TAG}"+ expect_value "round ${round}: B caches ${old_value}" '.tag.comment' "$old_value"++ # Mutate on A, then read B as fast as possible.+ api "$INSTANCE_A" PUT "/api/metalakes/${MAIN_METALAKE}/tags/${CONTROL_TAG}" \+ "{\"updates\":[{\"@type\":\"updateComment\",\"newComment\":\"${new_value}\"}]}"+ expect_http "round ${round}: A updates the control tag to ${new_value}" 200++ observed=$(read_field "$INSTANCE_B" \+ "/api/metalakes/${MAIN_METALAKE}/tags/${CONTROL_TAG}" '.tag.comment')+ if [[ "$observed" == "$old_value" ]]; then+ STALE_OBSERVED=$((STALE_OBSERVED + 1))+ printf ' round %d: B still served the cached %s\n' "$round" "$old_value"+ else+ printf ' round %d: B already served %s (poller won the race)\n' "$round" "$observed"+ fi++ # Let the round converge before warming the next one.+ await_value "round ${round}: B converges on ${new_value}" "$INSTANCE_B" \+ "/api/metalakes/${MAIN_METALAKE}/tags/${CONTROL_TAG}" '.tag.comment' "$new_value"+done++if ((STALE_OBSERVED > 0)); then+ record_cache_proof "TAG A -> B cache residency (${STALE_OBSERVED}/${STALE_CONTROL_ROUNDS} stale rounds)"+else+ fail "B never served a stale value in ${STALE_CONTROL_ROUNDS} rounds — the entity cache is not caching, so every convergence assertion in this suite is vacuous"+fi++mutate_a "drop stale-read control tag" DELETE "/api/metalakes/${MAIN_METALAKE}/tags/${CONTROL_TAG}"++section "CATALOG cache: alter, rename, disable/enable, rebuild, and drop"+mutate_a "create lifecycle catalog on A" POST "/api/metalakes/${MAIN_METALAKE}/catalogs" \+ "{\"name\":\"${LIFECYCLE_CATALOG}\",\"type\":\"FILESET\",\"comment\":\"catalog-old\",\"properties\":{\"disable-filesystem-ops\":\"true\"}}"++stale_value_control "CATALOG cache residency" "CATALOG A -> B" \+ "$INSTANCE_A" "$INSTANCE_B" PUT \+ "/api/metalakes/${MAIN_METALAKE}/catalogs/${LIFECYCLE_CATALOG}" \+ "/api/metalakes/${MAIN_METALAKE}/catalogs/${LIFECYCLE_CATALOG}" \+ '.catalog.comment' catalog-old \+ '{"updates":[{"@type":"updateComment","newComment":"__VALUE__"}]}' \+ catalog-proof++consistency_case "CATALOG alter propagates A -> B"+prewarm_value "B caches the old catalog before A alters it" "$INSTANCE_B" \+ "/api/metalakes/${MAIN_METALAKE}/catalogs/${LIFECYCLE_CATALOG}" '.catalog.comment' catalog-old+mutate_a "alter catalog comment on A" PUT "/api/metalakes/${MAIN_METALAKE}/catalogs/${LIFECYCLE_CATALOG}" \+ '{"updates":[{"@type":"updateComment","newComment":"catalog-new"}]}'+await_value "B sees altered catalog" "$INSTANCE_B" \+ "/api/metalakes/${MAIN_METALAKE}/catalogs/${LIFECYCLE_CATALOG}" '.catalog.comment' catalog-new++consistency_case "CATALOG rename invalidates the old name and connector on B"+prewarm_value "B caches the pre-rename catalog" "$INSTANCE_B" \+ "/api/metalakes/${MAIN_METALAKE}/catalogs/${LIFECYCLE_CATALOG}" '.catalog.comment' catalog-new+prewarm_http "B initializes the pre-rename catalog connector" "$INSTANCE_B" \+ "/api/metalakes/${MAIN_METALAKE}/catalogs/${LIFECYCLE_CATALOG}/schemas" 200+mutate_a "rename catalog on A" PUT "/api/metalakes/${MAIN_METALAKE}/catalogs/${LIFECYCLE_CATALOG}" \+ "{\"updates\":[{\"@type\":\"rename\",\"newName\":\"${RENAMED_CATALOG}\"}]}"+await_http "B invalidates the old catalog name" "$INSTANCE_B" \+ "/api/metalakes/${MAIN_METALAKE}/catalogs/${LIFECYCLE_CATALOG}" 404+await_value "B loads the renamed catalog" "$INSTANCE_B" \+ "/api/metalakes/${MAIN_METALAKE}/catalogs/${RENAMED_CATALOG}" '.catalog.name' "$RENAMED_CATALOG"++consistency_case "CATALOG disable rebuilds B's connector as unavailable"+prewarm_value "B caches the enabled catalog before A disables it" "$INSTANCE_B" \+ "/api/metalakes/${MAIN_METALAKE}/catalogs/${RENAMED_CATALOG}" '.catalog.properties["in-use"]' true+prewarm_http "B initializes the enabled catalog connector" "$INSTANCE_B" \+ "/api/metalakes/${MAIN_METALAKE}/catalogs/${RENAMED_CATALOG}/schemas" 200+mutate_a "disable catalog on A" PATCH "/api/metalakes/${MAIN_METALAKE}/catalogs/${RENAMED_CATALOG}" '{"inUse":false}'+await_value "B sees disabled catalog state" "$INSTANCE_B" \+ "/api/metalakes/${MAIN_METALAKE}/catalogs/${RENAMED_CATALOG}" '.catalog.properties["in-use"]' false+await_http "B rebuilds the disabled catalog instance" "$INSTANCE_B" \+ "/api/metalakes/${MAIN_METALAKE}/catalogs/${RENAMED_CATALOG}/schemas" 409++consistency_case "CATALOG enable rebuilds B's connector as available"+prewarm_value "B caches the disabled catalog before A enables it" "$INSTANCE_B" \+ "/api/metalakes/${MAIN_METALAKE}/catalogs/${RENAMED_CATALOG}" '.catalog.properties["in-use"]' false+prewarm_http "B caches the disabled catalog connector state" "$INSTANCE_B" \+ "/api/metalakes/${MAIN_METALAKE}/catalogs/${RENAMED_CATALOG}/schemas" 409+mutate_a "enable catalog on A" PATCH "/api/metalakes/${MAIN_METALAKE}/catalogs/${RENAMED_CATALOG}" '{"inUse":true}'+await_value "B sees enabled catalog state" "$INSTANCE_B" \+ "/api/metalakes/${MAIN_METALAKE}/catalogs/${RENAMED_CATALOG}" '.catalog.properties["in-use"]' true+await_http "B rebuilds the re-enabled catalog instance" "$INSTANCE_B" \+ "/api/metalakes/${MAIN_METALAKE}/catalogs/${RENAMED_CATALOG}/schemas" 200++consistency_case "CATALOG drop invalidates B's entity and connector caches"+prewarm_value "B caches the enabled catalog before A drops it" "$INSTANCE_B" \+ "/api/metalakes/${MAIN_METALAKE}/catalogs/${RENAMED_CATALOG}" '.catalog.properties["in-use"]' true+prewarm_http "B initializes the catalog connector before A drops it" "$INSTANCE_B" \+ "/api/metalakes/${MAIN_METALAKE}/catalogs/${RENAMED_CATALOG}/schemas" 200+mutate_a "drop catalog on A" DELETE "/api/metalakes/${MAIN_METALAKE}/catalogs/${RENAMED_CATALOG}?force=true"+await_http "B invalidates dropped catalog" "$INSTANCE_B" \+ "/api/metalakes/${MAIN_METALAKE}/catalogs/${RENAMED_CATALOG}" 404++section "CATALOG edge case: drop and recreate the same name in one poll window"+mutate_a "create recreate-probe catalog on A" POST "/api/metalakes/${MAIN_METALAKE}/catalogs" \+ "{\"name\":\"${RECREATE_CATALOG}\",\"type\":\"FILESET\",\"comment\":\"catalog-generation-1\",\"properties\":{\"disable-filesystem-ops\":\"true\"}}"++consistency_case "CATALOG drop plus same-name recreate evicts the old generation"+prewarm_value "B caches the first catalog generation" "$INSTANCE_B" \+ "/api/metalakes/${MAIN_METALAKE}/catalogs/${RECREATE_CATALOG}" '.catalog.comment' catalog-generation-1+mutate_a "drop first catalog generation on A" DELETE "/api/metalakes/${MAIN_METALAKE}/catalogs/${RECREATE_CATALOG}?force=true"+mutate_a "recreate the same catalog name on A" POST "/api/metalakes/${MAIN_METALAKE}/catalogs" \+ "{\"name\":\"${RECREATE_CATALOG}\",\"type\":\"FILESET\",\"comment\":\"catalog-generation-2\",\"properties\":{\"disable-filesystem-ops\":\"true\"}}"+await_value "B loads the second catalog generation" "$INSTANCE_B" \+ "/api/metalakes/${MAIN_METALAKE}/catalogs/${RECREATE_CATALOG}" '.catalog.comment' catalog-generation-2++section "Create external catalogs used by entity tests"+ICEBERG_BODY=$(jq -nc \+ --arg name "$ICEBERG_CATALOG" \+ --arg backend_name "multi_instance_${SUFFIX}" \+ --arg warehouse "file:///tmp/gravitino-multi-instance-iceberg-${SUFFIX}" \+ '{name:$name,type:"RELATIONAL",comment:"Iceberg cache test",provider:"lakehouse-iceberg",properties:{"catalog-backend":"jdbc",uri:"jdbc:mysql://127.0.0.1:3306/gravitino?useSSL=false&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true",warehouse:$warehouse,"catalog-backend-name":$backend_name,"jdbc-driver":"com.mysql.cj.jdbc.Driver","jdbc-user":"gravitino","jdbc-password":"gravitino","jdbc-initialize":"true"}}')+mutate_a "create Iceberg JDBC catalog" POST "/api/metalakes/${MAIN_METALAKE}/catalogs" "$ICEBERG_BODY"++mutate_a "create fileset catalog" POST "/api/metalakes/${MAIN_METALAKE}/catalogs" \+ "{\"name\":\"${FILESET_CATALOG}\",\"type\":\"FILESET\",\"comment\":\"Fileset cache test\",\"properties\":{\"disable-filesystem-ops\":\"true\"}}"++KAFKA_BODY=$(jq -nc --arg name "$KAFKA_CATALOG" --arg servers "$KAFKA_BOOTSTRAP_SERVERS" \+ '{name:$name,type:"MESSAGING",comment:"Kafka cache test",provider:"kafka",properties:{"bootstrap.servers":$servers}}')+mutate_a "create Kafka catalog" POST "/api/metalakes/${MAIN_METALAKE}/catalogs" "$KAFKA_BODY"++# ---------------------------------------------------------------------------+# From here on the entities live in an external backend (Iceberg or Kafka).+# A load merges live catalog state with the stored entity, and name, comment and+# properties are served by the catalog, not by any Gravitino cache — those+# assertions would hold even with the cache disabled. The audit block is served+# by the entity store (EntityCombined*#auditInfo() lets the entity's audit+# overwrite the catalog's), so it is the only field here that can prove B+# stopped serving a cached entity. Alters bump audit.lastModifiedTime, so cache+# consistency cases pair their catalog-side assertion with an audit-side one.+# Same-name recreates can return an empty audit block and are therefore labeled+# as external-backend E2E checks rather than cache assertions.+# ---------------------------------------------------------------------------++section "SCHEMA cache: alter; external-backend recreate E2E"+mutate_a "create Iceberg schema on A" POST "/api/metalakes/${MAIN_METALAKE}/catalogs/${ICEBERG_CATALOG}/schemas" \+ "{\"name\":\"${SCHEMA_NAME}\",\"comment\":\"schema-old\",\"properties\":{}}"+# Creating an entity sets only creator and createTime, so audit.lastModifiedTime+# stays null until the first alter. The audit probes below need a non-null+# baseline to mean anything, so prime the field here, outside the case.+mutate_a "prime schema audit on A" PUT "/api/metalakes/${MAIN_METALAKE}/catalogs/${ICEBERG_CATALOG}/schemas/${SCHEMA_NAME}" \+ '{"updates":[{"@type":"setProperty","property":"audit-prime","value":"1"}]}'++stale_changed_control "SCHEMA cache residency" "SCHEMA A -> B" \+ "$INSTANCE_A" "$INSTANCE_B" PUT \+ "/api/metalakes/${MAIN_METALAKE}/catalogs/${ICEBERG_CATALOG}/schemas/${SCHEMA_NAME}" \+ "/api/metalakes/${MAIN_METALAKE}/catalogs/${ICEBERG_CATALOG}/schemas/${SCHEMA_NAME}" \+ '.schema.audit.lastModifiedTime' \+ '{"updates":[{"@type":"setProperty","property":"cache-proof","value":"__VALUE__"}]}' \+ schema-proof schema-proof-final++consistency_case "SCHEMA alter propagates A -> B"+prewarm_value "B caches the old schema before A alters it" "$INSTANCE_B" \+ "/api/metalakes/${MAIN_METALAKE}/catalogs/${ICEBERG_CATALOG}/schemas/${SCHEMA_NAME}" \+ '.schema.name' "$SCHEMA_NAME"+STALE_SCHEMA_MODIFIED=$(read_field "$INSTANCE_B" \+ "/api/metalakes/${MAIN_METALAKE}/catalogs/${ICEBERG_CATALOG}/schemas/${SCHEMA_NAME}" \+ '.schema.audit.lastModifiedTime')+mutate_a "alter schema property on A" PUT "/api/metalakes/${MAIN_METALAKE}/catalogs/${ICEBERG_CATALOG}/schemas/${SCHEMA_NAME}" \+ '{"updates":[{"@type":"setProperty","property":"cache-key","value":"schema-new"}]}'+await_value "B sees altered schema" "$INSTANCE_B" \+ "/api/metalakes/${MAIN_METALAKE}/catalogs/${ICEBERG_CATALOG}/schemas/${SCHEMA_NAME}" '.schema.properties["cache-key"]' schema-new+await_changed "B drops the cached schema entity (audit moved on)" "$INSTANCE_B" \+ "/api/metalakes/${MAIN_METALAKE}/catalogs/${ICEBERG_CATALOG}/schemas/${SCHEMA_NAME}" \+ '.schema.audit.lastModifiedTime' "$STALE_SCHEMA_MODIFIED"++consistency_case "SCHEMA keeps the latest of several alters inside one poll window"+prewarm_value "B caches the schema before A performs rapid alters" "$INSTANCE_B" \+ "/api/metalakes/${MAIN_METALAKE}/catalogs/${ICEBERG_CATALOG}/schemas/${SCHEMA_NAME}" \+ '.schema.properties["cache-key"]' schema-new+STALE_SCHEMA_RAPID_MODIFIED=$(read_field "$INSTANCE_B" \+ "/api/metalakes/${MAIN_METALAKE}/catalogs/${ICEBERG_CATALOG}/schemas/${SCHEMA_NAME}" \+ '.schema.audit.lastModifiedTime')+mutate_a "set schema rapid value 1 on A" PUT "/api/metalakes/${MAIN_METALAKE}/catalogs/${ICEBERG_CATALOG}/schemas/${SCHEMA_NAME}" \+ '{"updates":[{"@type":"setProperty","property":"rapid-key","value":"schema-v1"}]}'+mutate_a "set schema rapid value 2 on A" PUT "/api/metalakes/${MAIN_METALAKE}/catalogs/${ICEBERG_CATALOG}/schemas/${SCHEMA_NAME}" \+ '{"updates":[{"@type":"setProperty","property":"rapid-key","value":"schema-v2"}]}'+mutate_a "set schema rapid value 3 on A" PUT "/api/metalakes/${MAIN_METALAKE}/catalogs/${ICEBERG_CATALOG}/schemas/${SCHEMA_NAME}" \+ '{"updates":[{"@type":"setProperty","property":"rapid-key","value":"schema-v3"}]}'+await_value "B sees the latest schema value" "$INSTANCE_B" \+ "/api/metalakes/${MAIN_METALAKE}/catalogs/${ICEBERG_CATALOG}/schemas/${SCHEMA_NAME}" '.schema.properties["rapid-key"]' schema-v3+await_changed "B drops the schema entity cached before the rapid batch" "$INSTANCE_B" \+ "/api/metalakes/${MAIN_METALAKE}/catalogs/${ICEBERG_CATALOG}/schemas/${SCHEMA_NAME}" \+ '.schema.audit.lastModifiedTime' "$STALE_SCHEMA_RAPID_MODIFIED"++section "TABLE cache: alter"+mutate_a "create Iceberg table on A" POST "/api/metalakes/${MAIN_METALAKE}/catalogs/${ICEBERG_CATALOG}/schemas/${SCHEMA_NAME}/tables" \+ "{\"name\":\"${TABLE_NAME}\",\"comment\":\"table-old\",\"columns\":[{\"name\":\"id\",\"type\":\"integer\",\"nullable\":false}],\"properties\":{}}"+# Prime audit.lastModifiedTime; see the note in the SCHEMA section.+mutate_a "prime table audit on A" PUT "/api/metalakes/${MAIN_METALAKE}/catalogs/${ICEBERG_CATALOG}/schemas/${SCHEMA_NAME}/tables/${TABLE_NAME}" \+ '{"updates":[{"@type":"setProperty","property":"audit-prime","value":"1"}]}'++stale_changed_control "TABLE cache residency" "TABLE A -> B" \+ "$INSTANCE_A" "$INSTANCE_B" PUT \+ "/api/metalakes/${MAIN_METALAKE}/catalogs/${ICEBERG_CATALOG}/schemas/${SCHEMA_NAME}/tables/${TABLE_NAME}" \+ "/api/metalakes/${MAIN_METALAKE}/catalogs/${ICEBERG_CATALOG}/schemas/${SCHEMA_NAME}/tables/${TABLE_NAME}" \+ '.table.audit.lastModifiedTime' \+ '{"updates":[{"@type":"setProperty","property":"cache-proof","value":"__VALUE__"}]}' \+ table-proof table-proof-final++consistency_case "TABLE alter propagates A -> B"+prewarm_value "B caches the old table before A alters it" "$INSTANCE_B" \+ "/api/metalakes/${MAIN_METALAKE}/catalogs/${ICEBERG_CATALOG}/schemas/${SCHEMA_NAME}/tables/${TABLE_NAME}" \+ '.table.comment' table-old+STALE_TABLE_MODIFIED=$(read_field "$INSTANCE_B" \+ "/api/metalakes/${MAIN_METALAKE}/catalogs/${ICEBERG_CATALOG}/schemas/${SCHEMA_NAME}/tables/${TABLE_NAME}" \+ '.table.audit.lastModifiedTime')+mutate_a "alter table comment on A" PUT "/api/metalakes/${MAIN_METALAKE}/catalogs/${ICEBERG_CATALOG}/schemas/${SCHEMA_NAME}/tables/${TABLE_NAME}" \+ '{"updates":[{"@type":"updateComment","newComment":"table-new"}]}'+await_value "B sees altered table" "$INSTANCE_B" \+ "/api/metalakes/${MAIN_METALAKE}/catalogs/${ICEBERG_CATALOG}/schemas/${SCHEMA_NAME}/tables/${TABLE_NAME}" '.table.comment' table-new+await_changed "B drops the cached table entity (audit moved on)" "$INSTANCE_B" \+ "/api/metalakes/${MAIN_METALAKE}/catalogs/${ICEBERG_CATALOG}/schemas/${SCHEMA_NAME}/tables/${TABLE_NAME}" \+ '.table.audit.lastModifiedTime' "$STALE_TABLE_MODIFIED"++section "TABLE external backend E2E: rename visibility"+prewarm_value "B caches the pre-rename table" "$INSTANCE_B" \+ "/api/metalakes/${MAIN_METALAKE}/catalogs/${ICEBERG_CATALOG}/schemas/${SCHEMA_NAME}/tables/${TABLE_NAME}" \+ '.table.comment' table-new+mutate_a "rename table on A" PUT "/api/metalakes/${MAIN_METALAKE}/catalogs/${ICEBERG_CATALOG}/schemas/${SCHEMA_NAME}/tables/${TABLE_NAME}" \+ "{\"updates\":[{\"@type\":\"rename\",\"newName\":\"${RENAMED_TABLE}\"}]}"+await_http "B invalidates the old table name" "$INSTANCE_B" \+ "/api/metalakes/${MAIN_METALAKE}/catalogs/${ICEBERG_CATALOG}/schemas/${SCHEMA_NAME}/tables/${TABLE_NAME}" 404+await_value "B loads the renamed table" "$INSTANCE_B" \+ "/api/metalakes/${MAIN_METALAKE}/catalogs/${ICEBERG_CATALOG}/schemas/${SCHEMA_NAME}/tables/${RENAMED_TABLE}" '.table.name' "$RENAMED_TABLE"++section "TABLE external backend E2E: drop visibility"+prewarm_value "B caches the renamed table before A drops it" "$INSTANCE_B" \+ "/api/metalakes/${MAIN_METALAKE}/catalogs/${ICEBERG_CATALOG}/schemas/${SCHEMA_NAME}/tables/${RENAMED_TABLE}" \+ '.table.name' "$RENAMED_TABLE"+mutate_a "drop table on A" DELETE "/api/metalakes/${MAIN_METALAKE}/catalogs/${ICEBERG_CATALOG}/schemas/${SCHEMA_NAME}/tables/${RENAMED_TABLE}?purge=true"+await_http "B observes the table removed from Iceberg" "$INSTANCE_B" \+ "/api/metalakes/${MAIN_METALAKE}/catalogs/${ICEBERG_CATALOG}/schemas/${SCHEMA_NAME}/tables/${RENAMED_TABLE}" 404++section "TABLE external backend E2E: same-name recreation setup"+mutate_a "create first recreate-probe table generation on A" POST "/api/metalakes/${MAIN_METALAKE}/catalogs/${ICEBERG_CATALOG}/schemas/${SCHEMA_NAME}/tables" \+ "{\"name\":\"${RECREATE_TABLE}\",\"comment\":\"table-generation-1\",\"columns\":[{\"name\":\"id\",\"type\":\"integer\",\"nullable\":false}],\"properties\":{}}"++section "TABLE external backend E2E: drop plus same-name recreate"+prewarm_value "B caches the first table generation" "$INSTANCE_B" \+ "/api/metalakes/${MAIN_METALAKE}/catalogs/${ICEBERG_CATALOG}/schemas/${SCHEMA_NAME}/tables/${RECREATE_TABLE}" \+ '.table.comment' table-generation-1+# No audit probe here, unlike the other externally backed cases. A same-name+# recreate of an Iceberg table comes back from B with a null audit block, so+# audit.createTime cannot distinguish "the stale entity was evicted" from "no+# entity was resolved at all". AuditInfo#merge runs with overwrite=true, so a+# null entity audit blanks the catalog-side values rather than falling back to+# them; that is worth chasing separately before relying on audit here.+mutate_a "drop first table generation on A" DELETE "/api/metalakes/${MAIN_METALAKE}/catalogs/${ICEBERG_CATALOG}/schemas/${SCHEMA_NAME}/tables/${RECREATE_TABLE}?purge=true"+mutate_a "recreate the same table name on A" POST "/api/metalakes/${MAIN_METALAKE}/catalogs/${ICEBERG_CATALOG}/schemas/${SCHEMA_NAME}/tables" \+ "{\"name\":\"${RECREATE_TABLE}\",\"comment\":\"table-generation-2\",\"columns\":[{\"name\":\"id\",\"type\":\"integer\",\"nullable\":false}],\"properties\":{}}"+await_value "B loads the second table generation" "$INSTANCE_B" \+ "/api/metalakes/${MAIN_METALAKE}/catalogs/${ICEBERG_CATALOG}/schemas/${SCHEMA_NAME}/tables/${RECREATE_TABLE}" '.table.comment' table-generation-2+mutate_a "remove recreate-probe table" DELETE "/api/metalakes/${MAIN_METALAKE}/catalogs/${ICEBERG_CATALOG}/schemas/${SCHEMA_NAME}/tables/${RECREATE_TABLE}?purge=true"++section "VIEW cache: alter; external-backend recreate E2E"+mutate_a "create Iceberg view on A" POST "/api/metalakes/${MAIN_METALAKE}/catalogs/${ICEBERG_CATALOG}/schemas/${SCHEMA_NAME}/views" \+ "{\"name\":\"${VIEW_NAME}\",\"comment\":\"view-old\",\"columns\":[{\"name\":\"id\",\"type\":\"integer\",\"nullable\":false}],\"representations\":[{\"type\":\"sql\",\"dialect\":\"spark\",\"sql\":\"SELECT 1 AS id\"}],\"properties\":{}}"+# Prime audit.lastModifiedTime; see the note in the SCHEMA section.+mutate_a "prime view audit on A" PUT "/api/metalakes/${MAIN_METALAKE}/catalogs/${ICEBERG_CATALOG}/schemas/${SCHEMA_NAME}/views/${VIEW_NAME}" \+ '{"updates":[{"@type":"setProperty","property":"audit-prime","value":"1"}]}'++stale_changed_control "VIEW cache residency" "VIEW A -> B" \+ "$INSTANCE_A" "$INSTANCE_B" PUT \+ "/api/metalakes/${MAIN_METALAKE}/catalogs/${ICEBERG_CATALOG}/schemas/${SCHEMA_NAME}/views/${VIEW_NAME}" \+ "/api/metalakes/${MAIN_METALAKE}/catalogs/${ICEBERG_CATALOG}/schemas/${SCHEMA_NAME}/views/${VIEW_NAME}" \+ '.view.audit.lastModifiedTime' \+ '{"updates":[{"@type":"setProperty","property":"cache-proof","value":"__VALUE__"}]}' \+ view-proof view-proof-final++consistency_case "VIEW alter propagates A -> B"+prewarm_value "B caches the old view before A alters it" "$INSTANCE_B" \+ "/api/metalakes/${MAIN_METALAKE}/catalogs/${ICEBERG_CATALOG}/schemas/${SCHEMA_NAME}/views/${VIEW_NAME}" \+ '.view.comment' view-old+STALE_VIEW_MODIFIED=$(read_field "$INSTANCE_B" \+ "/api/metalakes/${MAIN_METALAKE}/catalogs/${ICEBERG_CATALOG}/schemas/${SCHEMA_NAME}/views/${VIEW_NAME}" \+ '.view.audit.lastModifiedTime')+mutate_a "alter view property on A" PUT "/api/metalakes/${MAIN_METALAKE}/catalogs/${ICEBERG_CATALOG}/schemas/${SCHEMA_NAME}/views/${VIEW_NAME}" \+ '{"updates":[{"@type":"setProperty","property":"cache-key","value":"view-new"}]}'+await_value "B sees altered view" "$INSTANCE_B" \+ "/api/metalakes/${MAIN_METALAKE}/catalogs/${ICEBERG_CATALOG}/schemas/${SCHEMA_NAME}/views/${VIEW_NAME}" '.view.properties["cache-key"]' view-new+await_changed "B drops the cached view entity (audit moved on)" "$INSTANCE_B" \+ "/api/metalakes/${MAIN_METALAKE}/catalogs/${ICEBERG_CATALOG}/schemas/${SCHEMA_NAME}/views/${VIEW_NAME}" \+ '.view.audit.lastModifiedTime' "$STALE_VIEW_MODIFIED"++section "VIEW external backend E2E: rename visibility"+prewarm_value "B caches the pre-rename view" "$INSTANCE_B" \+ "/api/metalakes/${MAIN_METALAKE}/catalogs/${ICEBERG_CATALOG}/schemas/${SCHEMA_NAME}/views/${VIEW_NAME}" \+ '.view.properties["cache-key"]' view-new+mutate_a "rename view on A" PUT "/api/metalakes/${MAIN_METALAKE}/catalogs/${ICEBERG_CATALOG}/schemas/${SCHEMA_NAME}/views/${VIEW_NAME}" \+ "{\"updates\":[{\"@type\":\"rename\",\"newName\":\"${RENAMED_VIEW}\"}]}"+await_http "B invalidates the old view name" "$INSTANCE_B" \+ "/api/metalakes/${MAIN_METALAKE}/catalogs/${ICEBERG_CATALOG}/schemas/${SCHEMA_NAME}/views/${VIEW_NAME}" 404+await_value "B loads the renamed view" "$INSTANCE_B" \+ "/api/metalakes/${MAIN_METALAKE}/catalogs/${ICEBERG_CATALOG}/schemas/${SCHEMA_NAME}/views/${RENAMED_VIEW}" '.view.name' "$RENAMED_VIEW"++section "VIEW external backend E2E: drop plus same-name recreate"+prewarm_value "B caches the renamed view before A drops it" "$INSTANCE_B" \+ "/api/metalakes/${MAIN_METALAKE}/catalogs/${ICEBERG_CATALOG}/schemas/${SCHEMA_NAME}/views/${RENAMED_VIEW}" \+ '.view.name' "$RENAMED_VIEW"+mutate_a "drop view on A" DELETE "/api/metalakes/${MAIN_METALAKE}/catalogs/${ICEBERG_CATALOG}/schemas/${SCHEMA_NAME}/views/${RENAMED_VIEW}"+await_http "B invalidates dropped view" "$INSTANCE_B" \+ "/api/metalakes/${MAIN_METALAKE}/catalogs/${ICEBERG_CATALOG}/schemas/${SCHEMA_NAME}/views/${RENAMED_VIEW}" 404+mutate_a "recreate the dropped view name on A" POST "/api/metalakes/${MAIN_METALAKE}/catalogs/${ICEBERG_CATALOG}/schemas/${SCHEMA_NAME}/views" \+ "{\"name\":\"${RENAMED_VIEW}\",\"comment\":\"view-generation-2\",\"columns\":[{\"name\":\"id\",\"type\":\"integer\",\"nullable\":false}],\"representations\":[{\"type\":\"sql\",\"dialect\":\"spark\",\"sql\":\"SELECT 2 AS id\"}],\"properties\":{}}"+await_value "B loads the replacement view" "$INSTANCE_B" \+ "/api/metalakes/${MAIN_METALAKE}/catalogs/${ICEBERG_CATALOG}/schemas/${SCHEMA_NAME}/views/${RENAMED_VIEW}" \+ '.view.comment' view-generation-2+mutate_a "remove the replacement view" DELETE \+ "/api/metalakes/${MAIN_METALAKE}/catalogs/${ICEBERG_CATALOG}/schemas/${SCHEMA_NAME}/views/${RENAMED_VIEW}"++section "SCHEMA external backend E2E: drop plus same-name recreate"+prewarm_value "B caches the schema immediately before A drops it" "$INSTANCE_B" \+ "/api/metalakes/${MAIN_METALAKE}/catalogs/${ICEBERG_CATALOG}/schemas/${SCHEMA_NAME}" \+ '.schema.properties["rapid-key"]' schema-v3+mutate_a "drop the warmed schema on A" DELETE "/api/metalakes/${MAIN_METALAKE}/catalogs/${ICEBERG_CATALOG}/schemas/${SCHEMA_NAME}"+await_http "B invalidates dropped schema" "$INSTANCE_B" \+ "/api/metalakes/${MAIN_METALAKE}/catalogs/${ICEBERG_CATALOG}/schemas/${SCHEMA_NAME}" 404+mutate_a "recreate the dropped schema name on A" POST "/api/metalakes/${MAIN_METALAKE}/catalogs/${ICEBERG_CATALOG}/schemas" \+ "{\"name\":\"${SCHEMA_NAME}\",\"comment\":\"schema-generation-2\",\"properties\":{}}"+await_value "B loads the replacement schema" "$INSTANCE_B" \+ "/api/metalakes/${MAIN_METALAKE}/catalogs/${ICEBERG_CATALOG}/schemas/${SCHEMA_NAME}" \+ '.schema.comment' schema-generation-2++section "SCHEMA cascade: invalidate descendant entity caches"+mutate_a "create cascade schema on A" POST "/api/metalakes/${MAIN_METALAKE}/catalogs/${FILESET_CATALOG}/schemas" \+ "{\"name\":\"${CASCADE_SCHEMA}\",\"comment\":\"cascade schema\",\"properties\":{}}"+mutate_a "create cascade descendant fileset on A" POST "/api/metalakes/${MAIN_METALAKE}/catalogs/${FILESET_CATALOG}/schemas/${CASCADE_SCHEMA}/filesets" \+ "{\"name\":\"${CASCADE_FILESET}\",\"type\":\"EXTERNAL\",\"comment\":\"cascade fileset\",\"storageLocation\":\"file:///tmp/gravitino-cascade-fileset-${SUFFIX}\",\"properties\":{}}"++consistency_case "SCHEMA cascade drop invalidates its cached descendant"+prewarm_value "B caches the cascade schema before A drops it" "$INSTANCE_B" \+ "/api/metalakes/${MAIN_METALAKE}/catalogs/${FILESET_CATALOG}/schemas/${CASCADE_SCHEMA}" \+ '.schema.name' "$CASCADE_SCHEMA"+prewarm_value "B caches the descendant fileset before A drops its schema" "$INSTANCE_B" \+ "/api/metalakes/${MAIN_METALAKE}/catalogs/${FILESET_CATALOG}/schemas/${CASCADE_SCHEMA}/filesets/${CASCADE_FILESET}" \+ '.fileset.name' "$CASCADE_FILESET"+mutate_a "cascade-drop schema on A" DELETE "/api/metalakes/${MAIN_METALAKE}/catalogs/${FILESET_CATALOG}/schemas/${CASCADE_SCHEMA}?cascade=true"+await_http "B invalidates cascade-dropped schema" "$INSTANCE_B" \+ "/api/metalakes/${MAIN_METALAKE}/catalogs/${FILESET_CATALOG}/schemas/${CASCADE_SCHEMA}" 404+await_http "B invalidates cascade-dropped descendant fileset" "$INSTANCE_B" \+ "/api/metalakes/${MAIN_METALAKE}/catalogs/${FILESET_CATALOG}/schemas/${CASCADE_SCHEMA}/filesets/${CASCADE_FILESET}" 404++# Iceberg is the only built-in catalog that accepts hierarchical schema names,+# but its schema endpoint intentionally rejects cascade=true. Exercise four+# cached schema nodes (parent, child, grandchild, and sibling), then use forced+# catalog drop as the public recursive operation for the nested hierarchy.+section "Multi-level SCHEMA cache: parent, child, grandchild, and sibling"+mutate_a "create hierarchical parent schema on A" POST "/api/metalakes/${MAIN_METALAKE}/catalogs/${ICEBERG_CATALOG}/schemas" \+ "{\"name\":\"${HIER_PARENT}\",\"comment\":\"parent\",\"properties\":{}}"+mutate_a "create hierarchical child schema on A" POST "/api/metalakes/${MAIN_METALAKE}/catalogs/${ICEBERG_CATALOG}/schemas" \+ "{\"name\":\"${HIER_CHILD}\",\"comment\":\"child\",\"properties\":{}}"+mutate_a "create hierarchical grandchild schema on A" POST "/api/metalakes/${MAIN_METALAKE}/catalogs/${ICEBERG_CATALOG}/schemas" \+ "{\"name\":\"${HIER_GRANDCHILD}\",\"comment\":\"grandchild\",\"properties\":{}}"+mutate_a "create hierarchical sibling schema on A" POST "/api/metalakes/${MAIN_METALAKE}/catalogs/${ICEBERG_CATALOG}/schemas" \+ "{\"name\":\"${HIER_SIBLING}\",\"comment\":\"sibling\",\"properties\":{}}"+# Prime audit.lastModifiedTime for every externally backed schema. Their+# catalog-side properties are useful E2E signals, but only the audit proves+# that B discarded its cached Gravitino entity.+mutate_a "prime hierarchical parent audit on A" PUT "/api/metalakes/${MAIN_METALAKE}/catalogs/${ICEBERG_CATALOG}/schemas/${HIER_PARENT}" \+ '{"updates":[{"@type":"setProperty","property":"audit-prime","value":"1"}]}'+mutate_a "prime hierarchical child audit on A" PUT "/api/metalakes/${MAIN_METALAKE}/catalogs/${ICEBERG_CATALOG}/schemas/${HIER_CHILD}" \+ '{"updates":[{"@type":"setProperty","property":"audit-prime","value":"1"}]}'+mutate_a "prime hierarchical grandchild audit on A" PUT "/api/metalakes/${MAIN_METALAKE}/catalogs/${ICEBERG_CATALOG}/schemas/${HIER_GRANDCHILD}" \+ '{"updates":[{"@type":"setProperty","property":"audit-prime","value":"1"}]}'+mutate_a "prime hierarchical sibling audit on A" PUT "/api/metalakes/${MAIN_METALAKE}/catalogs/${ICEBERG_CATALOG}/schemas/${HIER_SIBLING}" \+ '{"updates":[{"@type":"setProperty","property":"audit-prime","value":"1"}]}'+mutate_a "create grandchild table on A" POST "/api/metalakes/${MAIN_METALAKE}/catalogs/${ICEBERG_CATALOG}/schemas/${HIER_GRANDCHILD}/tables" \+ "{\"name\":\"${HIER_TABLE}\",\"comment\":\"hierarchical table\",\"columns\":[{\"name\":\"id\",\"type\":\"integer\",\"nullable\":false}],\"properties\":{}}"+mutate_a "create sibling view on A" POST "/api/metalakes/${MAIN_METALAKE}/catalogs/${ICEBERG_CATALOG}/schemas/${HIER_SIBLING}/views" \+ "{\"name\":\"${HIER_VIEW}\",\"comment\":\"hierarchical view\",\"columns\":[{\"name\":\"id\",\"type\":\"integer\",\"nullable\":false}],\"representations\":[{\"type\":\"sql\",\"dialect\":\"spark\",\"sql\":\"SELECT 1 AS id\"}],\"properties\":{}}"++consistency_case "SCHEMA alter invalidates a cached top-level parent"+prewarm_value "B caches the top-level parent before A alters it" "$INSTANCE_B" \+ "/api/metalakes/${MAIN_METALAKE}/catalogs/${ICEBERG_CATALOG}/schemas/${HIER_PARENT}" \+ '.schema.name' "$HIER_PARENT"+STALE_HIER_PARENT_MODIFIED=$(read_field "$INSTANCE_B" \+ "/api/metalakes/${MAIN_METALAKE}/catalogs/${ICEBERG_CATALOG}/schemas/${HIER_PARENT}" \+ '.schema.audit.lastModifiedTime')+mutate_a "alter hierarchical parent on A" PUT "/api/metalakes/${MAIN_METALAKE}/catalogs/${ICEBERG_CATALOG}/schemas/${HIER_PARENT}" \+ '{"updates":[{"@type":"setProperty","property":"level-key","value":"parent-new"}]}'+await_value "B sees altered parent schema" "$INSTANCE_B" \+ "/api/metalakes/${MAIN_METALAKE}/catalogs/${ICEBERG_CATALOG}/schemas/${HIER_PARENT}" '.schema.properties["level-key"]' parent-new+await_changed "B reloads the altered parent entity" "$INSTANCE_B" \+ "/api/metalakes/${MAIN_METALAKE}/catalogs/${ICEBERG_CATALOG}/schemas/${HIER_PARENT}" \+ '.schema.audit.lastModifiedTime' "$STALE_HIER_PARENT_MODIFIED"++consistency_case "SCHEMA alter invalidates a cached middle-level child"+prewarm_value "B caches the middle-level child before A alters it" "$INSTANCE_B" \+ "/api/metalakes/${MAIN_METALAKE}/catalogs/${ICEBERG_CATALOG}/schemas/${HIER_CHILD}" \+ '.schema.name' "$HIER_CHILD"+STALE_HIER_CHILD_MODIFIED=$(read_field "$INSTANCE_B" \+ "/api/metalakes/${MAIN_METALAKE}/catalogs/${ICEBERG_CATALOG}/schemas/${HIER_CHILD}" \+ '.schema.audit.lastModifiedTime')+mutate_a "alter hierarchical child on A" PUT "/api/metalakes/${MAIN_METALAKE}/catalogs/${ICEBERG_CATALOG}/schemas/${HIER_CHILD}" \+ '{"updates":[{"@type":"setProperty","property":"level-key","value":"child-new"}]}'+await_value "B sees altered child schema" "$INSTANCE_B" \+ "/api/metalakes/${MAIN_METALAKE}/catalogs/${ICEBERG_CATALOG}/schemas/${HIER_CHILD}" '.schema.properties["level-key"]' child-new+await_changed "B reloads the altered child entity" "$INSTANCE_B" \+ "/api/metalakes/${MAIN_METALAKE}/catalogs/${ICEBERG_CATALOG}/schemas/${HIER_CHILD}" \+ '.schema.audit.lastModifiedTime' "$STALE_HIER_CHILD_MODIFIED"++consistency_case "SCHEMA alter invalidates a cached grandchild"+prewarm_value "B caches the grandchild before A alters it" "$INSTANCE_B" \+ "/api/metalakes/${MAIN_METALAKE}/catalogs/${ICEBERG_CATALOG}/schemas/${HIER_GRANDCHILD}" \+ '.schema.name' "$HIER_GRANDCHILD"+STALE_HIER_GRANDCHILD_MODIFIED=$(read_field "$INSTANCE_B" \+ "/api/metalakes/${MAIN_METALAKE}/catalogs/${ICEBERG_CATALOG}/schemas/${HIER_GRANDCHILD}" \+ '.schema.audit.lastModifiedTime')+mutate_a "alter hierarchical grandchild on A" PUT "/api/metalakes/${MAIN_METALAKE}/catalogs/${ICEBERG_CATALOG}/schemas/${HIER_GRANDCHILD}" \+ '{"updates":[{"@type":"setProperty","property":"level-key","value":"grandchild-new"}]}'+await_value "B sees altered grandchild schema" "$INSTANCE_B" \+ "/api/metalakes/${MAIN_METALAKE}/catalogs/${ICEBERG_CATALOG}/schemas/${HIER_GRANDCHILD}" '.schema.properties["level-key"]' grandchild-new+await_changed "B reloads the altered grandchild entity" "$INSTANCE_B" \+ "/api/metalakes/${MAIN_METALAKE}/catalogs/${ICEBERG_CATALOG}/schemas/${HIER_GRANDCHILD}" \+ '.schema.audit.lastModifiedTime' "$STALE_HIER_GRANDCHILD_MODIFIED"++consistency_case "SCHEMA alter invalidates a cached sibling branch"+prewarm_value "B caches the sibling branch before A alters it" "$INSTANCE_B" \+ "/api/metalakes/${MAIN_METALAKE}/catalogs/${ICEBERG_CATALOG}/schemas/${HIER_SIBLING}" \+ '.schema.name' "$HIER_SIBLING"+STALE_HIER_SIBLING_MODIFIED=$(read_field "$INSTANCE_B" \+ "/api/metalakes/${MAIN_METALAKE}/catalogs/${ICEBERG_CATALOG}/schemas/${HIER_SIBLING}" \+ '.schema.audit.lastModifiedTime')+mutate_a "alter hierarchical sibling on A" PUT "/api/metalakes/${MAIN_METALAKE}/catalogs/${ICEBERG_CATALOG}/schemas/${HIER_SIBLING}" \+ '{"updates":[{"@type":"setProperty","property":"level-key","value":"sibling-new"}]}'+await_value "B sees altered sibling schema" "$INSTANCE_B" \+ "/api/metalakes/${MAIN_METALAKE}/catalogs/${ICEBERG_CATALOG}/schemas/${HIER_SIBLING}" '.schema.properties["level-key"]' sibling-new+await_changed "B reloads the altered sibling entity" "$INSTANCE_B" \+ "/api/metalakes/${MAIN_METALAKE}/catalogs/${ICEBERG_CATALOG}/schemas/${HIER_SIBLING}" \+ '.schema.audit.lastModifiedTime' "$STALE_HIER_SIBLING_MODIFIED"++consistency_case "CATALOG force drop recursively invalidates the full schema tree"+prewarm_value "B caches the hierarchical catalog before A force-drops it" "$INSTANCE_B" \+ "/api/metalakes/${MAIN_METALAKE}/catalogs/${ICEBERG_CATALOG}" \+ '.catalog.name' "$ICEBERG_CATALOG"+prewarm_value "B re-caches the altered parent before the recursive drop" "$INSTANCE_B" \+ "/api/metalakes/${MAIN_METALAKE}/catalogs/${ICEBERG_CATALOG}/schemas/${HIER_PARENT}" \+ '.schema.properties["level-key"]' parent-new+prewarm_value "B re-caches the altered child before the recursive drop" "$INSTANCE_B" \+ "/api/metalakes/${MAIN_METALAKE}/catalogs/${ICEBERG_CATALOG}/schemas/${HIER_CHILD}" \+ '.schema.properties["level-key"]' child-new+prewarm_value "B re-caches the altered grandchild before the recursive drop" "$INSTANCE_B" \+ "/api/metalakes/${MAIN_METALAKE}/catalogs/${ICEBERG_CATALOG}/schemas/${HIER_GRANDCHILD}" \+ '.schema.properties["level-key"]' grandchild-new+prewarm_value "B re-caches the altered sibling before the recursive drop" "$INSTANCE_B" \+ "/api/metalakes/${MAIN_METALAKE}/catalogs/${ICEBERG_CATALOG}/schemas/${HIER_SIBLING}" \+ '.schema.properties["level-key"]' sibling-new+prewarm_value "B caches the grandchild table before the recursive drop" "$INSTANCE_B" \+ "/api/metalakes/${MAIN_METALAKE}/catalogs/${ICEBERG_CATALOG}/schemas/${HIER_GRANDCHILD}/tables/${HIER_TABLE}" \+ '.table.name' "$HIER_TABLE"+prewarm_value "B caches the sibling view before the recursive drop" "$INSTANCE_B" \+ "/api/metalakes/${MAIN_METALAKE}/catalogs/${ICEBERG_CATALOG}/schemas/${HIER_SIBLING}/views/${HIER_VIEW}" \+ '.view.name' "$HIER_VIEW"+STALE_HIER_PARENT_CREATED=$(read_field "$INSTANCE_B" \+ "/api/metalakes/${MAIN_METALAKE}/catalogs/${ICEBERG_CATALOG}/schemas/${HIER_PARENT}" \+ '.schema.audit.createTime')+STALE_HIER_CHILD_CREATED=$(read_field "$INSTANCE_B" \+ "/api/metalakes/${MAIN_METALAKE}/catalogs/${ICEBERG_CATALOG}/schemas/${HIER_CHILD}" \+ '.schema.audit.createTime')+STALE_HIER_GRANDCHILD_CREATED=$(read_field "$INSTANCE_B" \+ "/api/metalakes/${MAIN_METALAKE}/catalogs/${ICEBERG_CATALOG}/schemas/${HIER_GRANDCHILD}" \+ '.schema.audit.createTime')+STALE_HIER_SIBLING_CREATED=$(read_field "$INSTANCE_B" \+ "/api/metalakes/${MAIN_METALAKE}/catalogs/${ICEBERG_CATALOG}/schemas/${HIER_SIBLING}" \+ '.schema.audit.createTime')+mutate_a "force-drop hierarchical catalog on A" DELETE "/api/metalakes/${MAIN_METALAKE}/catalogs/${ICEBERG_CATALOG}?force=true"+await_http "B invalidates force-dropped hierarchical catalog" "$INSTANCE_B" \+ "/api/metalakes/${MAIN_METALAKE}/catalogs/${ICEBERG_CATALOG}" 404+await_http "B observes the parent removed from Iceberg" "$INSTANCE_B" \+ "/api/metalakes/${MAIN_METALAKE}/catalogs/${ICEBERG_CATALOG}/schemas/${HIER_PARENT}" 404+await_http "B observes the child removed from Iceberg" "$INSTANCE_B" \+ "/api/metalakes/${MAIN_METALAKE}/catalogs/${ICEBERG_CATALOG}/schemas/${HIER_CHILD}" 404+await_http "B observes the grandchild removed from Iceberg" "$INSTANCE_B" \+ "/api/metalakes/${MAIN_METALAKE}/catalogs/${ICEBERG_CATALOG}/schemas/${HIER_GRANDCHILD}" 404+await_http "B observes the sibling removed from Iceberg" "$INSTANCE_B" \+ "/api/metalakes/${MAIN_METALAKE}/catalogs/${ICEBERG_CATALOG}/schemas/${HIER_SIBLING}" 404+await_http "B observes the grandchild table removed from Iceberg" "$INSTANCE_B" \+ "/api/metalakes/${MAIN_METALAKE}/catalogs/${ICEBERG_CATALOG}/schemas/${HIER_GRANDCHILD}/tables/${HIER_TABLE}" 404+await_http "B observes the sibling view removed from Iceberg" "$INSTANCE_B" \+ "/api/metalakes/${MAIN_METALAKE}/catalogs/${ICEBERG_CATALOG}/schemas/${HIER_SIBLING}/views/${HIER_VIEW}" 404++# Recreate the catalog first to show that the old external tree is absent, then+# recreate the same schema names and compare their entity audit timestamps.+# The latter is the cache assertion: external 404s alone cannot prove that the+# Gravitino schema entities were evicted.+HIER_RECREATE_BODY=$(jq -nc \+ --arg name "$ICEBERG_CATALOG" \+ --arg backend_name "multi_instance_recreated_${SUFFIX}" \+ --arg warehouse "file:///tmp/gravitino-multi-instance-iceberg-recreated-${SUFFIX}" \+ '{name:$name,type:"RELATIONAL",comment:"Iceberg empty generation",provider:"lakehouse-iceberg",properties:{"catalog-backend":"jdbc",uri:"jdbc:mysql://127.0.0.1:3306/gravitino?useSSL=false&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true",warehouse:$warehouse,"catalog-backend-name":$backend_name,"jdbc-driver":"com.mysql.cj.jdbc.Driver","jdbc-user":"gravitino","jdbc-password":"gravitino","jdbc-initialize":"true"}}')+mutate_a "recreate an empty hierarchical catalog with the same name" POST "/api/metalakes/${MAIN_METALAKE}/catalogs" "$HIER_RECREATE_BODY"+api "$INSTANCE_B" GET "/api/metalakes/${MAIN_METALAKE}/catalogs/${ICEBERG_CATALOG}"+expect_value "B loads the empty replacement catalog" '.catalog.comment' "Iceberg empty generation"+api "$INSTANCE_B" GET "/api/metalakes/${MAIN_METALAKE}/catalogs/${ICEBERG_CATALOG}/schemas/${HIER_PARENT}"+expect_http "B does not leak the old parent through the replacement catalog" 404+api "$INSTANCE_B" GET "/api/metalakes/${MAIN_METALAKE}/catalogs/${ICEBERG_CATALOG}/schemas/${HIER_GRANDCHILD}"+expect_http "B does not leak the old grandchild through the replacement catalog" 404+api "$INSTANCE_B" GET "/api/metalakes/${MAIN_METALAKE}/catalogs/${ICEBERG_CATALOG}/schemas/${HIER_SIBLING}"+expect_http "B does not leak the old sibling through the replacement catalog" 404+mutate_a "recreate hierarchical parent schema" POST "/api/metalakes/${MAIN_METALAKE}/catalogs/${ICEBERG_CATALOG}/schemas" \+ "{\"name\":\"${HIER_PARENT}\",\"comment\":\"parent-generation-2\",\"properties\":{}}"+mutate_a "recreate hierarchical child schema" POST "/api/metalakes/${MAIN_METALAKE}/catalogs/${ICEBERG_CATALOG}/schemas" \+ "{\"name\":\"${HIER_CHILD}\",\"comment\":\"child-generation-2\",\"properties\":{}}"+mutate_a "recreate hierarchical grandchild schema" POST "/api/metalakes/${MAIN_METALAKE}/catalogs/${ICEBERG_CATALOG}/schemas" \+ "{\"name\":\"${HIER_GRANDCHILD}\",\"comment\":\"grandchild-generation-2\",\"properties\":{}}"+mutate_a "recreate hierarchical sibling schema" POST "/api/metalakes/${MAIN_METALAKE}/catalogs/${ICEBERG_CATALOG}/schemas" \+ "{\"name\":\"${HIER_SIBLING}\",\"comment\":\"sibling-generation-2\",\"properties\":{}}"+await_changed "B does not reuse the dropped parent schema entity" "$INSTANCE_B" \+ "/api/metalakes/${MAIN_METALAKE}/catalogs/${ICEBERG_CATALOG}/schemas/${HIER_PARENT}" \+ '.schema.audit.createTime' "$STALE_HIER_PARENT_CREATED"+await_changed "B does not reuse the dropped child schema entity" "$INSTANCE_B" \+ "/api/metalakes/${MAIN_METALAKE}/catalogs/${ICEBERG_CATALOG}/schemas/${HIER_CHILD}" \+ '.schema.audit.createTime' "$STALE_HIER_CHILD_CREATED"+await_changed "B does not reuse the dropped grandchild schema entity" "$INSTANCE_B" \+ "/api/metalakes/${MAIN_METALAKE}/catalogs/${ICEBERG_CATALOG}/schemas/${HIER_GRANDCHILD}" \+ '.schema.audit.createTime' "$STALE_HIER_GRANDCHILD_CREATED"+await_changed "B does not reuse the dropped sibling schema entity" "$INSTANCE_B" \+ "/api/metalakes/${MAIN_METALAKE}/catalogs/${ICEBERG_CATALOG}/schemas/${HIER_SIBLING}" \+ '.schema.audit.createTime' "$STALE_HIER_SIBLING_CREATED"+mutate_a "remove the replacement hierarchical catalog" DELETE "/api/metalakes/${MAIN_METALAKE}/catalogs/${ICEBERG_CATALOG}?force=true"++section "FILESET cache: alter, rename, and drop"+mutate_a "create fileset schema on A" POST "/api/metalakes/${MAIN_METALAKE}/catalogs/${FILESET_CATALOG}/schemas" \+ "{\"name\":\"${FILESET_SCHEMA}\",\"comment\":\"fileset schema\",\"properties\":{}}"+mutate_a "create fileset on A" POST "/api/metalakes/${MAIN_METALAKE}/catalogs/${FILESET_CATALOG}/schemas/${FILESET_SCHEMA}/filesets" \+ "{\"name\":\"${FILESET_NAME}\",\"type\":\"EXTERNAL\",\"comment\":\"fileset-old\",\"storageLocation\":\"file:///tmp/gravitino-fileset-${SUFFIX}\",\"properties\":{}}"++stale_value_control "FILESET cache residency" "FILESET A -> B" \+ "$INSTANCE_A" "$INSTANCE_B" PUT \+ "/api/metalakes/${MAIN_METALAKE}/catalogs/${FILESET_CATALOG}/schemas/${FILESET_SCHEMA}/filesets/${FILESET_NAME}" \+ "/api/metalakes/${MAIN_METALAKE}/catalogs/${FILESET_CATALOG}/schemas/${FILESET_SCHEMA}/filesets/${FILESET_NAME}" \+ '.fileset.comment' fileset-old \+ '{"updates":[{"@type":"updateComment","newComment":"__VALUE__"}]}' \+ fileset-proof++consistency_case "FILESET alter propagates A -> B"+prewarm_value "B caches the old fileset before A alters it" "$INSTANCE_B" \+ "/api/metalakes/${MAIN_METALAKE}/catalogs/${FILESET_CATALOG}/schemas/${FILESET_SCHEMA}/filesets/${FILESET_NAME}" \+ '.fileset.comment' fileset-old+mutate_a "alter fileset comment on A" PUT "/api/metalakes/${MAIN_METALAKE}/catalogs/${FILESET_CATALOG}/schemas/${FILESET_SCHEMA}/filesets/${FILESET_NAME}" \+ '{"updates":[{"@type":"updateComment","newComment":"fileset-new"}]}'+await_value "B sees altered fileset" "$INSTANCE_B" \+ "/api/metalakes/${MAIN_METALAKE}/catalogs/${FILESET_CATALOG}/schemas/${FILESET_SCHEMA}/filesets/${FILESET_NAME}" '.fileset.comment' fileset-new++consistency_case "FILESET rename invalidates the old name on B"+prewarm_value "B caches the pre-rename fileset" "$INSTANCE_B" \+ "/api/metalakes/${MAIN_METALAKE}/catalogs/${FILESET_CATALOG}/schemas/${FILESET_SCHEMA}/filesets/${FILESET_NAME}" \+ '.fileset.comment' fileset-new+mutate_a "rename fileset on A" PUT "/api/metalakes/${MAIN_METALAKE}/catalogs/${FILESET_CATALOG}/schemas/${FILESET_SCHEMA}/filesets/${FILESET_NAME}" \+ "{\"updates\":[{\"@type\":\"rename\",\"newName\":\"${RENAMED_FILESET}\"}]}"+await_http "B invalidates the old fileset name" "$INSTANCE_B" \+ "/api/metalakes/${MAIN_METALAKE}/catalogs/${FILESET_CATALOG}/schemas/${FILESET_SCHEMA}/filesets/${FILESET_NAME}" 404+await_value "B loads the renamed fileset" "$INSTANCE_B" \+ "/api/metalakes/${MAIN_METALAKE}/catalogs/${FILESET_CATALOG}/schemas/${FILESET_SCHEMA}/filesets/${RENAMED_FILESET}" '.fileset.name' "$RENAMED_FILESET"++consistency_case "FILESET drop invalidates B"+prewarm_value "B caches the renamed fileset before A drops it" "$INSTANCE_B" \+ "/api/metalakes/${MAIN_METALAKE}/catalogs/${FILESET_CATALOG}/schemas/${FILESET_SCHEMA}/filesets/${RENAMED_FILESET}" \+ '.fileset.name' "$RENAMED_FILESET"+mutate_a "drop fileset on A" DELETE "/api/metalakes/${MAIN_METALAKE}/catalogs/${FILESET_CATALOG}/schemas/${FILESET_SCHEMA}/filesets/${RENAMED_FILESET}"+await_http "B invalidates dropped fileset" "$INSTANCE_B" \+ "/api/metalakes/${MAIN_METALAKE}/catalogs/${FILESET_CATALOG}/schemas/${FILESET_SCHEMA}/filesets/${RENAMED_FILESET}" 404++section "FILESET edge case: drop and recreate the same name in one poll window"+mutate_a "create first recreate-probe fileset generation on A" POST "/api/metalakes/${MAIN_METALAKE}/catalogs/${FILESET_CATALOG}/schemas/${FILESET_SCHEMA}/filesets" \+ "{\"name\":\"${RECREATE_FILESET}\",\"type\":\"EXTERNAL\",\"comment\":\"fileset-generation-1\",\"storageLocation\":\"file:///tmp/gravitino-fileset-recreate-1-${SUFFIX}\",\"properties\":{}}"++consistency_case "FILESET drop plus same-name recreate evicts the old generation"+prewarm_value "B caches the first fileset generation" "$INSTANCE_B" \+ "/api/metalakes/${MAIN_METALAKE}/catalogs/${FILESET_CATALOG}/schemas/${FILESET_SCHEMA}/filesets/${RECREATE_FILESET}" \+ '.fileset.comment' fileset-generation-1+mutate_a "drop first fileset generation on A" DELETE "/api/metalakes/${MAIN_METALAKE}/catalogs/${FILESET_CATALOG}/schemas/${FILESET_SCHEMA}/filesets/${RECREATE_FILESET}"+mutate_a "recreate the same fileset name on A" POST "/api/metalakes/${MAIN_METALAKE}/catalogs/${FILESET_CATALOG}/schemas/${FILESET_SCHEMA}/filesets" \+ "{\"name\":\"${RECREATE_FILESET}\",\"type\":\"EXTERNAL\",\"comment\":\"fileset-generation-2\",\"storageLocation\":\"file:///tmp/gravitino-fileset-recreate-2-${SUFFIX}\",\"properties\":{}}"+await_value "B loads the second fileset generation" "$INSTANCE_B" \+ "/api/metalakes/${MAIN_METALAKE}/catalogs/${FILESET_CATALOG}/schemas/${FILESET_SCHEMA}/filesets/${RECREATE_FILESET}" '.fileset.comment' fileset-generation-2++section "TOPIC cache: alter"+mutate_a "create Kafka topic on A" POST "/api/metalakes/${MAIN_METALAKE}/catalogs/${KAFKA_CATALOG}/schemas/default/topics" \+ "{\"name\":\"${TOPIC_NAME}\",\"comment\":\"topic-priming\",\"properties\":{\"partition-count\":\"1\",\"replication-factor\":\"1\"}}"+# Prime audit.lastModifiedTime; see the note in the SCHEMA section. Kafka+# validates topic properties against its own config keys, so prime through the+# comment rather than an arbitrary property.+mutate_a "prime topic audit on A" PUT "/api/metalakes/${MAIN_METALAKE}/catalogs/${KAFKA_CATALOG}/schemas/default/topics/${TOPIC_NAME}" \+ '{"updates":[{"@type":"updateComment","newComment":"topic-old"}]}'++stale_changed_control "TOPIC cache residency" "TOPIC A -> B" \+ "$INSTANCE_A" "$INSTANCE_B" PUT \+ "/api/metalakes/${MAIN_METALAKE}/catalogs/${KAFKA_CATALOG}/schemas/default/topics/${TOPIC_NAME}" \+ "/api/metalakes/${MAIN_METALAKE}/catalogs/${KAFKA_CATALOG}/schemas/default/topics/${TOPIC_NAME}" \+ '.topic.audit.lastModifiedTime' \+ '{"updates":[{"@type":"updateComment","newComment":"__VALUE__"}]}' \+ topic-proof topic-old++consistency_case "TOPIC alter propagates A -> B"+prewarm_value "B caches the old topic before A alters it" "$INSTANCE_B" \+ "/api/metalakes/${MAIN_METALAKE}/catalogs/${KAFKA_CATALOG}/schemas/default/topics/${TOPIC_NAME}" \+ '.topic.comment' topic-old+STALE_TOPIC_MODIFIED=$(read_field "$INSTANCE_B" \+ "/api/metalakes/${MAIN_METALAKE}/catalogs/${KAFKA_CATALOG}/schemas/default/topics/${TOPIC_NAME}" \+ '.topic.audit.lastModifiedTime')+mutate_a "alter topic comment on A" PUT "/api/metalakes/${MAIN_METALAKE}/catalogs/${KAFKA_CATALOG}/schemas/default/topics/${TOPIC_NAME}" \+ '{"updates":[{"@type":"updateComment","newComment":"topic-new"}]}'+await_value "B sees altered topic" "$INSTANCE_B" \+ "/api/metalakes/${MAIN_METALAKE}/catalogs/${KAFKA_CATALOG}/schemas/default/topics/${TOPIC_NAME}" '.topic.comment' topic-new+await_changed "B drops the cached topic entity (audit moved on)" "$INSTANCE_B" \+ "/api/metalakes/${MAIN_METALAKE}/catalogs/${KAFKA_CATALOG}/schemas/default/topics/${TOPIC_NAME}" \+ '.topic.audit.lastModifiedTime' "$STALE_TOPIC_MODIFIED"++section "TOPIC external backend E2E: drop visibility"+prewarm_value "B caches the altered topic before A drops it" "$INSTANCE_B" \+ "/api/metalakes/${MAIN_METALAKE}/catalogs/${KAFKA_CATALOG}/schemas/default/topics/${TOPIC_NAME}" \+ '.topic.comment' topic-new+mutate_a "drop topic on A" DELETE "/api/metalakes/${MAIN_METALAKE}/catalogs/${KAFKA_CATALOG}/schemas/default/topics/${TOPIC_NAME}"+await_http "B observes the topic removed from Kafka" "$INSTANCE_B" \+ "/api/metalakes/${MAIN_METALAKE}/catalogs/${KAFKA_CATALOG}/schemas/default/topics/${TOPIC_NAME}" 404++section "TAG cache: alter, rename, and drop"+mutate_a "create tag on A" POST "/api/metalakes/${MAIN_METALAKE}/tags" \+ "{\"name\":\"${TAG_NAME}\",\"comment\":\"tag-old\",\"properties\":{}}"++consistency_case "TAG alter propagates A -> B"+prewarm_value "B caches the old tag before A alters it" "$INSTANCE_B" \+ "/api/metalakes/${MAIN_METALAKE}/tags/${TAG_NAME}" '.tag.comment' tag-old+mutate_a "alter tag comment on A" PUT "/api/metalakes/${MAIN_METALAKE}/tags/${TAG_NAME}" \+ '{"updates":[{"@type":"updateComment","newComment":"tag-new"}]}'+await_value "B sees altered tag" "$INSTANCE_B" \+ "/api/metalakes/${MAIN_METALAKE}/tags/${TAG_NAME}" '.tag.comment' tag-new++consistency_case "TAG rename invalidates the old name on B"+prewarm_value "B caches the pre-rename tag" "$INSTANCE_B" \+ "/api/metalakes/${MAIN_METALAKE}/tags/${TAG_NAME}" '.tag.comment' tag-new+mutate_a "rename tag on A" PUT "/api/metalakes/${MAIN_METALAKE}/tags/${TAG_NAME}" \+ "{\"updates\":[{\"@type\":\"rename\",\"newName\":\"${RENAMED_TAG}\"}]}"+await_http "B invalidates the old tag name" "$INSTANCE_B" \+ "/api/metalakes/${MAIN_METALAKE}/tags/${TAG_NAME}" 404+await_value "B loads the renamed tag" "$INSTANCE_B" \+ "/api/metalakes/${MAIN_METALAKE}/tags/${RENAMED_TAG}" '.tag.name' "$RENAMED_TAG"++consistency_case "TAG drop invalidates B"+prewarm_value "B caches the renamed tag before A drops it" "$INSTANCE_B" \+ "/api/metalakes/${MAIN_METALAKE}/tags/${RENAMED_TAG}" '.tag.name' "$RENAMED_TAG"+mutate_a "drop tag on A" DELETE "/api/metalakes/${MAIN_METALAKE}/tags/${RENAMED_TAG}"+await_http "B invalidates dropped tag" "$INSTANCE_B" \+ "/api/metalakes/${MAIN_METALAKE}/tags/${RENAMED_TAG}" 404++section "TAG edge cases: same-name recreate and rapid updates"+mutate_a "create first recreate-probe tag generation on A" POST "/api/metalakes/${MAIN_METALAKE}/tags" \+ "{\"name\":\"${RECREATE_TAG}\",\"comment\":\"tag-generation-1\",\"properties\":{}}"++consistency_case "TAG drop plus same-name recreate evicts the old generation"+prewarm_value "B caches the first tag generation" "$INSTANCE_B" \+ "/api/metalakes/${MAIN_METALAKE}/tags/${RECREATE_TAG}" '.tag.comment' tag-generation-1+mutate_a "drop first tag generation on A" DELETE "/api/metalakes/${MAIN_METALAKE}/tags/${RECREATE_TAG}"+mutate_a "recreate the same tag name on A" POST "/api/metalakes/${MAIN_METALAKE}/tags" \+ "{\"name\":\"${RECREATE_TAG}\",\"comment\":\"tag-generation-2\",\"properties\":{}}"+await_value "B loads the second tag generation" "$INSTANCE_B" \+ "/api/metalakes/${MAIN_METALAKE}/tags/${RECREATE_TAG}" '.tag.comment' tag-generation-2++mutate_a "create rapid-update tag on A" POST "/api/metalakes/${MAIN_METALAKE}/tags" \+ "{\"name\":\"${LATEST_TAG}\",\"comment\":\"tag-v0\",\"properties\":{}}"++consistency_case "TAG keeps the latest of several alters inside one poll window"+prewarm_value "B caches the tag before A performs rapid alters" "$INSTANCE_B" \+ "/api/metalakes/${MAIN_METALAKE}/tags/${LATEST_TAG}" '.tag.comment' tag-v0+mutate_a "set rapid tag value 1 on A" PUT "/api/metalakes/${MAIN_METALAKE}/tags/${LATEST_TAG}" \+ '{"updates":[{"@type":"updateComment","newComment":"tag-v1"}]}'+mutate_a "set rapid tag value 2 on A" PUT "/api/metalakes/${MAIN_METALAKE}/tags/${LATEST_TAG}" \+ '{"updates":[{"@type":"updateComment","newComment":"tag-v2"}]}'+mutate_a "set rapid tag value 3 on A" PUT "/api/metalakes/${MAIN_METALAKE}/tags/${LATEST_TAG}" \+ '{"updates":[{"@type":"updateComment","newComment":"tag-v3"}]}'+await_value "B sees the latest rapid tag value" "$INSTANCE_B" \+ "/api/metalakes/${MAIN_METALAKE}/tags/${LATEST_TAG}" '.tag.comment' tag-v3++section "POLICY cache: alter, rename, disable/enable, and drop"+POLICY_BODY=$(jq -nc --arg name "$POLICY_NAME" \+ '{name:$name,comment:"policy-old",policyType:"custom",enabled:true,content:{customRules:{retentionDays:30},supportedObjectTypes:["CATALOG","SCHEMA","TABLE"],properties:{owner:"platform"}}}')+mutate_a "create policy on A" POST "/api/metalakes/${MAIN_METALAKE}/policies" "$POLICY_BODY"++stale_value_control "POLICY cache residency" "POLICY A -> B" \+ "$INSTANCE_A" "$INSTANCE_B" PUT \+ "/api/metalakes/${MAIN_METALAKE}/policies/${POLICY_NAME}" \+ "/api/metalakes/${MAIN_METALAKE}/policies/${POLICY_NAME}" \+ '.policy.comment' policy-old \+ '{"updates":[{"@type":"updateComment","newComment":"__VALUE__"}]}' \+ policy-proof++consistency_case "POLICY alter propagates A -> B"+prewarm_value "B caches the old policy before A alters it" "$INSTANCE_B" \+ "/api/metalakes/${MAIN_METALAKE}/policies/${POLICY_NAME}" '.policy.comment' policy-old+mutate_a "alter policy comment on A" PUT "/api/metalakes/${MAIN_METALAKE}/policies/${POLICY_NAME}" \+ '{"updates":[{"@type":"updateComment","newComment":"policy-new"}]}'+await_value "B sees altered policy" "$INSTANCE_B" \+ "/api/metalakes/${MAIN_METALAKE}/policies/${POLICY_NAME}" '.policy.comment' policy-new++consistency_case "POLICY rename invalidates the old name on B"+prewarm_value "B caches the pre-rename policy" "$INSTANCE_B" \+ "/api/metalakes/${MAIN_METALAKE}/policies/${POLICY_NAME}" '.policy.comment' policy-new+mutate_a "rename policy on A" PUT "/api/metalakes/${MAIN_METALAKE}/policies/${POLICY_NAME}" \+ "{\"updates\":[{\"@type\":\"rename\",\"newName\":\"${RENAMED_POLICY}\"}]}"+await_http "B invalidates the old policy name" "$INSTANCE_B" \+ "/api/metalakes/${MAIN_METALAKE}/policies/${POLICY_NAME}" 404+await_value "B loads the renamed policy" "$INSTANCE_B" \+ "/api/metalakes/${MAIN_METALAKE}/policies/${RENAMED_POLICY}" '.policy.name' "$RENAMED_POLICY"++consistency_case "POLICY disable propagates A -> B"+prewarm_value "B caches the enabled policy before A disables it" "$INSTANCE_B" \+ "/api/metalakes/${MAIN_METALAKE}/policies/${RENAMED_POLICY}" '.policy.enabled' true+mutate_a "disable policy on A" PATCH "/api/metalakes/${MAIN_METALAKE}/policies/${RENAMED_POLICY}" '{"enable":false}'+await_value "B sees disabled policy state" "$INSTANCE_B" \+ "/api/metalakes/${MAIN_METALAKE}/policies/${RENAMED_POLICY}" '.policy.enabled' false++consistency_case "POLICY enable propagates A -> B"+prewarm_value "B caches the disabled policy before A enables it" "$INSTANCE_B" \+ "/api/metalakes/${MAIN_METALAKE}/policies/${RENAMED_POLICY}" '.policy.enabled' false+mutate_a "enable policy on A" PATCH "/api/metalakes/${MAIN_METALAKE}/policies/${RENAMED_POLICY}" '{"enable":true}'+await_value "B sees enabled policy state" "$INSTANCE_B" \+ "/api/metalakes/${MAIN_METALAKE}/policies/${RENAMED_POLICY}" '.policy.enabled' true++consistency_case "POLICY drop invalidates B"+prewarm_value "B caches the enabled policy before A drops it" "$INSTANCE_B" \+ "/api/metalakes/${MAIN_METALAKE}/policies/${RENAMED_POLICY}" '.policy.enabled' true+mutate_a "drop policy on A" DELETE "/api/metalakes/${MAIN_METALAKE}/policies/${RENAMED_POLICY}"+await_http "B invalidates dropped policy" "$INSTANCE_B" \+ "/api/metalakes/${MAIN_METALAKE}/policies/${RENAMED_POLICY}" 404++section "Reverse direction: mutate B and invalidate warmed caches on A"+mutate_a "create reverse-direction tag" POST "/api/metalakes/${MAIN_METALAKE}/tags" \+ "{\"name\":\"${REVERSE_TAG}\",\"comment\":\"reverse-tag-old\",\"properties\":{}}"++stale_value_control "TAG reverse-direction cache residency" "TAG B -> A" \+ "$INSTANCE_B" "$INSTANCE_A" PUT \+ "/api/metalakes/${MAIN_METALAKE}/tags/${REVERSE_TAG}" \+ "/api/metalakes/${MAIN_METALAKE}/tags/${REVERSE_TAG}" \+ '.tag.comment' reverse-tag-old \+ '{"updates":[{"@type":"updateComment","newComment":"__VALUE__"}]}' \+ reverse-tag-proof++consistency_case "TAG alter propagates B -> A"+prewarm_value "A caches the old tag before B alters it" "$INSTANCE_A" \+ "/api/metalakes/${MAIN_METALAKE}/tags/${REVERSE_TAG}" '.tag.comment' reverse-tag-old+mutate_b "alter reverse-direction tag on B" PUT "/api/metalakes/${MAIN_METALAKE}/tags/${REVERSE_TAG}" \+ '{"updates":[{"@type":"updateComment","newComment":"reverse-tag-new"}]}'+await_value "A sees the tag altered through B" "$INSTANCE_A" \+ "/api/metalakes/${MAIN_METALAKE}/tags/${REVERSE_TAG}" '.tag.comment' reverse-tag-new++consistency_case "TAG rename propagates B -> A"+prewarm_value "A caches the pre-rename tag" "$INSTANCE_A" \+ "/api/metalakes/${MAIN_METALAKE}/tags/${REVERSE_TAG}" '.tag.comment' reverse-tag-new+mutate_b "rename reverse-direction tag on B" PUT "/api/metalakes/${MAIN_METALAKE}/tags/${REVERSE_TAG}" \+ "{\"updates\":[{\"@type\":\"rename\",\"newName\":\"${RENAMED_REVERSE_TAG}\"}]}"+await_http "A invalidates the tag's old name" "$INSTANCE_A" \+ "/api/metalakes/${MAIN_METALAKE}/tags/${REVERSE_TAG}" 404+await_value "A loads the tag renamed through B" "$INSTANCE_A" \+ "/api/metalakes/${MAIN_METALAKE}/tags/${RENAMED_REVERSE_TAG}" '.tag.name' "$RENAMED_REVERSE_TAG"++mutate_a "create reverse-direction fileset" POST "/api/metalakes/${MAIN_METALAKE}/catalogs/${FILESET_CATALOG}/schemas/${FILESET_SCHEMA}/filesets" \+ "{\"name\":\"${REVERSE_FILESET}\",\"type\":\"EXTERNAL\",\"comment\":\"reverse-fileset-old\",\"storageLocation\":\"file:///tmp/gravitino-reverse-fileset-${SUFFIX}\",\"properties\":{}}"++consistency_case "FILESET alter propagates B -> A"+prewarm_value "A caches the old fileset before B alters it" "$INSTANCE_A" \+ "/api/metalakes/${MAIN_METALAKE}/catalogs/${FILESET_CATALOG}/schemas/${FILESET_SCHEMA}/filesets/${REVERSE_FILESET}" \+ '.fileset.comment' reverse-fileset-old+mutate_b "alter reverse-direction fileset on B" PUT "/api/metalakes/${MAIN_METALAKE}/catalogs/${FILESET_CATALOG}/schemas/${FILESET_SCHEMA}/filesets/${REVERSE_FILESET}" \+ '{"updates":[{"@type":"updateComment","newComment":"reverse-fileset-new"}]}'+await_value "A sees the fileset altered through B" "$INSTANCE_A" \+ "/api/metalakes/${MAIN_METALAKE}/catalogs/${FILESET_CATALOG}/schemas/${FILESET_SCHEMA}/filesets/${REVERSE_FILESET}" '.fileset.comment' reverse-fileset-new++consistency_case "FILESET rename propagates B -> A"+prewarm_value "A caches the pre-rename fileset" "$INSTANCE_A" \+ "/api/metalakes/${MAIN_METALAKE}/catalogs/${FILESET_CATALOG}/schemas/${FILESET_SCHEMA}/filesets/${REVERSE_FILESET}" \+ '.fileset.comment' reverse-fileset-new+mutate_b "rename reverse-direction fileset on B" PUT "/api/metalakes/${MAIN_METALAKE}/catalogs/${FILESET_CATALOG}/schemas/${FILESET_SCHEMA}/filesets/${REVERSE_FILESET}" \+ "{\"updates\":[{\"@type\":\"rename\",\"newName\":\"${RENAMED_REVERSE_FILESET}\"}]}"+await_http "A invalidates the fileset's old name" "$INSTANCE_A" \+ "/api/metalakes/${MAIN_METALAKE}/catalogs/${FILESET_CATALOG}/schemas/${FILESET_SCHEMA}/filesets/${REVERSE_FILESET}" 404+await_value "A loads the fileset renamed through B" "$INSTANCE_A" \+ "/api/metalakes/${MAIN_METALAKE}/catalogs/${FILESET_CATALOG}/schemas/${FILESET_SCHEMA}/filesets/${RENAMED_REVERSE_FILESET}" '.fileset.name' "$RENAMED_REVERSE_FILESET"++REVERSE_POLICY_BODY=$(jq -nc --arg name "$REVERSE_POLICY" \+ '{name:$name,comment:"reverse-policy",policyType:"custom",enabled:true,content:{customRules:{retentionDays:30},supportedObjectTypes:["CATALOG","SCHEMA","TABLE"],properties:{owner:"platform"}}}')+mutate_a "create reverse-direction policy" POST "/api/metalakes/${MAIN_METALAKE}/policies" "$REVERSE_POLICY_BODY"++consistency_case "POLICY disable propagates B -> A"+prewarm_value "A caches the enabled policy before B disables it" "$INSTANCE_A" \+ "/api/metalakes/${MAIN_METALAKE}/policies/${REVERSE_POLICY}" '.policy.enabled' true+mutate_b "disable reverse-direction policy on B" PATCH "/api/metalakes/${MAIN_METALAKE}/policies/${REVERSE_POLICY}" '{"enable":false}'+await_value "A sees the policy disabled through B" "$INSTANCE_A" \+ "/api/metalakes/${MAIN_METALAKE}/policies/${REVERSE_POLICY}" '.policy.enabled' false++consistency_case "POLICY enable propagates B -> A"+prewarm_value "A caches the disabled policy before B enables it" "$INSTANCE_A" \+ "/api/metalakes/${MAIN_METALAKE}/policies/${REVERSE_POLICY}" '.policy.enabled' false+mutate_b "enable reverse-direction policy on B" PATCH "/api/metalakes/${MAIN_METALAKE}/policies/${REVERSE_POLICY}" '{"enable":true}'+await_value "A sees the policy enabled through B" "$INSTANCE_A" \+ "/api/metalakes/${MAIN_METALAKE}/policies/${REVERSE_POLICY}" '.policy.enabled' true++section "Cross-type batch: invalidate parent and child entities in one poll"+mutate_a "create burst tag" POST "/api/metalakes/${MAIN_METALAKE}/tags" \+ "{\"name\":\"${BURST_TAG}\",\"comment\":\"burst-tag-old\",\"properties\":{}}"+BURST_POLICY_BODY=$(jq -nc --arg name "$BURST_POLICY" \+ '{name:$name,comment:"burst-policy-old",policyType:"custom",enabled:true,content:{customRules:{retentionDays:30},supportedObjectTypes:["CATALOG","SCHEMA","TABLE"],properties:{owner:"platform"}}}')+mutate_a "create burst policy" POST "/api/metalakes/${MAIN_METALAKE}/policies" "$BURST_POLICY_BODY"+mutate_a "create burst fileset" POST "/api/metalakes/${MAIN_METALAKE}/catalogs/${FILESET_CATALOG}/schemas/${FILESET_SCHEMA}/filesets" \+ "{\"name\":\"${BURST_FILESET}\",\"type\":\"EXTERNAL\",\"comment\":\"burst-fileset-old\",\"storageLocation\":\"file:///tmp/gravitino-burst-fileset-${SUFFIX}\",\"properties\":{}}"++consistency_case "CATALOG, SCHEMA, FILESET, TAG, and POLICY invalidate in one batch"+prewarm_value "B caches the catalog before the cross-type batch" "$INSTANCE_B" \+ "/api/metalakes/${MAIN_METALAKE}/catalogs/${FILESET_CATALOG}" \+ '.catalog.comment' "Fileset cache test"+prewarm_value "B caches the schema before the cross-type batch" "$INSTANCE_B" \+ "/api/metalakes/${MAIN_METALAKE}/catalogs/${FILESET_CATALOG}/schemas/${FILESET_SCHEMA}" \+ '.schema.name' "$FILESET_SCHEMA"+prewarm_value "B caches the fileset before the cross-type batch" "$INSTANCE_B" \+ "/api/metalakes/${MAIN_METALAKE}/catalogs/${FILESET_CATALOG}/schemas/${FILESET_SCHEMA}/filesets/${BURST_FILESET}" \+ '.fileset.comment' burst-fileset-old+prewarm_value "B caches the tag before the cross-type batch" "$INSTANCE_B" \+ "/api/metalakes/${MAIN_METALAKE}/tags/${BURST_TAG}" '.tag.comment' burst-tag-old+prewarm_value "B caches the policy before the cross-type batch" "$INSTANCE_B" \+ "/api/metalakes/${MAIN_METALAKE}/policies/${BURST_POLICY}" '.policy.comment' burst-policy-old+mutate_a "alter burst catalog on A" PUT "/api/metalakes/${MAIN_METALAKE}/catalogs/${FILESET_CATALOG}" \+ '{"updates":[{"@type":"updateComment","newComment":"burst-catalog-new"}]}'+mutate_a "alter burst schema on A" PUT "/api/metalakes/${MAIN_METALAKE}/catalogs/${FILESET_CATALOG}/schemas/${FILESET_SCHEMA}" \+ '{"updates":[{"@type":"setProperty","property":"burst-key","value":"burst-schema-new"}]}'+mutate_a "alter burst fileset on A" PUT "/api/metalakes/${MAIN_METALAKE}/catalogs/${FILESET_CATALOG}/schemas/${FILESET_SCHEMA}/filesets/${BURST_FILESET}" \+ '{"updates":[{"@type":"updateComment","newComment":"burst-fileset-new"}]}'+mutate_a "alter burst tag on A" PUT "/api/metalakes/${MAIN_METALAKE}/tags/${BURST_TAG}" \+ '{"updates":[{"@type":"updateComment","newComment":"burst-tag-new"}]}'+mutate_a "alter burst policy on A" PUT "/api/metalakes/${MAIN_METALAKE}/policies/${BURST_POLICY}" \+ '{"updates":[{"@type":"updateComment","newComment":"burst-policy-new"}]}'+await_value "B sees the catalog from the batch" "$INSTANCE_B" \+ "/api/metalakes/${MAIN_METALAKE}/catalogs/${FILESET_CATALOG}" '.catalog.comment' burst-catalog-new+await_value "B sees the schema from the batch" "$INSTANCE_B" \+ "/api/metalakes/${MAIN_METALAKE}/catalogs/${FILESET_CATALOG}/schemas/${FILESET_SCHEMA}" '.schema.properties["burst-key"]' burst-schema-new+await_value "B sees the fileset from the batch" "$INSTANCE_B" \+ "/api/metalakes/${MAIN_METALAKE}/catalogs/${FILESET_CATALOG}/schemas/${FILESET_SCHEMA}/filesets/${BURST_FILESET}" '.fileset.comment' burst-fileset-new+await_value "B sees the tag from the batch" "$INSTANCE_B" \+ "/api/metalakes/${MAIN_METALAKE}/tags/${BURST_TAG}" '.tag.comment' burst-tag-new+await_value "B sees the policy from the batch" "$INSTANCE_B" \+ "/api/metalakes/${MAIN_METALAKE}/policies/${BURST_POLICY}" '.policy.comment' burst-policy-new++section "JOB cache: cancellation alters the cached status"+JOB_SCRIPT="$(mktemp -t gravitino-entity-cache-job.XXXX.sh)"+printf '#!/usr/bin/env bash\nsleep 60\n' >"$JOB_SCRIPT"+chmod +x "$JOB_SCRIPT"+JOB_TEMPLATE_BODY=$(jq -nc --arg name "$JOB_TEMPLATE" --arg executable "$JOB_SCRIPT" \+ '{jobTemplate:{name:$name,jobType:"shell",comment:"Job cache test",executable:$executable,arguments:[],environments:{},customFields:{},scripts:[]}}')+mutate_a "register job template on A" POST "/api/metalakes/${MAIN_METALAKE}/jobs/templates" "$JOB_TEMPLATE_BODY"++consistency_case "JOB cancellation invalidates a warm target cache"+JOB_STALE_OBSERVED=0+for round in $(seq 1 "$PER_TYPE_STALE_CONTROL_ROUNDS"); do+ api "$INSTANCE_A" POST "/api/metalakes/${MAIN_METALAKE}/jobs/runs" \+ "{\"jobTemplateName\":\"${JOB_TEMPLATE}\",\"jobConf\":{}}"+ expect_http "JOB A -> B round ${round}: run job on A" 200+ JOB_ID=$(printf '%s' "$RESPONSE_BODY" | jq -r '.job.jobId // empty')+ if [[ -z "$JOB_ID" ]]; then+ fail "JOB A -> B round ${round}: job id returned — Body: $(body_snippet)"+ CASE_MUTATION_STARTED=true+ continue+ fi++ prewarm_one_of "JOB A -> B round ${round}: B caches the running job" "$INSTANCE_B" \+ "/api/metalakes/${MAIN_METALAKE}/jobs/runs/${JOB_ID}" '.job.status' queued started+ STALE_JOB_STATUS=$(printf '%s' "$RESPONSE_BODY" | jq -r '.job.status // empty')++ api "$INSTANCE_A" POST "/api/metalakes/${MAIN_METALAKE}/jobs/runs/${JOB_ID}"+ expect_http "JOB A -> B round ${round}: cancel job on A" 200+ CASE_MUTATION_STARTED=true++ OBSERVED_JOB_STATUS=$(read_field "$INSTANCE_B" \+ "/api/metalakes/${MAIN_METALAKE}/jobs/runs/${JOB_ID}" '.job.status')+ if [[ -n "$STALE_JOB_STATUS" && "$OBSERVED_JOB_STATUS" == "$STALE_JOB_STATUS" ]]; then+ JOB_STALE_OBSERVED=$((JOB_STALE_OBSERVED + 1))+ printf ' JOB A -> B round %d: B still served cached status %s\n' \+ "$round" "$STALE_JOB_STATUS"+ else+ printf ' JOB A -> B round %d: B already served %s (poller won the race)\n' \+ "$round" "$OBSERVED_JOB_STATUS"+ fi++ await_one_of "JOB A -> B round ${round}: B sees canceled job status" "$INSTANCE_B" \+ "/api/metalakes/${MAIN_METALAKE}/jobs/runs/${JOB_ID}" '.job.status' cancelling canceled+done++if ((JOB_STALE_OBSERVED > 0)); then+ record_cache_proof "JOB A -> B cache residency (${JOB_STALE_OBSERVED}/${PER_TYPE_STALE_CONTROL_ROUNDS} stale rounds)"+else+ fail "JOB A -> B never served a stale status in ${PER_TYPE_STALE_CONTROL_ROUNDS} rounds — B may be cold or bypassing the JOB cache"+fi++if [[ "$RUN_RESTART_TEST" == "true" ]]; then+ section "Instance B restart: initialize at high-water, then process new changes"+ mutate_a "create restart probe tag on A" POST "/api/metalakes/${MAIN_METALAKE}/tags" \+ "{\"name\":\"${RESTART_TAG}\",\"comment\":\"restart-old\",\"properties\":{}}"+ api "$INSTANCE_B" GET "/api/metalakes/${MAIN_METALAKE}/tags/${RESTART_TAG}"+ expect_value "warm restart probe tag on B" '.tag.comment' restart-old++ if [[ -x "${INSTANCE_B_HOME}/bin/gravitino.sh" ]]; then+ "${INSTANCE_B_HOME}/bin/gravitino.sh" stop+ # This is intentionally a cold-start check: stopping B discards its local+ # cache, so the scenario validates change-log high-water initialization.+ restart_case "Restarted B initializes at the current change-log high-water mark"+ mutate_a "alter probe while B is stopped" PUT "/api/metalakes/${MAIN_METALAKE}/tags/${RESTART_TAG}" \+ '{"updates":[{"@type":"updateComment","newComment":"restart-current"}]}'+ GRAVITINO_DEBUG_OPTS= "${INSTANCE_B_HOME}/bin/gravitino.sh" start+ if wait_ready "$INSTANCE_B"; then+ pass "instance B restarted"+ else+ fail "instance B did not restart in time"+ fi++ api "$INSTANCE_B" GET "/api/metalakes/${MAIN_METALAKE}/tags/${RESTART_TAG}"+ expect_value "restarted B loads current state without history replay" '.tag.comment' restart-current++ consistency_case "Restarted B resumes polling new changes"+ prewarm_value "restarted B caches the current tag before A alters it" "$INSTANCE_B" \+ "/api/metalakes/${MAIN_METALAKE}/tags/${RESTART_TAG}" '.tag.comment' restart-current+ mutate_a "alter warmed probe after B restart" PUT "/api/metalakes/${MAIN_METALAKE}/tags/${RESTART_TAG}" \+ '{"updates":[{"@type":"updateComment","newComment":"restart-future"}]}'+ await_value "restarted B polls and invalidates future changes" "$INSTANCE_B" \+ "/api/metalakes/${MAIN_METALAKE}/tags/${RESTART_TAG}" '.tag.comment' restart-future+ else+ fail "INSTANCE_B_HOME does not contain an executable bin/gravitino.sh"+ fi+fi++section "Summary"+if ((CACHE_PROOF_CASES == EXPECTED_CACHE_PROOF_CASES)); then+ pass "all ${EXPECTED_CACHE_PROOF_CASES} required warm-cache proofs executed"+else+ fail "expected ${EXPECTED_CACHE_PROOF_CASES} warm-cache proofs, executed ${CACHE_PROOF_CASES}"+fi+printf 'Consistency cases executed: %d\n' "$CONSISTENCY_CASES"+printf 'Warm-cache proofs executed: %d\n' "$CACHE_PROOF_CASES"+printf ' - %s\n' "${CACHE_PROOFS[@]}"+printf 'Assertions passed: %d\nAssertions failed: %d\n' "$PASS" "$FAIL"+if ((FAIL > 0)); then+ printf '\nFailed assertions:\n'+ printf ' - %s\n' "${FAILED_TESTS[@]}"+ exit 1+fi++printf '\nAll multi-instance entity-cache consistency assertions passed.\n'