Skip to content

Commit fe61ad5

Browse files
authored
refactor: Check on existing integration tests (#284)
1 parent 4a6ce28 commit fe61ad5

File tree

14 files changed

+1548
-450
lines changed

14 files changed

+1548
-450
lines changed

.github/workflows/helm-tests.yml

Lines changed: 80 additions & 329 deletions
Large diffs are not rendered by default.

.github/workflows/tests/test_raster.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,14 @@ def test_mosaic_api(raster_endpoint):
3030

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

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

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

4747
z, x, y = 15, 8589, 12849
4848
resp = client.get(
49-
f"{raster_endpoint}/searches/{searchid}/tiles/{z}/{x}/{y}",
49+
f"{raster_endpoint}/searches/{searchid}/tiles/WebMercatorQuad/{z}/{x}/{y}",
5050
params={"assets": "cog"},
5151
headers={"Accept-Encoding": "br, gzip"},
5252
timeout=10.0,
@@ -59,15 +59,15 @@ def test_mosaic_api(raster_endpoint):
5959
def test_mosaic_collection_api(raster_endpoint):
6060
"""test mosaic collection."""
6161
resp = client.get(
62-
f"{raster_endpoint}/collections/noaa-emergency-response/-85.6358,36.1624/assets"
62+
f"{raster_endpoint}/collections/noaa-emergency-response/point/-85.6358,36.1624/assets"
6363
)
6464
assert resp.status_code == 200
6565
assert len(resp.json()) == 1
6666
assert list(resp.json()[0]) == ["id", "bbox", "assets", "collection"]
6767
assert resp.json()[0]["id"] == "20200307aC0853900w361030"
6868

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

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

216216
resp = client.get(
217-
f"{raster_endpoint}/collections/noaa-emergency-response/items/20200307aC0853300w361200/tilejson.json",
217+
f"{raster_endpoint}/collections/noaa-emergency-response/items/20200307aC0853300w361200/WebMercatorQuad/tilejson.json",
218218
params={
219219
"assets": "cog",
220220
},

.github/workflows/tests/test_vector.py

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -39,21 +39,33 @@ def test_vector_api(vector_endpoint):
3939
"collections",
4040
]
4141

42-
total_timeout = 60 * 5
42+
total_timeout = 60 * 2
4343
start_time = time.time()
4444
while True:
45-
if resp.json()["numberMatched"] == 7:
45+
collections_data = resp.json()
46+
current_count = collections_data.get("numberMatched", 0)
47+
print(f"Current collections count: {current_count}/7")
48+
49+
if current_count == 7:
4650
break
4751

48-
if time.time() - start_time > total_timeout:
49-
print("Timeout exceeded")
50-
assert False
52+
elapsed_time = time.time() - start_time
53+
if elapsed_time > total_timeout:
54+
print(f"Timeout exceeded after {elapsed_time:.1f}s. Expected 7 collections, got {current_count}")
55+
if "collections" in collections_data:
56+
available_collections = [c.get("id", "unknown") for c in collections_data["collections"]]
57+
print(f"Available collections: {available_collections}")
58+
assert False, f"Expected 7 collections but found {current_count} after {elapsed_time:.1f}s timeout"
5159

52-
time.sleep(20)
60+
time.sleep(10)
5361
resp = client.get(f"{vector_endpoint}/collections")
5462

55-
assert resp.json()["numberMatched"] == 7 # one public table + 5 functions
56-
assert resp.json()["numberReturned"] == 7
63+
collections_data = resp.json()
64+
matched_count = collections_data.get("numberMatched", 0)
65+
returned_count = collections_data.get("numberReturned", 0)
66+
67+
assert matched_count == 7, f"Expected 7 matched collections, got {matched_count}. Available: {[c.get('id', 'unknown') for c in collections_data.get('collections', [])]}"
68+
assert returned_count == 7, f"Expected 7 returned collections, got {returned_count}"
5769

5870
collections = resp.json()["collections"]
5971
ids = [c["id"] for c in collections]

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@
44
charts/config.yaml
55
charts/eoapi/charts/*.tgz
66
config_ingress.yaml
7+
__pycache__

Makefile

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,21 +5,15 @@ HELM_REPO_URL=https://devseed.com/eoapi-k8s/
55
HELM_CHART_NAME=eoapi/eoapi
66
PGO_CHART_VERSION=5.7.4
77

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

1010
# Default target
1111
all: deploy
1212

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

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

3933
tests:
40-
@echo "Running tests."
34+
@echo "Running Helm unit tests..."
4135
@command -v helm >/dev/null 2>&1 || { echo "helm is required but not installed"; exit 1; }
42-
@helm unittest charts/eoapi -f 'tests/*.yaml' -v charts/eoapi/test-helm-values.yaml
36+
@./scripts/deploy.sh setup
37+
@./scripts/test.sh helm
38+
39+
integration:
40+
@echo "Running integration tests against Kubernetes cluster..."
41+
@command -v bash >/dev/null 2>&1 || { echo "bash is required but not installed"; exit 1; }
42+
@./scripts/test.sh integration
4343

4444
help:
4545
@echo "Makefile commands:"
46-
@echo " make deploy - Install eoAPI on a cluster kubectl is connected to."
46+
@echo " make deploy - Deploy eoAPI to the configured Kubernetes cluster."
4747
@echo " make minikube - Install eoAPI on minikube."
4848
@echo " make ingest - Ingest STAC collections and items into the database."
49+
@echo " make integration - Run integration tests on connected Kubernetes cluster."
50+
@echo " make tests - Run lint + unit tests."
4951
@echo " make help - Show this help message."

scripts/README.md

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
# eoAPI Kubernetes Scripts
2+
3+
Automation scripts for deploying, testing, and managing eoAPI on Kubernetes.
4+
5+
## Scripts Overview
6+
7+
| Script | Purpose | Usage |
8+
|--------|---------|-------|
9+
| **`deploy.sh`** | Deploy eoAPI to Kubernetes | `./deploy.sh [deploy\|setup\|cleanup] [--ci]` |
10+
| **`ingest.sh`** | Ingest STAC data into deployed eoAPI | `./ingest.sh [collections.json] [items.json]` |
11+
| **`test.sh`** | Run Helm and integration tests | `./test.sh [helm\|integration\|all] [--debug]` |
12+
| **`lib/`** | Shared utility functions | See [lib/README.md](lib/README.md) |
13+
14+
## Quick Start
15+
16+
```bash
17+
# Deploy eoAPI
18+
./scripts/deploy.sh
19+
20+
# Ingest sample data
21+
./scripts/ingest.sh collections.json items.json
22+
23+
# Run tests
24+
./scripts/test.sh
25+
```
26+
27+
## Prerequisites
28+
29+
- **kubectl** - Kubernetes CLI configured for your cluster
30+
- **helm** - Helm package manager v3+
31+
- **python3** - For data ingestion and testing
32+
- **jq** - JSON processor (for advanced features)
33+
34+
## Environment Variables (Optional)
35+
36+
Most settings are auto-detected. Override only when needed:
37+
38+
```bash
39+
# Deployment customization
40+
export PGO_VERSION=5.7.4 # PostgreSQL operator version
41+
export TIMEOUT=15m # Deployment timeout
42+
43+
# Override auto-detection (usually not needed)
44+
export NAMESPACE=my-eoapi # Target namespace
45+
export RELEASE_NAME=my-release # Helm release name
46+
47+
# Testing endpoints (auto-detected by test.sh)
48+
export STAC_ENDPOINT=http://... # Override STAC API endpoint
49+
export RASTER_ENDPOINT=http://... # Override Raster API endpoint
50+
export VECTOR_ENDPOINT=http://... # Override Vector API endpoint
51+
```
52+
53+
## Common Examples
54+
55+
**Deploy with custom namespace:**
56+
```bash
57+
NAMESPACE=my-eoapi ./scripts/deploy.sh
58+
```
59+
60+
**Setup dependencies only:**
61+
```bash
62+
./scripts/deploy.sh setup
63+
```
64+
65+
**Run tests with debug output:**
66+
```bash
67+
./scripts/test.sh all --debug
68+
```
69+
70+
**Cleanup deployment:**
71+
```bash
72+
./scripts/deploy.sh cleanup
73+
```
74+
75+
**CI mode deployment:**
76+
```bash
77+
./scripts/deploy.sh --ci
78+
```

0 commit comments

Comments
 (0)