-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
loadtest.py
executable file
·52 lines (38 loc) · 1.15 KB
/
loadtest.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
import json
import os
import uuid
from ailoads.fmwk import scenario, requests
URL_SERVER = os.getenv('URL_KINTO_SERVER',
"https://kinto.stage.mozaws.net/v1")
TIMEOUT = 30
_CONNECTIONS = {}
def get_connection(id=None):
if id is None or id not in _CONNECTIONS:
id = uuid.uuid4().hex
conn = KintoConnection(id)
_CONNECTIONS[id] = conn
return _CONNECTIONS[id]
class KintoConnection(object):
def __init__(self, id):
self.id = id
self.timeout = TIMEOUT
def post(self, endpoint, data):
return requests.post(
URL_SERVER + endpoint,
data=json.dumps(data),
timeout=self.timeout)
def get(self, endpoint):
return requests.get(
URL_SERVER + endpoint,
timeout=self.timeout)
def delete(self, endpoint):
return requests.delete(
URL_SERVER + endpoint,
timeout=self.timeout)
@scenario(1)
def demo_test():
conn = get_connection('demo_connection')
resp = conn.get('/')
# body = resp.json()
# assert "data" in body, "data not found in body"
resp.raise_for_status()