From: Tomi Ollila <tomi.ollila@iki.fi>
To: David Bremner <david@tethera.net>, notmuch@notmuchmail.org
Subject: Re: [PATCH] test: add (back) upgrade tests
Date: Sun, 17 Jan 2021 17:55:26 +0200 [thread overview]
Message-ID: <m24kjf8snl.fsf@guru.guru-group.fi> (raw)
In-Reply-To: <20210117124712.1298562-1-david@tethera.net>
On Sun, Jan 17 2021, David Bremner wrote:
> In ee897cab8b721 the upgrade tests from pre v3 databases were
> removed. The reasons for that are still valid, but we should still
> test the code paths that do the upgrade, and it is relatively
> straightforward to do that for v3 to v3 upgrades.
> ---
> test/README | 1 +
> test/T530-upgrade.sh | 51 ++++++++++++++++++++++++++++++++++++++++++++
> test/test-lib.sh | 1 +
> 3 files changed, 53 insertions(+)
> create mode 100755 test/T530-upgrade.sh
>
> diff --git a/test/README b/test/README
> index 11eaf18f..10f127cb 100644
> --- a/test/README
> +++ b/test/README
> @@ -25,6 +25,7 @@ that you know if you break anything.
> - gdb(1)
> - gpg(1)
> - python(1)
> + - xapian-metadata(1)
>
> If your system lacks these tools or have older, non-upgradable versions
> of these, please (possibly compile and) install these to some other
> diff --git a/test/T530-upgrade.sh b/test/T530-upgrade.sh
> new file mode 100755
> index 00000000..bdd8d282
> --- /dev/null
> +++ b/test/T530-upgrade.sh
> @@ -0,0 +1,51 @@
> +#!/usr/bin/env bash
> +test_description='database upgrades'
> +. $(dirname "$0")/test-lib.sh || exit 1
> +
> +test_require_external_prereq xapian-metadata
> +
> +XAPIAN_PATH=$MAIL_DIR/.notmuch/xapian
> +BACKUP_PATH=$MAIL_DIR/.notmuch
> +
> +delete_feature () {
> + local key=$1
> + features=$(xapian-metadata get $XAPIAN_PATH features | grep -v "^$key")
> + xapian-metadata set $XAPIAN_PATH features "$features"
> +}
> +
> +add_email_corpus
> +
> +for key in 'multiple paths per message' 'relative directory paths' 'exact folder:/path: search' \
could be split "earlier" so that this fits into 80 columns...
> + 'mail documents for missing messages' \
> + 'modification tracking'; do
> + backup_database
> + test_begin_subtest "upgrade is triggered by missing '$key'"
> + delete_feature "$key"
> + output=$(notmuch new | grep Welcome)
> + test_expect_equal "$output" "Welcome to a new version of notmuch! Your database will now be upgraded."
(here we have to tolerate long line)
> + restore_database
> +
> + backup_database
> + test_begin_subtest "backup can be restored ['$key']"
> + notmuch dump > BEFORE
> + delete_feature "$key"
> + notmuch new | grep "\(Welcome\|backup\)" > OUTPUT
could do grep -e Welcome -e backup (but above is fine too)
> + notmuch tag -inbox '*'
> + dump_file=$(ls ${BACKUP_PATH}/dump*)
$(echo ${BACKUP_PATH}/dump*)
(so using shell builtin instead of external command)
> + notmuch restore --input=$dump_file >> OUTPUT
> + notmuch dump > AFTER
> + test_expect_equal_file BEFORE AFTER
> + restore_database
> +
> +done
> +
> +for key in 'from/subject/message-ID in database' 'indexed MIME types' 'index body and headers separately'; do
clould be split "earlier" so lines fit into 80 columns
> + backup_database
> + test_begin_subtest "upgrade not triggered by missing '$key'"
> + delete_feature "$key"
> + output=$(notmuch new | grep Welcome)
> + test_expect_equal "$output" ""
> + restore_database
> +done
> +
> +test_done
> diff --git a/test/test-lib.sh b/test/test-lib.sh
> index c23a0d20..29baa0c1 100644
> --- a/test/test-lib.sh
> +++ b/test/test-lib.sh
> @@ -1270,3 +1270,4 @@ test_declare_external_prereq gpg
> test_declare_external_prereq openssl
> test_declare_external_prereq gpgsm
> test_declare_external_prereq ${NOTMUCH_PYTHON}
> +test_declare_external_prereq xapian-metadata
> --
> 2.29.2
> _______________________________________________
> notmuch mailing list -- notmuch@notmuchmail.org
> To unsubscribe send an email to notmuch-leave@notmuchmail.org
next prev parent reply other threads:[~2021-01-17 15:55 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-01-17 12:47 [PATCH] test: add (back) upgrade tests David Bremner
2021-01-17 15:55 ` Tomi Ollila [this message]
2021-01-17 17:28 ` David Bremner
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: https://notmuchmail.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=m24kjf8snl.fsf@guru.guru-group.fi \
--to=tomi.ollila@iki.fi \
--cc=david@tethera.net \
--cc=notmuch@notmuchmail.org \
/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://yhetil.org/notmuch.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).