Message ID | 2fdd8ea11331da13ec56d511fe4cadd47544419f.1711685809.git.gitgitgadget@gmail.com (mailing list archive) |
---|---|
State | Superseded |
Headers | show |
Series | reftable/stack: use geometric table compaction | expand |
"Justin Tobler via GitGitGadget" <gitgitgadget@gmail.com> writes: > From: Justin Tobler <jltobler@gmail.com> > > 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_NO_AUTOCOMPACTION` environment variable that, when > set, disables autocompaction of reftables. "when set" -> "when set to true"? > Signed-off-by: Justin Tobler <jltobler@gmail.com> > --- > reftable/stack.c | 2 +- > reftable/system.h | 1 + > t/t0610-reftable-basics.sh | 15 +++++++++++++++ > 3 files changed, 17 insertions(+), 1 deletion(-) > > diff --git a/reftable/stack.c b/reftable/stack.c > index 1ecf1b9751c..07262beaaf7 100644 > --- a/reftable/stack.c > +++ b/reftable/stack.c > @@ -681,7 +681,7 @@ int reftable_addition_commit(struct reftable_addition *add) > if (err) > goto done; > > - if (!add->stack->disable_auto_compact) > + if (!add->stack->disable_auto_compact && !git_env_bool("GIT_TEST_REFTABLE_NO_AUTOCOMPACTION", 0)) > err = reftable_stack_auto_compact(add->stack); > > done: > diff --git a/reftable/system.h b/reftable/system.h > index 5d8b6dede50..05b7c8554af 100644 > --- a/reftable/system.h > +++ b/reftable/system.h > @@ -17,6 +17,7 @@ license that can be found in the LICENSE file or at > #include "tempfile.h" > #include "hash-ll.h" /* hash ID, sizes.*/ > #include "dir.h" /* remove_dir_recursively, for tests.*/ > +#include "parse.h" > > int hash_size(uint32_t id); > > diff --git a/t/t0610-reftable-basics.sh b/t/t0610-reftable-basics.sh > index 686781192eb..434044078ed 100755 > --- a/t/t0610-reftable-basics.sh > +++ b/t/t0610-reftable-basics.sh > @@ -299,6 +299,21 @@ test_expect_success 'ref transaction: writes cause auto-compaction' ' > test_line_count = 1 repo/.git/reftable/tables.list > ' > > +test_expect_success 'ref transaction: environment variable disables auto-compaction' ' > + test_when_finished "rm -rf repo" && > + > + git init repo && > + test_commit -C repo A && > + for i in $(test_seq 20) > + do > + GIT_TEST_REFTABLE_NO_AUTOCOMPACTION=true git -C repo update-ref branch-$i HEAD || return 1 > + done && > + test_line_count = 23 repo/.git/reftable/tables.list && I am not sure if it is a sensible assumption that init + test_commit (which itself is opaque) will create exactly 3 tables forever, even if it may happen to be true right now. Shouldn't you be counting the lines before entering the for loop and adding 20 to that number to set the expectation? > + git -C repo update-ref foo HEAD && > + test_line_count = 1 repo/.git/reftable/tables.list > +' > + > check_fsync_events () { > local trace="$1" && > shift &&
"Justin Tobler via GitGitGadget" <gitgitgadget@gmail.com> writes: > - if (!add->stack->disable_auto_compact) > + if (!add->stack->disable_auto_compact && !git_env_bool("GIT_TEST_REFTABLE_NO_AUTOCOMPACTION", 0)) Fold the line after " &&", i.e. if (!add->stack->disable_auto_compact && !git_env_bool("GIT_TEST_REFTABLE_NO_AUTOCOMPACTION", 0)) > diff --git a/reftable/system.h b/reftable/system.h > index 5d8b6dede50..05b7c8554af 100644 > --- a/reftable/system.h > +++ b/reftable/system.h > @@ -17,6 +17,7 @@ license that can be found in the LICENSE file or at > #include "tempfile.h" > #include "hash-ll.h" /* hash ID, sizes.*/ > #include "dir.h" /* remove_dir_recursively, for tests.*/ > +#include "parse.h" > > int hash_size(uint32_t id); > > diff --git a/t/t0610-reftable-basics.sh b/t/t0610-reftable-basics.sh > index 686781192eb..434044078ed 100755 > --- a/t/t0610-reftable-basics.sh > +++ b/t/t0610-reftable-basics.sh > @@ -299,6 +299,21 @@ test_expect_success 'ref transaction: writes cause auto-compaction' ' > test_line_count = 1 repo/.git/reftable/tables.list > ' > > +test_expect_success 'ref transaction: environment variable disables auto-compaction' ' > + test_when_finished "rm -rf repo" && > + > + git init repo && > + test_commit -C repo A && > + for i in $(test_seq 20) > + do > + GIT_TEST_REFTABLE_NO_AUTOCOMPACTION=true git -C repo update-ref branch-$i HEAD || return 1 Fold the line before "git", i.e. GIT_TEST_REFTABLE_NO_AUTOCOMPACTION=true \ git -C repo update-ref branch-$i HEAD || return 1 > + done && > + test_line_count = 23 repo/.git/reftable/tables.list && > + > + git -C repo update-ref foo HEAD && > + test_line_count = 1 repo/.git/reftable/tables.list > +' > + > check_fsync_events () { > local trace="$1" && > shift &&
On Fri, Mar 29, 2024 at 04:16:47AM +0000, Justin Tobler via GitGitGadget wrote: > From: Justin Tobler <jltobler@gmail.com> > > 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_NO_AUTOCOMPACTION` environment variable that, when > set, disables autocompaction of reftables. > > Signed-off-by: Justin Tobler <jltobler@gmail.com> > --- > reftable/stack.c | 2 +- > reftable/system.h | 1 + > t/t0610-reftable-basics.sh | 15 +++++++++++++++ > 3 files changed, 17 insertions(+), 1 deletion(-) > > diff --git a/reftable/stack.c b/reftable/stack.c > index 1ecf1b9751c..07262beaaf7 100644 > --- a/reftable/stack.c > +++ b/reftable/stack.c > @@ -681,7 +681,7 @@ int reftable_addition_commit(struct reftable_addition *add) > if (err) > goto done; > > - if (!add->stack->disable_auto_compact) > + if (!add->stack->disable_auto_compact && !git_env_bool("GIT_TEST_REFTABLE_NO_AUTOCOMPACTION", 0)) > err = reftable_stack_auto_compact(add->stack); The double-negation in `GIT_TEST_REFTABLE_NO_AUTOCOMPACTION=false` may be somewhat hard to parse. Should we rename this to `GIT_TEST_REFTABLE_AUTO_COMPACTION` with a default value of `1`? Patrick > done: > diff --git a/reftable/system.h b/reftable/system.h > index 5d8b6dede50..05b7c8554af 100644 > --- a/reftable/system.h > +++ b/reftable/system.h > @@ -17,6 +17,7 @@ license that can be found in the LICENSE file or at > #include "tempfile.h" > #include "hash-ll.h" /* hash ID, sizes.*/ > #include "dir.h" /* remove_dir_recursively, for tests.*/ > +#include "parse.h" > > int hash_size(uint32_t id); > > diff --git a/t/t0610-reftable-basics.sh b/t/t0610-reftable-basics.sh > index 686781192eb..434044078ed 100755 > --- a/t/t0610-reftable-basics.sh > +++ b/t/t0610-reftable-basics.sh > @@ -299,6 +299,21 @@ test_expect_success 'ref transaction: writes cause auto-compaction' ' > test_line_count = 1 repo/.git/reftable/tables.list > ' > > +test_expect_success 'ref transaction: environment variable disables auto-compaction' ' > + test_when_finished "rm -rf repo" && > + > + git init repo && > + test_commit -C repo A && > + for i in $(test_seq 20) > + do > + GIT_TEST_REFTABLE_NO_AUTOCOMPACTION=true git -C repo update-ref branch-$i HEAD || return 1 > + done && > + test_line_count = 23 repo/.git/reftable/tables.list && > + > + git -C repo update-ref foo HEAD && > + test_line_count = 1 repo/.git/reftable/tables.list > +' > + > check_fsync_events () { > local trace="$1" && > shift && > -- > gitgitgadget >
Patrick Steinhardt <ps@pks.im> writes: >> - if (!add->stack->disable_auto_compact) >> + if (!add->stack->disable_auto_compact && !git_env_bool("GIT_TEST_REFTABLE_NO_AUTOCOMPACTION", 0)) >> err = reftable_stack_auto_compact(add->stack); > > The double-negation in `GIT_TEST_REFTABLE_NO_AUTOCOMPACTION=false` may be > somewhat hard to parse. Should we rename this to > `GIT_TEST_REFTABLE_AUTO_COMPACTION` with a default value of `1`? Sounds like a nice improvement. Also the overlong line should be folded. Thanks.
diff --git a/reftable/stack.c b/reftable/stack.c index 1ecf1b9751c..07262beaaf7 100644 --- a/reftable/stack.c +++ b/reftable/stack.c @@ -681,7 +681,7 @@ int reftable_addition_commit(struct reftable_addition *add) if (err) goto done; - if (!add->stack->disable_auto_compact) + if (!add->stack->disable_auto_compact && !git_env_bool("GIT_TEST_REFTABLE_NO_AUTOCOMPACTION", 0)) err = reftable_stack_auto_compact(add->stack); done: diff --git a/reftable/system.h b/reftable/system.h index 5d8b6dede50..05b7c8554af 100644 --- a/reftable/system.h +++ b/reftable/system.h @@ -17,6 +17,7 @@ license that can be found in the LICENSE file or at #include "tempfile.h" #include "hash-ll.h" /* hash ID, sizes.*/ #include "dir.h" /* remove_dir_recursively, for tests.*/ +#include "parse.h" int hash_size(uint32_t id); diff --git a/t/t0610-reftable-basics.sh b/t/t0610-reftable-basics.sh index 686781192eb..434044078ed 100755 --- a/t/t0610-reftable-basics.sh +++ b/t/t0610-reftable-basics.sh @@ -299,6 +299,21 @@ test_expect_success 'ref transaction: writes cause auto-compaction' ' test_line_count = 1 repo/.git/reftable/tables.list ' +test_expect_success 'ref transaction: environment variable disables auto-compaction' ' + test_when_finished "rm -rf repo" && + + git init repo && + test_commit -C repo A && + for i in $(test_seq 20) + do + GIT_TEST_REFTABLE_NO_AUTOCOMPACTION=true git -C repo update-ref branch-$i HEAD || return 1 + done && + test_line_count = 23 repo/.git/reftable/tables.list && + + git -C repo update-ref foo HEAD && + test_line_count = 1 repo/.git/reftable/tables.list +' + check_fsync_events () { local trace="$1" && shift &&