Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F28731967
raw.txt
No One
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Authored By
akosiaris
Apr 22 2019, 6:55 PM
2019-04-22 18:55:22 (UTC+0)
Size
1 KB
Referenced Files
None
Subscribers
None
raw.txt
View Options
from locust import HttpLocust, TaskSet, task
import string
import random
STRINGLENGTH = 32
BASE_URL = '/sessions/v1/'
class UserBehavior(TaskSet):
min_wait = 1000
max_wait = 5000
def on_start(self):
letters = string.ascii_lowercase
self.key = ''.join(random.choice(letters) for i in range(STRINGLENGTH))
self.key = BASE_URL + self.key
self.data = ''.join(random.choice(letters) for i in range(STRINGLENGTH))
@task(5)
def set(self):
self.client.post(
self.key,
data=self.data,
headers={'Content-Type': 'application/octet-stream'},
name='post',
)
@task(94)
def get(self):
with self.client.get(
self.key,
name='get',
catch_response=True) as response:
if response.status_code == 404:
response.success()
@task(1)
def delete(self):
self.client.delete(self.key, name='delete')
class HealthCheckBehavior(TaskSet):
min_wait = 10000
max_wait = 10000
@task
def healthz(self):
self.client.get('/healthz')
@task
def metrics(self):
self.client.get('/metrics')
class SessionUser(HttpLocust):
weight = 50
task_set = UserBehavior
class HealthCheckUser(HttpLocust):
weight = 1
task_set = HealthCheckBehavior
File Metadata
Details
Attached
Mime Type
text/plain; charset=utf-8
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
7334411
Default Alt Text
raw.txt (1 KB)
Attached To
Mode
P8425 locust_kask.py
Attached
Detach File
Event Timeline
Log In to Comment