File tree Expand file tree Collapse file tree 5 files changed +47
-11
lines changed
tests/backends/elasticsearch Expand file tree Collapse file tree 5 files changed +47
-11
lines changed Original file line number Diff line number Diff line change 1- FROM python:3.9-buster
1+ FROM python:3.9-slim-bullseye
22
33LABEL description="Test executor"
44
5- ENV DEBIAN_FRONTEND noninteractive
5+ ENV DEBIAN_FRONTEND= noninteractive
66RUN apt-get update --fix-missing \
77 && apt-get install -y --no-install-recommends \
88 binutils \
99 libproj-dev \
1010 gdal-bin \
11+ libgdal-dev \
1112 libsqlite3-mod-spatialite \
1213 spatialite-bin \
14+ build-essential \
1315 && rm -rf /var/lib/apt/lists/*
1416
1517RUN mkdir /app
@@ -19,13 +21,11 @@ COPY requirements-test.txt .
1921COPY requirements-dev.txt .
2022RUN pip install -r requirements-test.txt
2123RUN pip install -r requirements-dev.txt
24+ RUN gdal_version=$(gdal-config --version) && \
25+ pip install pygdal=="$gdal_version.*"
2226
2327COPY pygeofilter pygeofilter
2428COPY tests tests
2529COPY README.md .
2630COPY setup.py .
2731RUN pip install -e .
28-
29- RUN chmod +x tests/execute-tests.sh
30-
31- CMD ["tests/execute-tests.sh"]
Original file line number Diff line number Diff line change @@ -180,6 +180,8 @@ pip install -r requirements-dev.txt
180180pip install -r requirements-test.txt
181181```
182182
183+ GDAL must also be available in the local environment.
184+
183185The functionality can be tested using ` pytest ` .
184186
185187``` bash
@@ -188,11 +190,10 @@ python -m pytest
188190
189191### Docker
190192
191- To execute tests in Docker:
193+ To execute tests with Docker Compose :
192194
193195```
194- docker build -t pygeofilter/test -f Dockerfile-3.9 .
195- docker run --rm pygeofilter/test
196+ ./execute-tests.sh
196197```
197198
198199## Backends
Original file line number Diff line number Diff line change 1+ services :
2+ elasticsearch :
3+ image : elasticsearch:8.2.2
4+ ports :
5+ - 9200:9200
6+ - 9300:9300
7+ environment :
8+ discovery.type : single-node
9+ xpack.security.enabled : false
10+ xpack.security.http.ssl.enabled : false
11+ healthcheck :
12+ test : ["CMD-SHELL", "curl -s http://localhost:9200/_cluster/health | grep -q '\"status\":\"green\"'"]
13+ interval : 30s
14+ timeout : 10s
15+ retries : 3
16+ tester :
17+ build :
18+ dockerfile : ./Dockerfile-3.9
19+ environment :
20+ PYGEOFILTER_ELASTIC_HOST : elasticsearch
21+ depends_on :
22+ elasticsearch :
23+ condition : service_healthy
Original file line number Diff line number Diff line change 1+ #! /bin/bash
2+
3+ set -e
4+
5+ pushd $( dirname $0 )
6+
7+ dco=" docker compose -f docker-compose.test.yml"
8+ $dco build
9+ $dco run --rm tester pytest
Original file line number Diff line number Diff line change 2222from pygeofilter .backends .elasticsearch import to_filter
2323from pygeofilter .parsers .ecql import parse
2424from pygeofilter .util import parse_datetime
25-
25+ from os import environ
2626
2727class Wildcard (Field ):
2828 name = "wildcard"
@@ -54,7 +54,10 @@ class Index:
5454@pytest .fixture (autouse = True , scope = "session" )
5555def connection ():
5656 connections .create_connection (
57- hosts = ["http://localhost:9200" ],
57+ hosts = ["http://{}:{}" .format (
58+ environ .get ("PYGEOFILTER_ELASTIC_HOST" , "localhost" ),
59+ environ .get ("PYGEOFILTER_ELASTIC_PORT" , "9200" ),
60+ )],
5861 )
5962
6063
You can’t perform that action at this time.
0 commit comments