Skip to content

Commit

Permalink
Delete: check against supposedly-empty-directory failures
Browse files Browse the repository at this point in the history
This error should only occur when an actual problem happens,
not routinely for nearly every delete
  • Loading branch information
elliefm committed Dec 8, 2023
1 parent 6626264 commit a27303d
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions cassandane/Cassandane/Cyrus/Delete.pm
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,15 @@ sub check_folder_not_ondisk
}
}

sub check_syslog
{
my ($self, $instance) = @_;

my $remove_empty_pat = qr/Remove of supposedly empty directory/;

$self->assert_null($instance->_check_syslog($remove_empty_pat));
}

sub test_self_inbox_imm
:ImmediateDelete :SemidelayedExpunge :NoAltNameSpace
{
Expand Down Expand Up @@ -218,6 +227,8 @@ sub test_self_inbox_imm
$self->check_folder_not_ondisk($subfolder);
$self->check_folder_not_ondisk($inbox, deleted => 1);
$self->check_folder_not_ondisk($subfolder, deleted => 1);

$self->check_syslog($self->{instance});
}

sub test_self_inbox_del
Expand Down Expand Up @@ -293,6 +304,8 @@ sub test_self_inbox_del
$self->check_folder_not_ondisk($subfolder);
$self->check_folder_not_ondisk($inbox, deleted => 1);
$self->check_folder_not_ondisk($subfolder, deleted => 1);

$self->check_syslog($self->{instance});
}

# old version of this test for builds without newer httpd features
Expand Down Expand Up @@ -370,6 +383,8 @@ sub test_admin_inbox_imm_legacy
$self->check_folder_not_ondisk($subfolder);
$self->check_folder_not_ondisk($inbox, deleted => 1);
$self->check_folder_not_ondisk($subfolder, deleted => 1);

$self->check_syslog($self->{instance});
}

sub test_admin_inbox_imm
Expand Down Expand Up @@ -509,6 +524,8 @@ EOF
}
$self->assert_not_file_test($data->{user}{sieve}, '-e');
$self->assert_not_file_test($data->{xapian}{t1}, '-e');

$self->check_syslog($self->{instance});
}

sub test_admin_inbox_del
Expand Down Expand Up @@ -590,6 +607,8 @@ sub test_admin_inbox_del
$self->check_folder_not_ondisk($subfolder);
$self->check_folder_not_ondisk($inbox, deleted => 1);
$self->check_folder_not_ondisk($subfolder, deleted => 1);

$self->check_syslog($self->{instance});
}

sub test_bz3781
Expand Down Expand Up @@ -699,6 +718,8 @@ sub test_cyr_expire_delete

# and not exist from mbpath either...
$self->assert_null($self->{instance}->folder_to_deleted_directories("user.cassandane.$subfoldername"));

$self->check_syslog($self->{instance});
}

sub test_allowdeleted
Expand Down Expand Up @@ -741,6 +762,8 @@ sub test_allowdeleted
$talk->select($result->[1][2]);
$self->assert_str_equals('ok', $talk->get_last_completion_response());
$self->assert_num_equals(1, $talk->get_response_code('exists'));

$self->check_syslog($self->{instance});
}

sub test_cyr_expire_delete_with_annotation
Expand Down Expand Up @@ -811,6 +834,8 @@ sub test_cyr_expire_delete_with_annotation
xlog $self, "Run cyr_expire -D now, with -a, skipping annotation.";
$self->{instance}->run_command({ cyrus => 1 }, 'cyr_expire', '-D' => '0', '-a' );
$self->assert_not_file_test($path, '-d');

$self->check_syslog($self->{instance});
}

# https://github.com/cyrusimap/cyrus-imapd/issues/2413
Expand Down Expand Up @@ -883,6 +908,8 @@ sub test_cyr_expire_dont_resurrect_convdb

# expect user does not have a conversations database
$self->assert_not_file_test($convdbfile, '-f');

$self->check_syslog($self->{instance});
}

sub test_no_delete_with_children
Expand All @@ -906,6 +933,8 @@ sub test_no_delete_with_children

$talk->delete($subfolder);
$self->assert_str_equals('no', $talk->get_last_completion_response());

$self->check_syslog($self->{instance});
}

sub test_cyr_expire_inherit_annot
Expand Down Expand Up @@ -940,6 +969,8 @@ sub test_cyr_expire_inherit_annot
$talk->unselect();
$talk->select($subfolder);
$self->assert_num_equals(0, $talk->get_response_code('exists'));

$self->check_syslog($self->{instance});
}

sub test_cyr_expire_noexpire
Expand Down Expand Up @@ -991,6 +1022,8 @@ sub test_cyr_expire_noexpire
$talk->unselect();
$talk->select($subfolder);
$self->assert_num_equals(0, $talk->get_response_code('exists'));

$self->check_syslog($self->{instance});
}

sub test_cyr_expire_delete_noexpire
Expand Down Expand Up @@ -1048,6 +1081,8 @@ sub test_cyr_expire_delete_noexpire
xlog $self, "Run cyr_expire";
$self->{instance}->run_command({ cyrus => 1 }, 'cyr_expire', '-D' => '1s' );
$self->assert(!-d "$path");

$self->check_syslog($self->{instance});
}

1;

0 comments on commit a27303d

Please sign in to comment.