about summary refs log tree commit homepage
path: root/t
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2019-05-23 09:36:46 +0000
committerEric Wong <e@80x24.org>2019-05-23 17:43:50 +0000
commitac5a695030be64059fcb1ae826a0f3bfd2ca035b (patch)
tree316fd6d6a1ece471b8e0a6996c8e1a9c6f73d162 /t
parentf0cc8e6795077bc7a04e579655a1c5e90c80a4e8 (diff)
downloadpublic-inbox-ac5a695030be64059fcb1ae826a0f3bfd2ca035b.tar.gz
copydatabase(1) is an existing Xapian tool which is the
recommended way to upgrade existing DBs to the latest Xapian
database format (currently "glass" for stable/released
versions).  Our use of Xapian relies on preserving document IDs,
so we'll wrap it like we do xapian-compact(1) and use the
"--no-renumber" switch.

I could not name the tool "public-inbox-copydatabase" since it
would be ambiguous as to which DB it's actually copying.  So, I
abbreviated the suffix to "xcpdb" (Xapian CoPy DataBase), which
I hope is acceptable and unambiguous.
Diffstat (limited to 't')
-rw-r--r--t/indexlevels-mirror.t22
1 files changed, 22 insertions, 0 deletions
diff --git a/t/indexlevels-mirror.t b/t/indexlevels-mirror.t
index d124c755..61053b66 100644
--- a/t/indexlevels-mirror.t
+++ b/t/indexlevels-mirror.t
@@ -18,6 +18,7 @@ foreach my $mod (qw(DBD::SQLite)) {
 
 my $path = 'blib/script';
 my $index = "$path/public-inbox-index";
+my $xcpdb = "$path/public-inbox-xcpdb";
 
 my $mime = PublicInbox::MIME->create(
         header => [
@@ -108,6 +109,13 @@ sub import_index_incremental {
         ok($im->remove($mime), '2nd message removed');
         $im->done;
 
+        if ($level ne 'basic') {
+                is(system($xcpdb, $mirror), 0, "v$v xcpdb OK");
+                delete $ro_mirror->{$_} for (qw(over search));
+                ($nr, $msgs) = $ro_mirror->search->query('m:m@2');
+                is($nr, 1, "v$v found m\@2 via Xapian on $level");
+        }
+
         # sync the mirror
         is(system('git', "--git-dir=$fetch_dir", qw(fetch -q)), 0, 'fetch OK');
         is(system($index, $mirror), 0, "v$v index mirror again OK");
@@ -120,6 +128,10 @@ sub import_index_incremental {
                 is_deeply([glob("$ibx->{mainrepo}/xap*/?/")], [],
                          'no Xapian partition directories for v2 basic');
         }
+        if ($level ne 'basic') {
+                ($nr, $msgs) = $ro_mirror->search->reopen->query('m:m@2');
+                is($nr, 0, "v$v m\@2 gone from Xapian in mirror on $level");
+        }
 }
 
 # we can probably cull some other tests and put full/medium tests, here
@@ -131,4 +143,14 @@ for my $level (qw(basic)) {
         }
 }
 
+SKIP: {
+        require PublicInbox::Search;
+        PublicInbox::Search::load_xapian() or skip 'Search::Xapian missing', 2;
+        for my $v (1..2) {
+                subtest("v$v indexlevel=medium" => sub {
+                        import_index_incremental($v, 'medium');
+                })
+        }
+}
+
 done_testing();