diff --git a/nodejs/__test__/connection.test.ts b/nodejs/__test__/connection.test.ts index d195a0ca4..45c678cd3 100644 --- a/nodejs/__test__/connection.test.ts +++ b/nodejs/__test__/connection.test.ts @@ -7,6 +7,13 @@ import * as tmp from "tmp"; import { Connection, Table, connect, connectNamespace } from "../lancedb"; import { LocalTable } from "../lancedb/table"; +// The `_versions` directory may also contain `latest_version_hint.json`, which +// Lance writes on non-lexically-ordered stores (e.g. the local filesystem) to +// speed up latest-version lookup. Only assert on manifest files. +function manifestFiles(versionsDir: string): string[] { + return readdirSync(versionsDir).filter((f) => f.endsWith(".manifest")); +} + describe("when connecting", () => { let tmpDir: tmp.DirResult; beforeEach(() => { @@ -171,7 +178,7 @@ describe("given a connection", () => { let manifestDir = tmpDir.name + "/test_manifest_paths_v2_empty.lance/_versions"; - readdirSync(manifestDir).forEach((file) => { + manifestFiles(manifestDir).forEach((file) => { expect(file).toMatch(/^\d{20}\.manifest$/); }); @@ -180,7 +187,7 @@ describe("given a connection", () => { })) as LocalTable; expect(await table.usesV2ManifestPaths()).toBe(true); manifestDir = tmpDir.name + "/test_manifest_paths_v2.lance/_versions"; - readdirSync(manifestDir).forEach((file) => { + manifestFiles(manifestDir).forEach((file) => { expect(file).toMatch(/^\d{20}\.manifest$/); }); }); @@ -199,14 +206,14 @@ describe("given a connection", () => { const manifestDir = tmpDir.name + "/test_manifest_path_migration.lance/_versions"; - readdirSync(manifestDir).forEach((file) => { + manifestFiles(manifestDir).forEach((file) => { expect(file).toMatch(/^\d\.manifest$/); }); await table.migrateManifestPathsV2(); expect(await table.usesV2ManifestPaths()).toBe(true); - readdirSync(manifestDir).forEach((file) => { + manifestFiles(manifestDir).forEach((file) => { expect(file).toMatch(/^\d{20}\.manifest$/); }); }); diff --git a/python/python/tests/test_db.py b/python/python/tests/test_db.py index d3db372de..0230c11d0 100644 --- a/python/python/tests/test_db.py +++ b/python/python/tests/test_db.py @@ -450,6 +450,13 @@ async def test_create_exist_ok_async(tmp_db_async: lancedb.AsyncConnection): # await db.create_table("test", schema=bad_schema, exist_ok=True) +def _manifest_files(versions_dir): + # The `_versions` directory may also contain `latest_version_hint.json`, + # which Lance writes on non-lexically-ordered stores (e.g. the local + # filesystem) to speed up latest-version lookup. Only assert on manifests. + return [f for f in os.listdir(versions_dir) if f.endswith(".manifest")] + + @pytest.mark.asyncio async def test_create_table_v2_manifest_paths_async(tmp_path): db_with_v2_paths = await lancedb.connect_async( @@ -465,7 +472,7 @@ async def test_create_table_v2_manifest_paths_async(tmp_path): ) assert await tbl.uses_v2_manifest_paths() manifests_dir = tmp_path / "test_v2_manifest_paths.lance" / "_versions" - for manifest in os.listdir(manifests_dir): + for manifest in _manifest_files(manifests_dir): assert re.match(r"\d{20}\.manifest", manifest) # Start a table in V1 mode then migrate @@ -475,13 +482,13 @@ async def test_create_table_v2_manifest_paths_async(tmp_path): ) assert not await tbl.uses_v2_manifest_paths() manifests_dir = tmp_path / "test_v2_migration.lance" / "_versions" - for manifest in os.listdir(manifests_dir): + for manifest in _manifest_files(manifests_dir): assert re.match(r"\d\.manifest", manifest) await tbl.migrate_manifest_paths_v2() assert await tbl.uses_v2_manifest_paths() - for manifest in os.listdir(manifests_dir): + for manifest in _manifest_files(manifests_dir): assert re.match(r"\d{20}\.manifest", manifest)