|
| 1 | +#!/usr/bin/env bash |
| 2 | +set -euo pipefail |
| 3 | + |
| 4 | +ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)" |
| 5 | +cd "$ROOT_DIR" |
| 6 | + |
| 7 | +CATBOOST_INFO_DIR="$ROOT_DIR/catboost_info" |
| 8 | + |
| 9 | +cleanup_catboost_info() { |
| 10 | + if [[ "${PLEXE_IT_KEEP_CATBOOST_INFO:-0}" == "1" ]]; then |
| 11 | + return |
| 12 | + fi |
| 13 | + rm -rf "$CATBOOST_INFO_DIR" |
| 14 | +} |
| 15 | + |
| 16 | +# Remove stale CatBoost local artifacts from previous runs. |
| 17 | +cleanup_catboost_info |
| 18 | +# Keep repo clean even if a stage fails midway. |
| 19 | +trap cleanup_catboost_info EXIT |
| 20 | + |
| 21 | +if [[ -z "${PLEXE_IT_RUN_ID:-}" ]]; then |
| 22 | + PLEXE_IT_RUN_ID="$(date +%Y%m%d_%H%M%S)" |
| 23 | +fi |
| 24 | +export PLEXE_IT_RUN_ID |
| 25 | + |
| 26 | +ARTIFACT_ROOT="$ROOT_DIR/.pytest_cache/integration/$PLEXE_IT_RUN_ID" |
| 27 | +mkdir -p "$ARTIFACT_ROOT" |
| 28 | + |
| 29 | +if ! poetry run python -c "import importlib.util,sys; sys.exit(0 if importlib.util.find_spec('xdist') else 1)"; then |
| 30 | + echo "ERROR: pytest-xdist is required for staged integration tests." |
| 31 | + echo "Install dependencies with: poetry install" |
| 32 | + echo "Then verify with: poetry run pytest --help | grep -E '(^| )-n( |$)'" |
| 33 | + exit 2 |
| 34 | +fi |
| 35 | + |
| 36 | +if [[ -n "${PLEXE_IT_WORKERS:-}" ]]; then |
| 37 | + WORKERS="${PLEXE_IT_WORKERS}" |
| 38 | +elif [[ "${PLEXE_IT_VERBOSE:-0}" == "1" ]]; then |
| 39 | + # In verbose mode, default to main-process execution for reliable live logs. |
| 40 | + WORKERS="0" |
| 41 | +else |
| 42 | + WORKERS="auto" |
| 43 | +fi |
| 44 | +PYTEST_PARALLEL_ARGS=(-n "$WORKERS") |
| 45 | +PYTEST_LOG_DISABLE_ARGS=( |
| 46 | + --log-disable=LiteLLM |
| 47 | + --log-disable=litellm |
| 48 | + --log-disable=httpx |
| 49 | + --log-disable=httpcore |
| 50 | + --log-disable=urllib3 |
| 51 | + --log-disable=py4j |
| 52 | + --log-disable=py4j.clientserver |
| 53 | + --log-disable=py4j.java_gateway |
| 54 | +) |
| 55 | + |
| 56 | +run_stage() { |
| 57 | + local marker="$1" |
| 58 | + local cmd=(poetry run pytest tests/integration -m "$marker" "${PYTEST_PARALLEL_ARGS[@]}" --maxfail=1) |
| 59 | + |
| 60 | + if [[ "${PLEXE_IT_VERBOSE:-0}" == "1" ]]; then |
| 61 | + cmd+=(-s -vv -o log_cli=true -o log_cli_level=INFO --capture=tee-sys "${PYTEST_LOG_DISABLE_ARGS[@]}") |
| 62 | + fi |
| 63 | + |
| 64 | + "${cmd[@]}" |
| 65 | +} |
| 66 | + |
| 67 | +echo "Running staged integration tests with run id: $PLEXE_IT_RUN_ID" |
| 68 | +echo "Artifacts: $ARTIFACT_ROOT" |
| 69 | +echo "Workers: $WORKERS" |
| 70 | +if [[ "${PLEXE_IT_VERBOSE:-0}" == "1" ]]; then |
| 71 | + echo "Verbose mode: enabled (live logs and test output)" |
| 72 | +fi |
| 73 | + |
| 74 | +echo "" |
| 75 | +echo "Stage 1/3: building reusable seeds through phase 3" |
| 76 | +run_stage "integration_seed" |
| 77 | + |
| 78 | +echo "" |
| 79 | +echo "Stage 2/3: resuming from seeds through phase 4" |
| 80 | +run_stage "integration_search" |
| 81 | + |
| 82 | +echo "" |
| 83 | +echo "Stage 3/3: final evaluation, packaging, and predictor checks" |
| 84 | +run_stage "integration_eval" |
| 85 | + |
| 86 | +echo "" |
| 87 | +echo "Staged integration suite completed successfully." |
0 commit comments