unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
blob 2b933f62d4395eb7cb48c60f8d199f3b37e928bc 3643 bytes (raw)
name: test/T590-thread-breakage.sh 	 # note: path name is non-authoritative(*)

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
 
#!/usr/bin/env bash
#
# Copyright (c) 2016 Daniel Kahn Gillmor
#

test_description='thread breakage during reindexing

notmuch uses ghost documents to track messages we have seen references
to but have never seen.  Regardless of the order of delivery, message
deletion, and reindexing, the list of ghost messages for a given
stored corpus should not vary, so that threads can be reassmebled
cleanly.

In practice, we accept a small amount of variation (and therefore
traffic pattern metadata leakage to be stored in the index) for the
sake of efficiency.

This test also embeds some subtests to ensure that indexing actually
works properly and attempted fixes to threading issues do not break
the expected contents of the index.'

. ./test-lib.sh || exit 1

message_a() {
    mkdir -p ${MAIL_DIR}/cur
    cat > ${MAIL_DIR}/cur/a <<EOF
Subject: First message
Message-ID: <a@example.net>
From: Alice <alice@example.net>
To: Bob <bob@example.net>
Date: Thu, 31 Mar 2016 20:10:00 -0400

This is the first message in the thread.
Apple
EOF
}

message_b() {
    mkdir -p ${MAIL_DIR}/cur
    cat > ${MAIL_DIR}/cur/b <<EOF
Subject: Second message
Message-ID: <b@example.net>
In-Reply-To: <a@example.net>
References: <a@example.net>
From: Bob <bob@example.net>
To: Alice <alice@example.net>
Date: Thu, 31 Mar 2016 20:15:00 -0400

This is the second message in the thread.
Banana
EOF
}


test_content_count() {
    test_begin_subtest "${3:-looking for $2 instance of '$1'}"
    count=$(notmuch count --output=threads "$1")
    test_expect_equal "$count" "$2"
}

test_thread_count() {
    test_begin_subtest "${2:-Expecting $1 thread(s)}"
    count=$(notmuch count --output=threads)
    test_expect_equal "$count" "$1"
}

test_ghost_count() {
    test_begin_subtest "${2:-Expecting $1 ghosts(s)}"
    ghosts=$(../ghost-report ${MAIL_DIR}/.notmuch/xapian)
    test_expect_equal "$ghosts" "$1"
}

notmuch new >/dev/null
pwd
ls -la ${MAIL_DIR}/.notmuch/xapian

test_thread_count 0 'There should be no threads initially'
test_ghost_count 0 'There should be no ghosts initially'

message_a
notmuch new >/dev/null
test_thread_count 1 'One message in: one thread'
test_content_count apple 1
test_content_count banana 0
test_ghost_count 0

message_b
notmuch new >/dev/null
test_thread_count 1 'Second message in the same thread: one thread'
test_content_count apple 1
test_content_count banana 1
test_ghost_count 0

rm -f ${MAIL_DIR}/cur/a
notmuch new >/dev/null
test_thread_count 1 'First message removed: still only one thread'
test_content_count apple 0
test_content_count banana 1
test_begin_subtest 'should be one ghost after first message removed'
test_subtest_known_broken
ghosts=$(../ghost-report ${MAIL_DIR}/.notmuch/xapian)
test_expect_equal "$ghosts" "1"

message_a
notmuch new >/dev/null
# this is known to fail (it shows 2 threads) because no "ghost
# message" was created for message A when it was removed from the
# index, despite message B still pointing to it.
test_begin_subtest 'First message reappears: should return to the same thread'
test_subtest_known_broken
count=$(notmuch count --output=threads)
test_expect_equal "$count" "1"
test_content_count apple 1
test_content_count banana 1
test_ghost_count 0

rm -f ${MAIL_DIR}/cur/b
notmuch new >/dev/null
test_thread_count 1 'Removing second message: still only one thread'
test_content_count apple 1
test_content_count banana 0
test_ghost_count 0 'No ghosts should remain after deletion of second message'

rm -f ${MAIL_DIR}/cur/a
notmuch new >/dev/null
test_thread_count 0 'All messages gone: no threads'
test_content_count apple 0
test_content_count banana 0
test_ghost_count 0

test_done

debug log:

solving 2b933f6 ...
found 2b933f6 in https://yhetil.org/notmuch.git/

(*) Git path names are given by the tree(s) the blob belongs to.
    Blobs themselves have no identifier aside from the hash of its contents.^

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).