|
| 1 | +# Direct Cloud Run Testing |
| 2 | + |
| 3 | +This directory contains scripts for testing the Cloud Run service directly, bypassing the CI/CD pipeline. |
| 4 | + |
| 5 | +## Scripts |
| 6 | + |
| 7 | +### `test_cloud_run_direct.py` |
| 8 | +Direct testing script that sends requests to the deployed Cloud Run service and helps debug 500 errors. |
| 9 | + |
| 10 | +**Usage:** |
| 11 | +```bash |
| 12 | +# Set the service URL (defaults to the production URL) |
| 13 | +export SERVICE_URL="https://supply-graph-ai-1085931013579.us-west1.run.app" |
| 14 | +export USE_AUTH=true |
| 15 | + |
| 16 | +# Run the tests |
| 17 | +python test_cloud_run_direct.py |
| 18 | +``` |
| 19 | + |
| 20 | +**What it tests:** |
| 21 | +- List OKH manifests (to check storage service) |
| 22 | +- Create OKH manifest |
| 23 | +- Create OKW facility |
| 24 | +- Match OKH to OKW (if OKH creation succeeds) |
| 25 | + |
| 26 | +### `check_cloud_logs.sh` |
| 27 | +Helper script to check Cloud Run logs for errors. |
| 28 | + |
| 29 | +**Usage:** |
| 30 | +```bash |
| 31 | +# Set project and service name (optional, has defaults) |
| 32 | +export PROJECT_ID="nathan-playground-368310" |
| 33 | +export SERVICE_NAME="supply-graph-ai" |
| 34 | + |
| 35 | +# Run the script |
| 36 | +./check_cloud_logs.sh |
| 37 | +``` |
| 38 | + |
| 39 | +**What it shows:** |
| 40 | +- Recent ERROR level logs |
| 41 | +- Logs with "Error" or "Exception" in text |
| 42 | +- Recent 500 errors |
| 43 | +- Full tracebacks for recent errors |
| 44 | + |
| 45 | +## Workflow |
| 46 | + |
| 47 | +1. **Run the test script:** |
| 48 | + ```bash |
| 49 | + python test_cloud_run_direct.py |
| 50 | + ``` |
| 51 | + |
| 52 | +2. **If you see 500 errors, check the logs:** |
| 53 | + ```bash |
| 54 | + ./check_cloud_logs.sh |
| 55 | + ``` |
| 56 | + |
| 57 | +3. **Or check logs manually:** |
| 58 | + ```bash |
| 59 | + # View recent errors |
| 60 | + gcloud logging read \ |
| 61 | + 'resource.type=cloud_run_revision AND resource.labels.service_name=supply-graph-ai AND severity>=ERROR' \ |
| 62 | + --limit 50 --format json \ |
| 63 | + --project=nathan-playground-368310 |
| 64 | + ``` |
| 65 | + |
| 66 | +4. **Fix the issues found in the logs** |
| 67 | + |
| 68 | +5. **Re-run the test script to verify fixes** |
| 69 | + |
| 70 | +## Authentication |
| 71 | + |
| 72 | +The scripts use GCP identity tokens for authentication. Make sure you're authenticated: |
| 73 | + |
| 74 | +```bash |
| 75 | +gcloud auth login |
| 76 | +gcloud auth application-default login |
| 77 | +``` |
| 78 | + |
| 79 | +Or set an explicit token: |
| 80 | +```bash |
| 81 | +export IDENTITY_TOKEN=$(gcloud auth print-identity-token) |
| 82 | +``` |
0 commit comments