Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a database and test users for advanced testing #7

Open
nhoening opened this issue Oct 25, 2021 · 1 comment
Open

Add a database and test users for advanced testing #7

nhoening opened this issue Oct 25, 2021 · 1 comment
Labels

Comments

@nhoening
Copy link
Contributor

No description provided.

@nhoening nhoening added the tests label Oct 25, 2021
@victorgarcia98
Copy link
Contributor

Taking some bites from the FM core docker-compose.yaml, I suggest we add this file to the plugin template:

version: "3.4"

services:
  server:
    build:
      context: .
      dockerfile: Dockerfile
    ports:
      - 5000:5000
    depends_on:
      - test-db  # use -e SQLALCHEMY_TEST_DATABASE_URI=... to exec pytest
    restart: on-failure
    healthcheck:
      test: ["CMD", "curl", "-f", "http://localhost:5000/api/v3_0/health/ready"]
      start_period: 10s
      interval: 20s
      timeout: 10s
      retries: 6
    environment:
      SQLALCHEMY_DATABASE_URI: "postgresql://fm-test-db-user:fm-test-db-pass@test-db:5432/fm-test-db"
      SECRET_KEY: notsecret
      FLASK_ENV: development
      LOGGING_LEVEL: INFO 
      FLEXMEASURES_PLUGINS: /app/{{cookiecutter.plugin_name}}
    entrypoint: ["/bin/sh", "-c"]
    command:
    - |
      pip install -r instance/requirements.txt
      flexmeasures db upgrade
      flexmeasures add toy-account --name 'Docker Toy Account'
      gunicorn --bind 0.0.0.0:5000 --worker-tmp-dir /dev/shm --workers 1 --threads 4 wsgi:application
  test-db: #  sudo docker compose down --volumes
    image: postgres
    expose:
      - 5432
    restart: always
    environment:
      POSTGRES_DB: fm-test-db
      POSTGRES_USER: fm-test-db-user
      POSTGRES_PASSWORD: fm-test-db-pass
    volumes:
      - ./ci/load-psql-extensions.sql:/docker-entrypoint-initdb.d/load-psql-extensions.sql

For this to work, we would need to add the file load-psql-extensions.sql with the instructions to install the extensions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants