Skip to content

Commit d4e9eeb

Browse files
authored
Avoid resource conflicts in integration tests by using a random dir name (#2865)
## Changes Replace hard-coded dir name with random one ### Linked issues Resolves #2797 ### Functionality None ### Tests - [x] ran integration tests --------- Co-authored-by: Eric Vergnaud <eric.vergnaud@databricks.com>
1 parent e06fd44 commit d4e9eeb

File tree

3 files changed

+11
-10
lines changed

3 files changed

+11
-10
lines changed

tests/integration/conftest.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -804,12 +804,12 @@ def config(self) -> WorkspaceConfig:
804804
renamed_group_prefix=f'tmp-{self.inventory_database}-',
805805
)
806806

807-
def save_locations(self) -> None:
807+
def save_locations(self, make_random) -> None:
808808
locations: list[ExternalLocation] = []
809809
if self.workspace_client.config.is_azure:
810-
locations = [ExternalLocation("abfss://things@labsazurethings.dfs.core.windows.net/a", 1)]
810+
locations = [ExternalLocation(f"abfss://things@labsazurethings.dfs.core.windows.net/a", 1)]
811811
if self.workspace_client.config.is_aws:
812-
locations = [ExternalLocation("s3://labs-things/a", 1)]
812+
locations = [ExternalLocation(f"s3://labs-things/a", 1)]
813813
self.sql_backend.save_table(
814814
f"{self.inventory_database}.external_locations",
815815
locations,

tests/integration/hive_metastore/test_migrate.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -700,7 +700,6 @@ def test_migrate_table_in_mount(
700700
env_or_skip,
701701
make_random,
702702
runtime_ctx,
703-
make_acc_group,
704703
):
705704
if not ws.config.is_azure:
706705
pytest.skip("temporary: only works in azure test env")
@@ -710,17 +709,18 @@ def test_migrate_table_in_mount(
710709
connect=ws.config,
711710
)
712711
runtime_ctx = runtime_ctx.replace(config=config)
712+
b_dir = make_random(4).lower()
713713
table_path = make_random(4).lower()
714714
src_schema = make_schema(
715715
catalog_name="hive_metastore",
716716
name=f"mounted_{env_or_skip('TEST_MOUNT_NAME')}_{table_path}",
717717
)
718718
src_external_table = runtime_ctx.make_table(
719719
schema_name=src_schema.name,
720-
external_delta=f"dbfs:/mnt/{env_or_skip('TEST_MOUNT_NAME')}/a/b/{table_path}",
720+
external_delta=f"dbfs:/mnt/{env_or_skip('TEST_MOUNT_NAME')}/a/{b_dir}/{table_path}",
721721
columns=[("1-0`.0-ugly-column", "STRING")], # Test with column that needs escaping
722722
)
723-
table_in_mount_location = f"abfss://things@labsazurethings.dfs.core.windows.net/a/b/{table_path}"
723+
table_in_mount_location = f"abfss://things@labsazurethings.dfs.core.windows.net/a/{b_dir}/{table_path}"
724724
# TODO: Remove this hack below
725725
# This is done because we have to create the external table in a mount point, but TablesInMounts() has to use the adls/ path
726726
# Otherwise, if we keep the dbfs:/ path, the entire logic of TablesInMounts won't work

tests/integration/hive_metastore/test_table_move.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -201,20 +201,21 @@ def test_alias_tables(
201201

202202

203203
def test_move_tables_table_properties_mismatch_preserves_original(
204-
ws, sql_backend, make_catalog, make_schema, make_table, make_acc_group, make_random, env_or_skip
205-
):
204+
ws, sql_backend, make_catalog, make_schema, make_table, make_random
205+
) -> None:
206206
table_move = TableMove(ws, sql_backend)
207207
from_catalog = make_catalog()
208208
from_schema = make_schema(catalog_name=from_catalog.name)
209+
b_dir = make_random(4).lower()
209210
tbl_path = make_random(4).lower()
210211
tbl_properties = {"delta.enableDeletionVectors": "true"}
211212
from_table_1 = make_table(
212213
catalog_name=from_catalog.name,
213214
schema_name=from_schema.name,
214-
external_delta=f"abfss://things@labsazurethings.dfs.core.windows.net/a/b/{tbl_path}",
215+
external_delta=f"abfss://things@labsazurethings.dfs.core.windows.net/a/{b_dir}/{tbl_path}",
215216
tbl_properties=tbl_properties,
216217
)
217-
table_in_mount_location = f"abfss://things@labsazurethings.dfs.core.windows.net/a/b/{tbl_path}"
218+
table_in_mount_location = f"abfss://things@labsazurethings.dfs.core.windows.net/a/{b_dir}/{tbl_path}"
218219
from_table_1.storage_location = table_in_mount_location
219220

220221
to_catalog = make_catalog()

0 commit comments

Comments
 (0)