Commit f27e227e authored by Sebastian Miller's avatar Sebastian Miller
Browse files

different approach to running requests test

parent 6cf5ea65
......@@ -66,9 +66,8 @@ integration-tests:ensembler:
INFLUXDB_ADMIN_USER: admin
INFLUXDB_ADMIN_PASSWORD: admin1234
script:
# Install essential packages
- apk add --update --no-cache curl python3 py3-pip alpine-sdk
# Create appripriate databases in InfluxDB
- apk add --update --no-cache curl
# Create appropriate databases in InfluxDB
- 'curl --user admin:admin1234 -XPOST "http://influxdb:8086/query" --data-urlencode "q=CREATE DATABASE melodic_ui"'
- 'curl --user admin:admin1234 -XPOST "http://influxdb:8086/query" --data-urlencode "q=CREATE DATABASE morphemic"'
# Load the artifact image
......@@ -87,12 +86,13 @@ integration-tests:ensembler:
# Upload test data to InfluxDB
- ./fill_db.sh 'influxdb:8086' 'sample_data_separate_runs'
- cd $ENSEMBLER_DIR
# Install essential python packages
- pip3 install --no-cache-dir --upgrade pip setuptools wheel
- pip3 install --no-cache-dir poetry
- poetry install
# Build an image for running the requests test
- docker build -f ./tests/Dockerfile -t tests_image .
# Run the requests test
- ENSEMBLER_HOST_IP='127.0.0.1' poetry run pytest tests/test_requests.py
- docker run
--env ENSEMBLER_HOST_IP=$(docker inspect -f '{{range.NetworkSettings.Networks}}{{.IPAddress}}{{end}}' ensembler)
--env GITLAB_ACTIVEMQ_HOST_IP=$(getent hosts activemq | awk '{ print $1 }')
tests_image
- docker stop ensembler
# Push the built and tested image
......
FROM python:3.8-slim-buster
WORKDIR /testing
RUN apt-get update && \
pip install --no-cache-dir --upgrade \
pip \
pytest \
requests \
PyYAML \
stomp.py==7.0.0 \
python-dotenv==0.20.0
COPY tests tests
CMD pytest tests/test_requests.py
\ No newline at end of file
# Tests
NOTICE: Disregard the `Dockerfile` in this directory. It is used solely for running the
requests test in GitLab CI.
### Test descriptions
- `test_model_persistence.py`: model persistence unit tests
- `test_predictor.py`: unit tests of various utility methods crucial for the ensembler
......
......@@ -3,12 +3,11 @@ import requests
import pytest
import stomp
import os
import yaml
from time import sleep
from dotenv import dotenv_values
from ensembler_app.utils import parse
"""
Tests validating requests sent to the component, as well as training orders.
......@@ -26,7 +25,11 @@ TESTS_DIR = os.path.dirname(os.path.abspath(__file__))
CONFIG_DIR = os.path.join(TESTS_DIR, 'config')
server_config = dotenv_values(os.path.join(CONFIG_DIR, "server_params.env"))
properties = parse(os.path.join(CONFIG_DIR, 'properties.yml'))
properties = {}
with open(os.path.join(CONFIG_DIR, 'properties.yml'), "r") as stream:
properties = yaml.safe_load(stream)
GITLAB_ACTIVEMQ_HOST_IP = os.environ.get('GITLAB_ACTIVEMQ_HOST_IP')
RESPONSE_CODE = 200
NO_MODEL_CODE = properties["errors"]["no-adequate-model-code"] # 512
......@@ -56,8 +59,12 @@ class TestRequests:
max_forecast = 200
train_timeout = 60 # max time in seconds given for the NN to complete its training
metric = METRIC
conn = {}
conn = stomp.Connection([(HOST_IP, STOMP_PORT)])
if GITLAB_ACTIVEMQ_HOST_IP is None:
conn = stomp.Connection([(HOST_IP, STOMP_PORT)])
else:
conn = stomp.Connection([(GITLAB_ACTIVEMQ_HOST_IP, STOMP_PORT)])
conn.connect(USERNAME, PASSWORD, wait=True)
def create_json(self):
......
# Profile info:
# - local: for running the test environment locally - it builds the ensembler image
# - gitlab: for running the test environment in GitLab CI - it uses an existing ensembler image
version: '3.9'
services:
ensembler:
profiles:
- local
build: ../ensembler_flask
ports:
- 5000:5000
......@@ -16,18 +10,6 @@ services:
- ../ensembler_flask/tests/config/properties.yml:/ensembler/config/properties.yml
env_file:
- ../ensembler_flask/tests/config/server_params.env
ensembler_gitlab:
profiles:
- gitlab
image: ensembler
ports:
- 5000:5000
volumes:
- ../ensembler_flask/saved_models:/ensembler/saved_models
- ../ensembler_flask/logs:/ensembler/logs
- ../ensembler_flask/tests/config/properties.yml:/ensembler/config/properties.yml
env_file:
- ../ensembler_flask/tests/config/server_params.env
activemq:
image: rmohr/activemq:5.15.9
ports:
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment