Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
409 changes: 80 additions & 329 deletions .github/workflows/helm-tests.yml

Large diffs are not rendered by default.

14 changes: 7 additions & 7 deletions .github/workflows/tests/test_raster.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,14 @@ def test_mosaic_api(raster_endpoint):

searchid = resp.json()["id"]

resp = client.get(f"{raster_endpoint}/searches/{searchid}/-85.6358,36.1624/assets")
resp = client.get(f"{raster_endpoint}/searches/{searchid}/point/-85.6358,36.1624/assets")
assert resp.status_code == 200
assert len(resp.json()) == 1
assert list(resp.json()[0]) == ["id", "bbox", "assets", "collection"]
assert resp.json()[0]["id"] == "20200307aC0853900w361030"

resp = client.get(
f"{raster_endpoint}/searches/{searchid}/tiles/15/8589/12849/assets"
f"{raster_endpoint}/searches/{searchid}/tiles/WebMercatorQuad/15/8589/12849/assets"
)
assert resp.status_code == 200
assert len(resp.json()) == 1
Expand All @@ -46,7 +46,7 @@ def test_mosaic_api(raster_endpoint):

z, x, y = 15, 8589, 12849
resp = client.get(
f"{raster_endpoint}/searches/{searchid}/tiles/{z}/{x}/{y}",
f"{raster_endpoint}/searches/{searchid}/tiles/WebMercatorQuad/{z}/{x}/{y}",
params={"assets": "cog"},
headers={"Accept-Encoding": "br, gzip"},
timeout=10.0,
Expand All @@ -59,15 +59,15 @@ def test_mosaic_api(raster_endpoint):
def test_mosaic_collection_api(raster_endpoint):
"""test mosaic collection."""
resp = client.get(
f"{raster_endpoint}/collections/noaa-emergency-response/-85.6358,36.1624/assets"
f"{raster_endpoint}/collections/noaa-emergency-response/point/-85.6358,36.1624/assets"
)
assert resp.status_code == 200
assert len(resp.json()) == 1
assert list(resp.json()[0]) == ["id", "bbox", "assets", "collection"]
assert resp.json()[0]["id"] == "20200307aC0853900w361030"

resp = client.get(
f"{raster_endpoint}/collections/noaa-emergency-response/tiles/15/8589/12849/assets"
f"{raster_endpoint}/collections/noaa-emergency-response/tiles/WebMercatorQuad/15/8589/12849/assets"
)
assert resp.status_code == 200
assert len(resp.json()) == 1
Expand All @@ -76,7 +76,7 @@ def test_mosaic_collection_api(raster_endpoint):

z, x, y = 15, 8589, 12849
resp = client.get(
f"{raster_endpoint}/collections/noaa-emergency-response/tiles/{z}/{x}/{y}",
f"{raster_endpoint}/collections/noaa-emergency-response/tiles/WebMercatorQuad/{z}/{x}/{y}",
params={"assets": "cog"},
headers={"Accept-Encoding": "br, gzip"},
timeout=10.0,
Expand Down Expand Up @@ -214,7 +214,7 @@ def test_item(raster_endpoint):
assert resp.json() == ["cog"]

resp = client.get(
f"{raster_endpoint}/collections/noaa-emergency-response/items/20200307aC0853300w361200/tilejson.json",
f"{raster_endpoint}/collections/noaa-emergency-response/items/20200307aC0853300w361200/WebMercatorQuad/tilejson.json",
params={
"assets": "cog",
},
Expand Down
28 changes: 20 additions & 8 deletions .github/workflows/tests/test_vector.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,21 +39,33 @@ def test_vector_api(vector_endpoint):
"collections",
]

total_timeout = 60 * 5
total_timeout = 60 * 2
start_time = time.time()
while True:
if resp.json()["numberMatched"] == 7:
collections_data = resp.json()
current_count = collections_data.get("numberMatched", 0)
print(f"Current collections count: {current_count}/7")

if current_count == 7:
break

if time.time() - start_time > total_timeout:
print("Timeout exceeded")
assert False
elapsed_time = time.time() - start_time
if elapsed_time > total_timeout:
print(f"Timeout exceeded after {elapsed_time:.1f}s. Expected 7 collections, got {current_count}")
if "collections" in collections_data:
available_collections = [c.get("id", "unknown") for c in collections_data["collections"]]
print(f"Available collections: {available_collections}")
assert False, f"Expected 7 collections but found {current_count} after {elapsed_time:.1f}s timeout"

time.sleep(20)
time.sleep(10)
resp = client.get(f"{vector_endpoint}/collections")

assert resp.json()["numberMatched"] == 7 # one public table + 5 functions
assert resp.json()["numberReturned"] == 7
collections_data = resp.json()
matched_count = collections_data.get("numberMatched", 0)
returned_count = collections_data.get("numberReturned", 0)

assert matched_count == 7, f"Expected 7 matched collections, got {matched_count}. Available: {[c.get('id', 'unknown') for c in collections_data.get('collections', [])]}"
assert returned_count == 7, f"Expected 7 returned collections, got {returned_count}"

collections = resp.json()["collections"]
ids = [c["id"] for c in collections]
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@
charts/config.yaml
charts/eoapi/charts/*.tgz
config_ingress.yaml
__pycache__
28 changes: 15 additions & 13 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,15 @@ HELM_REPO_URL=https://devseed.com/eoapi-k8s/
HELM_CHART_NAME=eoapi/eoapi
PGO_CHART_VERSION=5.7.4

.PHONY: all deploy minikube ingest help
.PHONY: all deploy minikube ingest test-integration tests help

# Default target
all: deploy

deploy:
@echo "Installing dependencies."
@command -v helm >/dev/null 2>&1 || { echo "helm is required but not installed"; exit 1; }
helm upgrade --install --set disable_check_for_upgrades=true pgo oci://registry.developers.crunchydata.com/crunchydata/pgo --version $(PGO_CHART_VERSION)
@echo "Adding eoAPI helm repository."
@helm repo add eoapi $(HELM_REPO_URL)
@echo "Installing eoAPI helm chart."
@cd ./charts && \
helm dependency build ./eoapi && \
helm upgrade --install --namespace eoapi --create-namespace --set gitSha=$$(git rev-parse HEAD | cut -c1-10) eoapi ./eoapi
@echo "Deploying eoAPI."
@command -v bash >/dev/null 2>&1 || { echo "bash is required but not installed"; exit 1; }
@./scripts/deploy.sh

minikube:
@echo "Starting minikube."
Expand All @@ -37,13 +31,21 @@ ingest:
@./scripts/ingest.sh || { echo "Ingestion failed."; exit 1; }

tests:
@echo "Running tests."
@echo "Running Helm unit tests..."
@command -v helm >/dev/null 2>&1 || { echo "helm is required but not installed"; exit 1; }
@helm unittest charts/eoapi -f 'tests/*.yaml' -v charts/eoapi/test-helm-values.yaml
@./scripts/deploy.sh setup
@./scripts/test.sh helm

integration:
@echo "Running integration tests against Kubernetes cluster..."
@command -v bash >/dev/null 2>&1 || { echo "bash is required but not installed"; exit 1; }
@./scripts/test.sh integration

help:
@echo "Makefile commands:"
@echo " make deploy - Install eoAPI on a cluster kubectl is connected to."
@echo " make deploy - Deploy eoAPI to the configured Kubernetes cluster."
@echo " make minikube - Install eoAPI on minikube."
@echo " make ingest - Ingest STAC collections and items into the database."
@echo " make integration - Run integration tests on connected Kubernetes cluster."
@echo " make tests - Run lint + unit tests."
@echo " make help - Show this help message."
78 changes: 78 additions & 0 deletions scripts/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
# eoAPI Kubernetes Scripts

Automation scripts for deploying, testing, and managing eoAPI on Kubernetes.

## Scripts Overview

| Script | Purpose | Usage |
|--------|---------|-------|
| **`deploy.sh`** | Deploy eoAPI to Kubernetes | `./deploy.sh [deploy\|setup\|cleanup] [--ci]` |
| **`ingest.sh`** | Ingest STAC data into deployed eoAPI | `./ingest.sh [collections.json] [items.json]` |
| **`test.sh`** | Run Helm and integration tests | `./test.sh [helm\|integration\|all] [--debug]` |
| **`lib/`** | Shared utility functions | See [lib/README.md](lib/README.md) |

## Quick Start

```bash
# Deploy eoAPI
./scripts/deploy.sh

# Ingest sample data
./scripts/ingest.sh collections.json items.json

# Run tests
./scripts/test.sh
```

## Prerequisites

- **kubectl** - Kubernetes CLI configured for your cluster
- **helm** - Helm package manager v3+
- **python3** - For data ingestion and testing
- **jq** - JSON processor (for advanced features)

## Environment Variables (Optional)

Most settings are auto-detected. Override only when needed:

```bash
# Deployment customization
export PGO_VERSION=5.7.4 # PostgreSQL operator version
export TIMEOUT=15m # Deployment timeout

# Override auto-detection (usually not needed)
export NAMESPACE=my-eoapi # Target namespace
export RELEASE_NAME=my-release # Helm release name

# Testing endpoints (auto-detected by test.sh)
export STAC_ENDPOINT=http://... # Override STAC API endpoint
export RASTER_ENDPOINT=http://... # Override Raster API endpoint
export VECTOR_ENDPOINT=http://... # Override Vector API endpoint
```

## Common Examples

**Deploy with custom namespace:**
```bash
NAMESPACE=my-eoapi ./scripts/deploy.sh
```

**Setup dependencies only:**
```bash
./scripts/deploy.sh setup
```

**Run tests with debug output:**
```bash
./scripts/test.sh all --debug
```

**Cleanup deployment:**
```bash
./scripts/deploy.sh cleanup
```

**CI mode deployment:**
```bash
./scripts/deploy.sh --ci
```
Loading