reftable/stack: add env to disable autocompaction

In future tests it will be neccesary to create repositories with a set number of tables. To make this easier, introduce the `GIT_TEST_REFTABLE_AUTOCOMPACTION` environment variable that, when set to false, disables autocompaction of reftables. Signed-off-by: Justin Tobler <jltobler@gmail.com> Acked-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Justin Tobler committed Apr 8, 2024 at 16:16 UTC 7c8eb5928f3ae504f9ce92b67a1eb41db82d81f7
2 files changed +24
refs/reftable-backend.c
+3
@@ -18,6 +18,7 @@
18 #include "../reftable/reftable-merged.h"
19 #include "../setup.h"
20 #include "../strmap.h"
21 +#include "parse.h"
22 #include "refs-internal.h"
23
24 /*
@@ -247,6 +248,8 @@ static struct ref_store *reftable_be_init(struct repository *repo,
248 refs->write_options.block_size = 4096;
249 refs->write_options.hash_id = repo->hash_algo->format_id;
250 refs->write_options.default_permissions = calc_shared_perm(0666 & ~mask);
251 + refs->write_options.disable_auto_compact =
252 + !git_env_bool("GIT_TEST_REFTABLE_AUTOCOMPACTION", 1);
253
254 /*
255 * Set up the main reftable stack that is hosted in GIT_COMMON_DIR.
t/t0610-reftable-basics.sh
+21
@@ -299,6 +299,27 @@ test_expect_success 'ref transaction: writes cause auto-compaction' '
299 test_line_count = 1 repo/.git/reftable/tables.list
300 '
301
302 +test_expect_success 'ref transaction: env var disables compaction' '
303 + test_when_finished "rm -rf repo" &&
304 +
305 + git init repo &&
306 + test_commit -C repo A &&
307 +
308 + start=$(wc -l <repo/.git/reftable/tables.list) &&
309 + iterations=5 &&
310 + expected=$((start + iterations)) &&
311 +
312 + for i in $(test_seq $iterations)
313 + do
314 + GIT_TEST_REFTABLE_AUTOCOMPACTION=false \
315 + git -C repo update-ref branch-$i HEAD || return 1
316 + done &&
317 + test_line_count = $expected repo/.git/reftable/tables.list &&
318 +
319 + git -C repo update-ref foo HEAD &&
320 + test_line_count -lt $expected repo/.git/reftable/tables.list
321 +'
322 +
323 check_fsync_events () {
324 local trace="$1" &&
325 shift &&