Skip to content

Commit

Permalink
Updated examples files to use new wait_time API
Browse files Browse the repository at this point in the history
  • Loading branch information
heyman committed Oct 24, 2019
1 parent af92687 commit 36d6341
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 17 deletions.
4 changes: 2 additions & 2 deletions examples/custom_wait_function.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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


Expand Down
5 changes: 2 additions & 3 deletions examples/custom_xmlrpc_client/xmlrpc_locustfile.py
Original file line number Diff line number Diff line change
@@ -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):
Expand Down Expand Up @@ -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)
Expand Down
5 changes: 2 additions & 3 deletions examples/dynamice_user_credentials.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# locustfile.py

from locust import HttpLocust, TaskSet, task
from locust import HttpLocust, TaskSet, task, between

USER_CREDENTIALS = [
("user1", "password"),
Expand All @@ -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)
5 changes: 2 additions & 3 deletions examples/events.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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


Expand Down
5 changes: 2 additions & 3 deletions examples/multiple_hosts.py
Original file line number Diff line number Diff line change
@@ -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):
Expand All @@ -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
5 changes: 2 additions & 3 deletions examples/semaphore_wait.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from locust import HttpLocust, TaskSet, task, events
from locust import HttpLocust, TaskSet, task, events, between

from gevent.lock import Semaphore

Expand All @@ -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

0 comments on commit 36d6341

Please sign in to comment.