mirror of
https://github.com/featurebasedb/featurebase.git
synced 2026-08-28 10:54:59 +00:00
This is a bit complicated and entangled, sorry. First, we squash the auth-based smoke tests into the regular smoke tests; we just run all the tests with auth on and that way we don't need to spin up an entire separate cluster of machines just to run a single query against them. We improve the error detection, and standardize the jq-to-get-config code. The purpose of this is to try to make sure that, if we actually hit a failure and get "null" for a host name, we report *that* as an error, rather than running ahead and producing 20+ separate reports that ssh failed because it couldn't find a host named null.
69 lines
No EOL
3 KiB
Python
69 lines
No EOL
3 KiB
Python
import config
|
|
import json
|
|
import requests
|
|
|
|
|
|
createIndex = { 'options': { 'keys': False } }
|
|
createField = { 'options': { 'type': 'int', 'min': 0, 'max': 100000 } }
|
|
headers = {"Authorization": "Bearer " + config.admin_token}
|
|
|
|
def setup_module(module):
|
|
data_to_send = json.dumps(createIndex).encode("utf-8")
|
|
response = requests.post("https://" + config.datanode0 + ":10101/index/user", data = data_to_send, verify = False, headers = headers)
|
|
assert response.status_code == 200
|
|
assert response.headers["Content-Type"] == "application/json"
|
|
resp_body = response.json()
|
|
assert resp_body['success'] == True
|
|
|
|
data_to_send = json.dumps(createField).encode("utf-8")
|
|
response = requests.post("https://" + config.datanode0 + ":10101/index/user/field/stats", data = data_to_send, verify = False, headers = headers)
|
|
assert response.status_code == 200
|
|
assert response.headers["Content-Type"] == "application/json"
|
|
resp_body = response.json()
|
|
assert resp_body['success'] == True
|
|
|
|
|
|
def teardown_module(module):
|
|
response = requests.delete("https://" + config.datanode0 + ":10101/index/user", verify = False, headers = headers)
|
|
assert response.status_code == 200
|
|
assert response.headers["Content-Type"] == "application/json"
|
|
resp_body = response.json()
|
|
assert resp_body['success'] == True
|
|
|
|
|
|
def test_api_is_responding():
|
|
response = requests.get("https://" + config.datanode0 + ":10101/status", verify = False, headers = headers)
|
|
assert response.status_code == 200
|
|
assert response.headers["Content-Type"] == "application/json"
|
|
resp_body = response.json()
|
|
assert resp_body['state'] == "NORMAL"
|
|
|
|
|
|
def test_sql3_is_responding():
|
|
response = requests.post("https://" + config.datanode0 + ":10101/sql", data = "select 1", verify = False, headers = headers)
|
|
assert response.status_code == 200
|
|
assert response.headers["Content-Type"] == "application/json"
|
|
resp_body = response.json()
|
|
assert resp_body['schema']['fields'][0]['type'] == "INT"
|
|
assert resp_body['data'][0][0] == 1
|
|
|
|
def test_get_index_api():
|
|
response = requests.get("https://" + config.datanode0 + ":10101/index/user", verify = False, headers = headers)
|
|
assert response.status_code == 200
|
|
assert response.headers["Content-Type"] == "application/json"
|
|
resp_body = response.json()
|
|
assert resp_body['name'] == "user"
|
|
|
|
|
|
def test_set_and_read_query_api():
|
|
response = requests.post("https://" + config.datanode0 + ":10101/index/user/query", data = "Set(10, stats=1)", verify = False, headers = headers)
|
|
assert response.status_code == 200
|
|
assert response.headers["Content-Type"] == "application/json"
|
|
resp_body = response.json()
|
|
assert resp_body['results'][0] == True
|
|
|
|
response = requests.post("https://" + config.datanode0 + ":10101/index/user/query", data = "Row(stats=1)", verify = False, headers = headers)
|
|
assert response.status_code == 200
|
|
assert response.headers["Content-Type"] == "application/json"
|
|
resp_body = response.json()
|
|
assert resp_body['results'][0]['columns'][0] == 10 |