diff --git a/qa/suites/rados/rest/mgr-restful.yaml b/qa/suites/rados/rest/mgr-restful.yaml new file mode 100644 index 00000000000..8a452af5595 --- /dev/null +++ b/qa/suites/rados/rest/mgr-restful.yaml @@ -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 diff --git a/qa/workunits/rest/test_mgr_rest_api.py b/qa/workunits/rest/test_mgr_rest_api.py index c3521b51664..d6a8f534898 100755 --- a/qa/workunits/rest/test_mgr_rest_api.py +++ b/qa/workunits/rest/test_mgr_rest_api.py @@ -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 " % 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))