forked from locustio/locust
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Prima Update locust base version to 0.8.1 (#70) * find locustfile in the root directory * Add ability to write out csv file data as part of command line run * Update minimum version of gevent to fix locustio#598 * CSV flag, review comments * Modify gevent wsgi and libev dependencies * Sort all python imports * Sort setup.py imports * Standardize utf8 file coding declarations * Bump version to 0.8a3 for another pre-release candidate * Changed from deprecated method name * Added test_suite argument to setup.py’s setup() method call Not specifying the test_suite argument (using the default one) resulted in all tests being run multiple times (on Python 3.5). I haven’t looked in to why, since specifying “locust.test” should be correct, and fixes it. * Suppress a warning that appears when running the tests on Python 3, that can cause tests (that depends on output to stderr) to fail. * Apply gevent monkey patching before we import requests, to avoid infinite recursion error when doing SSL requests. Should fix locustio#655. * Also patch threading when applying gevent monkey patch. Should fix locustio#569. * Bumped version to 0.8a4 * Improved changelog * Update main.py Code comment and slightly more descriptive variable name * More info about 0.8 to the Changelog * Added some random examples that maybe could be useful to someone * Bumped version to 0.8 * Upgrade pyzmq to latest stable version, and changed so that we do not pin the version (will make it easier to install Locust on Windows) * Better installation instructions for Windows * Bumped version to 0.8.1 * Erlangga Add team_configuration property (#72) * add get team configuration * change read json path * Rizal upload json file for team configuration (#68) * enabling json uploading * fix modal ui in upload json * enabling upload on json also * modify ui a bit and avoid duplicated message * unify the function * bug fix team configuration function (#88) * change team_configuration function * update configuration works
- Loading branch information
1 parent
90790b6
commit dba803f
Showing
40 changed files
with
584 additions
and
267 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,7 +15,7 @@ matrix: | |
addons: | ||
apt: | ||
packages: | ||
- libevent-dev | ||
- libev-dev | ||
install: | ||
- pip install tox | ||
script: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
from locust import HttpLocust, TaskSet, task | ||
|
||
|
||
def index(l): | ||
l.client.get("/") | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
# This locust test script example will simulate a user | ||
# browsing the Locust documentation on http://docs.locust.io | ||
|
||
import random | ||
from locust import HttpLocust, TaskSet, task | ||
from pyquery import PyQuery | ||
|
||
|
||
class BrowseDocumentation(TaskSet): | ||
def on_start(self): | ||
# assume all users arrive at the index page | ||
self.index_page() | ||
self.urls_on_current_page = self.toc_urls | ||
|
||
@task(10) | ||
def index_page(self): | ||
r = self.client.get("/") | ||
pq = PyQuery(r.content) | ||
link_elements = pq(".toctree-wrapper a.internal") | ||
self.toc_urls = [ | ||
l.attrib["href"] for l in link_elements | ||
] | ||
|
||
@task(50) | ||
def load_page(self, url=None): | ||
url = random.choice(self.toc_urls) | ||
r = self.client.get(url) | ||
pq = PyQuery(r.content) | ||
link_elements = pq("a.internal") | ||
self.urls_on_current_page = [ | ||
l.attrib["href"] for l in link_elements | ||
] | ||
|
||
@task(30) | ||
def load_sub_page(self): | ||
url = random.choice(self.urls_on_current_page) | ||
r = self.client.get(url) | ||
|
||
|
||
class AwesomeUser(HttpLocust): | ||
task_set = BrowseDocumentation | ||
host = "http://docs.locust.io/en/latest/" | ||
|
||
# we assume someone who is browsing the Locust docs, | ||
# generally has a quite long waiting time (between | ||
# 20 and 600 seconds), since there's a bunch of text | ||
# on each page | ||
min_wait = 20 * 1000 | ||
max_wait = 600 * 1000 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# locustfile.py | ||
|
||
from locust import HttpLocust, TaskSet, task | ||
|
||
USER_CREDENTIALS = [ | ||
("user1", "password"), | ||
("user2", "password"), | ||
("user3", "password"), | ||
] | ||
|
||
class UserBehaviour(TaskSet): | ||
def on_start(self): | ||
if len(USER_CREDENTIALS) > 0: | ||
user, passw = USER_CREDENTIALS.pop() | ||
self.client.post("/login", {"username":user, "password":passw}) | ||
|
||
@task | ||
def some_task(self): | ||
# user should be logged in here (unless the USER_CREDENTIALS ran out) | ||
self.client.get("/protected/resource") | ||
|
||
class User(HttpLocust): | ||
task_set = UserBehaviour | ||
min_wait = 5000 | ||
max_wait = 60000 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import os | ||
|
||
from locust import HttpLocust, TaskSet, task | ||
from locust.clients import HttpSession | ||
|
||
class MultipleHostsLocust(HttpLocust): | ||
abstract = True | ||
|
||
def __init__(self, *args, **kwargs): | ||
super(MultipleHostsLocust, self).__init__(*args, **kwargs) | ||
self.api_client = HttpSession(base_url=os.environ["API_HOST"]) | ||
|
||
|
||
class UserTasks(TaskSet): | ||
# but it might be convenient to use the @task decorator | ||
@task | ||
def index(self): | ||
self.locust.client.get("/") | ||
|
||
@task | ||
def index_other_host(self): | ||
self.locust.api_client.get("/stats/requests") | ||
|
||
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 | ||
task_set = UserTasks |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
from locust import HttpLocust, TaskSet, task, events | ||
|
||
from gevent.coros import Semaphore | ||
all_locusts_spawned = Semaphore() | ||
all_locusts_spawned.acquire() | ||
|
||
def on_hatch_complete(**kw): | ||
all_locusts_spawned.release() | ||
|
||
events.hatch_complete += on_hatch_complete | ||
|
||
class UserTasks(TaskSet): | ||
def on_start(self): | ||
all_locusts_spawned.wait() | ||
self.wait() | ||
|
||
@task | ||
def index(self): | ||
self.client.get("/") | ||
|
||
class WebsiteUser(HttpLocust): | ||
host = "http://127.0.0.1:8089" | ||
min_wait = 2000 | ||
max_wait = 5000 | ||
task_set = UserTasks |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
from .core import HttpLocust, Locust, TaskSet, task | ||
from .exception import InterruptTaskSet, ResponseError, RescheduleTaskImmediately | ||
|
||
__version__ = "0.8a2" | ||
__version__ = "0.8.1" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.