From cc1d379c7140e95b7eb7bbdd013f0efe3fb68b61 Mon Sep 17 00:00:00 2001 From: Jonatan Heyman Date: Thu, 24 Oct 2019 15:01:40 +0200 Subject: [PATCH] Updated examples files to use new wait_time API --- examples/custom_wait_function.py | 4 ++-- examples/custom_xmlrpc_client/xmlrpc_locustfile.py | 5 ++--- examples/dynamice_user_credentials.py | 5 ++--- examples/events.py | 5 ++--- examples/multiple_hosts.py | 5 ++--- examples/semaphore_wait.py | 5 ++--- 6 files changed, 12 insertions(+), 17 deletions(-) diff --git a/examples/custom_wait_function.py b/examples/custom_wait_function.py index fad47c3174..9bbc8105dc 100644 --- a/examples/custom_wait_function.py +++ b/examples/custom_wait_function.py @@ -23,7 +23,7 @@ class WebsiteUser(HttpLocust): host = "http://127.0.0.1:8089" # Most task inter-arrival times approximate to exponential distributions # We will model this wait time as exponentially distributed with a mean of 1 second - wait_function = lambda self: random.expovariate(1)*1000 # *1000 to convert to milliseconds + wait_time = lambda self: random.expovariate(1) task_set = UserTasks def strictExp(min_wait,max_wait,mu=1): @@ -43,7 +43,7 @@ class StrictWebsiteUser(HttpLocust): Locust user class that makes exponential requests but strictly between two bounds. """ host = "http://127.0.0.1:8089" - wait_function = lambda self: strictExp(self.min_wait, self.max_wait)*1000 + wait_time = lambda self: strictExp(3, 7) task_set = UserTasks diff --git a/examples/custom_xmlrpc_client/xmlrpc_locustfile.py b/examples/custom_xmlrpc_client/xmlrpc_locustfile.py index f117acd779..c7dfca01b8 100644 --- a/examples/custom_xmlrpc_client/xmlrpc_locustfile.py +++ b/examples/custom_xmlrpc_client/xmlrpc_locustfile.py @@ -1,7 +1,7 @@ import time import xmlrpclib -from locust import Locust, TaskSet, events, task +from locust import Locust, TaskSet, events, task, between class XmlRpcClient(xmlrpclib.ServerProxy): @@ -41,8 +41,7 @@ def __init__(self, *args, **kwargs): class ApiUser(XmlRpcLocust): host = "http://127.0.0.1:8877/" - min_wait = 100 - max_wait = 1000 + wait_time = between(0.1, 1) class task_set(TaskSet): @task(10) diff --git a/examples/dynamice_user_credentials.py b/examples/dynamice_user_credentials.py index 6f8f66baa5..21029e12e4 100644 --- a/examples/dynamice_user_credentials.py +++ b/examples/dynamice_user_credentials.py @@ -1,6 +1,6 @@ # locustfile.py -from locust import HttpLocust, TaskSet, task +from locust import HttpLocust, TaskSet, task, between USER_CREDENTIALS = [ ("user1", "password"), @@ -21,5 +21,4 @@ def some_task(self): class User(HttpLocust): task_set = UserBehaviour - min_wait = 5000 - max_wait = 60000 + wait_time = between(5, 60) diff --git a/examples/events.py b/examples/events.py index 7b1de7fafe..fca5c11673 100644 --- a/examples/events.py +++ b/examples/events.py @@ -5,7 +5,7 @@ track the sum of the content-length header in all successful HTTP responses """ -from locust import HttpLocust, TaskSet, events, task, web +from locust import HttpLocust, TaskSet, events, task, web, between class MyTaskSet(TaskSet): @@ -19,8 +19,7 @@ def stats(l): class WebsiteUser(HttpLocust): host = "http://127.0.0.1:8089" - min_wait = 2000 - max_wait = 5000 + between(2, 5) task_set = MyTaskSet diff --git a/examples/multiple_hosts.py b/examples/multiple_hosts.py index b30585b37c..4101611c75 100644 --- a/examples/multiple_hosts.py +++ b/examples/multiple_hosts.py @@ -1,6 +1,6 @@ import os -from locust import HttpLocust, TaskSet, task +from locust import HttpLocust, TaskSet, task, between from locust.clients import HttpSession class MultipleHostsLocust(HttpLocust): @@ -26,6 +26,5 @@ class WebsiteUser(MultipleHostsLocust): Locust user class that does requests to the locust web server running on localhost """ host = "http://127.0.0.1:8089" - min_wait = 2000 - max_wait = 5000 + wait_time = between(2, 5) task_set = UserTasks diff --git a/examples/semaphore_wait.py b/examples/semaphore_wait.py index 8665b9d851..24df036196 100644 --- a/examples/semaphore_wait.py +++ b/examples/semaphore_wait.py @@ -1,4 +1,4 @@ -from locust import HttpLocust, TaskSet, task, events +from locust import HttpLocust, TaskSet, task, events, between from gevent.lock import Semaphore @@ -21,6 +21,5 @@ def index(self): class WebsiteUser(HttpLocust): host = "http://127.0.0.1:8089" - min_wait = 2000 - max_wait = 5000 + wait_time = between(2, 5) task_set = UserTasks