Add tests for mmaped archive indexes.

This commit is contained in:
Nick Tobey
2025-07-24 15:24:28 -07:00
committed by nick
parent b17c7b35d6
commit cd684f4360
2 changed files with 29 additions and 1 deletions
+2 -1
View File
@@ -51,5 +51,6 @@ const (
EnvGCSafepointControllerChoice = "DOLT_GC_SAFEPOINT_CONTROLLER_CHOICE"
// Used for tests. If set, Dolt will error if it would rebuild a table's row data.
EnvAssertNoTableRewrite = "DOLT_TEST_ASSERT_NO_TABLE_REWRITE"
EnvAssertNoTableRewrite = "DOLT_TEST_ASSERT_NO_TABLE_REWRITE"
EnvAssertNoInMemoryArchiveIndex = "DOLT_TEST_ASSERT_NO_IN_MEMORY_ARCHIVE_INDEX"
)
+27
View File
@@ -522,3 +522,30 @@ teardown() {
dolt fsck
}
@test "archive: can mmap archive index" {
mkdir -p remote/.dolt
# Copy the archive test repo to remote directory
cp -R $BATS_TEST_DIRNAME/archive-test-repos/base/* remote/.dolt
cd remote
# When mmap_archive_indexes is not set in the config, or is set to false,
# setting DOLT_TEST_ASSERT_NO_IN_MEMORY_ARCHIVE_INDEX should result in an error
run env DOLT_TEST_ASSERT_NO_IN_MEMORY_ARCHIVE_INDEX=1 dolt sql -q 'select sum(i) from tbl;'
[ $status -ne 0 ]
echo "$output"
[[ $output =~ "attempted to load archive index into memory but DOLT_TEST_ASSERT_NO_IN_MEMORY_ARCHIVE_INDEX was set" ]] || false
dolt config --local --set "mmap_archive_indexes" false
run env DOLT_TEST_ASSERT_NO_IN_MEMORY_ARCHIVE_INDEX=1 dolt sql -q 'select sum(i) from tbl;'
[ $status -ne 0 ]
[[ $output =~ "attempted to load archive index into memory but DOLT_TEST_ASSERT_NO_IN_MEMORY_ARCHIVE_INDEX was set" ]] || false
dolt config --local --set "mmap_archive_indexes" true
# Verify we can read data
run env DOLT_TEST_ASSERT_NO_IN_MEMORY_ARCHIVE_INDEX=1 dolt sql -q 'select sum(i) from tbl;'
echo "$output"
[[ "$status" -eq 0 ]] || false
[[ "$output" =~ "138075" ]] || false # i = 1 - 525, sum is 138075
}