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
2 changes: 1 addition & 1 deletion .github/workflows/helm-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ jobs:
continue-on-error: true
run: |
kubectl config set-context --current --namespace=eoapitest
while [[ -z "$(kubectl get pod | grep "^raster-$RELEASE_NAME-.*$" | cut -d' ' -f1 | xargs -I{} kubectl logs pod/{} | grep "GET /healthz" | head -n 1)" ]]; do
while [[ -z "$(kubectl get pod | grep "^raster-$RELEASE_NAME-.*$" | cut -d' ' -f1 | xargs -I{} kubectl logs pod/{} | grep "GET /.*/healthz" | head -n 1)" ]]; do
echo "still waiting for raster service to start..."
sleep 1
done
Expand Down
79 changes: 53 additions & 26 deletions .github/workflows/tests/test_raster.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,46 +11,71 @@

def test_raster_api():
"""test api."""
# health
resp = client.get(
f"{raster_endpoint}/healthz", headers={"Accept-Encoding": "br, gzip"}
)
assert resp.status_code == 200
assert resp.headers["content-type"] == "application/json"
#assert resp.headers["content-encoding"] == "gzip"

resp = client.get(f"{raster_endpoint}/healthz", headers={"Accept-Encoding": "br"})
assert resp.status_code == 200
assert resp.headers["content-type"] == "application/json"
#assert resp.headers["content-encoding"] == "br"


def test_mosaic_api():
"""test mosaic."""
query = {"collections": ["noaa-emergency-response"], "filter-lang": "cql-json"}
resp = client.post(f"{raster_endpoint}/mosaic/register", json=query)
resp = client.post(f"{raster_endpoint}/searches/register", json=query)
assert resp.headers["content-type"] == "application/json"
assert resp.status_code == 200
assert resp.json()["searchid"]
assert resp.json()["id"]
assert resp.json()["links"]

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

resp = client.get(f"{raster_endpoint}/searches/{searchid}/-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"
)
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"

z, x, y = 15, 8589, 12849
resp = client.get(
f"{raster_endpoint}/searches/{searchid}/tiles/{z}/{x}/{y}",
params={"assets": "cog"},
headers={"Accept-Encoding": "br, gzip"},
timeout=10.0,
)
assert resp.status_code == 200
assert resp.headers["content-type"] == "image/jpeg"
assert "content-encoding" not in resp.headers


resp = client.get(f"{raster_endpoint}/mosaic/{searchid}/-85.6358,36.1624/assets")
def test_mosaic_collection_api():
"""test mosaic collection."""
resp = client.get(
f"{raster_endpoint}/collections/noaa-emergency-response/-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}/mosaic/{searchid}/15/8589/12849/assets")
resp = client.get(
f"{raster_endpoint}/collections/noaa-emergency-response/tiles/15/8589/12849/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"

z, x, y = 15, 8589, 12849
resp = client.get(
f"{raster_endpoint}/mosaic/{searchid}/tiles/{z}/{x}/{y}",
f"{raster_endpoint}/collections/noaa-emergency-response/tiles/{z}/{x}/{y}",
params={"assets": "cog"},
headers={"Accept-Encoding": "br, gzip"},
timeout=10.0,
Expand Down Expand Up @@ -114,11 +139,11 @@ def test_mosaic_search():
},
]
for search in searches:
resp = client.post(f"{raster_endpoint}/mosaic/register", json=search)
resp = client.post(f"{raster_endpoint}/searches/register", json=search)
assert resp.status_code == 200
assert resp.json()["searchid"]
assert resp.json()["id"]

resp = client.get(f"{raster_endpoint}/mosaic/list")
resp = client.get(f"{raster_endpoint}/searches/list")
assert resp.headers["content-type"] == "application/json"
assert resp.status_code == 200
assert (
Expand All @@ -134,9 +159,11 @@ def test_mosaic_search():
assert len(links) == 2
assert links[0]["rel"] == "self"
assert links[1]["rel"] == "next"
assert links[1]["href"] == f"{raster_endpoint}/mosaic/list?limit=10&offset=10"
assert links[1]["href"] == f"{raster_endpoint}/searches/list?limit=10&offset=10"

resp = client.get(f"{raster_endpoint}/mosaic/list", params={"limit": 1, "offset": 1})
resp = client.get(
f"{raster_endpoint}/searches/list", params={"limit": 1, "offset": 1}
)
assert resp.status_code == 200
assert resp.json()["context"]["matched"] > 10
assert resp.json()["context"]["limit"] == 1
Expand All @@ -145,33 +172,33 @@ def test_mosaic_search():
links = resp.json()["links"]
assert len(links) == 3
assert links[0]["rel"] == "self"
assert links[0]["href"] == f"{raster_endpoint}/mosaic/list?limit=1&offset=1"
assert links[0]["href"] == f"{raster_endpoint}/searches/list?limit=1&offset=1"
assert links[1]["rel"] == "next"
assert links[1]["href"] == f"{raster_endpoint}/mosaic/list?limit=1&offset=2"
assert links[1]["href"] == f"{raster_endpoint}/searches/list?limit=1&offset=2"
assert links[2]["rel"] == "prev"
assert links[2]["href"] == f"{raster_endpoint}/mosaic/list?limit=1&offset=0"
assert links[2]["href"] == f"{raster_endpoint}/searches/list?limit=1&offset=0"

# Filter on mosaic metadata
resp = client.get(f"{raster_endpoint}/mosaic/list", params={"owner": "vincent"})
resp = client.get(f"{raster_endpoint}/searches/list", params={"owner": "vincent"})
assert resp.status_code == 200
assert resp.json()["context"]["matched"] == 7
assert resp.json()["context"]["limit"] == 10
assert resp.json()["context"]["returned"] == 7

# sortBy
resp = client.get(f"{raster_endpoint}/mosaic/list", params={"sortby": "lastused"})
resp = client.get(f"{raster_endpoint}/searches/list", params={"sortby": "lastused"})
assert resp.status_code == 200

resp = client.get(f"{raster_endpoint}/mosaic/list", params={"sortby": "usecount"})
resp = client.get(f"{raster_endpoint}/searches/list", params={"sortby": "usecount"})
assert resp.status_code == 200

resp = client.get(f"{raster_endpoint}/mosaic/list", params={"sortby": "-owner"})
resp = client.get(f"{raster_endpoint}/searches/list", params={"sortby": "-owner"})
assert resp.status_code == 200
assert (
"owner" not in resp.json()["searches"][0]["search"]["metadata"]
) # some mosaic don't have owners

resp = client.get(f"{raster_endpoint}/mosaic/list", params={"sortby": "owner"})
resp = client.get(f"{raster_endpoint}/searches/list", params={"sortby": "owner"})
assert resp.status_code == 200
assert "owner" in resp.json()["searches"][0]["search"]["metadata"]

Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/tests/test_vector.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ def test_vector_api():
"numberReturned",
"collections",
]
assert resp.json()["numberMatched"] == 4 # one public table + 3 functions
assert resp.json()["numberReturned"] == 4
assert resp.json()["numberMatched"] == 7 # one public table + 5 functions
assert resp.json()["numberReturned"] == 7

collections = resp.json()["collections"]
ids = [c["id"] for c in collections]
Expand Down
2 changes: 1 addition & 1 deletion helm-chart/eoapi/initdb-data/noaa-emergency-response.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"id":"noaa-emergency-response", "title": "NOAA Emergency Response Imagery", "description":"NOAA Emergency Response Imagery hosted on AWS Public Dataset.","stac_version":"1.0.0","license":"public-domain","links":[],"extent":{"spatial":{"bbox":[[-180,-90,180,90]]},"temporal":{"interval":[["2005-01-01T00:00:00Z","null"]]}}}
{"id":"noaa-emergency-response", "title": "NOAA Emergency Response Imagery", "description":"NOAA Emergency Response Imagery hosted on AWS Public Dataset.","stac_version":"1.0.0","license":"public-domain","links":[],"extent":{"spatial":{"bbox":[[-180,-90,180,90]]},"temporal":{"interval":[["2005-01-01T00:00:00Z",null]]}}}
2 changes: 2 additions & 0 deletions helm-chart/eoapi/templates/db/configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ metadata:
data:
load.sh: |
#!/bin/bash
apt update -y && apt install python3 python3-pip -y
pip install pypgstac[psycopg]
DSN="postgresql://$POSTGRES_USER:$POSTGRES_PASSWORD@$POSTGRES_HOST/$POSTGRES_DB"
pypgstac pgready --dsn $DSN
pypgstac load collections /opt/initdb/json-data/noaa-emergency-response.json --dsn $DSN --method insert_ignore
Expand Down