fix(tests/e2e#2839): cap concierge creates-workspace slug at 32 chars #2847

Merged
devops-engineer merged 1 commits from fix/concierge-slug-cap-2839 into main 2026-06-14 11:27:23 +00:00
3 changed files with 39 additions and 7 deletions
+6 -5
View File
@@ -85,12 +85,13 @@ make_collision_proof_slug_suffix() {
fi
# Suffix layout: <date:8> + - + <run_id:N> + - + <uuid:8> = N+18 chars.
# Full slug: <prefix_len> + 1 (separator) + (N+18) = prefix_len + N + 19.
# Cap: prefix_len + N + 19 <= CP_ORG_SLUG_MAX_LEN
# => N <= CP_ORG_SLUG_MAX_LEN - prefix_len - 19
local run_id_budget=$(( CP_ORG_SLUG_MAX_LEN - prefix_len - 19 ))
# The caller's literal prefix already includes its trailing separator,
# so the full slug is <prefix_len> + (N+18) = prefix_len + N + 18.
# Cap: prefix_len + N + 18 <= CP_ORG_SLUG_MAX_LEN
# => N <= CP_ORG_SLUG_MAX_LEN - prefix_len - 18
local run_id_budget=$(( CP_ORG_SLUG_MAX_LEN - prefix_len - 18 ))
if [ "$run_id_budget" -lt 1 ]; then
echo "make_collision_proof_slug_suffix: caller prefix (${prefix_len} chars) too long for CP_ORG_SLUG_MAX_LEN=${CP_ORG_SLUG_MAX_LEN}; uuid anchor (8 chars) + date (8 chars) + 3 separators = 19 chars minimum, no room for run_id segment. Shorten the prefix literal in the SLUG= assignment." >&2
echo "make_collision_proof_slug_suffix: caller prefix (${prefix_len} chars) too long for CP_ORG_SLUG_MAX_LEN=${CP_ORG_SLUG_MAX_LEN}; date (8 chars) + uuid anchor (8 chars) + 2 separators = 18 chars minimum after the prefix, no room for run_id segment. Shorten the prefix literal in the SLUG= assignment." >&2
return 1
fi
@@ -212,6 +212,37 @@ test_e2e_pv_prefix_caps_to_32() {
test_e2e_pv_prefix_caps_to_32 || failed=$((failed+1))
# core#2839 follow-up: the concierge "creates workspace" staging E2E
# uses a 13-char literal prefix (`e2e-cncrg-mk-`). With the corrected
# helper budget (prefix_len + N + 18 <= CP_ORG_SLUG_MAX_LEN) this
# prefix leaves room for a 1-char run_id segment plus the 8-hex uuid
# anchor, keeping the full slug ≤32 chars and matching the CP regex
# ^[a-z][a-z0-9-]{2,31}$.
test_e2e_cncrg_mk_prefix_caps_to_32() {
local s
s="e2e-cncrg-mk-$(make_collision_proof_slug_suffix "20260614-498600-1" 13)"
if ! assert_collision_proof_slug "$s"; then
echo "FAIL: test_e2e_cncrg_mk_prefix_caps_to_32 — slug '$s' (len=${#s}) failed assert_collision_proof_slug"
return 1
fi
if [ "${#s}" -gt 32 ]; then
echo "FAIL: test_e2e_cncrg_mk_prefix_caps_to_32 — slug '$s' is ${#s} chars (want <= 32 to match CP regex ^[a-z][a-z0-9-]{2,31}$)"
return 1
fi
if ! printf '%s' "$s" | grep -q "^e2e-cncrg-mk-"; then
echo "FAIL: test_e2e_cncrg_mk_prefix_caps_to_32 — slug '$s' does not start with 'e2e-cncrg-mk-'"
return 1
fi
if ! printf '%s' "$s" | grep -qE '^[a-z][a-z0-9-]{2,31}$'; then
echo "FAIL: test_e2e_cncrg_mk_prefix_caps_to_32 — slug '$s' does NOT match CP regex ^[a-z][a-z0-9-]{2,31}\$"
return 1
fi
echo "PASS: test_e2e_cncrg_mk_prefix_caps_to_32 (slug=$s, len=${#s})"
return 0
}
test_e2e_cncrg_mk_prefix_caps_to_32 || failed=$((failed+1))
if [ "$failed" -gt 0 ]; then
echo "FAILED: $failed test(s)"
exit 1
@@ -93,11 +93,11 @@ REQUIRE_LIVE="${E2E_REQUIRE_LIVE:-0}"
source "$(dirname "$0")/lib/collision-proof-slug.sh"
# The workspace name we will ask the concierge to create. The literal
# `e2e-cncrg-worker-` prefix is visible to the lint (so the SLUG=
# `e2e-cncrg-w-` prefix is visible to the lint (so the SLUG=
# has a covered e2e- prefix in the assignment); the uuid suffix
# makes the name unique per run so a poll for it can never collide
# with a sibling run's name.
WORKER_NAME="e2e-cncrg-worker-$(make_collision_proof_slug_suffix "${E2E_RUN_ID:-}" 17)"
WORKER_NAME="e2e-cncrg-w-$(make_collision_proof_slug_suffix "${E2E_RUN_ID:-}" 12)"
WORKER_NAME=$(echo "$WORKER_NAME" | tr -cd 'a-zA-Z0-9-' | head -c 48)
# Exported so the find_worker_by_name python subshell (run in a pipe) reads it
# via os.environ — a bare shell var would not survive into the subprocess env.