Commit 92f19f60 authored by Sebastian Miller's avatar Sebastian Miller
Browse files

reworked CI; different requests test philosophy

parent 14a12bf0
......@@ -41,50 +41,56 @@ build:ensembler:
- cd $ENSEMBLER_DIR
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
- docker pull $CONTAINER_RELEASE_IMAGE || true # Attempt to pull previous image as a cache for the below build.
- docker build --cache-from $CONTAINER_RELEASE_IMAGE -t $CONTAINER_BASE_TAG:$CI_COMMIT_SHA .
- docker build --cache-from $CONTAINER_RELEASE_IMAGE -t ensembler .
- docker image ls
- docker push $CONTAINER_BASE_TAG:$CI_COMMIT_SHA # Push the new, not-yet-tested image.
#- docker push $CONTAINER_BASE_TAG:$CI_COMMIT_SHA # Push the new, not-yet-tested image.
- cd $CI_PROJECT_DIR
- docker save ensembler > image/ensembler.tar # Save the image as an artifact for furhter stages
artifacts:
paths:
- image
integration-tests:ensembler:
stage: integration-tests
#image: docker/compose:1.29.2
image: python:3.8-slim-buster
image: docker/compose:1.29.2
#image: python:3.8-slim-buster
only:
- integration
#services:
# - $DOCKER_DIND_SERVICE
services:
- name: rmohr/activemq:5.15.9
alias: activemq
- name: influxdb:1.8.4
alias: influxdb
variables:
INFLUXDB_ADMIN_USER: admin
INFLUXDB_ADMIN_PASSWORD: admin1234
entrypoint: ["/bin/bash", "-c", "cp /builds/melodic/zpp-assembler/integration/system-setup/influxdb/influx_init.iql \
/docker-entrypoint-initdb.d/influx_init.iql/"] # Volume mounting workaround
- name: $CONTAINER_BASE_TAG:$CI_COMMIT_SHA
alias: ensembler
variables:
PORT: 5000
entrypoint: ["/bin/bash", "-c", "cp -R /builds/melodic/zpp-assembler/integration/ensembler_flask/tests/config/* \
/ensembler/config/"] # Volume mounting workaround
- $DOCKER_DIND_SERVICE
#services:
# - name: rmohr/activemq:5.15.9
# alias: activemq
# - name: influxdb:1.8.4
# alias: influxdb
# variables:
# INFLUXDB_ADMIN_USER: admin
# INFLUXDB_ADMIN_PASSWORD: admin1234
# entrypoint: ["/bin/bash", "-c", "cp /builds/melodic/zpp-assembler/integration/system-setup/influxdb/influx_init.iql \
# /docker-entrypoint-initdb.d/influx_init.iql/"] # Volume mounting workaround
# - name: $CONTAINER_BASE_TAG:$CI_COMMIT_SHA
# alias: ensembler
# variables:
# PORT: 5000
# entrypoint: ["/bin/bash", "-c", "cp -R /builds/melodic/zpp-assembler/integration/ensembler_flask/tests/config/* \
# /ensembler/config/"] # Volume mounting workaround
script:
#- apt-get update -y
#- apt-get install -y python3.8
- cd $SYSTEM_SETUP_DIR/influxdb
- docker load -i image/ensembler.tar # Load the artifact image
- apt-get update -y
- apt-get install -y python3.8
- cd $SYSTEM_SETUP_DIR
#- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
#- docker pull $CONTAINER_BASE_TAG:$CI_COMMIT_SHA
#- # Set proper image name in docker-compose.yml
#- docker-compose up --detach
#- cd influxdb
- ./fill_db.sh 'influxdb' 'sample_data_separate_runs' # Upload test data to InfluxDB
- cd $CI_PROJECT_DIR
- cd $ENSEMBLER_DIR
- docker-compose --profile gitlab up -d # Run the test environment
- cd influxdb
- chmod u+x ./fill_db.sh
- ./fill_db.sh '127.0.0.1' 'sample_data_separate_runs' # Upload test data to InfluxDB
- cd $CI_PROJECT_DIR/$ENSEMBLER_DIR
- pip install --no-cache-dir --upgrade pip
- pip install --no-cache-dir poetry
- poetry install
- ENSEMBLER_HOST_IP='ensembler' poetry run pytest tests/test_requests.py
- ENSEMBLER_HOST_IP='127.0.0.1' poetry run pytest tests/test_requests.py # Run the test
- docker-compose stop # Stop the test environment
# Push the built and tested image
deploy:ensembler:
......@@ -96,7 +102,8 @@ deploy:ensembler:
- $DOCKER_DIND_SERVICE
script:
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
- docker pull $CONTAINER_TEST_IMAGE
#- docker pull $CONTAINER_TEST_IMAGE
- docker load -i image/ensembler.tar # Load the artifact image
#- echo "$K8S_SECRET_DOCKER_PASSWORD" | docker login $CI_REGISTRY -u $K8S_SECRET_DOCKER_USER --password-stdin
- docker tag $CONTAINER_TEST_IMAGE $CONTAINER_RELEASE_IMAGE
- docker tag ensembler $CONTAINER_RELEASE_IMAGE
- docker push $CONTAINER_RELEASE_IMAGE
......@@ -6,9 +6,9 @@
### How to run the environment
Run the following command in this directory:
```
docker-compose up
docker-compose --profile local up
```
Remember to configure the `../ensembler_flask/config/properties.yml` and `../ensembler_flask/config/flask_params.env` files properly, as well as set the port mapping in the `docker-compose.yml` file.
Remember to configure the `../ensembler_flask/tests/config/properties.yml` and `../ensembler_flask/tests/config/flask_params.env` files properly, as well as set the port mapping in the `docker-compose.yml` file.
### How to setup the environment (only after the first startup)
- Enter the `influxdb` directory.
......
# 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
......@@ -10,6 +16,18 @@ 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