Created
October 18, 2013 23:27
-
-
Save bcarpio/7049741 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
#!/usr/bin/python | |
# vim: set expandtab: | |
import config | |
import requests | |
import json | |
import os | |
import requests | |
def deploy_multi_region_elasticsearch(env): | |
url = config.urls() | |
headers = {'content-type': 'application/json'} | |
iplist = [] | |
post_json = { "environment": env, "app_name": "qatest", "team_id": "zz" } | |
r = requests.post(url['elasticsearch_url'],data=json.dumps(post_json),headers=headers) | |
r.raise_for_status() | |
return r.json() | |
def read_test_data(): | |
json_data=open(os.path.join(os.path.dirname(__file__),'elasticsearch_input_test')).read() | |
data = json.loads(json_data) | |
return data | |
def test_elasticsearch_cluster(env): | |
json_data = read_test_data() | |
test_data = config.test_data() | |
headers = {'content-type': 'application/json'} | |
hosts = [] | |
for host in json_data['_embedded']['instances']: | |
hosts.append(host['ip']) | |
for host in hosts: | |
print "about to write" | |
p = requests.put('http://'+host+':9200/qatest/qatest/1',data=json.dumps(test_data),headers=headers) | |
p.raise_for_status() | |
print "insert successful" | |
for host in hosts: | |
g = requests.get('http://'+host+':9200/qatest/qatest/1') | |
print g.json() | |
g.raise_for_status() | |
output = g.json()['_source'] | |
if test_data != output: | |
raise Exception("Test Data Did Not Match Outout") | |
print "read successful" | |
d = requests.delete('http://'+host+':9200/qatest/qatest/1') | |
d.raise_for_status() | |
print "delete successful" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment