melhorando testes

This commit is contained in:
José Henrique Ivanchechen 2023-09-24 12:56:02 -03:00
parent 2dbdbea018
commit 94c2296738
2 changed files with 24 additions and 11 deletions

View File

@ -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 = [ API_REQUESTS = [
('/status/ok', 'GET', range(0, 30_000, 5000), None), ('/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()), ('/image/save-big-image', 'POST', range(0, 10_000, 1_000), open('big-image.png', 'rb').read()),

View File

@ -6,19 +6,14 @@ import sys
import os import os
from math import floor from math import floor
from init import init from init import init
from common import API_REQUESTS from common import FRAMEWORKS, ENDPOINTS, 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 <framework name> [container name]")
sys.exit(1)
init() init()
THREADS = 10 THREADS = 10
FRAMEWORK_NAME = sys.argv[1] FRAMEWORK_NAME = ""
CONTAINER_NAME = sys.argv[2] if len(sys.argv) > 2 else "" CONTAINER_NAME = ""
URL_BASE = 'http://localhost:9090' URL_BASE = 'http://localhost:9090'
BLUR_RADIUS = 5
def send_request(url, method = 'GET', payload = None): def send_request(url, method = 'GET', payload = None):
success = False success = False
@ -135,6 +130,11 @@ if __name__ == "__main__":
if not os.path.exists("data"): if not os.path.exists("data"):
os.mkdir("data") os.mkdir("data")
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: for endpoint, method, num_requests, metadata in API_REQUESTS:
print(f"# {endpoint}") print(f"# {endpoint}")
run_tests(endpoint, method, num_requests, metadata) run_tests(endpoint, method, num_requests, metadata)