|
|
@@ -27,6 +27,7 @@ import os
|
|
|
|
|
|
from desktop.auth.backend import rewrite_user
|
|
|
from desktop.lib.django_test_util import make_logged_in_client
|
|
|
+from impala.conf import COORDINATOR_UI_SPNEGO
|
|
|
from useradmin.models import User
|
|
|
|
|
|
from jobbrowser.apis.query_api import QueryApi
|
|
|
@@ -102,3 +103,74 @@ class TestApi():
|
|
|
assert_equal(resp.status_code, 200)
|
|
|
assert_equal(resp['Content-Disposition'], 'attachment; filename="query-profile_00001.txt"')
|
|
|
assert_equal(resp.content, b'Query (id=d94d2fb4815a05c4:b1ccec1500000000):\n Summary:...')
|
|
|
+
|
|
|
+ def test_doc_url(self):
|
|
|
+ with patch('jobbrowser.apis.query_api._get_api') as _get_api:
|
|
|
+ with patch('jobbrowser.apis.query_api.QueryApi.apps') as apps:
|
|
|
+ _get_api.return_value = Mock(
|
|
|
+ url='https://coordinator:25000'
|
|
|
+ )
|
|
|
+
|
|
|
+ apps.return_value = {
|
|
|
+ "apps": [{
|
|
|
+ "id": "b246701d30ab0dd1:afc9f65900000000",
|
|
|
+ "name": "SELECT *\nFROM `default`.web_logs\nLIMIT 100",
|
|
|
+ "status": "FINISHED",
|
|
|
+ "apiStatus": "SUCCEEDED",
|
|
|
+ "type": "QUERY",
|
|
|
+ "user": "test",
|
|
|
+ "queue": "root.test",
|
|
|
+ "progress": "4 / 4 ( 100%)",
|
|
|
+ "isRunning": False,
|
|
|
+ "canWrite": True,
|
|
|
+ "duration": 1291.0,
|
|
|
+ "submitted": "2024-03-06 17:59:15.304000",
|
|
|
+ "rows_fetched": 100,
|
|
|
+ "waiting": True,
|
|
|
+ "waiting_time": "2s610ms"
|
|
|
+ }],
|
|
|
+ "total": 1
|
|
|
+ }
|
|
|
+
|
|
|
+ result = QueryApi(self.user).app('b246701d30ab0dd1:afc9f65900000000')
|
|
|
+ assert_equal(result.get('doc_url'),
|
|
|
+ 'https://coordinator:25000/query_plan?query_id=b246701d30ab0dd1:afc9f65900000000')
|
|
|
+
|
|
|
+ def test_doc_url_spnego(self):
|
|
|
+ resets = [
|
|
|
+ COORDINATOR_UI_SPNEGO.set_for_testing(True)
|
|
|
+ ]
|
|
|
+ with patch('jobbrowser.apis.query_api._get_api') as _get_api:
|
|
|
+ with patch('jobbrowser.apis.query_api.QueryApi.apps') as apps:
|
|
|
+ _get_api.return_value = Mock(
|
|
|
+ url='https://coordinator:25000'
|
|
|
+ )
|
|
|
+
|
|
|
+ apps.return_value = {
|
|
|
+ "apps": [{
|
|
|
+ "id": "b246701d30ab0dd1:afc9f65900000000",
|
|
|
+ "name": "SELECT *\nFROM `default`.web_logs\nLIMIT 100",
|
|
|
+ "status": "FINISHED",
|
|
|
+ "apiStatus": "SUCCEEDED",
|
|
|
+ "type": "QUERY",
|
|
|
+ "user": "test",
|
|
|
+ "queue": "root.test",
|
|
|
+ "progress": "4 / 4 ( 100%)",
|
|
|
+ "isRunning": False,
|
|
|
+ "canWrite": True,
|
|
|
+ "duration": 1291.0,
|
|
|
+ "submitted": "2024-03-06 17:59:15.304000",
|
|
|
+ "rows_fetched": 100,
|
|
|
+ "waiting": True,
|
|
|
+ "waiting_time": "2s610ms"
|
|
|
+ }],
|
|
|
+ "total": 1
|
|
|
+ }
|
|
|
+ try:
|
|
|
+ result = QueryApi(self.user).app('b246701d30ab0dd1:afc9f65900000000')
|
|
|
+ assert_equal(result.get('doc_url'),
|
|
|
+ 'https://coordinator:25000/query_plan?'
|
|
|
+ 'scheme=https&host=coordinator&port=25000&query_id=b246701d30ab0dd1:afc9f65900000000')
|
|
|
+ finally:
|
|
|
+ for reset in resets:
|
|
|
+ reset()
|