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

Develop #35

Merged
merged 3 commits into from
Nov 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ docker-compose pull

### Install python dependencies
docker-compose run --rm --no-deps web pip install --upgrade pip
docker-compose run --rm --no-deps web pip3 install --no-cache-dir -r requirements.txt
docker-compose run --rm --no-deps web pip3 install --no-cache-dir -r requirements_dev.txt

### Install nodejs dependencies
docker-compose run --rm --no-deps api npm install --prefer-online
Expand Down
13 changes: 12 additions & 1 deletion app/database.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
from app.utils import configParser
from app.logger import log
from sqlalchemy import create_engine
from sqlmodel import Session
from sqlalchemy.exc import OperationalError
from sqlalchemy.pool import NullPool


class Database:
logger = log.get_logger("database")

def __init__(self):

config_file = 'config.global.py'
Expand All @@ -27,8 +31,15 @@ def check_database_connection(self):
return False

def get_session(self):
with Session(self.engine) as session:
session = Session(self.engine)
try:
yield session
except Exception:
self.logger.exception("Session rollback because of exception")
session.rollback()
raise
finally:
session.close()

def create_session(self):
return Session(self.engine)
Expand Down
17 changes: 17 additions & 0 deletions app/tests/locust.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
from locust import HttpUser, task, between


class WebsiteUser(HttpUser):
# wait_time can be overridden for individual TaskSets
wait_time = between(10, 300)

# Host for locust interface: https://metrics-dev.rciam.grnet.gr
@task
def metrics_egi_devel_tenenv(self):
headers = {
'accept': 'application/json',
'x-tenant': 'egi',
'x-environment': 'devel'
}

self.client.get("/api/v1/tenenv/egi/devel", headers=headers)
11 changes: 11 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,17 @@ services:
# - ./javascript/node_modules
tty: true

locust:
image: metricsrciam:latest
container_name: metrics.rciam.locust
command: locust -f app/tests/locust.py
ports:
- "8089:8089"
- "3100:3100"
volumes:
- .:/app
tty: true

volumes:
pgdata:

Expand Down
28 changes: 28 additions & 0 deletions requirements_dev.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
alembic==1.10.2
asgiref==3.5.2
asyncpg==0.28.0
click==8.1.3
fastapi==0.100.0
geoip2
h11==0.13.0
importlib-resources==5.7.1
Mako==1.2.0
MarkupSafe==2.1.1
psycopg2-binary==2.9.7
pydantic==1.10.7
PyGreSQL==5.2.5
SQLAlchemy==1.4.41
sqlalchemy2-stubs==0.0.2a32
sqlmodel==0.0.8
typer==0.4.1
typing_extensions==4.5.0
uvicorn==0.21.1
zipp==3.8.0
cachetools==5.3.0
Authlib==1.2.0
itsdangerous==2.1.2
httpx==0.23.3
pyjwt==2.7.0
geoip2==4.7.0
gunicorn==21.2.0
locust==2.17.0
Loading