From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp2 ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms11 with LMTPS id kNFwFOcxBGC1LQAA0tVLHw (envelope-from ) for ; Sun, 17 Jan 2021 12:47:35 +0000 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp2 with LMTPS id iGs4EOcxBGAfZwAAB5/wlQ (envelope-from ) for ; Sun, 17 Jan 2021 12:47:35 +0000 Received: from mail.notmuchmail.org (nmbug.tethera.net [IPv6:2607:5300:201:3100::1657]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (2048 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id CADC59403A5 for ; Sun, 17 Jan 2021 12:47:34 +0000 (UTC) Received: from nmbug.tethera.net (localhost [127.0.0.1]) by mail.notmuchmail.org (Postfix) with ESMTP id C4DB529C96; Sun, 17 Jan 2021 07:47:26 -0500 (EST) Received: from fethera.tethera.net (fethera.tethera.net [198.245.60.197]) by mail.notmuchmail.org (Postfix) with ESMTP id 4F95627C7D for ; Sun, 17 Jan 2021 07:47:23 -0500 (EST) Received: by fethera.tethera.net (Postfix, from userid 1001) id C28AB5FF47; Sun, 17 Jan 2021 07:47:21 -0500 (EST) Received: (nullmailer pid 1298612 invoked by uid 1000); Sun, 17 Jan 2021 12:47:19 -0000 From: David Bremner To: notmuch@notmuchmail.org Cc: David Bremner Subject: [PATCH] test: add (back) upgrade tests Date: Sun, 17 Jan 2021 08:47:12 -0400 Message-Id: <20210117124712.1298562-1-david@tethera.net> X-Mailer: git-send-email 2.29.2 MIME-Version: 1.0 Message-ID-Hash: CG6UHOMQZZ4JRYRGU3U7CJ572U2VTGG4 X-Message-ID-Hash: CG6UHOMQZZ4JRYRGU3U7CJ572U2VTGG4 X-MailFrom: bremner@tethera.net X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-notmuch.notmuchmail.org-0; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header X-Mailman-Version: 3.2.1 Precedence: list List-Id: "Use and development of the notmuch mail system." List-Help: List-Post: List-Subscribe: List-Unsubscribe: Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Migadu-Flow: FLOW_IN X-Migadu-Spam-Score: -0.89 Authentication-Results: aspmx1.migadu.com; dkim=none; dmarc=none; spf=pass (aspmx1.migadu.com: domain of notmuch-bounces@notmuchmail.org designates 2607:5300:201:3100::1657 as permitted sender) smtp.mailfrom=notmuch-bounces@notmuchmail.org X-Migadu-Queue-Id: CADC59403A5 X-Spam-Score: -0.89 X-Migadu-Scanner: scn1.migadu.com X-TUID: AqmBFL/bIt/J 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' \ + '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." + restore_database + + backup_database + test_begin_subtest "backup can be restored ['$key']" + notmuch dump > BEFORE + delete_feature "$key" + notmuch new | grep "\(Welcome\|backup\)" > OUTPUT + notmuch tag -inbox '*' + dump_file=$(ls ${BACKUP_PATH}/dump*) + 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 + 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