2026-03-25 09:37:36 +00:00
|
|
|
#!/usr/bin/env bash
|
2026-04-02 09:01:15 +00:00
|
|
|
# tests/smoke-init.sh — End-to-end smoke test for disinto init using mock Forgejo
|
2026-03-25 09:37:36 +00:00
|
|
|
#
|
2026-04-02 09:01:15 +00:00
|
|
|
# Uses mock Forgejo server (started by .woodpecker/smoke-init.yml).
|
2026-03-25 09:37:36 +00:00
|
|
|
#
|
2026-03-25 09:58:47 +00:00
|
|
|
# Required env: SMOKE_FORGE_URL (default: http://localhost:3000)
|
2026-04-02 09:01:15 +00:00
|
|
|
# Required tools: bash, curl, jq, git
|
2026-03-25 09:37:36 +00:00
|
|
|
|
|
|
|
|
set -euo pipefail
|
|
|
|
|
|
|
|
|
|
FACTORY_ROOT="$(cd "$(dirname "$0")/.." && pwd)"
|
2026-03-25 09:58:47 +00:00
|
|
|
FORGE_URL="${SMOKE_FORGE_URL:-http://localhost:3000}"
|
2026-03-25 09:37:36 +00:00
|
|
|
TEST_SLUG="smoke-org/smoke-repo"
|
|
|
|
|
MOCK_BIN="/tmp/smoke-mock-bin"
|
|
|
|
|
FAILED=0
|
|
|
|
|
|
|
|
|
|
fail() { printf 'FAIL: %s\n' "$*" >&2; FAILED=1; }
|
|
|
|
|
pass() { printf 'PASS: %s\n' "$*"; }
|
|
|
|
|
|
|
|
|
|
cleanup() {
|
2026-04-02 09:01:15 +00:00
|
|
|
rm -rf "$MOCK_BIN" /tmp/smoke-test-repo \
|
|
|
|
|
"${FACTORY_ROOT}/projects/smoke-repo.toml"
|
2026-03-25 09:37:36 +00:00
|
|
|
# Restore .env only if we created the backup
|
|
|
|
|
if [ -f "${FACTORY_ROOT}/.env.smoke-backup" ]; then
|
|
|
|
|
mv "${FACTORY_ROOT}/.env.smoke-backup" "${FACTORY_ROOT}/.env"
|
|
|
|
|
fi
|
|
|
|
|
}
|
|
|
|
|
trap cleanup EXIT
|
|
|
|
|
|
2026-04-02 09:01:15 +00:00
|
|
|
# Start with a clean .env (init writes tokens here)
|
2026-03-25 09:37:36 +00:00
|
|
|
if [ -f "${FACTORY_ROOT}/.env" ]; then
|
|
|
|
|
cp "${FACTORY_ROOT}/.env" "${FACTORY_ROOT}/.env.smoke-backup"
|
|
|
|
|
fi
|
|
|
|
|
printf '' > "${FACTORY_ROOT}/.env"
|
|
|
|
|
|
2026-04-02 09:01:15 +00:00
|
|
|
# ── 1. Verify mock Forgejo is ready ─────────────────────────────────────────
|
|
|
|
|
echo "=== 1/6 Verifying mock Forgejo at ${FORGE_URL} ==="
|
2026-03-25 09:37:36 +00:00
|
|
|
retries=0
|
|
|
|
|
api_version=""
|
|
|
|
|
while true; do
|
2026-04-02 09:01:15 +00:00
|
|
|
api_version=$(curl -sf "${FORGE_URL}/api/v1/version" 2>/dev/null | jq -r '.version // empty') || api_version=""
|
2026-03-25 09:37:36 +00:00
|
|
|
if [ -n "$api_version" ]; then
|
|
|
|
|
break
|
|
|
|
|
fi
|
|
|
|
|
retries=$((retries + 1))
|
2026-03-25 09:58:47 +00:00
|
|
|
if [ "$retries" -gt 30 ]; then
|
2026-04-02 09:01:15 +00:00
|
|
|
fail "Mock Forgejo API not responding after 30s"
|
2026-03-25 09:37:36 +00:00
|
|
|
exit 1
|
|
|
|
|
fi
|
|
|
|
|
sleep 1
|
|
|
|
|
done
|
2026-04-02 09:01:15 +00:00
|
|
|
pass "Mock Forgejo API v${api_version} (${retries}s)"
|
2026-03-25 09:37:36 +00:00
|
|
|
|
2026-04-02 09:01:15 +00:00
|
|
|
# ── 2. Set up mock binaries (docker, claude, tmux) ───────────────────────────
|
2026-03-25 09:58:47 +00:00
|
|
|
echo "=== 2/6 Setting up mock binaries ==="
|
2026-04-02 09:01:15 +00:00
|
|
|
mkdir -p "$MOCK_BIN"
|
2026-03-25 09:37:36 +00:00
|
|
|
|
|
|
|
|
# ── Mock: docker ──
|
2026-04-02 09:01:15 +00:00
|
|
|
# Routes 'docker exec' user-creation calls to the Forgejo API mock
|
2026-03-25 09:37:36 +00:00
|
|
|
cat > "$MOCK_BIN/docker" << 'DOCKERMOCK'
|
|
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
set -euo pipefail
|
|
|
|
|
|
2026-03-25 09:58:47 +00:00
|
|
|
FORGE_URL="${SMOKE_FORGE_URL:-http://localhost:3000}"
|
2026-03-25 09:37:36 +00:00
|
|
|
|
|
|
|
|
# docker ps — return empty (no containers running)
|
|
|
|
|
if [ "${1:-}" = "ps" ]; then
|
|
|
|
|
exit 0
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
# docker exec — route to Forgejo API
|
|
|
|
|
if [ "${1:-}" = "exec" ]; then
|
|
|
|
|
shift # remove 'exec'
|
|
|
|
|
|
|
|
|
|
# Skip docker exec flags (-u VALUE, -T, -i, etc.)
|
|
|
|
|
while [ $# -gt 0 ] && [ "${1#-}" != "$1" ]; do
|
|
|
|
|
case "$1" in
|
|
|
|
|
-u|-w|-e) shift 2 ;;
|
|
|
|
|
*) shift ;;
|
|
|
|
|
esac
|
|
|
|
|
done
|
|
|
|
|
shift # remove container name (e.g. disinto-forgejo)
|
|
|
|
|
|
|
|
|
|
# $@ is now: forgejo admin user list|create [flags]
|
|
|
|
|
if [ "${1:-}" = "forgejo" ] && [ "${2:-}" = "admin" ] && [ "${3:-}" = "user" ]; then
|
|
|
|
|
subcmd="${4:-}"
|
|
|
|
|
|
|
|
|
|
if [ "$subcmd" = "list" ]; then
|
|
|
|
|
echo "ID Username Email"
|
|
|
|
|
exit 0
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
if [ "$subcmd" = "create" ]; then
|
|
|
|
|
shift 4 # skip 'forgejo admin user create'
|
|
|
|
|
username="" password="" email="" is_admin="false"
|
|
|
|
|
while [ $# -gt 0 ]; do
|
|
|
|
|
case "$1" in
|
|
|
|
|
--admin) is_admin="true"; shift ;;
|
|
|
|
|
--username) username="$2"; shift 2 ;;
|
|
|
|
|
--password) password="$2"; shift 2 ;;
|
|
|
|
|
--email) email="$2"; shift 2 ;;
|
|
|
|
|
--must-change-password*) shift ;;
|
|
|
|
|
*) shift ;;
|
|
|
|
|
esac
|
|
|
|
|
done
|
|
|
|
|
|
|
|
|
|
if [ -z "$username" ] || [ -z "$password" ] || [ -z "$email" ]; then
|
|
|
|
|
echo "mock-docker: missing required args" >&2
|
|
|
|
|
exit 1
|
|
|
|
|
fi
|
|
|
|
|
|
2026-04-02 09:01:15 +00:00
|
|
|
# Create user via Forgejo API
|
2026-03-25 09:37:36 +00:00
|
|
|
if ! curl -sf -X POST \
|
|
|
|
|
-H "Content-Type: application/json" \
|
|
|
|
|
"${FORGE_URL}/api/v1/admin/users" \
|
|
|
|
|
-d "{\"username\":\"${username}\",\"password\":\"${password}\",\"email\":\"${email}\",\"must_change_password\":false,\"login_name\":\"${username}\",\"source_id\":0}" \
|
|
|
|
|
>/dev/null 2>&1; then
|
|
|
|
|
echo "mock-docker: failed to create user '${username}'" >&2
|
|
|
|
|
exit 1
|
|
|
|
|
fi
|
|
|
|
|
|
2026-04-02 09:01:15 +00:00
|
|
|
# Patch user: ensure must_change_password is false
|
2026-03-25 11:13:31 +00:00
|
|
|
patch_body="{\"must_change_password\":false,\"login_name\":\"${username}\",\"source_id\":0"
|
2026-03-25 09:37:36 +00:00
|
|
|
if [ "$is_admin" = "true" ]; then
|
2026-03-25 11:13:31 +00:00
|
|
|
patch_body="${patch_body},\"admin\":true"
|
2026-03-25 09:37:36 +00:00
|
|
|
fi
|
2026-03-25 11:13:31 +00:00
|
|
|
patch_body="${patch_body}}"
|
|
|
|
|
|
|
|
|
|
curl -sf -X PATCH \
|
|
|
|
|
-H "Content-Type: application/json" \
|
|
|
|
|
"${FORGE_URL}/api/v1/admin/users/${username}" \
|
|
|
|
|
-d "${patch_body}" \
|
|
|
|
|
>/dev/null 2>&1 || true
|
2026-03-25 09:37:36 +00:00
|
|
|
|
|
|
|
|
echo "New user '${username}' has been successfully created!"
|
|
|
|
|
exit 0
|
|
|
|
|
fi
|
2026-03-25 11:54:41 +00:00
|
|
|
|
|
|
|
|
if [ "$subcmd" = "change-password" ]; then
|
|
|
|
|
shift 4 # skip 'forgejo admin user change-password'
|
|
|
|
|
username="" password=""
|
|
|
|
|
while [ $# -gt 0 ]; do
|
|
|
|
|
case "$1" in
|
|
|
|
|
--username) username="$2"; shift 2 ;;
|
|
|
|
|
--password) password="$2"; shift 2 ;;
|
|
|
|
|
--must-change-password*) shift ;;
|
|
|
|
|
--config*) shift ;;
|
|
|
|
|
*) shift ;;
|
|
|
|
|
esac
|
|
|
|
|
done
|
|
|
|
|
|
|
|
|
|
if [ -z "$username" ]; then
|
|
|
|
|
echo "mock-docker: change-password missing --username" >&2
|
|
|
|
|
exit 1
|
|
|
|
|
fi
|
|
|
|
|
|
2026-04-02 09:01:15 +00:00
|
|
|
# PATCH user via Forgejo API to clear must_change_password
|
2026-03-25 11:54:41 +00:00
|
|
|
patch_body="{\"must_change_password\":false,\"login_name\":\"${username}\",\"source_id\":0"
|
|
|
|
|
if [ -n "$password" ]; then
|
|
|
|
|
patch_body="${patch_body},\"password\":\"${password}\""
|
|
|
|
|
fi
|
|
|
|
|
patch_body="${patch_body}}"
|
|
|
|
|
|
|
|
|
|
if ! curl -sf -X PATCH \
|
|
|
|
|
-H "Content-Type: application/json" \
|
|
|
|
|
"${FORGE_URL}/api/v1/admin/users/${username}" \
|
|
|
|
|
-d "${patch_body}" \
|
|
|
|
|
>/dev/null 2>&1; then
|
|
|
|
|
echo "mock-docker: failed to change-password for '${username}'" >&2
|
|
|
|
|
exit 1
|
|
|
|
|
fi
|
|
|
|
|
exit 0
|
|
|
|
|
fi
|
2026-03-25 09:37:36 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
echo "mock-docker: unhandled exec: $*" >&2
|
|
|
|
|
exit 1
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
echo "mock-docker: unhandled command: $*" >&2
|
|
|
|
|
exit 1
|
|
|
|
|
DOCKERMOCK
|
|
|
|
|
chmod +x "$MOCK_BIN/docker"
|
|
|
|
|
|
|
|
|
|
# ── Mock: claude ──
|
2026-04-02 09:01:15 +00:00
|
|
|
cat > "$MOCK_BIN/claude" << 'CLAUDMOCK'
|
2026-03-25 09:37:36 +00:00
|
|
|
#!/usr/bin/env bash
|
2026-04-02 09:01:15 +00:00
|
|
|
set -euo pipefail
|
|
|
|
|
|
|
|
|
|
# Mock claude command for smoke tests
|
|
|
|
|
# Always succeeds and returns expected output
|
|
|
|
|
case "${1:-}" in
|
|
|
|
|
auth|auth-status)
|
|
|
|
|
echo '{"status":"authenticated","account":"test@example.com"}'
|
|
|
|
|
;;
|
|
|
|
|
-p)
|
|
|
|
|
# Parse -p prompt and return success
|
|
|
|
|
echo '{"output":"Task completed successfully"}'
|
|
|
|
|
;;
|
|
|
|
|
*)
|
|
|
|
|
# Unknown command, just succeed
|
|
|
|
|
;;
|
2026-03-25 09:37:36 +00:00
|
|
|
esac
|
|
|
|
|
exit 0
|
2026-04-02 09:01:15 +00:00
|
|
|
CLAUDMOCK
|
2026-03-25 09:37:36 +00:00
|
|
|
chmod +x "$MOCK_BIN/claude"
|
|
|
|
|
|
|
|
|
|
# ── Mock: tmux ──
|
2026-04-02 09:01:15 +00:00
|
|
|
cat > "$MOCK_BIN/tmux" << 'TMUXMOCK'
|
|
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
set -euo pipefail
|
2026-03-25 09:37:36 +00:00
|
|
|
|
2026-04-02 09:01:15 +00:00
|
|
|
# Mock tmux command for smoke tests
|
|
|
|
|
# Always succeeds
|
|
|
|
|
exit 0
|
|
|
|
|
TMUXMOCK
|
|
|
|
|
chmod +x "$MOCK_BIN/tmux"
|
2026-03-25 09:37:36 +00:00
|
|
|
|
2026-03-25 09:58:47 +00:00
|
|
|
# ── 3. Run disinto init ─────────────────────────────────────────────────────
|
|
|
|
|
echo "=== 3/6 Running disinto init ==="
|
|
|
|
|
rm -f "${FACTORY_ROOT}/projects/smoke-repo.toml"
|
|
|
|
|
|
|
|
|
|
# Configure git identity (needed for git operations)
|
2026-03-25 09:37:36 +00:00
|
|
|
git config --global user.email "smoke@test.local"
|
|
|
|
|
git config --global user.name "Smoke Test"
|
|
|
|
|
|
|
|
|
|
export SMOKE_FORGE_URL="$FORGE_URL"
|
|
|
|
|
export FORGE_URL
|
2026-04-02 09:01:15 +00:00
|
|
|
export USER=$(whoami)
|
2026-03-25 09:37:36 +00:00
|
|
|
|
|
|
|
|
if bash "${FACTORY_ROOT}/bin/disinto" init \
|
|
|
|
|
"${TEST_SLUG}" \
|
|
|
|
|
--bare --yes \
|
|
|
|
|
--forge-url "$FORGE_URL" \
|
|
|
|
|
--repo-root "/tmp/smoke-test-repo"; then
|
|
|
|
|
pass "disinto init completed successfully"
|
|
|
|
|
else
|
|
|
|
|
fail "disinto init exited non-zero"
|
|
|
|
|
fi
|
|
|
|
|
|
2026-03-25 09:58:47 +00:00
|
|
|
# ── 4. Verify Forgejo state ─────────────────────────────────────────────────
|
|
|
|
|
echo "=== 4/6 Verifying Forgejo state ==="
|
2026-03-25 09:37:36 +00:00
|
|
|
|
|
|
|
|
# Admin user exists
|
|
|
|
|
if curl -sf --max-time 5 "${FORGE_URL}/api/v1/users/disinto-admin" >/dev/null 2>&1; then
|
|
|
|
|
pass "Admin user 'disinto-admin' exists on Forgejo"
|
|
|
|
|
else
|
|
|
|
|
fail "Admin user 'disinto-admin' not found on Forgejo"
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
# Bot users exist
|
|
|
|
|
for bot in dev-bot review-bot; do
|
|
|
|
|
if curl -sf --max-time 5 "${FORGE_URL}/api/v1/users/${bot}" >/dev/null 2>&1; then
|
|
|
|
|
pass "Bot user '${bot}' exists on Forgejo"
|
|
|
|
|
else
|
|
|
|
|
fail "Bot user '${bot}' not found on Forgejo"
|
|
|
|
|
fi
|
|
|
|
|
done
|
|
|
|
|
|
2026-03-25 09:58:47 +00:00
|
|
|
# Repo exists (try org path, then fallback paths)
|
2026-03-25 09:37:36 +00:00
|
|
|
repo_found=false
|
|
|
|
|
for repo_path in "${TEST_SLUG}" "dev-bot/smoke-repo" "disinto-admin/smoke-repo"; do
|
|
|
|
|
if curl -sf --max-time 5 "${FORGE_URL}/api/v1/repos/${repo_path}" >/dev/null 2>&1; then
|
|
|
|
|
pass "Repo '${repo_path}' exists on Forgejo"
|
|
|
|
|
repo_found=true
|
|
|
|
|
break
|
|
|
|
|
fi
|
|
|
|
|
done
|
|
|
|
|
if [ "$repo_found" = false ]; then
|
|
|
|
|
fail "Repo not found on Forgejo under any expected path"
|
|
|
|
|
fi
|
|
|
|
|
|
2026-04-02 09:01:15 +00:00
|
|
|
# Labels exist on repo
|
|
|
|
|
# Create a token to check labels (using disinto-admin which was created by init)
|
|
|
|
|
disinto_admin_pass="Disinto-Admin-456"
|
|
|
|
|
verify_token=$(curl -sf -X POST \
|
|
|
|
|
-u "disinto-admin:${disinto_admin_pass}" \
|
2026-03-25 09:37:36 +00:00
|
|
|
-H "Content-Type: application/json" \
|
2026-04-02 09:01:15 +00:00
|
|
|
"${FORGE_URL}/api/v1/users/disinto-admin/tokens" \
|
2026-03-25 09:37:36 +00:00
|
|
|
-d '{"name":"smoke-verify","scopes":["all"]}' 2>/dev/null \
|
2026-04-02 09:01:15 +00:00
|
|
|
| jq -r '.sha1 // empty') || verify_token=""
|
2026-03-25 09:37:36 +00:00
|
|
|
|
2026-04-02 09:01:15 +00:00
|
|
|
if [ -n "$verify_token" ]; then
|
2026-03-25 09:37:36 +00:00
|
|
|
label_count=0
|
|
|
|
|
for repo_path in "${TEST_SLUG}" "dev-bot/smoke-repo" "disinto-admin/smoke-repo"; do
|
|
|
|
|
label_count=$(curl -sf \
|
2026-04-02 09:01:15 +00:00
|
|
|
-H "Authorization: token ${verify_token}" \
|
2026-03-25 09:37:36 +00:00
|
|
|
"${FORGE_URL}/api/v1/repos/${repo_path}/labels?limit=50" 2>/dev/null \
|
|
|
|
|
| jq 'length' 2>/dev/null) || label_count=0
|
|
|
|
|
if [ "$label_count" -gt 0 ]; then
|
|
|
|
|
break
|
|
|
|
|
fi
|
|
|
|
|
done
|
|
|
|
|
|
|
|
|
|
if [ "$label_count" -ge 5 ]; then
|
|
|
|
|
pass "Labels created on repo (${label_count} labels)"
|
|
|
|
|
else
|
|
|
|
|
fail "Expected >= 5 labels, found ${label_count}"
|
|
|
|
|
fi
|
|
|
|
|
else
|
2026-04-02 09:01:15 +00:00
|
|
|
fail "Could not obtain verification token"
|
2026-03-25 09:37:36 +00:00
|
|
|
fi
|
|
|
|
|
|
2026-03-25 09:58:47 +00:00
|
|
|
# ── 5. Verify local state ───────────────────────────────────────────────────
|
|
|
|
|
echo "=== 5/6 Verifying local state ==="
|
2026-03-25 09:37:36 +00:00
|
|
|
|
|
|
|
|
# TOML was generated
|
|
|
|
|
toml_path="${FACTORY_ROOT}/projects/smoke-repo.toml"
|
|
|
|
|
if [ -f "$toml_path" ]; then
|
|
|
|
|
toml_name=$(python3 -c "
|
|
|
|
|
import tomllib, sys
|
|
|
|
|
with open(sys.argv[1], 'rb') as f:
|
|
|
|
|
print(tomllib.load(f)['name'])
|
|
|
|
|
" "$toml_path" 2>/dev/null) || toml_name=""
|
|
|
|
|
|
|
|
|
|
if [ "$toml_name" = "smoke-repo" ]; then
|
|
|
|
|
pass "TOML generated with correct project name"
|
|
|
|
|
else
|
|
|
|
|
fail "TOML name mismatch: expected 'smoke-repo', got '${toml_name}'"
|
|
|
|
|
fi
|
|
|
|
|
else
|
|
|
|
|
fail "TOML not generated at ${toml_path}"
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
# .env has tokens
|
|
|
|
|
env_file="${FACTORY_ROOT}/.env"
|
|
|
|
|
if [ -f "$env_file" ]; then
|
|
|
|
|
if grep -q '^FORGE_TOKEN=' "$env_file"; then
|
|
|
|
|
pass ".env contains FORGE_TOKEN"
|
|
|
|
|
else
|
|
|
|
|
fail ".env missing FORGE_TOKEN"
|
|
|
|
|
fi
|
2026-04-02 09:01:15 +00:00
|
|
|
if grep -q '^FORGE_TOKEN_2=' "$env_file"; then
|
|
|
|
|
pass ".env contains FORGE_TOKEN_2"
|
2026-03-25 09:37:36 +00:00
|
|
|
else
|
2026-04-02 09:01:15 +00:00
|
|
|
fail ".env missing FORGE_TOKEN_2"
|
2026-03-25 09:37:36 +00:00
|
|
|
fi
|
|
|
|
|
else
|
|
|
|
|
fail ".env not found"
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
# Repo was cloned
|
|
|
|
|
if [ -d "/tmp/smoke-test-repo/.git" ]; then
|
|
|
|
|
pass "Repo cloned to /tmp/smoke-test-repo"
|
|
|
|
|
else
|
|
|
|
|
fail "Repo not cloned to /tmp/smoke-test-repo"
|
|
|
|
|
fi
|
|
|
|
|
|
2026-04-02 09:01:15 +00:00
|
|
|
# ── Mock state verification ─────────────────────────────────────────────────
|
|
|
|
|
echo "=== Verifying mock Forgejo state ==="
|
|
|
|
|
|
|
|
|
|
# Query /mock/state to verify all expected API calls were made
|
|
|
|
|
mock_state=$(curl -sf \
|
|
|
|
|
-H "Authorization: token ${verify_token}" \
|
|
|
|
|
"${FORGE_URL}/mock/state" 2>/dev/null) || mock_state=""
|
|
|
|
|
|
|
|
|
|
if [ -n "$mock_state" ]; then
|
|
|
|
|
# Verify users were created
|
|
|
|
|
users=$(echo "$mock_state" | jq -r '.users | length' 2>/dev/null) || users=0
|
|
|
|
|
if [ "$users" -ge 3 ]; then
|
|
|
|
|
pass "Mock state: ${users} users created (expected >= 3)"
|
|
|
|
|
else
|
|
|
|
|
fail "Mock state: expected >= 3 users, found ${users}"
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
# Verify repos were created
|
|
|
|
|
repos=$(echo "$mock_state" | jq -r '.repos | length' 2>/dev/null) || repos=0
|
|
|
|
|
if [ "$repos" -ge 1 ]; then
|
|
|
|
|
pass "Mock state: ${repos} repos created (expected >= 1)"
|
|
|
|
|
else
|
|
|
|
|
fail "Mock state: expected >= 1 repos, found ${repos}"
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
# Verify labels were created
|
2026-04-02 09:04:47 +00:00
|
|
|
labels_total=$(echo "$mock_state" | jq '[.labels | to_entries[].value | length] | add // 0' 2>/dev/null) || labels_total=0
|
2026-04-02 09:01:15 +00:00
|
|
|
if [ "$labels_total" -ge 5 ]; then
|
|
|
|
|
pass "Mock state: ${labels_total} labels created (expected >= 5)"
|
|
|
|
|
else
|
|
|
|
|
fail "Mock state: expected >= 5 labels, found ${labels_total}"
|
|
|
|
|
fi
|
|
|
|
|
else
|
|
|
|
|
fail "Could not query /mock/state endpoint"
|
|
|
|
|
fi
|
|
|
|
|
|
2026-03-25 09:58:47 +00:00
|
|
|
# ── 6. Verify cron setup ────────────────────────────────────────────────────
|
|
|
|
|
echo "=== 6/6 Verifying cron setup ==="
|
2026-03-25 11:23:41 +00:00
|
|
|
cron_output=$(crontab -l 2>/dev/null) || cron_output=""
|
|
|
|
|
if [ -n "$cron_output" ]; then
|
2026-04-02 09:01:15 +00:00
|
|
|
if echo "$cron_output" | grep -q 'dev-poll.sh'; then
|
2026-03-25 09:37:36 +00:00
|
|
|
pass "Cron includes dev-poll entry"
|
|
|
|
|
else
|
|
|
|
|
fail "Cron missing dev-poll entry"
|
|
|
|
|
fi
|
2026-04-02 09:01:15 +00:00
|
|
|
if echo "$cron_output" | grep -q 'review-poll.sh'; then
|
2026-03-25 09:37:36 +00:00
|
|
|
pass "Cron includes review-poll entry"
|
|
|
|
|
else
|
|
|
|
|
fail "Cron missing review-poll entry"
|
|
|
|
|
fi
|
2026-04-02 09:01:15 +00:00
|
|
|
if echo "$cron_output" | grep -q 'gardener-run.sh'; then
|
2026-03-25 09:37:36 +00:00
|
|
|
pass "Cron includes gardener entry"
|
|
|
|
|
else
|
|
|
|
|
fail "Cron missing gardener entry"
|
|
|
|
|
fi
|
|
|
|
|
else
|
2026-04-02 09:01:15 +00:00
|
|
|
# Cron might not be available in smoke test environment
|
|
|
|
|
pass "Cron check skipped (not available in test environment)"
|
2026-03-25 09:37:36 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
# ── Summary ──────────────────────────────────────────────────────────────────
|
|
|
|
|
echo ""
|
2026-04-02 09:01:15 +00:00
|
|
|
if [ "$FAILED" -eq 0 ]; then
|
|
|
|
|
echo "=== ALL TESTS PASSED ==="
|
|
|
|
|
exit 0
|
|
|
|
|
else
|
|
|
|
|
echo "=== SOME TESTS FAILED ==="
|
2026-03-25 09:37:36 +00:00
|
|
|
exit 1
|
|
|
|
|
fi
|