From 8309d585e81239f51e297de737b830104155cd73 Mon Sep 17 00:00:00 2001 From: jokiefer Date: Tue, 14 Nov 2023 08:53:12 +0100 Subject: [PATCH] * fixing docker file and docker testing docs * fixing geoalchemy deprecations --- README.md | 5 ++--- Dockerfile-3.9 => bullseye-3.9.Dockerfile | 8 ++++---- docker-compose.yml | 13 +++++++++++++ tests/backends/elasticsearch/test_evaluate.py | 5 +++-- tests/backends/sqlalchemy/test_evaluate.py | 1 - 5 files changed, 22 insertions(+), 10 deletions(-) rename Dockerfile-3.9 => bullseye-3.9.Dockerfile (81%) diff --git a/README.md b/README.md index ab2f23d..d8a36d8 100644 --- a/README.md +++ b/README.md @@ -209,9 +209,8 @@ python -m pytest To execute tests in Docker: -``` -docker build -t pygeofilter/test -f Dockerfile-3.9 . -docker run --rm pygeofilter/test +```bash +docker compose up --build test ``` diff --git a/Dockerfile-3.9 b/bullseye-3.9.Dockerfile similarity index 81% rename from Dockerfile-3.9 rename to bullseye-3.9.Dockerfile index 94c019a..9b8cd40 100644 --- a/Dockerfile-3.9 +++ b/bullseye-3.9.Dockerfile @@ -1,4 +1,4 @@ -FROM python:3.9-buster +FROM python:3.9-bullseye LABEL description="Test executor" @@ -8,6 +8,7 @@ RUN apt-get update --fix-missing \ binutils \ libproj-dev \ gdal-bin \ + libgdal-dev \ libsqlite3-mod-spatialite \ spatialite-bin \ && rm -rf /var/lib/apt/lists/* @@ -19,6 +20,7 @@ COPY requirements-test.txt . COPY requirements-dev.txt . RUN pip install -r requirements-test.txt RUN pip install -r requirements-dev.txt +RUN pip install pygdal=="`gdal-config --version`.*" COPY pygeofilter pygeofilter COPY tests tests @@ -26,6 +28,4 @@ COPY README.md . COPY setup.py . RUN pip install -e . -RUN chmod +x tests/execute-tests.sh - -CMD ["tests/execute-tests.sh"] +CMD ["python", "-m", "pytest"] diff --git a/docker-compose.yml b/docker-compose.yml index bfe1270..682637c 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,5 +1,18 @@ version: '3.8' services: + + test: + build: + context: . + dockerfile: bullseye-3.9.Dockerfile + tty: true # To support colorized log output. + networks: + - default + depends_on: + - es01 + environment: + - eshostname=es01 + es01: depends_on: setup: diff --git a/tests/backends/elasticsearch/test_evaluate.py b/tests/backends/elasticsearch/test_evaluate.py index d1a2cfc..bdec193 100644 --- a/tests/backends/elasticsearch/test_evaluate.py +++ b/tests/backends/elasticsearch/test_evaluate.py @@ -1,5 +1,5 @@ # pylint: disable=W0621,C0114,C0115,C0116 - +import os import pytest from elasticsearch_dsl import ( Date, @@ -53,8 +53,9 @@ class Index: @pytest.fixture(autouse=True, scope="session") def connection(): + hostname = os.environ.get("eshostname", "localhost") connections.create_connection( - hosts=["https://localhost:9200"], + hosts=[f"https://{hostname}:9200"], ca_certs=False, verify_certs=False, basic_auth=("elastic", "changeme") diff --git a/tests/backends/sqlalchemy/test_evaluate.py b/tests/backends/sqlalchemy/test_evaluate.py index 705f3af..b12e019 100644 --- a/tests/backends/sqlalchemy/test_evaluate.py +++ b/tests/backends/sqlalchemy/test_evaluate.py @@ -31,7 +31,6 @@ class Record(Base): geometry_type="MULTIPOLYGON", srid=4326, spatial_index=False, - management=True, ) ) float_attribute = Column(Float)