Skip to content

Commit

Permalink
test: check that Audit doesn't screw up search
Browse files Browse the repository at this point in the history
  • Loading branch information
brong committed Sep 1, 2024
1 parent 2adcc5c commit 9dba60b
Show file tree
Hide file tree
Showing 2 changed files with 77 additions and 0 deletions.
1 change: 1 addition & 0 deletions cassandane/Cassandane/Cyrus/SearchFuzzy.pm
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,7 @@ sub run_delve {
sub delve_docs
{
my ($self, $dir) = @_;
return ([], []) unless -e "$dir/iamglass";
my $delveout = $self->run_delve($dir, '-V0');
$delveout =~ s/^Value 0 for each document: //;
my @docs = split ' ', $delveout;
Expand Down
76 changes: 76 additions & 0 deletions cassandane/tiny-tests/SearchFuzzy/index_tier_audit_bug
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
#!perl
use Cassandane::Tiny;

sub test_index_tier_audit_bug
:min_version_3_3 :needs_search_xapian
{
my ($self) = @_;

my $xapdirs = ($self->{instance}->run_mbpath(-u => 'cassandane'))->{xapian};

my $talk = $self->{store}->get_client();

xlog "create a message";
$self->make_message("xyzzy") || die;
$self->{instance}->run_command({cyrus => 1}, 'squatter', '-i');

xlog "assert that we can find the message";
my $uids = $talk->search('fuzzy', 'subject', 'xyzzy');
$self->assert_num_equals(1, scalar @$uids);

xlog "assert that we have a part";
my ($gdocs, $parts) = $self->delve_docs($xapdirs->{t1} . "/xapian");
$self->assert_num_equals(1, scalar @$parts);
$self->assert_num_equals(1, scalar @$gdocs);

xlog "compact to t2 tier";
$self->{instance}->run_command({cyrus => 1}, 'squatter', '-z', 't2', '-t', 't1');

xlog "assert that the message is now in t2";
($gdocs, $parts) = $self->delve_docs($xapdirs->{t2} . "/xapian");
$self->assert_num_equals(1, scalar @$parts);
$self->assert_num_equals(1, scalar @$gdocs);

xlog "assert that the message isn't in t1 still";
($gdocs, $parts) = $self->delve_docs($xapdirs->{t1} . "/xapian");
$self->assert_num_equals(0, scalar @$parts);
$self->assert_num_equals(0, scalar @$gdocs);

xlog "assert that we can still find the message";
$uids = $talk->search('fuzzy', 'subject', 'xyzzy');
$self->assert_num_equals(1, scalar @$uids);

xlog "run an audit";
$self->{instance}->run_command({cyrus => 1}, 'squatter', '-A');

xlog "assert that we can still find the message";
$uids = $talk->search('fuzzy', 'subject', 'xyzzy');
$self->assert_num_equals(1, scalar @$uids);

xlog "assert that the message is now in t2";
($gdocs, $parts) = $self->delve_docs($xapdirs->{t2} . "/xapian");
$self->assert_num_equals(1, scalar @$parts);
$self->assert_num_equals(1, scalar @$gdocs);

xlog "assert that the message isn't in t1 still";
($gdocs, $parts) = $self->delve_docs($xapdirs->{t1} . "/xapian");
$self->assert_num_equals(0, scalar @$parts);
$self->assert_num_equals(0, scalar @$gdocs);

xlog "compact to t2 tier";
$self->{instance}->run_command({cyrus => 1}, 'squatter', '-z', 't2', '-t', 't1');

xlog "assert that the message is now in t2";
($gdocs, $parts) = $self->delve_docs($xapdirs->{t2} . "/xapian");
$self->assert_num_equals(1, scalar @$parts);
$self->assert_num_equals(1, scalar @$gdocs);

xlog "assert that the message isn't in t1 still";
($gdocs, $parts) = $self->delve_docs($xapdirs->{t1} . "/xapian");
$self->assert_num_equals(0, scalar @$parts);
$self->assert_num_equals(0, scalar @$gdocs);

xlog "assert that we can still find the message";
$uids = $talk->search('fuzzy', 'subject', 'xyzzy');
$self->assert_num_equals(1, scalar @$uids);
}

0 comments on commit 9dba60b

Please sign in to comment.