From 10e54e21878b20e72fe3c4573292f527c3e2fe55 Mon Sep 17 00:00:00 2001 From: Jan Rose Date: Thu, 16 Jul 2026 13:32:50 +0200 Subject: [PATCH] acc: fix flaky grants-remove-principal plan golden The testserver deliberately randomizes grant-assignment order (it iterates a Go map, mirroring the Azure backend; see libs/testserver/grants.go), but this test dumped remote_state.__embed__ straight into out.plan.grants.json without normalizing the order. The golden happened to match on most runs and failed whenever map iteration emitted the principals in the other order (it surfaced on linux/direct on main). Sort __embed__ by principal in the jq step, matching how the sibling grants/schemas/out_of_band_principal test handles the same array. Co-authored-by: Isaac --- .../readplan/grants-remove-principal/out.plan.grants.json | 8 ++++---- .../bundle/deploy/readplan/grants-remove-principal/script | 4 +++- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/acceptance/bundle/deploy/readplan/grants-remove-principal/out.plan.grants.json b/acceptance/bundle/deploy/readplan/grants-remove-principal/out.plan.grants.json index 79ead177c6a..0b90f0b19e6 100644 --- a/acceptance/bundle/deploy/readplan/grants-remove-principal/out.plan.grants.json +++ b/acceptance/bundle/deploy/readplan/grants-remove-principal/out.plan.grants.json @@ -25,15 +25,15 @@ "full_name": "main.myschema", "__embed__": [ { - "principal": "[USERNAME]", + "principal": "extra@example.test", "privileges": [ - "USE_SCHEMA" + "CREATE_TABLE" ] }, { - "principal": "extra@example.test", + "principal": "[USERNAME]", "privileges": [ - "CREATE_TABLE" + "USE_SCHEMA" ] } ] diff --git a/acceptance/bundle/deploy/readplan/grants-remove-principal/script b/acceptance/bundle/deploy/readplan/grants-remove-principal/script index df94954d5a9..a0625c5653d 100644 --- a/acceptance/bundle/deploy/readplan/grants-remove-principal/script +++ b/acceptance/bundle/deploy/readplan/grants-remove-principal/script @@ -12,8 +12,10 @@ trace print_requests.py //unity-catalog/permissions --sort grep -v 'TO_REMOVE' databricks.yml > updated.yml && mv updated.yml databricks.yml # Generate update plan: entry.RemoteState captures both principals as GrantsState. +# remote_state.__embed__ principal order is non-deterministic (the backend, and the +# testserver mirroring it, iterate a map), so sort it by principal for a stable golden. trace $CLI bundle plan -o json > tmp.plan.json -jq '.plan["resources.schemas.myschema.grants"]' tmp.plan.json > out.plan.grants.json +jq '.plan["resources.schemas.myschema.grants"] | .remote_state.__embed__ |= sort_by(.principal)' tmp.plan.json > out.plan.grants.json trace print_requests.py --get //unity-catalog/permissions --sort # Deploy from serialized plan (READPLAN=1) or without (READPLAN="").