Skip to content

Commit

Permalink
cleanup tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mmacata committed Dec 11, 2023
1 parent d3d5d9c commit 767c7d5
Show file tree
Hide file tree
Showing 12 changed files with 47 additions and 307 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,15 @@ released from main
...

## [4.12.0](https://github.com/actinia-org/actinia-core/releases/tag/4.12.0) - 2023-11-21

released from main

### Added

- Checking pixellimit for r.import commands by @linakrisztian in https://github.com/actinia-org/actinia-core/pull/491

### Changed

- chore(deps): update mundialis/actinia-core docker tag to v4.11.0 by @renovate in https://github.com/actinia-org/actinia-core/pull/492

**Full Changelog**: https://github.com/actinia-org/actinia-core/compare/4.11.0...4.12.0
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ devtest:
sh ./tests_with_redis.sh dev

noauthtest:
sh ./tests_with_redis.sh noauth
sh ./tests_with_redis.sh noauth

integrationtest:
sh ./tests_with_redis.sh integrationtest
56 changes: 21 additions & 35 deletions docker/actinia-core-alpine/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,58 +1,47 @@
FROM mundialis/actinia:alpine-dependencies-2023-10-12 as build-base
FROM mundialis/actinia:alpine-dependencies-2023-12-06 as build-base
FROM osgeo/grass-gis:releasebranch_8_3-alpine as grass

FROM build-base as build
FROM build-base as requirements

LABEL authors="Carmen Tawalika,Anika Bettge,Markus Neteler,Sören Gebbert"
LABEL authors="Carmen Tawalika,Anika Weinmann,Markus Neteler,Sören Gebbert"
LABEL maintainer="[email protected],[email protected],[email protected]"

COPY . /src/actinia_core
WORKDIR /src/actinia_core
RUN pip3 install build && python3 -m build --outdir /build .
RUN if [[ -f /build/UNKNOWN* ]];then echo "ERROR - Check actinia-core build";exit 1;fi


FROM mundialis/actinia:alpine-dependencies-2023-06-03 as actinia_installation

ENV LC_ALL "en_US.UTF-8"
ENV GDAL_CACHEMAX=2000
ENV GRASS_COMPRESSOR=ZSTD
ENV GRASS_SKIP_MAPSET_OWNER_CHECK 1
ENV GISBASE ""
ENV ACTINIA_API_VERSION 3.4.0

USER root

# GRASS GIS SETUP
COPY --from=grass /usr/local/bin/grass /usr/local/bin/grass
COPY --from=grass /usr/local/grass* /usr/local/grass/
RUN pip3 install --upgrade pip six grass-session --ignore-installed six
RUN pip install --upgrade pip six grass-session --ignore-installed six
RUN ln -s /usr/local/grass `grass --config path`
RUN grass --tmp-location EPSG:4326 --exec g.version -rge && \
pdal --version && \
python3 --version
python --version

# install GRASS GIS addon d.rast.multi, because it is needed for STRDS render
# endpoint
# Install GRASS GIS addon d.rast.multi (needed for STRDS render endpoint)
RUN grass --tmp-location EPSG:4326 --exec g.extension -s \
extension=d.rast.multi url=https://github.com/mundialis/d_rast_multi
extension=d.rast.multi url=https://github.com/mundialis/d_rast_multi

# actinia-core and actinia libs BUILD
WORKDIR /build
ARG WHEEL_NAME=actinia_api-${ACTINIA_API_VERSION}-py3-none-any.whl
RUN curl -L --output /build/${WHEEL_NAME} \
https://github.com/actinia-org/actinia-api/releases/download/${ACTINIA_API_VERSION}/${WHEEL_NAME}

# Install actinia-core and libs
COPY --from=build /build/*.whl /build/
RUN pip3 install /build/*
FROM build-base as build

# Duplicate install actinia_core requirements. They are already included
# in alpine-build / alpine-runtime images, but check for updates here.
COPY requirements.txt /src/requirements.txt
RUN pip3 install -r /src/requirements.txt
COPY . /src/actinia_core
WORKDIR /src/actinia_core
RUN pip install build && python -m build --outdir /build .
RUN if [[ -f /build/UNKNOWN* ]];then echo "ERROR - Check actinia-core build";exit 1;fi


FROM requirements as actinia

# Copy actinia config file and start scripts + set needed envs
# actinia-core and requirements installation
WORKDIR /build
COPY --from=build /build/*.whl /build/
RUN pip install /build/*

# Copy actinia config file and start script
COPY docker/actinia-core-alpine/actinia.cfg /etc/default/actinia
COPY docker/actinia-core-alpine/start.sh /src/start.sh

Expand All @@ -66,9 +55,6 @@ RUN mkdir -p /actinia_core/grassdb && \
mkdir -p /actinia_core/userdata && \
ln -s /actinia_core /root/actinia


FROM actinia_installation as actinia

VOLUME /grassdb
WORKDIR /src/actinia_core

Expand Down
35 changes: 12 additions & 23 deletions docker/actinia-core-tests/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,9 @@ FROM mundialis/actinia-core:latest as actinia_test
LABEL authors="Carmen Tawalika,Anika Weinmann"
LABEL maintainer="[email protected],[email protected]"

ENV ACTINIA_API_VERSION 3.4.0

ENV SETUPTOOLS_SCM_PRETEND_VERSION=0.0.0
ENV ACTINIA_CUSTOM_TEST_CFG /etc/default/actinia_test
# TODO do not set DEFAULT_CONFIG_PATH if this is fixed
ENV DEFAULT_CONFIG_PATH /etc/default/actinia_test
ENV GRASS_DATABASE=/tmp/actinia_core/grassdb

# install things only for tests
RUN apk add redis
RUN pip3 install iniconfig colorlog

# uninstall actinia core from FROM-image
RUN pip3 uninstall actinia-core -y
# Path must be equal to actinia config "GRASS_DATABASE"
ARG GRASS_DATABASE=/tmp/actinia_core/grassdb

# add data for tests
WORKDIR ${GRASS_DATABASE}
Expand All @@ -31,6 +20,16 @@ RUN wget --quiet https://grass.osgeo.org/sampledata/north_carolina/nc_spm_mapset
mv modis_lst nc_spm_08/modis_lst
RUN chown -R 1001:1001 nc_spm_08/modis_lst && chmod -R g+w nc_spm_08/modis_lst

# install GRASS addons required for tests
RUN grass --tmp-location EPSG:4326 --exec g.extension -s extension=r.colors.out_sld

# install things only for tests
RUN apk add redis
RUN pip install pytest pytest-cov iniconfig

# uninstall actinia core from FROM-image
RUN pip uninstall actinia-core -y

RUN rmdir /actinia_core/grassdb
RUN rmdir /actinia_core/userdata
RUN rmdir /actinia_core/resources
Expand All @@ -41,21 +40,11 @@ RUN rmdir /actinia_core/workspace/tmp
RUN rmdir /actinia_core/workspace
RUN rmdir /actinia_core

# install actinia-api
RUN pip3 install actinia-api@https://github.com/actinia-org/actinia-api/releases/download/${ACTINIA_API_VERSION}/actinia_api-${ACTINIA_API_VERSION}-py3-none-any.whl

# install GRASS addons required for tests
RUN grass --tmp-location EPSG:4326 --exec g.extension -s extension=r.colors.out_sld
RUN grass --tmp-location EPSG:4326 --exec g.extension -s \
extension=d.rast.multi url=https://github.com/mundialis/d_rast_multi

# copy needed files and configs for test
COPY docker/actinia-core-alpine/actinia.cfg /etc/default/actinia
COPY docker/actinia-core-tests/actinia-test.cfg /etc/default/actinia_test
COPY docker/actinia-core-tests/actinia-test-noauth.cfg /etc/default/actinia_test_noauth

RUN pip3 install pytest pytest-cov

# TODO: Postgres for tests
# using tests/data/poly.gpkg

Expand Down
44 changes: 0 additions & 44 deletions src/actinia_core/core/redis.conf

This file was deleted.

30 changes: 0 additions & 30 deletions src/actinia_core/testsuite.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,6 @@ class ActiniaTestCaseBase(unittest.TestCase):
"""Base class for GRASS GIS REST API tests"""

server_test = False
custom_actinia_cfg = False
guest = None
user = None
admin = None
Expand All @@ -141,37 +140,8 @@ class ActiniaTestCaseBase(unittest.TestCase):
if "ACTINIA_SERVER_TEST" in os.environ:
server_test = bool(os.environ["ACTINIA_SERVER_TEST"])

if "ACTINIA_CUSTOM_TEST_CFG" in os.environ:
custom_actinia_cfg = str(os.environ["ACTINIA_CUSTOM_TEST_CFG"])

@classmethod
def setUpClass(cls):
if cls.server_test is False and cls.custom_actinia_cfg is False:
global_config.REDIS_SERVER_SERVER = "localhost"
global_config.REDIS_SERVER_PORT = 7000
global_config.GRASS_RESOURCE_DIR = "/tmp"
global_config.DOWNLOAD_CACHE = "/tmp/download_cache"
global_config.REDIS_QUEUE_SERVER_URL = "localhost"
global_config.REDIS_QUEUE_SERVER_PORT = 6379
global_config.NUMBER_OF_WORKERS = 3
# Create the job queue
# redis_interface.create_job_queues(
# global_config.REDIS_QUEUE_SERVER_URL,
# global_config.REDIS_QUEUE_SERVER_PORT,
# global_config.NUMBER_OF_WORKERS)

# If the custom_actinia_cfg variable is set, then the actinia config
# file will be read to configure Redis queue
if cls.server_test is False and cls.custom_actinia_cfg is not False:
global_config.read(cls.custom_actinia_cfg)

# # Create the job queue
# redis_interface.create_job_queues(
# global_config.REDIS_QUEUE_SERVER_URL,
# global_config.REDIS_QUEUE_SERVER_PORT,
# global_config.NUMBER_OF_WORKERS
# )

# create configured folders
os.makedirs(global_config.GRASS_USER_DATABASE, exist_ok=True)
os.makedirs(global_config.GRASS_TMP_DATABASE, exist_ok=True)
Expand Down
4 changes: 2 additions & 2 deletions tests/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ Redis authorization is set by `from actinia_core.core.common import redis_interf
from actinia_core.core.common import redis_interface # PROBLEM!!!!
from actinia_core.core.common.config import global_config
custom_actinia_cfg = str(os.environ["ACTINIA_CUSTOM_TEST_CFG"])
custom_actinia_cfg = str(os.environ["DEFAULT_CONFIG_PATH"])
global_config.read(custom_actinia_cfg)
global_config.REDIS_SERVER_PW
```
Expand All @@ -66,7 +66,7 @@ Redis authorization is set by `from actinia_core.core.common import redis_interf
import os
from actinia_core.core.common.config import global_config
custom_actinia_cfg = str(os.environ["ACTINIA_CUSTOM_TEST_CFG"])
custom_actinia_cfg = str(os.environ["DEFAULT_CONFIG_PATH"])
global_config.read(custom_actinia_cfg)
global_config.REDIS_SERVER_PW
```
Expand Down
Loading

0 comments on commit 767c7d5

Please sign in to comment.