MCPcopy Create free account
hub / github.com/apache/impala / cleanup_database

Function cleanup_database

tests/conftest.py:373–396  ·  view source on GitHub ↗
(client, db_name, must_exist)

Source from the content-addressed store, hash-verified

371 'characters.'.format(db_name))
372
373 def cleanup_database(client, db_name, must_exist):
374 # By default, dropping a database will move the files to the trash. Since the dev
375 # environment uses a long fs.trash.interval, these files will accumulate and
376 # waste disk space. To avoid that, we blast away the database directory (skipping
377 # trash) before dropping the database.
378 #
379 # When there are external tables, the external locations are not removed by cascade.
380 # These preexisting files/directories can cause errors when tests run repeatedly or
381 # use a data snapshot (see IMPALA-9702). Deleting the database directory prevents
382 # this as well.
383 db_location = "{0}/{1}.db".format(WAREHOUSE, db_name)
384 request.instance.filesystem_client.delete_file_dir(db_location, recursive=True)
385 for i in range(2):
386 try:
387 result = client.execute('DROP DATABASE {0} `{1}` CASCADE'.format(
388 "" if must_exist else "IF EXISTS", db_name))
389 break
390 except Exception as e:
391 if i == 0:
392 # Retry in case we hit IMPALA-14228.
393 LOG.warn("Ignored cleanup failure once: " + str(e))
394 else:
395 raise e
396 assert result.success
397
398 def cleanup():
399 with request.instance.create_impala_client(protocol=HS2) as client:

Callers 2

cleanupFunction · 0.85
unique_databaseFunction · 0.85

Calls 5

rangeFunction · 0.85
warnMethod · 0.80
formatMethod · 0.45
delete_file_dirMethod · 0.45
executeMethod · 0.45

Tested by

no test coverage detected