-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
57 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import random | ||
import threading | ||
|
||
from locust import HttpUser, TaskSet, task | ||
|
||
|
||
class TokenTaskSet(TaskSet): | ||
received_tokens = set() | ||
token_lock = threading.Lock() | ||
hosts = ["http://localhost:8080", "http://localhost:8081"] | ||
|
||
@task | ||
def get_token(self): | ||
host = random.choice(self.hosts) | ||
with self.client.get(host + "/api/v1/token", catch_response=True) as response: | ||
if response.status_code == 200: | ||
token = response.text.strip() | ||
with self.token_lock: | ||
if token in self.received_tokens: | ||
response.failure(f"Duplicate token found: {token}") | ||
else: | ||
response.success() | ||
self.received_tokens.add(token) | ||
else: | ||
response.failure(f"Failed to get token from {host}, status code: {response.status_code}") | ||
|
||
|
||
class User(HttpUser): | ||
tasks = [TokenTaskSet] | ||
|
||
def on_start(self): | ||
self.host = None |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
blinker==1.8.2 | ||
Brotli==1.1.0 | ||
certifi==2024.2.2 | ||
charset-normalizer==3.3.2 | ||
click==8.1.7 | ||
ConfigArgParse==1.7 | ||
Flask==3.0.3 | ||
Flask-Cors==4.0.1 | ||
Flask-Login==0.6.3 | ||
gevent==24.2.1 | ||
geventhttpclient==2.2.1 | ||
greenlet==3.0.3 | ||
idna==3.7 | ||
itsdangerous==2.2.0 | ||
Jinja2==3.1.4 | ||
locust==2.27.0 | ||
MarkupSafe==2.1.5 | ||
msgpack==1.0.8 | ||
psutil==5.9.8 | ||
pyzmq==26.0.3 | ||
requests==2.31.0 | ||
urllib3==2.2.1 | ||
Werkzeug==3.0.3 | ||
zope.event==5.0 | ||
zope.interface==6.4 |