From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp1 ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id sHVjDRzvmmAXaQEAgWs5BA (envelope-from ) for ; Tue, 11 May 2021 22:54:52 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp1 with LMTPS id sMgFCRzvmmCHKgAAbx9fmQ (envelope-from ) for ; Tue, 11 May 2021 20:54:52 +0000 Received: from mail.notmuchmail.org (nmbug.tethera.net [144.217.243.247]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id E4AD715FCF for ; Tue, 11 May 2021 22:54:51 +0200 (CEST) Received: from nmbug.tethera.net (localhost [127.0.0.1]) by mail.notmuchmail.org (Postfix) with ESMTP id 6F12727180; Tue, 11 May 2021 16:54:45 -0400 (EDT) X-Greylist: delayed 335 seconds by postgrey-1.36 at nmbug; Tue, 11 May 2021 16:54:42 EDT Received: from mailproxy05.manitu.net (mailproxy05.manitu.net [IPv6:2a00:1828:1000:1110::2]) by mail.notmuchmail.org (Postfix) with ESMTPS id 7BE152717A for ; Tue, 11 May 2021 16:54:42 -0400 (EDT) Received: from localhost (200116b86017d900ae2f9e0a625a9927.dip.versatel-1u1.de [IPv6:2001:16b8:6017:d900:ae2f:9e0a:625a:9927]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: michael@grubix.eu) by mailproxy05.manitu.net (Postfix) with ESMTPSA id 84B301B61291; Tue, 11 May 2021 22:48:54 +0200 (CEST) From: Michael J Gruber To: notmuch@notmuchmail.org Subject: [PATCH] test: change database from within pre-new hook Date: Tue, 11 May 2021 22:48:52 +0200 Message-Id: X-Mailer: git-send-email 2.31.1.708.gc9a0ac0934 In-Reply-To: <162076424929.3234.3999254277296434834.git@grubix.eu> References: <162076424929.3234.3999254277296434834.git@grubix.eu> MIME-Version: 1.0 Message-ID-Hash: PZ7JVRRKL2XXKDXIJLKBERNONVB2VTSV X-Message-ID-Hash: PZ7JVRRKL2XXKDXIJLKBERNONVB2VTSV X-MailFrom: git@grubix.eu 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 ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1620766492; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=EUGSlyulGSWIiv5iUZho/smONddXuF0gcNW8D2Uo0II=; b=ofu0CRelOWXhHDcAa3nURh3B7koQMLU5QRWqLedJ39D4wINKlJcn6zIm/A0Pj+LVZTX/SO kQM/C+CQzkPnpGd8REiy2oT07nYLx89QXravpJWNZNPYO/QgCmOD4nwXr/2szQRj2JaFnp AQVUJz1Soh/SOKHx5vf6EnNXrND2Fk7iEJGub4ciKNk2b1qa5yV/5SiPiOEdBrOqi7Jg3C 4IGMpupA6xqW3iQL8l8g9spOdQh+1cW0aaA2lNybAoycyrTRiZDRoroNjeVRAFLGj99Nx5 MhwRsL8Hjv+66tLSBA87AIgugMq+vRT6adQ2L4kzk4fthYAVOcA6M7KQIwQxUg== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1620766492; a=rsa-sha256; cv=none; b=Av3u2rXSlcLUrZ+u7oFrBLQgITdjyWiEISEhZSUQC6o27Lfyx1/kyGnz3A23r/ND6p5oql Hrr+xcKrJlrrXYMy2SrLq5o2H2JcDHsP2QDwMWsxLYB6cAwrzlzm5XypY+FUmQl3GEtKe5 2Wn9dPFV3KDJkOA1a97bydDcXE1KbwN5VnklRDI32rcgkAvroR18SWglguoOz9ZK/c/W+z s4nH4KwVYHewIKxmL03q10QIa1MuNWCN3DY8+9V6Um27jel7OHTViTahkhBZwzejTf25Er pwoErkPG4k/AmSf/6rO+KNp8B9Ntm9JHludVnyJt/+RS51Juuty1onhhcWyBbg== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=none; spf=pass (aspmx1.migadu.com: domain of notmuch-bounces@notmuchmail.org designates 144.217.243.247 as permitted sender) smtp.mailfrom=notmuch-bounces@notmuchmail.org X-Migadu-Spam-Score: 0.44 Authentication-Results: aspmx1.migadu.com; dkim=none; dmarc=none; spf=pass (aspmx1.migadu.com: domain of notmuch-bounces@notmuchmail.org designates 144.217.243.247 as permitted sender) smtp.mailfrom=notmuch-bounces@notmuchmail.org X-Migadu-Queue-Id: E4AD715FCF X-Spam-Score: 0.44 X-Migadu-Scanner: scn0.migadu.com X-TUID: iGfgCIhbnGYA Due to the change in the config system, notmuch keeps a notmuch database open when it would not do so before. Consequently, it can miss changes to the database which are done from a hook (while notmuch holds the databse in read only mode). When notmuch itself writes to the database after that it uses wrong assumptions about the last used doc id etc. Demonstrate this by triggering an assertion. (This new test succeeds with notmuch 0.31.4.) Signed-off-by: Michael J Gruber --- test/T400-hooks.sh | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/test/T400-hooks.sh b/test/T400-hooks.sh index 00c99337..58e2b1dd 100755 --- a/test/T400-hooks.sh +++ b/test/T400-hooks.sh @@ -28,6 +28,16 @@ EOF echo "${TOKEN}" > ${2} } +create_change_hook () { + mkdir -p ${HOOK_DIR} + cat <"${HOOK_DIR}/${1}" +#!/bin/sh +notmuch insert --no-hooks < ${2} > /dev/null +rm -f ${2} +EOF + chmod +x "${HOOK_DIR}/${1}" +} + create_failing_hook () { local HOOK_DIR=${2} mkdir -p ${HOOK_DIR} @@ -176,6 +186,17 @@ EOF NOTMUCH_NEW test_expect_equal_file write.expected write.output + test_begin_subtest "pre-new with change in database [${config}]" + test_subtest_known_broken + rm -rf ${HOOK_DIR} + notmuch search '*' > change.expected + generate_message '[subject]="Inserted"' + create_change_hook "pre-new" $gen_msg_filename $HOOK_DIR + generate_message + NOTMUCH_NEW + output=$(notmuch search id:$gen_msg_id | notmuch_search_sanitize) + test_expect_equal "$output" "thread:XXX 2001-01-05 [1/1] Notmuch Test Suite; pre-new with change in database [${config}] (inbox unread)" + rm -rf ${HOOK_DIR} done test_done -- 2.31.1.708.gc9a0ac0934