From d79ec7e065e36509abb208c3d1a1f58ca7ef6dde Mon Sep 17 00:00:00 2001 From: Onur Ates Date: Wed, 22 Jun 2022 15:19:15 +0200 Subject: [PATCH 1/3] added script for load testing --- loadtesting.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 loadtesting.py diff --git a/loadtesting.py b/loadtesting.py new file mode 100644 index 0000000..21f746a --- /dev/null +++ b/loadtesting.py @@ -0,0 +1,15 @@ +from molotov import scenario + +# requirement: pip install molotov +# for autosizing run: molotov --sizing loadtesting.py + +# _API = "https://neo-viewer-dev.brainsimulation.eu/blockdata/?url=https://gin.g-node.org/NeuralEnsemble/ephy_testing_data/raw/master/axon/File_axon_1.abf" +# _API = "http://127.0.0.1:8000/blockdata/?url=https://gin.g-node.org/NeuralEnsemble/ephy_testing_data/raw/master/axon/File_axon_1.abf" + +_API = "http://127.0.0.1:8000/api/blockdata/?url=https://gin.g-node.org/NeuralEnsemble/ephy_testing_data/raw/master/brainwaresrc/block_300ms_4rep_1clust_part_ch1.src" +# _API = "https://neo-viewer.brainsimulation.eu/api/blockdata/?url=https://gin.g-node.org/NeuralEnsemble/ephy_testing_data/raw/master/brainwaresrc/block_300ms_4rep_1clust_part_ch1.src" + +@scenario(weight=100) +async def _test(session): + async with session.get(_API) as resp: + assert resp.status == 200, resp.status From b908e92a8c71a27cf2a901c440720c97a0ec3b63 Mon Sep 17 00:00:00 2001 From: Onur Ates Date: Wed, 29 Jun 2022 16:25:15 +0200 Subject: [PATCH 2/3] add closing of neo files and default throttling policy --- api/neoview/views.py | 7 ++++++- api/neural_activity_app/settings.py | 11 +++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/api/neoview/views.py b/api/neoview/views.py index d4f79fd..9527567 100644 --- a/api/neoview/views.py +++ b/api/neoview/views.py @@ -95,6 +95,8 @@ def get_block(request): lazy = False na_file = _get_file_from_url(request) + neo_io = None + r = None if 'type' in request.GET and request.GET.get('type'): iotype = request.GET.get('type') @@ -120,7 +122,10 @@ def get_block(request): raise NeoViewError('incorrect file type', status.HTTP_415_UNSUPPORTED_MEDIA_TYPE, str(err)) - + if neo_io and hasattr(neo_io, 'close'): + neo_io.close() + if r and hasattr(r, 'close'): + r.close() return block, na_file, lazy diff --git a/api/neural_activity_app/settings.py b/api/neural_activity_app/settings.py index 15e6deb..bb6c072 100644 --- a/api/neural_activity_app/settings.py +++ b/api/neural_activity_app/settings.py @@ -164,3 +164,14 @@ } DOWNLOADED_FILE_CACHE_DIR = os.path.join(BASE_DIR, "download_cache") + +REST_FRAMEWORK = { + 'DEFAULT_THROTTLE_CLASSES': [ + 'rest_framework.throttling.AnonRateThrottle', + 'rest_framework.throttling.UserRateThrottle' + ], + 'DEFAULT_THROTTLE_RATES': { + 'anon': '100/minute', + 'user': '100/minute' + } +} From d33870398973d7fe37606cca5c1c255f1f0ba5b2 Mon Sep 17 00:00:00 2001 From: Onur Ates Date: Thu, 22 Dec 2022 12:00:54 +0100 Subject: [PATCH 3/3] removed check for neo close functions --- api/neoview/views.py | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/api/neoview/views.py b/api/neoview/views.py index 9527567..d4f79fd 100644 --- a/api/neoview/views.py +++ b/api/neoview/views.py @@ -95,8 +95,6 @@ def get_block(request): lazy = False na_file = _get_file_from_url(request) - neo_io = None - r = None if 'type' in request.GET and request.GET.get('type'): iotype = request.GET.get('type') @@ -122,10 +120,7 @@ def get_block(request): raise NeoViewError('incorrect file type', status.HTTP_415_UNSUPPORTED_MEDIA_TYPE, str(err)) - if neo_io and hasattr(neo_io, 'close'): - neo_io.close() - if r and hasattr(r, 'close'): - r.close() + return block, na_file, lazy