test: migrate deployment smoke fixtures to the P1.1 layout

This commit is contained in:
2026-08-11 15:11:52 +02:00
parent 5446885006
commit a071e0baff
3 changed files with 447 additions and 79 deletions
+197 -50
View File
@@ -473,22 +473,93 @@ EOF
chmod 0600 "$TASK13_ENV_FILE"
}
task13_seed_registry() {
mkdir -p "$TASK13_SEED/workspaces"
task13_run_logged "initialize bare workspace registry" \
git init --bare --initial-branch=main "$TASK13_REMOTE"
task13_run_logged "initialize workspace seed" git -C "$TASK13_SEED" init --initial-branch=main
cp "$TASK13_ROOT/scripts/fixtures/workspace-registry-task13.yaml" \
"$TASK13_SEED/workspaces/task13-smoke.yaml"
task13_run_logged "commit initial workspace" git -C "$TASK13_SEED" add workspaces/task13-smoke.yaml
task13_run_logged "commit initial workspace" git -C "$TASK13_SEED" \
-c user.name='Task 13 Smoke' -c user.email='task13-smoke@example.invalid' \
commit -m 'Seed Task 13 workspace'
task13_run_logged "push initial workspace" git -C "$TASK13_SEED" \
push "$TASK13_REMOTE" "HEAD:$TASK13_BRANCH"
task13_workspace_metadata() {
local fixture="$1"
awk '
/^workspace:[[:space:]]*$/ { in_workspace = 1; next }
in_workspace && /^[^[:space:]]/ { in_workspace = 0 }
in_workspace && /^ id:[[:space:]]*/ {
sub(/^ id:[[:space:]]*/, "")
id = $0
next
}
in_workspace && /^ name:[[:space:]]*/ {
sub(/^ name:[[:space:]]*/, "")
name = $0
next
}
in_workspace && /^ description:[[:space:]]*/ {
sub(/^ description:[[:space:]]*/, "")
description = $0
next
}
END {
if (id == "" || name == "") exit 1
print id
print name
if (description != "") print description
}
' "$fixture"
}
task13_write_catalog() {
local catalog_path="$1" id="$2" name="$3" description="${4:-}"
{
printf 'schema_version: 1\n'
printf 'workspaces:\n'
printf ' - id: %s\n' "$id"
printf ' name: %s\n' "$name"
if [[ -n "$description" ]]; then
printf ' description: %s\n' "$description"
fi
} >"$catalog_path"
}
task13_replace_once() {
local target="$1" old="$2" new="$3"
python3 - "$target" "$old" "$new" <<'PY'
from pathlib import Path
import sys
path = Path(sys.argv[1])
old = sys.argv[2]
new = sys.argv[3]
text = path.read_text()
count = text.count(old)
if count != 1:
raise SystemExit(f"expected exactly one occurrence of {old!r} in {path}, found {count}")
path.write_text(text.replace(old, new, 1))
PY
}
task13_commit_registry_change() {
local message="$1"
task13_run_logged "$message" git -C "$TASK13_SEED" add -A
task13_run_logged "$message" git -C "$TASK13_SEED" -c user.name='Task 13 Smoke' -c user.email='task13-smoke@example.invalid' commit -m "$message"
task13_run_logged "$message" git -C "$TASK13_SEED" push "$TASK13_REMOTE" "HEAD:$TASK13_BRANCH"
chmod -R a+rX "$TASK13_REMOTE"
}
task13_seed_registry() {
local fixture metadata
fixture="$TASK13_ROOT/scripts/fixtures/workspace-registry-task13.yaml"
mapfile -t metadata < <(task13_workspace_metadata "$fixture")
TASK13_WORKSPACE_ID="${metadata[0]}"
TASK13_WORKSPACE_NAME="${metadata[1]}"
TASK13_WORKSPACE_DESCRIPTION="${metadata[2]-}"
mkdir -p "$TASK13_SEED"
task13_run_logged "initialize bare workspace registry" git init --bare --initial-branch=main "$TASK13_REMOTE"
task13_run_logged "initialize workspace seed" git -C "$TASK13_SEED" init --initial-branch=main
mkdir -p "$TASK13_SEED/$TASK13_WORKSPACE_ID"
cp "$fixture" "$TASK13_SEED/$TASK13_WORKSPACE_ID/workspace.yaml"
task13_write_catalog "$TASK13_SEED/thoth-workspaces.yaml" "$TASK13_WORKSPACE_ID" "$TASK13_WORKSPACE_NAME" "$TASK13_WORKSPACE_DESCRIPTION"
if grep -Fq 'type: filesystem' "$fixture"; then
mkdir -p "$TASK13_SEED/$TASK13_WORKSPACE_ID/evidence"
printf 'guide v1\n' >"$TASK13_SEED/$TASK13_WORKSPACE_ID/evidence/guide.md"
fi
task13_commit_registry_change 'Seed Task 13 workspace registry'
}
task13_build_thothctl() {
local os arch
mkdir -p "$TASK13_THOTHCTL_DIR"
@@ -773,8 +844,9 @@ task13_prepare_persistence() {
}
task13_registry_lifecycle() {
local offline_status offline_head valid_head
printf '== Recreate offline and retain the validated registry snapshot ==\n'
local offline_status offline_head valid_head evidence_head repaired_head
printf '== Recreate offline and retain the validated registry snapshot ==
'
task13_write_environment /fixtures/offline.git
task13_compose_logged "offline Compose recreation" up --detach --force-recreate --wait --wait-timeout 120
offline_status="$(task13_registry_status)"
@@ -784,48 +856,78 @@ task13_registry_lifecycle() {
task13_assert_sentinels
[[ "$(task13_mount_fingerprint)" == "$TASK13_INITIAL_MOUNTS" ]] || task13_fail "offline recreation changed volume identity"
printf '== Pull a valid Git workspace update ==\n'
sed -i.bak 's/name: Task 13 Smoke/name: Task 13 Smoke Updated/' \
"$TASK13_SEED/workspaces/task13-smoke.yaml"
rm "$TASK13_SEED/workspaces/task13-smoke.yaml.bak"
task13_run_logged "commit valid workspace update" git -C "$TASK13_SEED" add workspaces/task13-smoke.yaml
task13_run_logged "commit valid workspace update" git -C "$TASK13_SEED" \
-c user.name='Task 13 Smoke' -c user.email='task13-smoke@example.invalid' \
commit -m 'Update Task 13 workspace'
task13_run_logged "push valid workspace update" git -C "$TASK13_SEED" \
push "$TASK13_REMOTE" "HEAD:$TASK13_BRANCH"
chmod -R a+rX "$TASK13_REMOTE"
printf '== Pull a valid catalog+descriptor metadata update ==
'
task13_replace_once "$TASK13_SEED/$TASK13_WORKSPACE_ID/workspace.yaml" 'name: Task 13 Smoke' 'name: Task 13 Smoke Updated'
task13_replace_once "$TASK13_SEED/thoth-workspaces.yaml" 'name: Task 13 Smoke' 'name: Task 13 Smoke Updated'
task13_commit_registry_change 'Update Task 13 workspace metadata'
task13_write_environment /fixtures/remote.git
task13_compose_logged "online Compose recreation" up --detach --force-recreate --wait --wait-timeout 120
task13_compose exec -T core curl --connect-timeout 3 --max-time 15 -fsS -X POST \
http://127.0.0.1:8787/workspace-registry/pull >/dev/null
task13_compose exec -T core curl --connect-timeout 3 --max-time 10 -fsS \
http://127.0.0.1:8787/workspaces \
| grep -Fq 'Task 13 Smoke Updated' || task13_fail "valid Git update was not activated"
task13_compose exec -T core curl --connect-timeout 3 --max-time 15 -fsS -X POST http://127.0.0.1:8787/workspace-registry/pull >/dev/null
task13_compose exec -T core curl --connect-timeout 3 --max-time 10 -fsS http://127.0.0.1:8787/workspaces | grep -Fq 'Task 13 Smoke Updated' || task13_fail "valid Git update was not activated"
valid_head="$(task13_active_registry_head)"
[[ "$valid_head" =~ ^[0-9a-f]{40}$ && "$valid_head" != "$TASK13_INITIAL_HEAD" ]] \
|| task13_fail "valid Git update did not advance the registry head"
[[ "$valid_head" =~ ^[0-9a-f]{40}$ && "$valid_head" != "$TASK13_INITIAL_HEAD" ]] || task13_fail "valid Git update did not advance the registry head"
TASK13_INITIAL_HEAD="$valid_head"
task13_assert_sentinels
printf '== Reject invalid Git content and retain the valid snapshot ==\n'
printf 'workspace: invalid\n' >"$TASK13_SEED/workspaces/task13-smoke.yaml"
task13_run_logged "commit invalid workspace update" git -C "$TASK13_SEED" add workspaces/task13-smoke.yaml
task13_run_logged "commit invalid workspace update" git -C "$TASK13_SEED" \
-c user.name='Task 13 Smoke' -c user.email='task13-smoke@example.invalid' \
commit -m 'Invalid Task 13 workspace fixture'
task13_run_logged "push invalid workspace update" git -C "$TASK13_SEED" \
push "$TASK13_REMOTE" "HEAD:$TASK13_BRANCH"
chmod -R a+rX "$TASK13_REMOTE"
if task13_compose exec -T core curl --connect-timeout 3 --max-time 15 -fsS -X POST \
http://127.0.0.1:8787/workspace-registry/pull >>"$TASK13_LOG" 2>&1; then
task13_fail "registry accepted invalid Git content"
printf '== Pull a content-only Git Evidence update ==
'
printf 'guide v2\n' >"$TASK13_SEED/$TASK13_WORKSPACE_ID/evidence/guide.md"
task13_commit_registry_change 'Update Task 13 workspace evidence only'
task13_compose exec -T core curl --connect-timeout 3 --max-time 15 -fsS -X POST http://127.0.0.1:8787/workspace-registry/pull >/dev/null
evidence_head="$(task13_active_registry_head)"
[[ "$evidence_head" =~ ^[0-9a-f]{40}$ && "$evidence_head" != "$valid_head" ]] || task13_fail "content-only Git Evidence update did not advance the registry head"
TASK13_INITIAL_HEAD="$evidence_head"
task13_assert_sentinels
printf '== Reject catalog/descriptor metadata mismatch and retain the valid snapshot ==
'
task13_replace_once "$TASK13_SEED/thoth-workspaces.yaml" 'name: Task 13 Smoke Updated' 'name: Task 13 Smoke Drift'
task13_commit_registry_change 'Break Task 13 workspace metadata parity'
if task13_compose exec -T core curl --connect-timeout 3 --max-time 15 -fsS -X POST http://127.0.0.1:8787/workspace-registry/pull >>"$TASK13_LOG" 2>&1; then
task13_fail "registry accepted catalog/descriptor metadata mismatch"
fi
[[ "$(task13_active_registry_head)" == "$TASK13_INITIAL_HEAD" ]] \
|| task13_fail "invalid Git content replaced the valid registry head"
task13_compose exec -T core curl --connect-timeout 3 --max-time 10 -fsS \
http://127.0.0.1:8787/workspaces \
| grep -Fq 'Task 13 Smoke Updated' || task13_fail "invalid Git content displaced the valid workspace"
[[ "$(task13_active_registry_head)" == "$TASK13_INITIAL_HEAD" ]] || task13_fail "metadata mismatch replaced the valid registry head"
task13_compose exec -T core curl --connect-timeout 3 --max-time 10 -fsS http://127.0.0.1:8787/workspaces | grep -Fq 'Task 13 Smoke Updated' || task13_fail "metadata mismatch displaced the valid workspace"
task13_replace_once "$TASK13_SEED/thoth-workspaces.yaml" 'name: Task 13 Smoke Drift' 'name: Task 13 Smoke Updated'
task13_commit_registry_change 'Restore Task 13 workspace metadata parity'
task13_compose exec -T core curl --connect-timeout 3 --max-time 15 -fsS -X POST http://127.0.0.1:8787/workspace-registry/pull >/dev/null
repaired_head="$(task13_active_registry_head)"
[[ "$repaired_head" =~ ^[0-9a-f]{40}$ && "$repaired_head" != "$TASK13_INITIAL_HEAD" ]] || task13_fail "metadata repair did not restore a fresh valid registry head"
TASK13_INITIAL_HEAD="$repaired_head"
printf '== Reject orphan descriptor directories not listed in the catalog ==
'
mkdir -p "$TASK13_SEED/orphan"
cp "$TASK13_SEED/$TASK13_WORKSPACE_ID/workspace.yaml" "$TASK13_SEED/orphan/workspace.yaml"
task13_replace_once "$TASK13_SEED/orphan/workspace.yaml" 'id: task13-smoke' 'id: orphan'
task13_replace_once "$TASK13_SEED/orphan/workspace.yaml" 'name: Task 13 Smoke Updated' 'name: Orphan Workspace'
task13_replace_once "$TASK13_SEED/orphan/workspace.yaml" 'collection: task13-smoke' 'collection: orphan'
task13_replace_once "$TASK13_SEED/orphan/workspace.yaml" 'uri: task13-smoke/evidence' 'uri: orphan/evidence'
mkdir -p "$TASK13_SEED/orphan/evidence"
printf 'orphan guide\n' >"$TASK13_SEED/orphan/evidence/guide.md"
task13_commit_registry_change 'Add orphan Task 13 workspace directory'
if task13_compose exec -T core curl --connect-timeout 3 --max-time 15 -fsS -X POST http://127.0.0.1:8787/workspace-registry/pull >>"$TASK13_LOG" 2>&1; then
task13_fail "registry accepted orphan Task 13 descriptor directory"
fi
[[ "$(task13_active_registry_head)" == "$TASK13_INITIAL_HEAD" ]] || task13_fail "orphan descriptor directory replaced the valid registry head"
task13_compose exec -T core curl --connect-timeout 3 --max-time 10 -fsS http://127.0.0.1:8787/workspaces | grep -Fq 'Task 13 Smoke Updated' || task13_fail "orphan descriptor displaced the valid workspace"
rm -rf "$TASK13_SEED/orphan"
task13_commit_registry_change 'Remove orphan Task 13 workspace directory'
task13_compose exec -T core curl --connect-timeout 3 --max-time 15 -fsS -X POST http://127.0.0.1:8787/workspace-registry/pull >/dev/null
TASK13_INITIAL_HEAD="$(task13_active_registry_head)"
printf '== Reject the retired flat workspace layout and retain the valid snapshot ==
'
mkdir -p "$TASK13_SEED/workspaces" "$TASK13_SEED/workspace-content/$TASK13_WORKSPACE_ID/evidence"
cp "$TASK13_ROOT/scripts/fixtures/workspace-registry-task13.yaml" "$TASK13_SEED/workspaces/$TASK13_WORKSPACE_ID.yaml"
printf 'legacy guide\n' >"$TASK13_SEED/workspace-content/$TASK13_WORKSPACE_ID/evidence/guide.md"
task13_commit_registry_change 'Reintroduce retired flat Task 13 workspace layout'
if task13_compose exec -T core curl --connect-timeout 3 --max-time 15 -fsS -X POST http://127.0.0.1:8787/workspace-registry/pull >>"$TASK13_LOG" 2>&1; then
task13_fail "registry accepted the retired flat Task 13 workspace layout"
fi
[[ "$(task13_active_registry_head)" == "$TASK13_INITIAL_HEAD" ]] || task13_fail "retired flat workspace layout replaced the valid registry head"
task13_compose exec -T core curl --connect-timeout 3 --max-time 10 -fsS http://127.0.0.1:8787/workspaces | grep -Fq 'Task 13 Smoke Updated' || task13_fail "retired flat workspace layout displaced the valid workspace"
task13_assert_sentinels
}
@@ -1541,6 +1643,49 @@ task13_self_test_case() {
esac
}
task13_fixtures_only() {
local tmp descriptor_path catalog_path initial_head updated_head
tmp="$(mktemp -d "${TMPDIR:-/tmp}/thothii-task13-fixtures.XXXXXX")"
trap 'rm -rf "$tmp"' RETURN
TASK13_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd -P)"
TASK13_TMP="$tmp"
TASK13_REMOTE="$tmp/remote.git"
TASK13_SEED="$tmp/seed"
TASK13_BRANCH="task13-smoke"
TASK13_LOG="$tmp/task13.log"
TASK13_FAILURE_LOGGED=0
: >"$TASK13_LOG"
task13_seed_registry
descriptor_path="$TASK13_SEED/$TASK13_WORKSPACE_ID/workspace.yaml"
catalog_path="$TASK13_SEED/thoth-workspaces.yaml"
[[ -f "$catalog_path" ]] || task13_fail "missing Task 13 root workspace catalog"
[[ -f "$descriptor_path" ]] || task13_fail "missing Task 13 nested workspace descriptor"
[[ -f "$TASK13_SEED/$TASK13_WORKSPACE_ID/evidence/guide.md" ]] || task13_fail "missing Task 13 nested workspace evidence"
[[ ! -e "$TASK13_SEED/workspaces/$TASK13_WORKSPACE_ID.yaml" ]] || task13_fail "legacy Task 13 flat descriptor path exists"
[[ ! -e "$TASK13_SEED/workspace-content/$TASK13_WORKSPACE_ID" ]] || task13_fail "legacy Task 13 flat evidence path exists"
initial_head="$(git -C "$TASK13_SEED" rev-parse HEAD)"
task13_replace_once "$descriptor_path" 'name: Task 13 Smoke' 'name: Task 13 Smoke Updated'
task13_replace_once "$catalog_path" 'name: Task 13 Smoke' 'name: Task 13 Smoke Updated'
task13_commit_registry_change 'Update Task 13 workspace metadata'
updated_head="$(git -C "$TASK13_SEED" rev-parse HEAD)"
[[ "$updated_head" != "$initial_head" ]] || task13_fail "Task 13 metadata update did not advance Git head"
printf 'guide v2\n' >"$TASK13_SEED/$TASK13_WORKSPACE_ID/evidence/guide.md"
task13_commit_registry_change 'Update Task 13 workspace evidence only'
[[ "$(git -C "$TASK13_SEED" rev-parse HEAD)" != "$updated_head" ]] || task13_fail "Task 13 evidence-only commit did not advance Git head"
mkdir -p "$TASK13_SEED/workspaces" "$TASK13_SEED/workspace-content/$TASK13_WORKSPACE_ID/evidence"
cp "$TASK13_ROOT/scripts/fixtures/workspace-registry-task13.yaml" "$TASK13_SEED/workspaces/$TASK13_WORKSPACE_ID.yaml"
printf 'legacy guide\n' >"$TASK13_SEED/workspace-content/$TASK13_WORKSPACE_ID/evidence/guide.md"
[[ -f "$TASK13_SEED/workspaces/$TASK13_WORKSPACE_ID.yaml" ]] || task13_fail "missing Task 13 legacy flat descriptor fixture"
[[ -f "$TASK13_SEED/workspace-content/$TASK13_WORKSPACE_ID/evidence/guide.md" ]] || task13_fail "missing Task 13 legacy flat evidence fixture"
printf 'Task 13 fixture contract passed.
'
}
task13_initialize() {
umask 077
TASK13_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd -P)"
@@ -1639,6 +1784,8 @@ if [[ "${BASH_SOURCE[0]}" == "$0" ]]; then
elif [[ "${1:-}" == "--self-test-case" ]]; then
[[ -n "${2:-}" ]] || task13_fail "--self-test-case requires a case name"
task13_self_test_case "$2"
elif [[ "${1:-}" == "--fixtures-only" ]]; then
task13_fixtures_only
else
task13_supervise "$TASK13_SMOKE_TIMEOUT" "unified deployment smoke" task13_smoke_main full
fi