From f0637215de4d788f087fc39e609abd18dc806394 Mon Sep 17 00:00:00 2001 From: Rostyslav Zatserkovnyi Date: Tue, 24 Oct 2023 17:13:51 +0300 Subject: [PATCH] Add option to modify rate limiting for perftests --- .github/workflows/performance-tests.yml | 2 +- dev/local/Makefile | 11 ++++++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/.github/workflows/performance-tests.yml b/.github/workflows/performance-tests.yml index 11d085337..ec30856d0 100644 --- a/.github/workflows/performance-tests.yml +++ b/.github/workflows/performance-tests.yml @@ -63,7 +63,7 @@ jobs: - name: Build & run epidata run: | cd ../driver - sudo make web sql="${{ secrets.DB_CONN_STRING }}" + sudo make web sql="${{ secrets.DB_CONN_STRING }}" rate_limit="999999/second" sudo make redis - name: Check out delphi-admin uses: actions/checkout@v3 diff --git a/dev/local/Makefile b/dev/local/Makefile index fb02668ee..84c308257 100644 --- a/dev/local/Makefile +++ b/dev/local/Makefile @@ -37,6 +37,7 @@ # test= Only runs tests in the directories provided here, e.g. # repos/delphi/delphi-epidata/tests/acquisition/covidcast # sql= Overrides the default SQL connection string. +# rate_limit= Overrides the default rate limit for API requests. # Set optional argument defaults @@ -56,6 +57,14 @@ else sqlalchemy_uri:=mysql+mysqldb://user:pass@delphi_database_epidata:3306/epidata endif +ifdef rate_limit +# Notation found here: https://flask-limiter.readthedocs.io/en/stable/#rate-limit-string-notation + rate_limit_settings:=--env "RATE_LIMIT=$(rate_limit)" +else +# Default behavior is to set the rate limit to "5/hour" for API key tests via this environment variable + rate_limit_settings:=--env "TESTING_MODE=True" +endif + SHELL:=/bin/sh # Get the Makefile's absolute path: https://stackoverflow.com/a/324782/4784655 @@ -104,7 +113,7 @@ web: --env "REDIS_PASSWORD=1234" \ --env "API_KEY_ADMIN_PASSWORD=test_admin_password" \ --env "API_KEY_REGISTER_WEBHOOK_TOKEN=abc" \ - --env "TESTING_MODE=True" \ + $(rate_limit_settings) \ --network delphi-net --name delphi_web_epidata \ delphi_web_epidata >$(LOG_WEB) 2>&1 &