64 lines
2.2 KiB
Bash
64 lines
2.2 KiB
Bash
#!/usr/bin/env bash
|
|
# Test: Fetch from Wild Directory and redeploy
|
|
# Verifies: fetch re-copies package from source, deploy succeeds after fetch
|
|
# Idempotent: leaves app in same state as before
|
|
|
|
MANIFEST_PATH="${DATA_DIR}/instances/${INSTANCE}/apps/${APP_NAME}/manifest.yaml"
|
|
PACKAGE_DIR="${DATA_DIR}/instances/${INSTANCE}/apps/${APP_NAME}/.package"
|
|
|
|
# --- Record current version ---
|
|
|
|
test_start "Fetch: Record current version"
|
|
CURRENT_VERSION=$(grep '^version:' "$MANIFEST_PATH" 2>/dev/null | head -1 | awk '{print $2}')
|
|
assert_not_empty "$CURRENT_VERSION" "Should have a current version in manifest"
|
|
|
|
# --- Fetch from Wild Directory ---
|
|
|
|
test_start "Fetch: Re-fetch from source"
|
|
api_post "/api/v1/instances/${INSTANCE}/apps/${APP_NAME}/fetch"
|
|
assert_http "200" "Fetch should return 200"
|
|
|
|
# --- Verify .package directory exists (source backup) ---
|
|
|
|
test_start "Fetch: .package directory exists after fetch"
|
|
if [[ -d "$PACKAGE_DIR" ]]; then
|
|
test_pass
|
|
else
|
|
test_fail ".package directory should exist after fetch"
|
|
fi
|
|
|
|
# --- Verify manifest version still present ---
|
|
|
|
test_start "Fetch: Version preserved after fetch"
|
|
AFTER_VERSION=$(grep '^version:' "$MANIFEST_PATH" 2>/dev/null | head -1 | awk '{print $2}')
|
|
assert_not_empty "$AFTER_VERSION" "Version should still be present after fetch"
|
|
|
|
# --- Check source drift is cleared ---
|
|
|
|
test_start "Fetch: No source drift after fetch"
|
|
api_get "/api/v1/instances/${INSTANCE}/apps/${APP_NAME}/enhanced"
|
|
SRC_DRIFTED=$(echo "$RESP" | jq -r '.drift.source.drifted // false' 2>/dev/null)
|
|
assert_eq "$SRC_DRIFTED" "false" "Source drift should be false after fresh fetch"
|
|
|
|
# --- Deploy after fetch ---
|
|
|
|
test_start "Fetch: Deploy after fetch"
|
|
if start_async_and_wait "/api/v1/instances/${INSTANCE}/apps/${APP_NAME}/deploy" "" "$DEPLOY_TIMEOUT"; then
|
|
test_pass
|
|
else
|
|
test_fail "Deploy failed after fetch"
|
|
fi
|
|
|
|
test_start "Fetch: Pods ready after deploy"
|
|
if wait_for_pods "$APP_NAME" 120; then
|
|
test_pass
|
|
else
|
|
test_fail "Pods not ready after fetch+deploy"
|
|
fi
|
|
|
|
# --- Verify status OK ---
|
|
|
|
test_start "Fetch: Status OK after fetch+deploy"
|
|
api_get "/api/v1/instances/${INSTANCE}/apps/${APP_NAME}/status"
|
|
assert_http "200" "Status should return 200 after fetch+deploy"
|