-
Notifications
You must be signed in to change notification settings - Fork 27
/
Copy pathjr.py
41 lines (36 loc) · 933 Bytes
/
jr.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
"""
JR Locust library
"""
import time
import subprocess
from locust import User
class JRUser(User):
"""
Superclass for JR users
"""
abstract = True
def __init__(self, environment):
"""
Init User
"""
super().__init__(environment)
self.env = environment
self.jr = "/usr/bin/jr"
def run_jr(self, args):
"""
Runs JR
"""
start_perf_counter = time.perf_counter()
exc = None
try:
subprocess.run([self.jr]+args, check=True)
except subprocess.CalledProcessError as e:
exc = e
self.env.events.request.fire(
request_type="jr",
name="jr",
response_time=(time.perf_counter() - start_perf_counter) * 1000,
response_length=0,
response=None,
context=None,
exception=exc)