From: Patrick Steinhardt <ps@pks.im>
To: git@vger.kernel.org
Cc: Han-Wen Nienhuys <hanwenn@gmail.com>,
Jonathan Nieder <jrnieder@gmail.com>
Subject: [PATCH 4/8] reftable/stack: verify that `reftable_stack_add()` uses auto-compaction
Date: Tue, 21 Nov 2023 08:04:22 +0100 [thread overview]
Message-ID: <c9b4ac7916d1ee2474ad37eaa21073adcd54fc5d.1700549493.git.ps@pks.im> (raw)
In-Reply-To: <cover.1700549493.git.ps@pks.im>
[-- Attachment #1: Type: text/plain, Size: 2503 bytes --]
While we have several tests that check whether we correctly perform
auto-compaction when manually calling `reftable_stack_auto_compact()`,
we don't have any tests that verify whether `reftable_stack_add()` does
call it automatically. Add one.
Signed-off-by: Patrick Steinhardt <ps@pks.im>
---
reftable/stack_test.c | 47 +++++++++++++++++++++++++++++++++++++++++++
1 file changed, 47 insertions(+)
diff --git a/reftable/stack_test.c b/reftable/stack_test.c
index 0644c8ad2e..c979d177c2 100644
--- a/reftable/stack_test.c
+++ b/reftable/stack_test.c
@@ -850,6 +850,52 @@ static void test_reftable_stack_auto_compaction(void)
clear_dir(dir);
}
+static void test_reftable_stack_add_performs_auto_compaction(void)
+{
+ struct reftable_write_options cfg = { 0 };
+ struct reftable_stack *st = NULL;
+ char *dir = get_tmp_dir(__LINE__);
+ int err, i, n = 20;
+
+ err = reftable_new_stack(&st, dir, cfg);
+ EXPECT_ERR(err);
+
+ for (i = 0; i <= n; i++) {
+ struct reftable_ref_record ref = {
+ .update_index = reftable_stack_next_update_index(st),
+ .value_type = REFTABLE_REF_SYMREF,
+ .value.symref = "master",
+ };
+ char name[100];
+
+ /*
+ * Disable auto-compaction for all but the last runs. Like this
+ * we can ensure that we indeed honor this setting and have
+ * better control over when exactly auto compaction runs.
+ */
+ st->disable_auto_compact = i != n;
+
+ snprintf(name, sizeof(name), "branch%04d", i);
+ ref.refname = name;
+
+ err = reftable_stack_add(st, &write_test_ref, &ref);
+ EXPECT_ERR(err);
+
+ /*
+ * The stack length should grow continuously for all runs where
+ * auto compaction is disabled. When enabled, we should merge
+ * all tables in the stack.
+ */
+ if (i != n)
+ EXPECT(st->merged->stack_len == i + 1);
+ else
+ EXPECT(st->merged->stack_len == 1);
+ }
+
+ reftable_stack_destroy(st);
+ clear_dir(dir);
+}
+
static void test_reftable_stack_compaction_concurrent(void)
{
struct reftable_write_options cfg = { 0 };
@@ -960,6 +1006,7 @@ int stack_test_main(int argc, const char *argv[])
RUN_TEST(test_reftable_stack_add);
RUN_TEST(test_reftable_stack_add_one);
RUN_TEST(test_reftable_stack_auto_compaction);
+ RUN_TEST(test_reftable_stack_add_performs_auto_compaction);
RUN_TEST(test_reftable_stack_compaction_concurrent);
RUN_TEST(test_reftable_stack_compaction_concurrent_clean);
RUN_TEST(test_reftable_stack_hash_id);
--
2.42.0
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
next prev parent reply other threads:[~2023-11-21 7:04 UTC|newest]
Thread overview: 58+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-11-21 7:04 [PATCH 0/8] reftable: small set of fixes Patrick Steinhardt
2023-11-21 7:04 ` [PATCH 1/8] reftable: wrap EXPECT macros in do/while Patrick Steinhardt
2023-11-21 7:04 ` [PATCH 2/8] reftable: handle interrupted reads Patrick Steinhardt
2023-11-21 7:04 ` [PATCH 3/8] reftable: handle interrupted writes Patrick Steinhardt
2023-11-21 7:04 ` Patrick Steinhardt [this message]
2023-11-21 7:04 ` [PATCH 5/8] reftable/stack: perform auto-compaction with transactional interface Patrick Steinhardt
2023-12-21 10:29 ` Han-Wen Nienhuys
2023-12-21 10:45 ` Patrick Steinhardt
2023-11-21 7:04 ` [PATCH 6/8] reftable/stack: reuse buffers when reloading stack Patrick Steinhardt
2023-11-21 7:04 ` [PATCH 7/8] reftable/merged: reuse buffer to compute record keys Patrick Steinhardt
2023-12-21 10:48 ` Han-Wen Nienhuys
2023-11-21 7:04 ` [PATCH 8/8] reftable/stack: fix stale lock when dying Patrick Steinhardt
2023-12-08 14:52 ` [PATCH v2 00/11] reftable: small set of fixes Patrick Steinhardt
2023-12-08 14:52 ` [PATCH v2 01/11] reftable: wrap EXPECT macros in do/while Patrick Steinhardt
2023-12-08 14:53 ` [PATCH v2 02/11] reftable: handle interrupted reads Patrick Steinhardt
2023-12-08 21:30 ` Taylor Blau
2023-12-11 9:08 ` Patrick Steinhardt
2023-12-08 14:53 ` [PATCH v2 03/11] reftable: handle interrupted writes Patrick Steinhardt
2023-12-08 14:53 ` [PATCH v2 04/11] reftable/stack: verify that `reftable_stack_add()` uses auto-compaction Patrick Steinhardt
2023-12-08 21:35 ` Taylor Blau
2023-12-08 23:46 ` Eric Sunshine
2023-12-11 9:08 ` Patrick Steinhardt
2023-12-11 9:36 ` Eric Sunshine
2023-12-08 14:53 ` [PATCH v2 05/11] reftable/stack: perform auto-compaction with transactional interface Patrick Steinhardt
2023-12-08 22:14 ` Taylor Blau
2023-12-11 9:08 ` Patrick Steinhardt
2023-12-08 14:53 ` [PATCH v2 06/11] reftable/stack: reuse buffers when reloading stack Patrick Steinhardt
2023-12-08 22:17 ` Taylor Blau
2023-12-11 9:08 ` Patrick Steinhardt
2023-12-21 10:58 ` Han-Wen Nienhuys
2023-12-08 14:53 ` [PATCH v2 07/11] reftable/stack: fix stale lock when dying Patrick Steinhardt
2023-12-08 22:24 ` Taylor Blau
2023-12-11 9:08 ` Patrick Steinhardt
2023-12-08 14:53 ` [PATCH v2 08/11] reftable/stack: fix use of unseeded randomness Patrick Steinhardt
2023-12-21 10:49 ` Han-Wen Nienhuys
2023-12-08 14:53 ` [PATCH v2 09/11] reftable/merged: reuse buffer to compute record keys Patrick Steinhardt
2023-12-08 14:53 ` [PATCH v2 10/11] reftable/block: introduce macro to initialize `struct block_iter` Patrick Steinhardt
2023-12-08 14:53 ` [PATCH v2 11/11] reftable/block: reuse buffer to compute record keys Patrick Steinhardt
2023-12-21 10:43 ` Han-Wen Nienhuys
2023-12-28 5:53 ` Patrick Steinhardt
2023-12-08 22:26 ` [PATCH v2 00/11] reftable: small set of fixes Taylor Blau
2023-12-11 9:07 ` [PATCH v3 " Patrick Steinhardt
2023-12-11 9:07 ` [PATCH v3 01/11] reftable: wrap EXPECT macros in do/while Patrick Steinhardt
2023-12-11 9:07 ` [PATCH v3 02/11] reftable: handle interrupted reads Patrick Steinhardt
2023-12-11 9:07 ` [PATCH v3 03/11] reftable: handle interrupted writes Patrick Steinhardt
2023-12-11 9:07 ` [PATCH v3 04/11] reftable/stack: verify that `reftable_stack_add()` uses auto-compaction Patrick Steinhardt
2023-12-11 20:15 ` Taylor Blau
2023-12-12 3:44 ` Patrick Steinhardt
2023-12-11 9:07 ` [PATCH v3 05/11] reftable/stack: perform auto-compaction with transactional interface Patrick Steinhardt
2023-12-11 9:07 ` [PATCH v3 06/11] reftable/stack: reuse buffers when reloading stack Patrick Steinhardt
2023-12-11 9:07 ` [PATCH v3 07/11] reftable/stack: fix stale lock when dying Patrick Steinhardt
2023-12-11 9:07 ` [PATCH v3 08/11] reftable/stack: fix use of unseeded randomness Patrick Steinhardt
2023-12-11 9:08 ` [PATCH v3 09/11] reftable/merged: reuse buffer to compute record keys Patrick Steinhardt
2023-12-11 9:08 ` [PATCH v3 10/11] reftable/block: introduce macro to initialize `struct block_iter` Patrick Steinhardt
2023-12-11 9:08 ` [PATCH v3 11/11] reftable/block: reuse buffer to compute record keys Patrick Steinhardt
2023-12-11 20:16 ` [PATCH v3 00/11] reftable: small set of fixes Taylor Blau
2023-12-12 3:45 ` Patrick Steinhardt
2023-12-21 11:08 ` [PATCH 0/8] " Han-Wen Nienhuys
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=c9b4ac7916d1ee2474ad37eaa21073adcd54fc5d.1700549493.git.ps@pks.im \
--to=ps@pks.im \
--cc=git@vger.kernel.org \
--cc=hanwenn@gmail.com \
--cc=jrnieder@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).