Skip to content

Commit

Permalink
Load test
Browse files Browse the repository at this point in the history
  • Loading branch information
markalbrand56 committed Oct 2, 2023
1 parent 89f5d71 commit 01fbdae
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions backend/tests/load/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import requests
import concurrent.futures

# URL y JSON de solicitud
url = "https://whole-letisha-markalbrand56.koyeb.app/api/login"
payload = {
"usuario": "prueba@prueba",
"contra": "prueba"
}


# Función para enviar una solicitud HTTP
def send_request(url, payload):
try:
response = requests.post(url, json=payload)
if response.status_code == 200:
print("Solicitud exitosa")
else:
print(f"Fallo en la solicitud: {response.status_code}")
except Exception as e:
print(f"Error: {str(e)}")


# Número de hilos concurrentes
num_threads = 200 # Puedes ajustar este valor según tus necesidades

# Crear un ThreadPoolExecutor para enviar solicitudes concurrentes
with concurrent.futures.ThreadPoolExecutor(max_workers=num_threads) as executor:
futures = [executor.submit(send_request, url, payload) for _ in range(num_threads)]

# Esperar a que todas las solicitudes se completen
concurrent.futures.wait(futures)

0 comments on commit 01fbdae

Please sign in to comment.