git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Patrick Steinhardt <ps@pks.im>
To: Han-Wen Nienhuys <hanwen@google.com>
Cc: Junio C Hamano <gitster@pobox.com>, git@vger.kernel.org
Subject: Re: [PATCH 00/11] t: reduce direct disk access to data structures
Date: Mon, 23 Oct 2023 15:58:12 +0200	[thread overview]
Message-ID: <ZTZ79DENl6c-1C0q@tanuki> (raw)
In-Reply-To: <CAFQ2z_Om724+o+EG1FAhC9VrvJECnQ5UA+Z04Rzycpi_mXvMHg@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 3406 bytes --]

On Thu, Oct 19, 2023 at 12:13:12PM +0200, Han-Wen Nienhuys wrote:
> On Wed, Oct 18, 2023 at 5:32 PM Junio C Hamano <gitster@pobox.com> wrote:
> > > this patch series refactors a bunch of our tests to perform less direct
> > > disk access to on-disk data structures. Instead, the tests are converted
> > > to use Git tools or our test-tool to access data to the best extent
> > > possible. This serves two benefits:
> >
> > Laudable goal.
> >
> > >     - We increase test coverage of our own code base.
> >
> > Meaning the new code added to test-tool for this series will also
> > get tested and bugs spotted?

For now all the helpers of the test-tool only have implicit test
coverage, but I get your point. If we decide to instead transform this
test tool into production-level code as you suggested (e.g. `git
rev-parse --exists`) then this becomes less of a discussion point as we
would of course have proper test coverage for it.

> > >     - We become less dependent on the actual on-disk format.
> >
> > Yes, this is very desirable.  Without looking at the implementation,
> > I see some issues aiming for this goal may involve. [a] using the
> > production code for validation would mean our expectation to be
> > compared to the reality to be validated can be affected by the same
> > bug, making two wrongs to appear right; [b] using a separate
> > implementation used only for validation would at least mean we will
> > have to make the same mistake in unique part of both implementations
> > that is less likely to miss bugs compared to [a], but bugs in shared
> > part of the production code and validation code will be hidden the
> > same way as [a].
> 
> I think it would be really great if there were separate unittests for
> the ref backend API. Some of the reftable work was needlessly
> difficult because the contract of the API was underspecified. The API
> is well compartmentalized in refs-internal.h, and a lot of the API
> behavior can be tested as a black box, eg.
> 
> * setup symref HEAD pointing to R1
> * setup transaction updating ref R1 from C1 to C2
> * commit transaction, check that it succeeds
> * read ref R1, check if it is C2
> * read reflog for R1, see that it has a C1 => C2 update
> * read reflog for HEAD, see that it has a C1 => C2 update
> 
> Tests for the loose/packed backend could directly mess with the
> on-disk files to test failure scenarios.
> 
> With unittests like that, the tests can zoom in on the functionality
> of the ref backend, and provide more convenient coverage for
> dynamic/static analysis.

Agreed. Ideally, I think our tests should be split up into two layers:

    1. Low-level tests which are backend specific. These allow us to
       assert the on-disk state of the respective backend thoroughly and
       also allow us to explicitly test for edge cases that are only of
       relevance to this specific backend.

       The reftable backend in its current (non-upstream) already has
       such tests, but we don't really have explicit tests for the files
       backend. This is a gap that should ideally be filled at some
       point in time.

    2. Higher-level tests should then be allowed to assume that the
       underlying logic works as expected. These tests are thus free to
       use plumbing tools that tie into the reference backends.

Patrick

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

  parent reply	other threads:[~2023-10-23 13:58 UTC|newest]

Thread overview: 59+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-18  5:35 [PATCH 00/11] t: reduce direct disk access to data structures Patrick Steinhardt
2023-10-18  5:35 ` [PATCH 01/11] t: add helpers to test for reference existence Patrick Steinhardt
2023-10-18 16:06   ` Junio C Hamano
2023-10-23 13:58     ` Patrick Steinhardt
2023-10-18 17:08   ` Eric Sunshine
2023-10-23 13:58     ` Patrick Steinhardt
2023-10-18  5:35 ` [PATCH 02/11] t: allow skipping expected object ID in `ref-store update-ref` Patrick Steinhardt
2023-10-18 16:08   ` Junio C Hamano
2023-10-23 13:58     ` Patrick Steinhardt
2023-10-23 19:06       ` Junio C Hamano
2023-10-18  5:35 ` [PATCH 03/11] t: convert tests to use helpers for reference existence Patrick Steinhardt
2023-10-18 16:28   ` Junio C Hamano
2023-10-18  5:35 ` [PATCH 04/11] t: convert tests to not write references via the filesystem Patrick Steinhardt
2023-10-18 18:34   ` Junio C Hamano
2023-10-23 13:58     ` Patrick Steinhardt
2023-10-23 19:10       ` Junio C Hamano
2023-10-18 21:18   ` Junio C Hamano
2023-10-23 13:58     ` Patrick Steinhardt
2023-10-18  5:35 ` [PATCH 05/11] t: convert tests to not access symrefs " Patrick Steinhardt
2023-10-20 19:52   ` Junio C Hamano
2023-10-18  5:35 ` [PATCH 06/11] t: convert tests to not access reflog " Patrick Steinhardt
2023-10-21 23:13   ` Junio C Hamano
2023-10-18  5:35 ` [PATCH 07/11] t1450: convert tests to remove worktrees via git-worktree(1) Patrick Steinhardt
2023-10-18  5:35 ` [PATCH 08/11] t4207: delete replace references via git-update-ref(1) Patrick Steinhardt
2023-10-18 13:27   ` Han-Wen Nienhuys
2023-10-23 13:58     ` Patrick Steinhardt
2023-10-23 16:42   ` Taylor Blau
2023-10-24  6:42     ` Patrick Steinhardt
2023-10-18  5:35 ` [PATCH 09/11] t7300: assert exact states of repo Patrick Steinhardt
2023-10-18  5:35 ` [PATCH 10/11] t7900: assert the absence of refs via git-for-each-ref(1) Patrick Steinhardt
2023-10-18  5:35 ` [PATCH 11/11] t: mark several tests that assume the files backend with REFFILES Patrick Steinhardt
2023-10-18  5:39 ` [PATCH 00/11] t: reduce direct disk access to data structures Patrick Steinhardt
2023-10-18 23:40   ` Junio C Hamano
2023-10-23 11:57     ` Patrick Steinhardt
2023-10-18 15:32 ` Junio C Hamano
2023-10-19 10:13   ` Han-Wen Nienhuys
2023-10-19 17:55     ` Junio C Hamano
2023-10-23 13:58     ` Patrick Steinhardt [this message]
2023-10-24 14:04 ` [PATCH v2 0/9] " Patrick Steinhardt
2023-10-24 14:04   ` [PATCH v2 1/9] t: allow skipping expected object ID in `ref-store update-ref` Patrick Steinhardt
2023-10-24 14:04   ` [PATCH v2 2/9] t: convert tests to not write references via the filesystem Patrick Steinhardt
2023-10-24 14:05   ` [PATCH v2 3/9] t: convert tests to not access symrefs " Patrick Steinhardt
2023-10-24 14:05   ` [PATCH v2 4/9] t: convert tests to not access reflog " Patrick Steinhardt
2023-10-24 14:05   ` [PATCH v2 5/9] t1450: convert tests to remove worktrees via git-worktree(1) Patrick Steinhardt
2023-10-27  2:42     ` Eric Sunshine
2023-10-24 14:05   ` [PATCH v2 6/9] t4207: delete replace references via git-update-ref(1) Patrick Steinhardt
2023-10-24 14:05   ` [PATCH v2 7/9] t7300: assert exact states of repo Patrick Steinhardt
2023-10-24 14:05   ` [PATCH v2 8/9] t7900: assert the absence of refs via git-for-each-ref(1) Patrick Steinhardt
2023-10-24 14:05   ` [PATCH v2 9/9] t: mark several tests that assume the files backend with REFFILES Patrick Steinhardt
2023-11-02  8:46 ` [PATCH v3 0/9] t: reduce direct disk access to data structures Patrick Steinhardt
2023-11-02  8:46   ` [PATCH v3 1/9] t: allow skipping expected object ID in `ref-store update-ref` Patrick Steinhardt
2023-11-02  8:46   ` [PATCH v3 2/9] t: convert tests to not write references via the filesystem Patrick Steinhardt
2023-11-02  8:46   ` [PATCH v3 3/9] t: convert tests to not access symrefs " Patrick Steinhardt
2023-11-02  8:46   ` [PATCH v3 4/9] t: convert tests to not access reflog " Patrick Steinhardt
2023-11-02  8:46   ` [PATCH v3 5/9] t1450: convert tests to remove worktrees via git-worktree(1) Patrick Steinhardt
2023-11-02  8:47   ` [PATCH v3 6/9] t4207: delete replace references via git-update-ref(1) Patrick Steinhardt
2023-11-02  8:47   ` [PATCH v3 7/9] t7300: assert exact states of repo Patrick Steinhardt
2023-11-02  8:47   ` [PATCH v3 8/9] t7900: assert the absence of refs via git-for-each-ref(1) Patrick Steinhardt
2023-11-02  8:47   ` [PATCH v3 9/9] t: mark several tests that assume the files backend with REFFILES Patrick Steinhardt

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

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ZTZ79DENl6c-1C0q@tanuki \
    --to=ps@pks.im \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=hanwen@google.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.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

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 read-only IMAP folder(s) and NNTP newsgroup(s).