diff --git a/.github/workflows/test-conformance.yml b/.github/workflows/test-conformance.yml index b96e50a8..37484e44 100644 --- a/.github/workflows/test-conformance.yml +++ b/.github/workflows/test-conformance.yml @@ -43,8 +43,11 @@ jobs: cp .env.example .env # start the stack - docker compose up --build -d - sleep 10 + docker compose \ + -f docker-compose.yml \ + -f docker-compose.override.yml \ + -f docker-compose.tests.yml \ + up postgres django --build -d # deploy static files and migrate database docker compose run django python manage.py collectstatic --no-input @@ -56,15 +59,8 @@ jobs: - name: Healthcheck run: wget --no-check-certificate https://localhost/oapif/collections/poles/items - - uses: actions/setup-python@v4 - with: - python-version: '3.9' - - - name: Install and run conformance test - run: | - # Wrapper around official test suite for more convenient handling in CI - pip install -r ./conformance-tests/requirements.txt - python3 -m unittest ./conformance-tests/ogcf.py + - name: Run conformance test + run: docker compose run test_client - name: Failure logs if: failure() diff --git a/conformance-tests/Dockerfile b/conformance-tests/Dockerfile new file mode 100644 index 00000000..032e289d --- /dev/null +++ b/conformance-tests/Dockerfile @@ -0,0 +1,4 @@ +FROM python:3.9 +COPY requirements.txt . +RUN pip3 install -r requirements.txt +CMD ["python3", "-m", "unittest", "./conformance-tests/ogcf.py"] diff --git a/conformance-tests/ogcf.py b/conformance-tests/ogcf.py index 65ef26ce..8cb731d1 100644 --- a/conformance-tests/ogcf.py +++ b/conformance-tests/ogcf.py @@ -3,19 +3,35 @@ import requests -test_client_url = "http://localhost:8081/teamengine/rest/suites/ogcapi-features-1.0/run" -api_url = "http://localhost:8000/oapif/" - class ConformanceTest(unittest.TestCase): + @classmethod + def setUpClass(cls): + app_service = "django" + conformance_service = "conformance_test_client" + cls.api_url = f"http://{app_service}/oapif/" + cls.test_client_url = f"http://{conformance_service}/teamengine/rest/suites/ogcapi-features-1.0/run" + + def test_url(self): + print(f"Trying to access: {self.api_url}") + response = requests.get(self.api_url) + condition = response.status_code == 200 + + if not condition: + print(response.status_code) + self.assertTrue(condition) + def test_endpoint(self): - params = {"iut": api_url} + params = {"iut": self.api_url} encoded_params = urlencode(params, quote_via=quote_plus) - url = f"{test_client_url}?{encoded_params}" + url = f"{self.test_client_url}?{encoded_params}" headers = {"Accept": "application/xml"} - print(f"Validating: {api_url} with {url}") + + print(f"Validating: {self.api_url} with {url}") response = requests.get(url, headers=headers) - print(f"{response.text}") + + condition = response.status_code == 200 + self.assertTrue(condition) if __name__ == "__main__": diff --git a/docker-compose.tests.yml b/docker-compose.tests.yml new file mode 100644 index 00000000..3fef6661 --- /dev/null +++ b/docker-compose.tests.yml @@ -0,0 +1,9 @@ +services: + conformance_suite: + image: ogccite/ets-ogcapi-features10 + depends_on: [django] + + test_client: + build: ${PWD}/conformance-tests + volumes: + - ${PWD}/conformance-tests:/conformance-tests