From 94c22967383ddcebefb06cb90564ad922dd1cf50 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Henrique=20Ivanchechen?= Date: Sun, 24 Sep 2023 12:56:02 -0300 Subject: [PATCH] melhorando testes --- scripts/common.py | 13 +++++++++++++ scripts/testes.py | 22 +++++++++++----------- 2 files changed, 24 insertions(+), 11 deletions(-) diff --git a/scripts/common.py b/scripts/common.py index d116d1d..ba19864 100644 --- a/scripts/common.py +++ b/scripts/common.py @@ -1,3 +1,16 @@ +FRAMEWORKS = [ + ('Actix', 'tcc-actix'), + ('ASP.NET', 'tcc-aspnet'), + ('Flask', 'tcc-flask'), +] + +ENDPOINTS = { + 'Actix': 'http://localhost:9083', + 'ASP.NET': 'http://localhost:9081', + 'Flask': 'http://localhost:9082', +} + +BLUR_RADIUS = 5 API_REQUESTS = [ ('/status/ok', 'GET', range(0, 30_000, 5000), None), ('/image/save-big-image', 'POST', range(0, 10_000, 1_000), open('big-image.png', 'rb').read()), diff --git a/scripts/testes.py b/scripts/testes.py index af586c6..d601dc0 100644 --- a/scripts/testes.py +++ b/scripts/testes.py @@ -6,19 +6,14 @@ import sys import os from math import floor from init import init -from common import API_REQUESTS - -if len(sys.argv) < 2 or len(sys.argv) > 3 or sys.argv[1] == '-h' or sys.argv[1] == '--help': - print("Usage: python testes.py [container name]") - sys.exit(1) +from common import FRAMEWORKS, ENDPOINTS, API_REQUESTS init() THREADS = 10 -FRAMEWORK_NAME = sys.argv[1] -CONTAINER_NAME = sys.argv[2] if len(sys.argv) > 2 else "" +FRAMEWORK_NAME = "" +CONTAINER_NAME = "" URL_BASE = 'http://localhost:9090' -BLUR_RADIUS = 5 def send_request(url, method = 'GET', payload = None): success = False @@ -135,6 +130,11 @@ if __name__ == "__main__": if not os.path.exists("data"): os.mkdir("data") - for endpoint, method, num_requests, metadata in API_REQUESTS: - print(f"# {endpoint}") - run_tests(endpoint, method, num_requests, metadata) + for i in range(len(FRAMEWORKS)): + FRAMEWORK_NAME = FRAMEWORKS[i][0] + CONTAINER_NAME = FRAMEWORKS[i][1] + URL_BASE = ENDPOINTS[FRAMEWORK_NAME] + + for endpoint, method, num_requests, metadata in API_REQUESTS: + print(f"# {endpoint}") + run_tests(endpoint, method, num_requests, metadata)