1 Return-Path: <amthrax@drake.mit.edu>
\r
2 X-Original-To: notmuch@notmuchmail.org
\r
3 Delivered-To: notmuch@notmuchmail.org
\r
4 Received: from localhost (localhost [127.0.0.1])
\r
5 by olra.theworths.org (Postfix) with ESMTP id 3ED99429E2F
\r
6 for <notmuch@notmuchmail.org>; Thu, 17 Feb 2011 23:59:20 -0800 (PST)
\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org
\r
11 X-Spam-Status: No, score=0 tagged_above=-999 required=5
\r
12 tests=[RCVD_IN_DNSWL_NONE=-0.0001] autolearn=disabled
\r
13 Received: from olra.theworths.org ([127.0.0.1])
\r
14 by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)
\r
15 with ESMTP id LiUqQVuL6JVV for <notmuch@notmuchmail.org>;
\r
16 Thu, 17 Feb 2011 23:59:19 -0800 (PST)
\r
17 Received: from dmz-mailsec-scanner-5.mit.edu (DMZ-MAILSEC-SCANNER-5.MIT.EDU
\r
19 by olra.theworths.org (Postfix) with ESMTP id 728FA429E2A
\r
20 for <notmuch@notmuchmail.org>; Thu, 17 Feb 2011 23:59:19 -0800 (PST)
\r
21 X-AuditID: 12074422-b7c3eae000000a70-b4-4d5e26d7ddde
\r
22 Received: from mailhub-auth-2.mit.edu ( [18.7.62.36])
\r
23 by dmz-mailsec-scanner-5.mit.edu (Symantec Brightmail Gateway) with
\r
24 SMTP id 21.81.02672.7D62E5D4; Fri, 18 Feb 2011 02:59:19 -0500 (EST)
\r
25 Received: from outgoing.mit.edu (OUTGOING-AUTH.MIT.EDU [18.7.22.103])
\r
26 by mailhub-auth-2.mit.edu (8.13.8/8.9.2) with ESMTP id p1I7xIet007702;
\r
27 Fri, 18 Feb 2011 02:59:18 -0500
\r
28 Received: from drake.mit.edu
\r
29 (209-6-116-242.c3-0.arl-ubr1.sbo-arl.ma.cable.rcn.com
\r
30 [209.6.116.242]) (authenticated bits=0)
\r
31 (User authenticated as amdragon@ATHENA.MIT.EDU)
\r
32 by outgoing.mit.edu (8.13.6/8.12.4) with ESMTP id p1I7xGnv001518
\r
33 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NOT);
\r
34 Fri, 18 Feb 2011 02:59:17 -0500 (EST)
\r
35 Received: from amthrax by drake.mit.edu with local (Exim 4.72)
\r
36 (envelope-from <amthrax@drake.mit.edu>)
\r
37 id 1PqLFE-0008L5-Tc; Fri, 18 Feb 2011 02:59:16 -0500
\r
38 From: Austin Clements <amdragon@MIT.EDU>
\r
39 To: notmuch@notmuchmail.org
\r
40 Subject: [PATCH 01/10] test: Test atomicity of notmuch new.
\r
41 Date: Fri, 18 Feb 2011 02:58:51 -0500
\r
42 Message-Id: <1298015940-31986-2-git-send-email-amdragon@mit.edu>
\r
43 X-Mailer: git-send-email 1.7.2.3
\r
44 In-Reply-To: <1298015940-31986-1-git-send-email-amdragon@mit.edu>
\r
45 References: <1298015940-31986-1-git-send-email-amdragon@mit.edu>
\r
46 X-Brightmail-Tracker: AAAAAhdxle4Xck+E
\r
47 Cc: amdragon@mit.edu
\r
48 X-BeenThere: notmuch@notmuchmail.org
\r
49 X-Mailman-Version: 2.1.13
\r
51 List-Id: "Use and development of the notmuch mail system."
\r
52 <notmuch.notmuchmail.org>
\r
53 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
54 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
55 List-Archive: <http://notmuchmail.org/pipermail/notmuch>
\r
56 List-Post: <mailto:notmuch@notmuchmail.org>
\r
57 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
58 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
59 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
60 X-List-Received-Date: Fri, 18 Feb 2011 07:59:20 -0000
\r
62 This tests notmuch new's ability to recover from arbitrary stopping
\r
63 failures. It interrupts notmuch new after every database commit and,
\r
64 on every resulting database snapshot, re-runs notmuch new to
\r
65 completion and checks that the final database state is invariant.
\r
67 test/atomicity | 90 ++++++++++++++++++++++++++++++++++++++++++++++++++++
\r
68 test/atomicity.gdb | 38 ++++++++++++++++++++++
\r
70 test/notmuch-test | 1 +
\r
71 4 files changed, 132 insertions(+), 1 deletions(-)
\r
72 create mode 100755 test/atomicity
\r
73 create mode 100644 test/atomicity.gdb
\r
75 diff --git a/test/atomicity b/test/atomicity
\r
76 new file mode 100755
\r
77 index 0000000..e242802
\r
79 +++ b/test/atomicity
\r
82 +test_description='atomicity'
\r
85 +# Create a maildir structure to also stress flag synchronization
\r
86 +mkdir $MAIL_DIR/cur
\r
87 +mkdir $MAIL_DIR/new
\r
88 +mkdir $MAIL_DIR/tmp
\r
89 +mkdir $MAIL_DIR/.remove-dir
\r
91 +# Prepare the initial database
\r
92 +generate_message [subject]='Duplicate' [filename]='duplicate:2,' [dir]=cur
\r
93 +generate_message [subject]='Remove' [filename]='remove:2,' [dir]=cur
\r
94 +generate_message [subject]='"Remove duplicate"' [filename]='remove-duplicate:2,' [dir]=cur
\r
95 +cp $MAIL_DIR/cur/remove-duplicate:2, $MAIL_DIR/cur/remove-duplicate-copy:2,
\r
96 +generate_message [subject]='Rename' [filename]='rename:2,' [dir]=cur
\r
97 +generate_message [subject]='"Rename duplicate"' [filename]='rename-duplicate:2,' [dir]=cur
\r
98 +generate_message [subject]='"Move 1"' [filename]='move1:2,' [dir]=cur
\r
99 +generate_message [subject]='"Move 2"' [filename]='move2:2,' [dir]=new
\r
100 +generate_message [subject]='Flag' [filename]='flag:2,' [dir]=cur
\r
101 +generate_message [subject]='"Flag duplicate"' [filename]='flag-duplicate:2,' [dir]=cur
\r
102 +cp $MAIL_DIR/cur/flag-duplicate:2, $MAIL_DIR/cur/flag-duplicate-copy:2,F
\r
103 +generate_message [subject]='"Remove directory"' [filename]='remove-directory:2,' [dir]=.remove-dir
\r
104 +generate_message [subject]='"Remove directory duplicate"' [filename]='remove-directory-duplicate:2,' [dir]=.remove-dir
\r
105 +cp $MAIL_DIR/.remove-dir/remove-directory-duplicate:2, $MAIL_DIR/cur/
\r
106 +notmuch new > /dev/null
\r
108 +# Make all database changes
\r
109 +generate_message [subject]='Added' [filename]='added:2,' [dir]=cur
\r
110 +cp $MAIL_DIR/cur/duplicate:2, $MAIL_DIR/cur/duplicate-copy:2,
\r
111 +generate_message [subject]='"Add duplicate"' [filename]='add-duplicate:2,' [dir]=cur
\r
112 +generate_message [subject]='"Add duplicate copy"' [filename]='add-duplicate-copy:2,' [dir]=cur
\r
113 +rm $MAIL_DIR/cur/remove:2,
\r
114 +rm $MAIL_DIR/cur/remove-duplicate-copy:2,
\r
115 +mv $MAIL_DIR/cur/rename:2, $MAIL_DIR/cur/renamed:2,
\r
116 +mv $MAIL_DIR/cur/rename-duplicate:2, $MAIL_DIR/cur/renamed-duplicate:2,
\r
117 +mv $MAIL_DIR/cur/move1:2, $MAIL_DIR/new/move1:2,
\r
118 +mv $MAIL_DIR/new/move2:2, $MAIL_DIR/cur/move2:2,
\r
119 +mv $MAIL_DIR/cur/flag:2, $MAIL_DIR/cur/flag:2,F
\r
120 +rm $MAIL_DIR/cur/flag-duplicate-copy:2,F
\r
121 +rm $MAIL_DIR/.remove-dir/remove-directory:2,
\r
122 +rm $MAIL_DIR/.remove-dir/remove-directory-duplicate:2,
\r
123 +rmdir $MAIL_DIR/.remove-dir
\r
124 +increment_mtime $MAIL_DIR/cur
\r
125 +increment_mtime $MAIL_DIR/new
\r
126 +increment_mtime $MAIL_DIR
\r
128 +# Prepare the database snapshot
\r
129 +cp -ra $MAIL_DIR $MAIL_DIR.snap
\r
130 +cp ${NOTMUCH_CONFIG} ${NOTMUCH_CONFIG}.snap
\r
131 +NOTMUCH_CONFIG=${NOTMUCH_CONFIG}.snap notmuch config set database.path $MAIL_DIR.snap
\r
134 +test_begin_subtest '"notmuch new" is idempotent under arbitrary aborts'
\r
136 +# Execute notmuch new and, at every call to rename, snapshot the
\r
137 +# database, run notmuch new again on the snapshot, and capture the
\r
138 +# results of search.
\r
140 +gdb -batch -x ../atomicity.gdb notmuch > /dev/null 2>&1
\r
142 +# Get the final, golden output
\r
143 +notmuch search '*' > expected
\r
145 +# Check output against golden output
\r
146 +outcount=$(cat outcount)
\r
147 +echo -n > searchall
\r
148 +echo -n > expectall
\r
149 +for ((i = 0; i < $outcount; i++)); do
\r
150 + if ! cmp -s search.$i expected; then
\r
151 + # Find the range of interruptions that match this output
\r
152 + for ((end = $i + 1 ; end < $outcount; end++)); do
\r
153 + if ! cmp -s search.$i search.$end; then
\r
157 + echo "When interrupted after $test/backtrace.$(expr $i - 1) (abort points $i-$(expr $end - 1))" >> searchall
\r
158 + cat search.$i >> searchall
\r
159 + cat expected >> expectall
\r
160 + echo >> searchall
\r
161 + echo >> expectall
\r
163 + i=$(expr $end - 1)
\r
166 +test_expect_equal "$(cat searchall)" "$(cat expectall)"
\r
168 +test_expect_success "detected $outcount>10 abort points" "test $outcount -gt 10"
\r
171 diff --git a/test/atomicity.gdb b/test/atomicity.gdb
\r
172 new file mode 100644
\r
173 index 0000000..a20d977
\r
175 +++ b/test/atomicity.gdb
\r
179 +# Make Xapian commit after every operation instead of batching
\r
180 +set environment XAPIAN_FLUSH_THRESHOLD = 1
\r
182 +# gdb can't keep track of a simple integer. This is me weeping.
\r
183 +shell echo 0 > outcount
\r
185 +shell touch inodes
\r
189 +# As an optimization, only consider snapshots after a Xapian commit.
\r
190 +# Xapian overwrites record.base? as the last step in the commit.
\r
191 +shell echo > gdbcmd
\r
192 +shell stat -c %i $MAIL_DIR/.notmuch/xapian/record.base* > inodes.new
\r
193 +shell if cmp inodes inodes.new; then echo cont > gdbcmd; fi
\r
194 +shell mv inodes.new inodes
\r
197 +# Save a backtrace in case the test does fail
\r
198 +set logging file backtrace
\r
202 +shell mv backtrace backtrace.`cat outcount`
\r
204 +# Snapshot the database
\r
205 +shell rm -r $MAIL_DIR.snap/.notmuch
\r
206 +shell cp -r $MAIL_DIR/.notmuch $MAIL_DIR.snap/.notmuch
\r
207 +# Run notmuch new to completion on the snapshot
\r
208 +shell NOTMUCH_CONFIG=${NOTMUCH_CONFIG}.snap XAPIAN_FLUSH_THRESHOLD=1000 notmuch new > /dev/null
\r
209 +shell NOTMUCH_CONFIG=${NOTMUCH_CONFIG}.snap notmuch search '*' > search.`cat outcount` 2>&1
\r
210 +shell echo $(expr $(cat outcount) + 1) > outcount
\r
215 diff --git a/test/basic b/test/basic
\r
216 index 3b43ad9..f9d5fc3 100755
\r
219 @@ -57,7 +57,9 @@ available=$(ls -1 ../ | \
\r
220 sed -r -e "/^(aggregate-results.sh|Makefile|Makefile.local|notmuch-test)/d" \
\r
221 -e "/^(README|test-lib.sh|test-results|tmp.*|valgrind|corpus*)/d" \
\r
222 -e "/^(emacs.expected-output|smtp-dummy|smtp-dummy.c|test-verbose)/d" \
\r
223 - -e "/^(test.expected-output|.*~)/d" | sort)
\r
224 + -e "/^(test.expected-output|.*~)/d" \
\r
225 + -e "/^(atomicity.gdb)/d" \
\r
227 test_expect_equal "$tests_in_suite" "$available"
\r
229 EXPECTED=../test.expected-output
\r
230 diff --git a/test/notmuch-test b/test/notmuch-test
\r
231 index 9d77c0f..c506705 100755
\r
232 --- a/test/notmuch-test
\r
233 +++ b/test/notmuch-test
\r
234 @@ -36,6 +36,7 @@ TESTS="
\r
241 # Clean up any results from a previous run
\r