mirror of
https://github.com/ceph/ceph
synced 2025-01-03 01:22:53 +00:00
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:
commit
b98fad9b1c
18
qa/suites/rados/rest/mgr-restful.yaml
Normal file
18
qa/suites/rados/rest/mgr-restful.yaml
Normal 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
|
@ -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))
|
||||
|
Loading…
Reference in New Issue
Block a user