Created
September 8, 2015 06:03
-
-
Save ubershmekel/a83e53b463bf134ab66a to your computer and use it in GitHub Desktop.
This file contains hidden or 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
import sys | |
import pprint | |
import json | |
import requests | |
base_url = 'http://localhost:9200' | |
INDEX_COUNT = 400 | |
CONTENT_SIZE = 500 | |
def put(index, type, id, doc): | |
url = '/'.join([base_url, index, type, id]) | |
res = requests.put(url, data=json.dumps(doc)) | |
#pprint.pprint(res.json()) | |
return res.json() | |
def search(): | |
data = { | |
"size": 2, | |
"from": 5, | |
} | |
url = '/'.join([base_url, '_all', '_search?q=123']) | |
print(url) | |
res = requests.get(url, data=json.dumps(data)) | |
#pprint.pprint(res.json()) | |
return res.json() | |
def spam(): | |
for i in range(INDEX_COUNT): | |
res = put('abcindex%d' % i, 'abctype', 'abcid', {'whatever': "abc 123 " * CONTENT_SIZE}) | |
pprint.pprint(res) | |
def test_search(): | |
failed = None | |
failed_count = 0 | |
TEST_COUNT = 100 | |
for i in range(TEST_COUNT): | |
res = search() | |
failed = res.get('_shards', {}).get('failed', {}) | |
if failed: | |
failed_count += 1 | |
pprint.pprint(res) | |
# EsRejectedExecutionException[rejected execution (queue capacity 1000) on org.elasticsearch.search.action.SearchServiceTransportAction$23@1ba5b9e] | |
print('Failed %d of the tests' % failed_count) | |
#debug() | |
spam() | |
test_search() | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment