Merge pull request #15604 from liewegas/wip-rest-test-qa

qa/suites/rados/rest: test restful mgr module

Reviewed-by: Boris Ranto <branto@redhat.com>
This commit is contained in:
Sage Weil 2017-06-12 12:47:32 -05:00 committed by GitHub
commit b98fad9b1c
2 changed files with 36 additions and 5 deletions

View File

@ -0,0 +1,18 @@
# ubuntu trusty has old requests. xenial is okay, but we can't blacklist
# just trusty, so:
os_type: centos
roles:
- [mon.a, mgr.x, osd.0, osd.1, osd.2, mds.a, client.a]
tasks:
- install:
- ceph:
- exec:
mon.a:
- ceph config-key put mgr/restful/x/server_addr 127.0.0.1
- ceph config-key put mgr/restful/x/server_port 9999
- ceph tell mgr.x restful create-key admin
- ceph.restart: [mgr.x]
- workunit:
clients:
client.a:
- rest/test-restful.sh

View File

@ -3,10 +3,15 @@
import requests
import time
import sys
import json
# Do not show the stupid message about verify=False
from requests.packages.urllib3.exceptions import InsecureRequestWarning
requests.packages.urllib3.disable_warnings(category=InsecureRequestWarning)
# Do not show the stupid message about verify=False. ignore exceptions bc
# this doesn't work on some distros.
try:
from requests.packages.urllib3.exceptions import InsecureRequestWarning
requests.packages.urllib3.disable_warnings(category=InsecureRequestWarning)
except:
pass
if len(sys.argv) < 3:
print("Usage: %s <url> <admin_key>" % sys.argv[0])
@ -18,7 +23,11 @@ auth = ('admin', sys.argv[2])
request = None
# Create a pool and get its id
request = requests.post(addr + '/pool?wait=yes', json={'name': 'supertestfriends', 'pg_num': 128}, verify=False, auth=auth)
request = requests.post(
addr + '/pool?wait=yes',
data=json.dumps({'name': 'supertestfriends', 'pg_num': 128}),
verify=False,
auth=auth)
print(request.text)
request = requests.get(addr + '/pool', verify=False, auth=auth)
assert(request.json()[-1]['pool_name'] == 'supertestfriends')
@ -70,7 +79,11 @@ for method, endpoint, args in screenplay:
continue
url = addr + endpoint
print("URL = " + url)
request = getattr(requests, method)(url, json=args, verify=False, auth=auth)
request = getattr(requests, method)(
url,
data=json.dumps(args),
verify=False,
auth=auth)
print(request.text)
if request.status_code != 200 or 'error' in request.json():
print('ERROR: %s request for URL "%s" failed' % (method, url))