(self, vector, unique_database)
| 160 | # query at the backend through beewax or hs2 clients. The objective is to assure |
| 161 | # the load query completes successfully. |
| 162 | def test_async_load(self, vector, unique_database): |
| 163 | enable_async_load_data = vector.get_value('enable_async_load_data_execution') |
| 164 | protocol = vector.get_value('protocol') |
| 165 | client = self.create_impala_client(protocol=protocol) |
| 166 | |
| 167 | # Form a fully qualified table name with '-' in protocol 'hs2-http' dropped as |
| 168 | # '-' is not allowed in Impala table name even delimited with ``. |
| 169 | qualified_table_name = '{0}.{1}_{2}_{3}'.format(unique_database, TEST_TBL_NOPART, |
| 170 | protocol if protocol != 'hs2-http' else 'hs2http', enable_async_load_data) |
| 171 | |
| 172 | # Form a staging path that is protocol and enable_async_load_data dependent to |
| 173 | # allow parallel creating distinct HDFS directories for each test object. |
| 174 | staging_path = "{0}_{1}_{2}".format(STAGING_PATH, protocol, enable_async_load_data) |
| 175 | |
| 176 | # Put some data into the staging path |
| 177 | self.filesystem_client.delete_file_dir(staging_path, recursive=True) |
| 178 | self.filesystem_client.make_dir(staging_path, permission=777) |
| 179 | self.filesystem_client.copy(ALLTYPES_PATH, "{0}/100101.txt".format(staging_path)) |
| 180 | |
| 181 | # Create a table with the staging path |
| 182 | self.client.execute("create table {0} like functional.alltypesnopart \ |
| 183 | location \'{1}\'".format(qualified_table_name, staging_path)) |
| 184 | |
| 185 | try: |
| 186 | |
| 187 | # The load data is going to need the metadata of the table. To avoid flakiness |
| 188 | # about metadata loading, this selects from the table first to get the metadata |
| 189 | # loaded. |
| 190 | self.execute_query_expect_success(client, |
| 191 | "select count(*) from {0}".format(qualified_table_name)) |
| 192 | |
| 193 | # Configure whether to use async LOAD and add an appropriate delay of 3 seconds |
| 194 | new_vector = deepcopy(vector) |
| 195 | new_vector.get_value('exec_option')['enable_async_load_data_execution'] = \ |
| 196 | enable_async_load_data |
| 197 | delay = "CRS_DELAY_BEFORE_LOAD_DATA:SLEEP@3000" |
| 198 | new_vector.get_value('exec_option')['debug_action'] = "{0}".format(delay) |
| 199 | load_stmt = "load data inpath \'{1}\' \ |
| 200 | into table {0}".format(qualified_table_name, staging_path) |
| 201 | exec_start = time.time() |
| 202 | handle = self.execute_query_async_using_client(client, load_stmt, new_vector) |
| 203 | exec_end = time.time() |
| 204 | exec_time = exec_end - exec_start |
| 205 | exec_end_state = client.get_impala_exec_state(handle) |
| 206 | |
| 207 | # Wait for the statement to finish with a timeout of 20 seconds |
| 208 | # (30 seconds without shortcircuit reads) |
| 209 | wait_time = 20 if IS_HDFS else 30 |
| 210 | wait_start = time.time() |
| 211 | client.wait_for_impala_state(handle, FINISHED, wait_time) |
| 212 | wait_end = time.time() |
| 213 | wait_time = wait_end - wait_start |
| 214 | self.close_query_using_client(client, handle) |
| 215 | if enable_async_load_data: |
| 216 | # In async mode: |
| 217 | # The compilation of LOAD is processed in the exec step without delay. And the |
| 218 | # processing of the LOAD plan is in wait step with delay. Relax the wait time |
| 219 | # to at least 2 seconds because wait_start not strictly starts at the point |
nothing calls this directly
no test coverage detected