2013-07-11 00:42:33 +00:00
|
|
|
#!/usr/bin/python
|
|
|
|
|
|
|
|
import exceptions
|
2013-07-24 23:08:30 +00:00
|
|
|
import json
|
2013-07-11 00:42:33 +00:00
|
|
|
import os
|
|
|
|
import requests
|
|
|
|
import subprocess
|
|
|
|
import sys
|
|
|
|
import time
|
2014-07-02 17:38:43 +00:00
|
|
|
import uuid
|
2013-07-11 00:42:33 +00:00
|
|
|
import xml.etree.ElementTree
|
|
|
|
|
|
|
|
BASEURL = os.environ.get('BASEURL', 'http://localhost:5000/api/v0.1')
|
|
|
|
|
|
|
|
def fail(r, msg):
|
|
|
|
print >> sys.stderr, 'FAILURE: url ', r.url
|
|
|
|
print >> sys.stderr, msg
|
|
|
|
print >> sys.stderr, 'Response content: ', r.content
|
|
|
|
print >> sys.stderr, 'Headers: ', r.headers
|
|
|
|
sys.exit(1)
|
|
|
|
|
|
|
|
def expect(url, method, respcode, contenttype, extra_hdrs=None, data=None):
|
2013-08-01 01:08:39 +00:00
|
|
|
failmsg, r = expect_nofail(url, method, respcode, contenttype, extra_hdrs,
|
|
|
|
data)
|
|
|
|
if failmsg:
|
|
|
|
fail(r, failmsg)
|
|
|
|
return r
|
|
|
|
|
|
|
|
def expect_nofail(url, method, respcode, contenttype, extra_hdrs=None,
|
|
|
|
data=None):
|
2013-07-11 00:42:33 +00:00
|
|
|
|
|
|
|
fdict = {'get':requests.get, 'put':requests.put}
|
|
|
|
f = fdict[method.lower()]
|
|
|
|
r = f(BASEURL + '/' + url, headers=extra_hdrs, data=data)
|
|
|
|
|
2013-07-27 07:26:41 +00:00
|
|
|
print '{0} {1}: {2} {3}'.format(method, url, contenttype, r.status_code)
|
2013-07-11 00:42:33 +00:00
|
|
|
|
|
|
|
if r.status_code != respcode:
|
2013-08-01 01:08:39 +00:00
|
|
|
return 'expected {0}, got {1}'.format(respcode, r.status_code), r
|
|
|
|
|
2013-07-11 00:42:33 +00:00
|
|
|
r_contenttype = r.headers['content-type']
|
|
|
|
|
|
|
|
if contenttype in ['json', 'xml']:
|
|
|
|
contenttype = 'application/' + contenttype
|
|
|
|
elif contenttype:
|
|
|
|
contenttype = 'text/' + contenttype
|
|
|
|
|
|
|
|
if contenttype and r_contenttype != contenttype:
|
2013-08-01 01:08:39 +00:00
|
|
|
return 'expected {0}, got "{1}"'.format(contenttype, r_contenttype), r
|
2013-07-11 00:42:33 +00:00
|
|
|
|
|
|
|
if contenttype.startswith('application'):
|
|
|
|
if r_contenttype == 'application/json':
|
|
|
|
try:
|
2013-07-24 23:08:30 +00:00
|
|
|
# older requests.py doesn't create r.myjson; create it myself
|
|
|
|
r.myjson = json.loads(r.content)
|
|
|
|
assert(r.myjson != None)
|
2013-07-11 00:42:33 +00:00
|
|
|
except Exception as e:
|
2013-08-01 01:08:39 +00:00
|
|
|
return 'Invalid JSON returned: "{0}"'.format(str(e)), r
|
2013-07-11 00:42:33 +00:00
|
|
|
|
|
|
|
if r_contenttype == 'application/xml':
|
|
|
|
try:
|
|
|
|
# if it's there, squirrel it away for use in the caller
|
|
|
|
r.tree = xml.etree.ElementTree.fromstring(r.content)
|
|
|
|
except Exception as e:
|
2013-08-01 01:08:39 +00:00
|
|
|
return 'Invalid XML returned: "{0}"'.format(str(e)), r
|
2013-07-11 00:42:33 +00:00
|
|
|
|
2013-08-01 01:08:39 +00:00
|
|
|
return '', r
|
2013-07-11 00:42:33 +00:00
|
|
|
|
|
|
|
|
|
|
|
JSONHDR={'accept':'application/json'}
|
|
|
|
XMLHDR={'accept':'application/xml'}
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
expect('auth/export', 'GET', 200, 'plain')
|
|
|
|
expect('auth/export.json', 'GET', 200, 'json')
|
|
|
|
expect('auth/export.xml', 'GET', 200, 'xml')
|
|
|
|
expect('auth/export', 'GET', 200, 'json', JSONHDR)
|
|
|
|
expect('auth/export', 'GET', 200, 'xml', XMLHDR)
|
|
|
|
|
|
|
|
expect('auth/add?entity=client.xx&'
|
2013-07-26 04:41:32 +00:00
|
|
|
'caps=mon&caps=allow&caps=osd&caps=allow+*', 'PUT', 200, 'json',
|
2013-07-11 00:42:33 +00:00
|
|
|
JSONHDR)
|
|
|
|
|
|
|
|
r = expect('auth/export?entity=client.xx', 'GET', 200, 'plain')
|
|
|
|
# must use text/plain; default is application/x-www-form-urlencoded
|
|
|
|
expect('auth/add?entity=client.xx', 'PUT', 200, 'plain',
|
|
|
|
{'Content-Type':'text/plain'}, data=r.content)
|
|
|
|
|
|
|
|
r = expect('auth/list', 'GET', 200, 'plain')
|
|
|
|
assert('client.xx' in r.content)
|
|
|
|
|
|
|
|
r = expect('auth/list.json', 'GET', 200, 'json')
|
2013-07-24 23:08:30 +00:00
|
|
|
dictlist = r.myjson['output']['auth_dump']
|
2013-07-11 00:42:33 +00:00
|
|
|
xxdict = [d for d in dictlist if d['entity'] == 'client.xx'][0]
|
|
|
|
assert(xxdict)
|
|
|
|
assert('caps' in xxdict)
|
|
|
|
assert('mon' in xxdict['caps'])
|
|
|
|
assert('osd' in xxdict['caps'])
|
|
|
|
|
|
|
|
expect('auth/get-key?entity=client.xx', 'GET', 200, 'json', JSONHDR)
|
|
|
|
expect('auth/print-key?entity=client.xx', 'GET', 200, 'json', JSONHDR)
|
|
|
|
expect('auth/print_key?entity=client.xx', 'GET', 200, 'json', JSONHDR)
|
|
|
|
|
2013-07-26 04:41:32 +00:00
|
|
|
expect('auth/caps?entity=client.xx&caps=osd&caps=allow+rw', 'PUT', 200,
|
2013-07-11 00:42:33 +00:00
|
|
|
'json', JSONHDR)
|
|
|
|
r = expect('auth/list.json', 'GET', 200, 'json')
|
2013-07-24 23:08:30 +00:00
|
|
|
dictlist = r.myjson['output']['auth_dump']
|
2013-07-11 00:42:33 +00:00
|
|
|
xxdict = [d for d in dictlist if d['entity'] == 'client.xx'][0]
|
|
|
|
assert(xxdict)
|
|
|
|
assert('caps' in xxdict)
|
|
|
|
assert(not 'mon' in xxdict['caps'])
|
|
|
|
assert('osd' in xxdict['caps'])
|
|
|
|
assert(xxdict['caps']['osd'] == 'allow rw')
|
|
|
|
|
|
|
|
# export/import/export, compare
|
|
|
|
r = expect('auth/export', 'GET', 200, 'plain')
|
|
|
|
exp1 = r.content
|
|
|
|
assert('client.xx' in exp1)
|
|
|
|
r = expect('auth/import', 'PUT', 200, 'plain',
|
|
|
|
{'Content-Type':'text/plain'}, data=r.content)
|
|
|
|
r2 = expect('auth/export', 'GET', 200, 'plain')
|
|
|
|
assert(exp1 == r2.content)
|
|
|
|
expect('auth/del?entity=client.xx', 'PUT', 200, 'json', JSONHDR)
|
|
|
|
|
|
|
|
r = expect('osd/dump', 'GET', 200, 'json', JSONHDR)
|
2013-07-24 23:08:30 +00:00
|
|
|
assert('epoch' in r.myjson['output'])
|
2013-07-11 00:42:33 +00:00
|
|
|
|
|
|
|
assert('GLOBAL' in expect('df', 'GET', 200, 'plain').content)
|
|
|
|
assert('CATEGORY' in expect('df?detail=detail', 'GET', 200, 'plain').content)
|
|
|
|
# test param with no value (treated as param=param)
|
|
|
|
assert('CATEGORY' in expect('df?detail', 'GET', 200, 'plain').content)
|
|
|
|
|
|
|
|
r = expect('df', 'GET', 200, 'json', JSONHDR)
|
2014-08-16 20:06:02 +00:00
|
|
|
assert('total_used_bytes' in r.myjson['output']['stats'])
|
2013-07-11 00:42:33 +00:00
|
|
|
r = expect('df', 'GET', 200, 'xml', XMLHDR)
|
2014-08-16 20:06:02 +00:00
|
|
|
assert(r.tree.find('output/stats/stats/total_used_bytes') is not None)
|
2013-07-11 00:42:33 +00:00
|
|
|
|
|
|
|
r = expect('df?detail', 'GET', 200, 'json', JSONHDR)
|
2013-07-24 23:08:30 +00:00
|
|
|
assert('rd_kb' in r.myjson['output']['pools'][0]['stats'])
|
2013-07-11 00:42:33 +00:00
|
|
|
r = expect('df?detail', 'GET', 200, 'xml', XMLHDR)
|
|
|
|
assert(r.tree.find('output/stats/pools/pool/stats/rd_kb') is not None)
|
|
|
|
|
|
|
|
expect('fsid', 'GET', 200, 'json', JSONHDR)
|
|
|
|
expect('health', 'GET', 200, 'json', JSONHDR)
|
|
|
|
expect('health?detail', 'GET', 200, 'json', JSONHDR)
|
|
|
|
expect('health?detail', 'GET', 200, 'plain')
|
|
|
|
|
|
|
|
# XXX no ceph -w equivalent yet
|
|
|
|
|
|
|
|
expect('mds/cluster_down', 'PUT', 200, '')
|
2013-07-23 04:04:01 +00:00
|
|
|
expect('mds/cluster_down', 'PUT', 200, '')
|
|
|
|
expect('mds/cluster_up', 'PUT', 200, '')
|
2013-07-11 00:42:33 +00:00
|
|
|
expect('mds/cluster_up', 'PUT', 200, '')
|
|
|
|
|
|
|
|
expect('mds/compat/rm_incompat?feature=4', 'PUT', 200, '')
|
|
|
|
expect('mds/compat/rm_incompat?feature=4', 'PUT', 200, '')
|
|
|
|
|
|
|
|
r = expect('mds/compat/show', 'GET', 200, 'json', JSONHDR)
|
2013-07-24 23:08:30 +00:00
|
|
|
assert('incompat' in r.myjson['output'])
|
2013-07-11 00:42:33 +00:00
|
|
|
r = expect('mds/compat/show', 'GET', 200, 'xml', XMLHDR)
|
|
|
|
assert(r.tree.find('output/mds_compat/incompat') is not None)
|
|
|
|
|
|
|
|
# EEXIST from CLI
|
|
|
|
expect('mds/deactivate?who=2', 'PUT', 400, '')
|
|
|
|
|
|
|
|
r = expect('mds/dump.xml', 'GET', 200, 'xml')
|
|
|
|
assert(r.tree.find('output/mdsmap/created') is not None)
|
|
|
|
|
2013-08-01 01:09:20 +00:00
|
|
|
failresps = []
|
|
|
|
while len(failresps) < 10:
|
|
|
|
r = expect('mds/dump.json', 'GET', 200, 'json')
|
|
|
|
assert('created' in r.myjson['output'])
|
|
|
|
current_epoch = r.myjson['output']['epoch']
|
|
|
|
|
|
|
|
map = expect('mds/getmap', 'GET', 200, '')
|
|
|
|
assert(len(map.content) != 0)
|
|
|
|
msg, r = expect_nofail(
|
|
|
|
'mds/setmap?epoch={0}'.format(current_epoch + 1), 'PUT', 200,
|
|
|
|
'plain', {'Content-Type':'text/plain'}, data=map.content
|
|
|
|
)
|
|
|
|
if msg:
|
|
|
|
failresps.append(msg + r.content)
|
|
|
|
else:
|
|
|
|
break
|
|
|
|
|
|
|
|
if len(failresps) == 10:
|
|
|
|
fail(r, 'Could not mds setmap in 10 tries; responses:' +
|
|
|
|
'\n'.join(failresps))
|
2013-07-11 00:42:33 +00:00
|
|
|
expect('mds/newfs?metadata=0&data=1&sure=--yes-i-really-mean-it', 'PUT',
|
|
|
|
200, '')
|
|
|
|
expect('osd/pool/create?pool=data2&pg_num=10', 'PUT', 200, '')
|
|
|
|
r = expect('osd/dump', 'GET', 200, 'json', JSONHDR)
|
2013-07-24 23:08:30 +00:00
|
|
|
pools = r.myjson['output']['pools']
|
2013-07-11 00:42:33 +00:00
|
|
|
poolnum = None
|
|
|
|
for p in pools:
|
|
|
|
if p['pool_name'] == 'data2':
|
|
|
|
poolnum = p['pool']
|
|
|
|
assert(p['pg_num'] == 10)
|
|
|
|
break
|
|
|
|
assert(poolnum is not None)
|
2013-10-17 21:38:37 +00:00
|
|
|
expect('mds/add_data_pool?pool={0}'.format(poolnum), 'PUT', 200, '')
|
|
|
|
expect('mds/remove_data_pool?pool={0}'.format(poolnum), 'PUT', 200, '')
|
2013-07-11 00:42:33 +00:00
|
|
|
expect('osd/pool/delete?pool=data2&pool2=data2'
|
|
|
|
'&sure=--yes-i-really-really-mean-it', 'PUT', 200, '')
|
|
|
|
expect('mds/set_max_mds?maxmds=4', 'PUT', 200, '')
|
2014-02-04 00:54:08 +00:00
|
|
|
expect('mds/set?var=max_mds&val=4', 'PUT', 200, '')
|
2014-02-08 16:22:29 +00:00
|
|
|
expect('mds/set?var=max_file_size&val=1048576', 'PUT', 200, '')
|
2014-02-04 00:54:08 +00:00
|
|
|
expect('mds/set?var=allow_new_snaps&val=true&confirm=--yes-i-really-mean-it', 'PUT', 200, '')
|
|
|
|
expect('mds/set?var=allow_new_snaps&val=0', 'PUT', 200, '')
|
|
|
|
expect('mds/set?var=inline_data&val=true&confirm=--yes-i-really-mean-it', 'PUT', 200, '')
|
|
|
|
expect('mds/set?var=inline_data&val=0', 'PUT', 200, '')
|
2013-07-11 00:42:33 +00:00
|
|
|
r = expect('mds/dump.json', 'GET', 200, 'json')
|
2013-07-24 23:08:30 +00:00
|
|
|
assert(r.myjson['output']['max_mds'] == 4)
|
2013-07-11 00:42:33 +00:00
|
|
|
expect('mds/set_max_mds?maxmds=3', 'PUT', 200, '')
|
|
|
|
r = expect('mds/stat.json', 'GET', 200, 'json')
|
2014-01-17 23:56:36 +00:00
|
|
|
expect('mds/set?var=max_mds&val=2', 'PUT', 200, '')
|
2014-01-15 06:07:24 +00:00
|
|
|
r = expect('mds/stat.json', 'GET', 200, 'json')
|
2013-07-24 23:08:30 +00:00
|
|
|
assert('info' in r.myjson['output']['mdsmap'])
|
2013-07-11 00:42:33 +00:00
|
|
|
r = expect('mds/stat.xml', 'GET', 200, 'xml')
|
2013-07-23 04:54:16 +00:00
|
|
|
assert(r.tree.find('output/mds_stat/mdsmap/info') is not None)
|
2013-07-11 00:42:33 +00:00
|
|
|
|
|
|
|
# more content tests below, just check format here
|
|
|
|
expect('mon/dump.json', 'GET', 200, 'json')
|
|
|
|
expect('mon/dump.xml', 'GET', 200, 'xml')
|
|
|
|
|
|
|
|
r = expect('mon/getmap', 'GET', 200, '')
|
|
|
|
assert(len(r.content) != 0)
|
|
|
|
r = expect('mon_status.json', 'GET', 200, 'json')
|
2013-07-24 23:08:30 +00:00
|
|
|
assert('name' in r.myjson['output'])
|
2013-07-11 00:42:33 +00:00
|
|
|
r = expect('mon_status.xml', 'GET', 200, 'xml')
|
|
|
|
assert(r.tree.find('output/mon_status/name') is not None)
|
|
|
|
|
|
|
|
bl = '192.168.0.1:0/1000'
|
|
|
|
expect('osd/blacklist?blacklistop=add&addr=' + bl, 'PUT', 200, '')
|
|
|
|
r = expect('osd/blacklist/ls.json', 'GET', 200, 'json')
|
2013-07-24 23:08:30 +00:00
|
|
|
assert([b for b in r.myjson['output'] if b['addr'] == bl])
|
2013-07-11 00:42:33 +00:00
|
|
|
expect('osd/blacklist?blacklistop=rm&addr=' + bl, 'PUT', 200, '')
|
|
|
|
r = expect('osd/blacklist/ls.json', 'GET', 200, 'json')
|
2013-07-24 23:08:30 +00:00
|
|
|
assert([b for b in r.myjson['output'] if b['addr'] == bl] == [])
|
2013-07-11 00:42:33 +00:00
|
|
|
|
|
|
|
expect('osd/crush/tunables?profile=legacy', 'PUT', 200, '')
|
|
|
|
expect('osd/crush/tunables?profile=bobtail', 'PUT', 200, '')
|
|
|
|
|
|
|
|
expect('osd/scrub?who=0', 'PUT', 200, '')
|
|
|
|
expect('osd/deep-scrub?who=0', 'PUT', 200, '')
|
|
|
|
expect('osd/repair?who=0', 'PUT', 200, '')
|
|
|
|
|
|
|
|
expect('osd/set?key=noup', 'PUT', 200, '')
|
|
|
|
|
|
|
|
expect('osd/down?ids=0', 'PUT', 200, '')
|
|
|
|
r = expect('osd/dump', 'GET', 200, 'json', JSONHDR)
|
2013-07-24 23:08:30 +00:00
|
|
|
assert(r.myjson['output']['osds'][0]['osd'] == 0)
|
|
|
|
assert(r.myjson['output']['osds'][0]['up'] == 0)
|
2013-07-11 00:42:33 +00:00
|
|
|
|
|
|
|
expect('osd/unset?key=noup', 'PUT', 200, '')
|
|
|
|
|
|
|
|
for i in range(0,100):
|
|
|
|
r = expect('osd/dump', 'GET', 200, 'json', JSONHDR)
|
2013-07-24 23:08:30 +00:00
|
|
|
assert(r.myjson['output']['osds'][0]['osd'] == 0)
|
|
|
|
if r.myjson['output']['osds'][0]['up'] == 1:
|
2013-07-11 00:42:33 +00:00
|
|
|
break
|
|
|
|
else:
|
|
|
|
print >> sys.stderr, "waiting for osd.0 to come back up"
|
|
|
|
time.sleep(10)
|
|
|
|
|
|
|
|
r = expect('osd/dump', 'GET', 200, 'json', JSONHDR)
|
2013-07-24 23:08:30 +00:00
|
|
|
assert(r.myjson['output']['osds'][0]['osd'] == 0)
|
|
|
|
assert(r.myjson['output']['osds'][0]['up'] == 1)
|
2013-07-11 00:42:33 +00:00
|
|
|
|
|
|
|
r = expect('osd/find?id=1', 'GET', 200, 'json', JSONHDR)
|
2013-07-24 23:08:30 +00:00
|
|
|
assert(r.myjson['output']['osd'] == 1)
|
2013-07-11 00:42:33 +00:00
|
|
|
|
|
|
|
expect('osd/out?ids=1', 'PUT', 200, '')
|
|
|
|
r = expect('osd/dump', 'GET', 200, 'json', JSONHDR)
|
2013-07-24 23:08:30 +00:00
|
|
|
assert(r.myjson['output']['osds'][1]['osd'] == 1)
|
|
|
|
assert(r.myjson['output']['osds'][1]['in'] == 0)
|
2013-07-11 00:42:33 +00:00
|
|
|
|
|
|
|
expect('osd/in?ids=1', 'PUT', 200, '')
|
|
|
|
r = expect('osd/dump', 'GET', 200, 'json', JSONHDR)
|
2013-07-24 23:08:30 +00:00
|
|
|
assert(r.myjson['output']['osds'][1]['osd'] == 1)
|
|
|
|
assert(r.myjson['output']['osds'][1]['in'] == 1)
|
2013-07-11 00:42:33 +00:00
|
|
|
|
|
|
|
r = expect('osd/find?id=0', 'GET', 200, 'json', JSONHDR)
|
2013-07-24 23:08:30 +00:00
|
|
|
assert(r.myjson['output']['osd'] == 0)
|
2013-07-11 00:42:33 +00:00
|
|
|
|
|
|
|
r = expect('osd/getmaxosd', 'GET', 200, 'xml', XMLHDR)
|
|
|
|
assert(r.tree.find('output/getmaxosd/max_osd') is not None)
|
|
|
|
r = expect('osd/getmaxosd', 'GET', 200, 'json', JSONHDR)
|
2013-07-24 23:08:30 +00:00
|
|
|
saved_maxosd = r.myjson['output']['max_osd']
|
2013-07-11 00:42:33 +00:00
|
|
|
expect('osd/setmaxosd?newmax=10', 'PUT', 200, '')
|
|
|
|
r = expect('osd/getmaxosd', 'GET', 200, 'json', JSONHDR)
|
2013-07-24 23:08:30 +00:00
|
|
|
assert(r.myjson['output']['max_osd'] == 10)
|
2013-07-11 00:42:33 +00:00
|
|
|
expect('osd/setmaxosd?newmax={0}'.format(saved_maxosd), 'PUT', 200, '')
|
|
|
|
r = expect('osd/getmaxosd', 'GET', 200, 'json', JSONHDR)
|
2013-07-24 23:08:30 +00:00
|
|
|
assert(r.myjson['output']['max_osd'] == saved_maxosd)
|
2013-07-11 00:42:33 +00:00
|
|
|
|
2014-07-02 17:38:43 +00:00
|
|
|
osd_uuid=uuid.uuid1()
|
|
|
|
r = expect('osd/create?uuid={0}'.format(osd_uuid), 'PUT', 200, 'json', JSONHDR)
|
2013-07-24 23:08:30 +00:00
|
|
|
assert('osdid' in r.myjson['output'])
|
|
|
|
osdid = r.myjson['output']['osdid']
|
2013-07-11 00:42:33 +00:00
|
|
|
expect('osd/lost?id={0}'.format(osdid), 'PUT', 400, '')
|
|
|
|
expect('osd/lost?id={0}&sure=--yes-i-really-mean-it'.format(osdid),
|
|
|
|
'PUT', 200, 'json', JSONHDR)
|
|
|
|
expect('osd/rm?ids={0}'.format(osdid), 'PUT', 200, '')
|
|
|
|
r = expect('osd/ls', 'GET', 200, 'json', JSONHDR)
|
2013-07-24 23:08:30 +00:00
|
|
|
assert(isinstance(r.myjson['output'], list))
|
2013-07-11 00:42:33 +00:00
|
|
|
r = expect('osd/ls', 'GET', 200, 'xml', XMLHDR)
|
|
|
|
assert(r.tree.find('output/osds/osd') is not None)
|
|
|
|
|
|
|
|
|
|
|
|
expect('osd/pause', 'PUT', 200, '')
|
|
|
|
r = expect('osd/dump', 'GET', 200, 'json', JSONHDR)
|
2013-07-24 23:08:30 +00:00
|
|
|
assert('pauserd,pausewr' in r.myjson['output']['flags'])
|
2013-07-11 00:42:33 +00:00
|
|
|
expect('osd/unpause', 'PUT', 200, '')
|
|
|
|
r = expect('osd/dump', 'GET', 200, 'json', JSONHDR)
|
2013-07-24 23:08:30 +00:00
|
|
|
assert('pauserd,pausewr' not in r.myjson['output']['flags'])
|
2013-07-11 00:42:33 +00:00
|
|
|
|
|
|
|
r = expect('osd/tree', 'GET', 200, 'json', JSONHDR)
|
2013-07-24 23:08:30 +00:00
|
|
|
assert('nodes' in r.myjson['output'])
|
2013-07-11 00:42:33 +00:00
|
|
|
r = expect('osd/tree', 'GET', 200, 'xml', XMLHDR)
|
|
|
|
assert(r.tree.find('output/tree/nodes') is not None)
|
|
|
|
expect('osd/pool/mksnap?pool=data&snap=datasnap', 'PUT', 200, '')
|
|
|
|
r = subprocess.call('rados -p data lssnap | grep -q datasnap', shell=True)
|
|
|
|
assert(r == 0)
|
|
|
|
expect('osd/pool/rmsnap?pool=data&snap=datasnap', 'PUT', 200, '')
|
|
|
|
|
|
|
|
expect('osd/pool/create?pool=data2&pg_num=10', 'PUT', 200, '')
|
2013-07-23 07:15:32 +00:00
|
|
|
r = expect('osd/lspools', 'GET', 200, 'json', JSONHDR)
|
2013-07-24 23:08:30 +00:00
|
|
|
assert([p for p in r.myjson['output'] if p['poolname'] == 'data2'])
|
2013-07-11 00:42:33 +00:00
|
|
|
expect('osd/pool/rename?srcpool=data2&destpool=data3', 'PUT', 200, '')
|
2013-07-23 07:15:32 +00:00
|
|
|
r = expect('osd/lspools', 'GET', 200, 'json', JSONHDR)
|
2013-07-24 23:08:30 +00:00
|
|
|
assert([p for p in r.myjson['output'] if p['poolname'] == 'data3'])
|
2013-07-11 00:42:33 +00:00
|
|
|
expect('osd/pool/delete?pool=data3', 'PUT', 400, '')
|
|
|
|
expect('osd/pool/delete?pool=data3&pool2=data3&sure=--yes-i-really-really-mean-it', 'PUT', 200, '')
|
|
|
|
|
|
|
|
r = expect('osd/stat', 'GET', 200, 'json', JSONHDR)
|
2013-07-24 23:08:30 +00:00
|
|
|
assert('num_up_osds' in r.myjson['output'])
|
2013-07-11 00:42:33 +00:00
|
|
|
r = expect('osd/stat', 'GET', 200, 'xml', XMLHDR)
|
|
|
|
assert(r.tree.find('output/osdmap/num_up_osds') is not None)
|
|
|
|
|
|
|
|
r = expect('osd/ls', 'GET', 200, 'json', JSONHDR)
|
2013-07-24 23:08:30 +00:00
|
|
|
for osdid in r.myjson['output']:
|
2013-07-27 07:26:41 +00:00
|
|
|
expect('tell/osd.{0}/version'.format(osdid), 'GET', 200, '')
|
2013-07-11 00:42:33 +00:00
|
|
|
|
|
|
|
expect('pg/debug?debugop=unfound_objects_exist', 'GET', 200, '')
|
|
|
|
expect('pg/debug?debugop=degraded_pgs_exist', 'GET', 200, '')
|
|
|
|
expect('pg/deep-scrub?pgid=0.0', 'PUT', 200, '')
|
|
|
|
r = expect('pg/dump', 'GET', 200, 'json', JSONHDR)
|
2013-07-24 23:08:30 +00:00
|
|
|
assert('pg_stats_sum' in r.myjson['output'])
|
2013-07-11 00:42:33 +00:00
|
|
|
r = expect('pg/dump', 'GET', 200, 'xml', XMLHDR)
|
|
|
|
assert(r.tree.find('output/pg_map/pg_stats_sum') is not None)
|
|
|
|
|
|
|
|
expect('pg/dump_json', 'GET', 200, 'json', JSONHDR)
|
|
|
|
expect('pg/dump_pools_json', 'GET', 200, 'json', JSONHDR)
|
|
|
|
expect('pg/dump_stuck?stuckops=inactive', 'GET', 200, '')
|
|
|
|
expect('pg/dump_stuck?stuckops=unclean', 'GET', 200, '')
|
|
|
|
expect('pg/dump_stuck?stuckops=stale', 'GET', 200, '')
|
|
|
|
|
|
|
|
r = expect('pg/getmap', 'GET', 200, '')
|
|
|
|
assert(len(r.content) != 0)
|
|
|
|
|
|
|
|
r = expect('pg/map?pgid=0.0', 'GET', 200, 'json', JSONHDR)
|
2013-07-24 23:08:30 +00:00
|
|
|
assert('acting' in r.myjson['output'])
|
|
|
|
assert(r.myjson['output']['pgid'] == '0.0')
|
2013-07-11 00:42:33 +00:00
|
|
|
r = expect('pg/map?pgid=0.0', 'GET', 200, 'xml', XMLHDR)
|
|
|
|
assert(r.tree.find('output/pg_map/acting') is not None)
|
|
|
|
assert(r.tree.find('output/pg_map/pgid').text == '0.0')
|
|
|
|
|
|
|
|
expect('pg/repair?pgid=0.0', 'PUT', 200, '')
|
|
|
|
expect('pg/scrub?pgid=0.0', 'PUT', 200, '')
|
|
|
|
|
|
|
|
expect('pg/send_pg_creates', 'PUT', 200, '')
|
|
|
|
|
|
|
|
expect('pg/set_full_ratio?ratio=0.90', 'PUT', 200, '')
|
|
|
|
r = expect('pg/dump', 'GET', 200, 'json', JSONHDR)
|
2013-07-24 23:08:30 +00:00
|
|
|
assert(float(r.myjson['output']['full_ratio']) == 0.90)
|
2013-07-11 00:42:33 +00:00
|
|
|
expect('pg/set_full_ratio?ratio=0.95', 'PUT', 200, '')
|
|
|
|
expect('pg/set_nearfull_ratio?ratio=0.90', 'PUT', 200, '')
|
|
|
|
r = expect('pg/dump', 'GET', 200, 'json', JSONHDR)
|
2013-07-24 23:08:30 +00:00
|
|
|
assert(float(r.myjson['output']['near_full_ratio']) == 0.90)
|
2013-07-11 00:42:33 +00:00
|
|
|
expect('pg/set_full_ratio?ratio=0.85', 'PUT', 200, '')
|
|
|
|
|
|
|
|
r = expect('pg/stat', 'GET', 200, 'json', JSONHDR)
|
2013-07-24 23:08:30 +00:00
|
|
|
assert('pg_stats_sum' in r.myjson['output'])
|
2013-07-11 00:42:33 +00:00
|
|
|
r = expect('pg/stat', 'GET', 200, 'xml', XMLHDR)
|
|
|
|
assert(r.tree.find('output/pg_map/pg_stats_sum') is not None)
|
|
|
|
|
2013-07-27 07:26:41 +00:00
|
|
|
expect('tell/0.0/query', 'GET', 200, 'json', JSONHDR)
|
2013-07-11 00:42:33 +00:00
|
|
|
expect('quorum?quorumcmd=enter', 'PUT', 200, 'json', JSONHDR)
|
|
|
|
expect('quorum?quorumcmd=enter', 'PUT', 200, 'xml', XMLHDR)
|
|
|
|
expect('quorum_status', 'GET', 200, 'json', JSONHDR)
|
|
|
|
expect('quorum_status', 'GET', 200, 'xml', XMLHDR)
|
|
|
|
|
|
|
|
# report's CRC needs to be handled
|
|
|
|
# r = expect('report', 'GET', 200, 'json', JSONHDR)
|
2013-07-24 23:08:30 +00:00
|
|
|
# assert('osd_stats' in r.myjson['output'])
|
2013-07-11 00:42:33 +00:00
|
|
|
# r = expect('report', 'GET', 200, 'xml', XMLHDR)
|
|
|
|
# assert(r.tree.find('output/report/osdmap') is not None)
|
|
|
|
|
|
|
|
r = expect('status', 'GET', 200, 'json', JSONHDR)
|
2013-07-24 23:08:30 +00:00
|
|
|
assert('osdmap' in r.myjson['output'])
|
2013-07-11 00:42:33 +00:00
|
|
|
r = expect('status', 'GET', 200, 'xml', XMLHDR)
|
|
|
|
assert(r.tree.find('output/status/osdmap') is not None)
|
|
|
|
|
2013-07-27 07:26:41 +00:00
|
|
|
r = expect('tell/osd.0/version', 'GET', 200, '')
|
|
|
|
assert('ceph version' in r.content)
|
|
|
|
expect('tell/osd.999/version', 'GET', 400, '')
|
|
|
|
expect('tell/osd.foo/version', 'GET', 400, '')
|
2013-07-11 00:42:33 +00:00
|
|
|
|
2013-07-27 07:26:41 +00:00
|
|
|
r = expect('tell/osd.0/dump_pg_recovery_stats', 'GET', 200, '')
|
|
|
|
assert('Started' in r.content)
|
2013-07-11 00:42:33 +00:00
|
|
|
|
|
|
|
expect('osd/reweight?id=0&weight=0.9', 'PUT', 200, '')
|
|
|
|
expect('osd/reweight?id=0&weight=-1', 'PUT', 400, '')
|
|
|
|
expect('osd/reweight?id=0&weight=1', 'PUT', 200, '')
|
|
|
|
|
|
|
|
for v in ['pg_num', 'pgp_num', 'size', 'min_size', 'crash_replay_interval',
|
|
|
|
'crush_ruleset']:
|
|
|
|
r = expect('osd/pool/get.json?pool=data&var=' + v, 'GET', 200, 'json')
|
2013-07-24 23:08:30 +00:00
|
|
|
assert(v in r.myjson['output'])
|
2013-07-11 00:42:33 +00:00
|
|
|
|
|
|
|
r = expect('osd/pool/get.json?pool=data&var=size', 'GET', 200, 'json')
|
2013-07-24 23:08:30 +00:00
|
|
|
assert(r.myjson['output']['size'] == 2)
|
2013-07-11 00:42:33 +00:00
|
|
|
|
|
|
|
expect('osd/pool/set?pool=data&var=size&val=3', 'PUT', 200, 'plain')
|
|
|
|
r = expect('osd/pool/get.json?pool=data&var=size', 'GET', 200, 'json')
|
2013-07-24 23:08:30 +00:00
|
|
|
assert(r.myjson['output']['size'] == 3)
|
2013-07-11 00:42:33 +00:00
|
|
|
|
|
|
|
expect('osd/pool/set?pool=data&var=size&val=2', 'PUT', 200, 'plain')
|
|
|
|
r = expect('osd/pool/get.json?pool=data&var=size', 'GET', 200, 'json')
|
2013-07-24 23:08:30 +00:00
|
|
|
assert(r.myjson['output']['size'] == 2)
|
2013-07-11 00:42:33 +00:00
|
|
|
|
|
|
|
r = expect('osd/pool/get.json?pool=rbd&var=crush_ruleset', 'GET', 200, 'json')
|
2013-12-28 18:36:27 +00:00
|
|
|
assert(r.myjson['output']['crush_ruleset'] == 0)
|
2013-07-11 00:42:33 +00:00
|
|
|
|
|
|
|
print 'OK'
|