|
27 | 27 |
|
28 | 28 | from desktop.auth.backend import rewrite_user
|
29 | 29 | from desktop.lib.django_test_util import make_logged_in_client
|
| 30 | +from impala.conf import COORDINATOR_UI_SPNEGO |
30 | 31 | from useradmin.models import User
|
31 | 32 |
|
32 | 33 | from jobbrowser.apis.query_api import QueryApi
|
@@ -102,3 +103,74 @@ def test_download_profile(self):
|
102 | 103 | assert_equal(resp.status_code, 200)
|
103 | 104 | assert_equal(resp['Content-Disposition'], 'attachment; filename="query-profile_00001.txt"')
|
104 | 105 | assert_equal(resp.content, b'Query (id=d94d2fb4815a05c4:b1ccec1500000000):\n Summary:...')
|
| 106 | + |
| 107 | + def test_doc_url(self): |
| 108 | + with patch('jobbrowser.apis.query_api._get_api') as _get_api: |
| 109 | + with patch('jobbrowser.apis.query_api.QueryApi.apps') as apps: |
| 110 | + _get_api.return_value = Mock( |
| 111 | + url='https://coordinator:25000' |
| 112 | + ) |
| 113 | + |
| 114 | + apps.return_value = { |
| 115 | + "apps": [{ |
| 116 | + "id": "b246701d30ab0dd1:afc9f65900000000", |
| 117 | + "name": "SELECT *\nFROM `default`.web_logs\nLIMIT 100", |
| 118 | + "status": "FINISHED", |
| 119 | + "apiStatus": "SUCCEEDED", |
| 120 | + "type": "QUERY", |
| 121 | + "user": "test", |
| 122 | + "queue": "root.test", |
| 123 | + "progress": "4 / 4 ( 100%)", |
| 124 | + "isRunning": False, |
| 125 | + "canWrite": True, |
| 126 | + "duration": 1291.0, |
| 127 | + "submitted": "2024-03-06 17:59:15.304000", |
| 128 | + "rows_fetched": 100, |
| 129 | + "waiting": True, |
| 130 | + "waiting_time": "2s610ms" |
| 131 | + }], |
| 132 | + "total": 1 |
| 133 | + } |
| 134 | + |
| 135 | + result = QueryApi(self.user).app('b246701d30ab0dd1:afc9f65900000000') |
| 136 | + assert_equal(result.get('doc_url'), |
| 137 | + 'https://coordinator:25000/query_plan?query_id=b246701d30ab0dd1:afc9f65900000000') |
| 138 | + |
| 139 | + def test_doc_url_spnego(self): |
| 140 | + resets = [ |
| 141 | + COORDINATOR_UI_SPNEGO.set_for_testing(True) |
| 142 | + ] |
| 143 | + with patch('jobbrowser.apis.query_api._get_api') as _get_api: |
| 144 | + with patch('jobbrowser.apis.query_api.QueryApi.apps') as apps: |
| 145 | + _get_api.return_value = Mock( |
| 146 | + url='https://coordinator:25000' |
| 147 | + ) |
| 148 | + |
| 149 | + apps.return_value = { |
| 150 | + "apps": [{ |
| 151 | + "id": "b246701d30ab0dd1:afc9f65900000000", |
| 152 | + "name": "SELECT *\nFROM `default`.web_logs\nLIMIT 100", |
| 153 | + "status": "FINISHED", |
| 154 | + "apiStatus": "SUCCEEDED", |
| 155 | + "type": "QUERY", |
| 156 | + "user": "test", |
| 157 | + "queue": "root.test", |
| 158 | + "progress": "4 / 4 ( 100%)", |
| 159 | + "isRunning": False, |
| 160 | + "canWrite": True, |
| 161 | + "duration": 1291.0, |
| 162 | + "submitted": "2024-03-06 17:59:15.304000", |
| 163 | + "rows_fetched": 100, |
| 164 | + "waiting": True, |
| 165 | + "waiting_time": "2s610ms" |
| 166 | + }], |
| 167 | + "total": 1 |
| 168 | + } |
| 169 | + try: |
| 170 | + result = QueryApi(self.user).app('b246701d30ab0dd1:afc9f65900000000') |
| 171 | + assert_equal(result.get('doc_url'), |
| 172 | + 'https://coordinator:25000/query_plan?' |
| 173 | + 'scheme=https&host=coordinator&port=25000&query_id=b246701d30ab0dd1:afc9f65900000000') |
| 174 | + finally: |
| 175 | + for reset in resets: |
| 176 | + reset() |
0 commit comments