forked from AlexanderChudnovets/magnetodb-test-bench
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Alexander Chudnovets
committed
Jul 11, 2014
1 parent
54adec7
commit 0a8d785
Showing
7 changed files
with
144 additions
and
93 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 |
---|---|---|
@@ -1,7 +1,9 @@ | ||
to run master: | ||
To run benchmark: | ||
|
||
locust -f magnetodb.py -H http://192.168.56.101:8480 --master -n 1000 | ||
sudo python benchmark_runner.py /path/to/benchmark_runner.cfg /path/to/locust_file.py | ||
|
||
to run slave: | ||
Example: | ||
sudo python benchmark_runner.py /home/alex/benchmark_runner.cfg /home/alex/locust/test_query.py | ||
|
||
locust -f magnetodb.py -H http://192.168.56.101:8480 --no-web --slave | ||
FIXME: | ||
locust should be installed as package. I used venv in this script. |
This file was deleted.
Oops, something went wrong.
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,16 @@ | ||
[global] | ||
base_dir=/home/alex | ||
result_dir_prefix=test | ||
|
||
[locust] | ||
host_to_test=http://192.168.56.101:8480 | ||
requests_count=1000 | ||
master_ip=192.168.56.102 | ||
master_port=5557 | ||
worker_ips=192.168.56.102,192.168.56.102 | ||
master_user=alex | ||
master_password=password | ||
|
||
[192.168.56.102] | ||
user=alex | ||
password=password |
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 was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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 +1,63 @@ | ||
import locust | ||
|
||
|
||
IS_FIRST_RUN = True | ||
SLAVE_COUNT = 2 | ||
LOCUST_COUNT = 100 | ||
HATCH_RATE = 10 | ||
|
||
QUERY_RQ = """ | ||
{ | ||
"key_conditions": { | ||
"ForumName": { | ||
"attribute_value_list": [ | ||
{ | ||
"S": "MagnetoDB" | ||
} | ||
], | ||
"comparison_operator": "EQ" | ||
} | ||
} | ||
} | ||
""" | ||
|
||
TOKEN = """ | ||
MIIIAQYJKoZIhvcNAQcCoIIH8jCCB+4CAQExCTAHBgUrDgMCGjCCBlcGCSqGSIb3DQEHAaCCBkgEggZEeyJ0b2tlbiI6IHsibWV0aG9kcyI6IFsicGFzc3dvcmQiXSwgInJvbGVzIjogW3siaWQiOiAiYWVlNzBhM2ZlY2QyNGViZGFiZGZiN2NlZjNjNGNjNTEiLCAibmFtZSI6ICJNZW1iZXIifV0sICJleHBpcmVzX2F0IjogIjIwMTQtMDctMThUMTg6Mjg6MjYuMDcxMzc0WiIsICJwcm9qZWN0IjogeyJkb21haW4iOiB7ImlkIjogIjE0MDI2OGUxZjgzMzRkYmU4ZDc2OTM3MjcxYWIxMWEyIiwgIm5hbWUiOiAiZG9tYWluMSJ9LCAiaWQiOiAiZTg1MmI1YmE1MDc0NDBmZDk5ZWVlNzU1OTNiM2EzNWYiLCAibmFtZSI6ICJwcm9qZWN0MSJ9LCAiY2F0YWxvZyI6IFt7ImVuZHBvaW50cyI6IFt7InVybCI6ICJodHRwOi8vMTkyLjE2OC41Ni4xMDE6ODQ4MC92MS9lODUyYjViYTUwNzQ0MGZkOTllZWU3NTU5M2IzYTM1ZiIsICJyZWdpb24iOiAiUmVnaW9uT25lIiwgImludGVyZmFjZSI6ICJhZG1pbiIsICJpZCI6ICIxODYxYTFkYjk5ZWQ0NzZlODg5YzE1Y2IzYmNmMjBhYyJ9LCB7InVybCI6ICJ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TdkZGQxZjg0ODQ2YjNmN2FkNzhmYjM4ZTI5YiJ9XSwgInR5cGUiOiAiaWRlbnRpdHkiLCAiaWQiOiAiZjlmOWY4NTEzMzkzNDllYWIxZGY4OGFkMTA4OTAzOWIiLCAibmFtZSI6ICJrZXlzdG9uZSJ9XSwgImV4dHJhcyI6IHt9LCAidXNlciI6IHsiZG9tYWluIjogeyJpZCI6ICIxNDAyNjhlMWY4MzM0ZGJlOGQ3NjkzNzI3MWFiMTFhMiIsICJuYW1lIjogImRvbWFpbjEifSwgImlkIjogImExMTMxMzA5Y2Y4MjRhMjY5MDIyNDExNmZlMjM2MjY1IiwgIm5hbWUiOiAidXNlcjEifSwgImlzc3VlZF9hdCI6ICIyMDE0LTA2LTE4VDE4OjI4OjI2LjA3MTQzMVoifX0xggGBMIIBfQIBATBcMFcxCzAJBgNVBAYTAlVTMQ4wDAYDVQQIDAVVbnNldDEOMAwGA1UEBwwFVW5zZXQxDjAMBgNVBAoMBVVuc2V0MRgwFgYDVQQDDA93d3cuZXhhbXBsZS5jb20CAQEwBwYFKw4DAhowDQYJKoZIhvcNAQEBBQAEggEAhzdBEX+wTCNO0IXVtOkVoDjuk-TGZbq17s12WxczFg8pUIIwa+5jaXeIw9s6cfacP5tSs+7rghZz+ClXEsI8SIVrLroPJsp5uQMQmmHYKZhLbBnUL2xnhibaD8zTlzCn7ExXnP0lBQ5zMS78Z1tGwodj29DQfLGxsbzwYlk4yrdLT-vcRWpclpiQDCwV8ABBT4ME4jv7qWYSS229DNHAYui2Aponbln8Pe785XYOC01VipLW-BOAyZik1zdeVfuU2IIZjylLCgVibAY1-bnfFT6J0acGmeol+vbT1F+T1yPHLfHPmUUcx0dyJ8vcDktlM0CaJpPqNWGFQvxUtGOY6Q== | ||
""" | ||
|
||
|
||
class UserBehavior(locust.TaskSet): | ||
@locust.task | ||
def query(self): | ||
req_url = ('/v1/e852b5ba507440fd99eee75593b3a35f' | ||
'/data/tables/Thread/query') | ||
req_headers = { | ||
'Content-Type': 'application/json', | ||
'Accept': 'application/json', | ||
'X-Auth-Token': TOKEN.strip() | ||
} | ||
self.client.post(req_url, QUERY_RQ.strip(), headers=req_headers) | ||
|
||
|
||
class MagnetoDBUser(locust.HttpLocust): | ||
task_set = UserBehavior | ||
min_wait = 5000 | ||
max_wait = 9000 | ||
|
||
|
||
# Master code | ||
def on_slave_report(client_id, data): | ||
global IS_FIRST_RUN | ||
runner = locust.runners.locust_runner | ||
|
||
if IS_FIRST_RUN and runner.slave_count == SLAVE_COUNT: | ||
runner.start_hatching(LOCUST_COUNT, HATCH_RATE) | ||
IS_FIRST_RUN = False | ||
|
||
num_rq = sum([val.num_requests for val in | ||
runner.request_stats.itervalues()]) | ||
if runner.num_requests and num_rq >= runner.num_requests: | ||
raise KeyboardInterrupt() | ||
|
||
|
||
locust.events.slave_report += on_slave_report |