Skip to content

Commit

Permalink
Add test for issue slusarz#38
Browse files Browse the repository at this point in the history
  • Loading branch information
edieterich committed Jan 4, 2023
1 parent f7f6458 commit ae73576
Show file tree
Hide file tree
Showing 9 changed files with 608 additions and 2 deletions.
24 changes: 22 additions & 2 deletions .github/actions/dovecot-fts-flatcurve-test/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,27 @@ RUN apt-get update && apt-get install -y \
libexttextcat-dev \
libicu-dev \
libxapian-dev \
dovecot-imaptest
dovecot-imaptest \
libclucene-dev \
unzip \
poppler-utils \
bash \
procps \
lsof \
sudo \
default-jre \
libexpat1-dev

# We need to build Dovecot ourselves, since "standard" Dovecot does not
# come with necessary ICU libraries built-in
RUN mkdir /dovecot
RUN git clone --depth 1 --branch release-2.3 \
https://github.com/dovecot/core.git /dovecot/core
COPY patches /patches
RUN cd /dovecot/core && patch -p1 < /patches/fts-squat.patch
RUN cd /dovecot/core && \
./autogen.sh && \
PANDOC=false ./configure --with-stemmer --with-textcat --with-icu && \
PANDOC=false ./configure --with-stemmer --with-textcat --with-icu --with-lucene --with-solr && \
make install

RUN git clone --depth 1 https://github.com/slusarz/dovecot-fts-flatcurve.git \
Expand All @@ -51,6 +62,15 @@ ADD configs/ /dovecot/configs
RUN chown -R vmail:vmail /dovecot/configs/virtual
ADD imaptest/ /dovecot/imaptest

RUN wget --quiet https://www-eu.apache.org/dist/lucene/solr/8.11.2/solr-8.11.2.tgz
RUN tar xzf solr-8.11.2.tgz solr-8.11.2/bin/install_solr_service.sh --strip-components=2
RUN bash ./install_solr_service.sh solr-8.11.2.tgz && sudo -u solr /opt/solr/bin/solr create -c dovecot
RUN rm -f /var/solr/data/dovecot/conf/schema.xml
RUN rm -f /var/solr/data/dovecot/conf/managed-schema
RUN rm -f /var/solr/data/dovecot/conf/solrconfig.xml
RUN cp /dovecot/core/doc/solr-config-7.7.0.xml /var/solr/data/dovecot/conf/solrconfig.xml
RUN cp /dovecot/core/doc/solr-schema-7.7.0.xml /var/solr/data/dovecot/conf/schema.xml

ADD fts-flatcurve-test.sh /fts-flatcurve-test.sh
RUN chmod +x /fts-flatcurve-test.sh
ENTRYPOINT ["/fts-flatcurve-test.sh"]
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
!include /dovecot/configs/dovecot.conf

plugin {
fts_decoder = decode2text
}

service decode2text {
executable = script /usr/local/libexec/dovecot/decode2text.sh
unix_listener decode2text {
mode = 0666
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
!include /dovecot/configs/dovecot.conf

mail_plugins = $mail_plugins fts fts_lucene

plugin {
fts = lucene
fts_lucene = whitespace_chars=@.
}

plugin {
fts_decoder = decode2text
}

service decode2text {
executable = script /usr/local/libexec/dovecot/decode2text.sh
unix_listener decode2text {
mode = 0666
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
!include /dovecot/configs/dovecot.conf

mail_plugins = $mail_plugins fts fts_solr

plugin {
fts = solr
fts_solr = url=http://127.0.0.1:8983/solr/dovecot/
}

plugin {
fts_decoder = decode2text
}

service decode2text {
executable = script /usr/local/libexec/dovecot/decode2text.sh
unix_listener decode2text {
mode = 0666
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
!include /dovecot/configs/dovecot.conf

mail_plugins = $mail_plugins fts fts_squat

plugin {
fts = squat
fts_squat = partial=4 full=10
}

plugin {
fts_decoder = decode2text
}

service decode2text {
executable = script /usr/local/libexec/dovecot/decode2text.sh
unix_listener decode2text {
mode = 0666
}
}
16 changes: 16 additions & 0 deletions .github/actions/dovecot-fts-flatcurve-test/fts-flatcurve-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -195,3 +195,19 @@ done
run_test "Testing virtual search" \
/dovecot/configs/dovecot.conf.virtual \
/dovecot/imaptest/virtual

/etc/init.d/solr start

TESTBOX=imaptest
run_test "Testing GitHub Issue #38 using Solr" \
/dovecot/configs/dovecot.conf.issue-38-solr \
/dovecot/imaptest/issue-38/issue-38
run_test "Testing GitHub Issue #38 using Lucene" \
/dovecot/configs/dovecot.conf.issue-38-lucene \
/dovecot/imaptest/issue-38/issue-38
run_test "Testing GitHub Issue #38 using Squat" \
/dovecot/configs/dovecot.conf.issue-38-squat \
/dovecot/imaptest/issue-38/issue-38
run_test "Testing GitHub Issue #38 using Flatcurve" \
/dovecot/configs/dovecot.conf.issue-38-flatcurve \
/dovecot/imaptest/issue-38/issue-38

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
messages: all

ok search body bodybody
* search 1
ok search body attachment
* search 1
ok search or body bodybody header reply-to bodybody
* search 1
ok search or body attachment header reply-to attachment
* search 1
45 changes: 45 additions & 0 deletions .github/actions/dovecot-fts-flatcurve-test/patches/fts-squat.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
diff --git a/src/plugins/fts-squat/fts-backend-squat.c b/src/plugins/fts-squat/fts-backend-squat.c
index fbd7bbe156..ff6d429f61 100644
--- a/src/plugins/fts-squat/fts-backend-squat.c
+++ b/src/plugins/fts-squat/fts-backend-squat.c
@@ -21,7 +21,7 @@ struct squat_fts_backend {
struct squat_trie *trie;

unsigned int partial_len, full_len;
- bool refresh;
+ /* bool refresh; */
};

struct squat_fts_backend_update_context {
@@ -105,8 +105,9 @@ fts_backend_squat_set_box(struct squat_fts_backend *backend,
struct mailbox_status status;
const char *path;
enum squat_index_flags flags = 0;
- int ret;
+ /* int ret; */

+ /*
if (backend->box == box)
{
if (backend->refresh) {
@@ -117,8 +118,9 @@ fts_backend_squat_set_box(struct squat_fts_backend *backend,
}
return 0;
}
+ */
fts_backend_squat_unset_box(backend);
- backend->refresh = FALSE;
+ /* backend->refresh = FALSE; */
if (box == NULL)
return 0;

@@ -343,7 +345,8 @@ static int fts_backend_squat_refresh(struct fts_backend *_backend)
struct squat_fts_backend *backend =
(struct squat_fts_backend *)_backend;

- backend->refresh = TRUE;
+ /* backend->refresh = TRUE; */
+ fts_backend_squat_unset_box(backend);
return 0;
}

0 comments on commit ae73576

Please sign in to comment.