Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cassandane: infer needs from wants/magic #5037

Draft
wants to merge 7 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions cassandane/Cassandane/Cyrus/Conversations.pm
Original file line number Diff line number Diff line change
Expand Up @@ -445,7 +445,7 @@ sub _munge_annot_crc
$fh->close();
}
sub test_replication_reply_200
:min_version_3_1 :needs_component_replication
:min_version_3_1
{
my ($self) = @_;
my %exp;
Expand Down Expand Up @@ -514,7 +514,7 @@ sub test_replication_reply_200
# Test APPEND of messages to IMAP
#
sub test_replication_reconstruct
:min_version_3_1 :needs_component_replication
:min_version_3_1
{
my ($self) = @_;
my %exp;
Expand Down Expand Up @@ -676,7 +676,7 @@ sub bogus_test_double_clash
# Test that a CID clash resolved on the master is replicated
#
sub bogus_test_replication_clash
:min_version_3_0 :needs_component_replication
:min_version_3_0
{
my ($self) = @_;
my %exp;
Expand Down Expand Up @@ -849,7 +849,7 @@ sub bogus_test_cross_user_copy
# Test APPEND of messages to IMAP
#
sub test_replication_trashseen
:min_version_3_1 :needs_component_replication
:min_version_3_1
{
my ($self) = @_;
my %exp;
Expand Down
1 change: 0 additions & 1 deletion cassandane/Cassandane/Cyrus/Quota.pm
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,6 @@ sub XXtest_getset_multiple

# Magic: the word 'replication' in the name enables a replica
sub XXtest_replication_multiple
:needs_component_replication
{
my ($self) = @_;

Expand Down
4 changes: 1 addition & 3 deletions cassandane/Cassandane/Cyrus/Rename.pm
Original file line number Diff line number Diff line change
Expand Up @@ -652,7 +652,7 @@ sub test_rename_user
}

sub test_rename_deepuser
:AllowMoves :Replication :SyncLog :needs_component_replication
:AllowMoves :Replication :SyncLog
{
my ($self) = @_;

Expand Down Expand Up @@ -686,7 +686,6 @@ sub test_rename_deepuser

sub test_rename_user_sieve
:AllowMoves :Replication :SyncLog :needs_component_sieve
:needs_component_replication
{
my ($self) = @_;

Expand Down Expand Up @@ -798,7 +797,6 @@ sub test_rename_paths

sub test_rename_deepuser_unixhs
:AllowMoves :Replication :SyncLog :UnixHierarchySep
:needs_component_replication
{
my ($self) = @_;

Expand Down
5 changes: 1 addition & 4 deletions cassandane/Cassandane/Cyrus/Replication.pm
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,7 @@ use Cassandane::Config;
sub new
{
my $class = shift;
my $self = $class->SUPER::new({ replica => 1, adminstore => 1 }, @_);

$self->needs('component', 'replication');
return $self;
return $class->SUPER::new({ replica => 1, adminstore => 1 }, @_);
}

sub set_up
Expand Down
61 changes: 53 additions & 8 deletions cassandane/Cassandane/Cyrus/TestCase.pm
Original file line number Diff line number Diff line change
Expand Up @@ -127,10 +127,24 @@ sub new
if length($leftovers);

my $self = $class->SUPER::new(@args);

$self->{_name} = $args[0] || 'unknown';
$self->{_want} = $want;
$self->{_instance_params} = $instance_params;

# process constructor wants through sub want() because it knows about
# the needs mappings (but shush logging "who wants it")
$self->{_current_magic} = '';
while (my ($name, $value) = each %{$want}) {
$self->want($name, $value) if $value;
}

# initialise config and run magic early, so needs are determined before
# we try to use them to skip tests whose features are missing
my $config = $self->{_instance_params}->{config}
|| Cassandane::Config->default();
$self->{_config} = $config->clone();
$self->_run_magic();

return $self;
}

Expand Down Expand Up @@ -206,22 +220,58 @@ sub _who_wants_it
return "Test " . $self->{_name};
}

my $want_needs = {
'replica' => [ [ 'component', 'replication' ] ],
};

sub want
{
my ($self, $name, $value) = @_;

if ($name eq 'services') {
# smoothly work around services being a subcategory of want
$self->want_services(@{$value});
return;
}

$value = 1 if !defined $value;
$self->{_want}->{$name} = $value;
xlog $self->_who_wants_it() . " wants $name = $value";

my $who_wants_it = $self->_who_wants_it();
if ($who_wants_it) {
xlog $self->_who_wants_it() . " wants $name = $value";
}

if ($want_needs->{$name}) {
foreach my $need (@{$want_needs->{$name}}) {
xlog "XXX want '$name' implies need @{$need}";
$self->needs(@{$need});
}
}
}

my $want_service_needs = {
};

sub want_services
{
my ($self, @services) = @_;

@{$self->{_want}->{services}} = uniq(@{$self->{_want}->{services}},
@services);
xlog $self->_who_wants_it() . " wants services " . join(', ', @services);

my $who_wants_it = $self->_who_wants_it();
if ($who_wants_it) {
xlog $who_wants_it . " wants services " . join(', ', @services);
}

foreach my $name (@services) {
if ($want_service_needs->{$name}) {
foreach my $need (@{$want_service_needs->{$name}}) {
$self->needs(@{$need});
}
}
}
}

sub needs
Expand Down Expand Up @@ -539,11 +589,6 @@ sub _create_instances
my $backend1_service_port;
my $backend2_service_port;

$self->{_config} = $self->{_instance_params}->{config} || Cassandane::Config->default();
$self->{_config} = $self->{_config}->clone();

$self->_run_magic();

my $want = $self->{_want};
my %instance_params = %{$self->{_instance_params}};

Expand Down
5 changes: 2 additions & 3 deletions cassandane/testrunner.pl
Original file line number Diff line number Diff line change
Expand Up @@ -367,9 +367,8 @@ sub usage
die "$joined formatters all want to write to stdout\n";
}

my @filters = qw(x skip_version skip_missing_features
skip_runtime_check
enable_wanted_properties);
my @filters = qw(x skip_version skip_runtime_check
enable_wanted_properties skip_missing_features);
push @filters, 'skip_slow' if $plan->{skip_slow};
push @filters, 'slow_only' if $plan->{slow_only};

Expand Down
2 changes: 1 addition & 1 deletion cassandane/tiny-tests/Caldav/replication_delete
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
use Cassandane::Tiny;

sub test_replication_delete
:needs_component_replication
:want_replica
{
my ($self) = @_;

Expand Down
1 change: 0 additions & 1 deletion cassandane/tiny-tests/Carddav/replication
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
use Cassandane::Tiny;

sub test_replication
:needs_component_replication
{
my ($self) = @_;

Expand Down
1 change: 0 additions & 1 deletion cassandane/tiny-tests/FastMail/mailbox_rename_long_chain
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ use Cassandane::Tiny;

sub test_mailbox_rename_long_chain
:AllowMoves :Replication :SyncLog :min_version_3_3
:needs_component_replication
{
my ($self) = @_;

Expand Down
1 change: 0 additions & 1 deletion cassandane/tiny-tests/FastMail/mailbox_rename_switch_ab
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ use Cassandane::Tiny;

sub test_mailbox_rename_switch_ab
:AllowMoves :Replication :SyncLog :min_version_3_3
:needs_component_replication
{
my ($self) = @_;

Expand Down
1 change: 0 additions & 1 deletion cassandane/tiny-tests/FastMail/sync_reset_legacy
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ use Cassandane::Tiny;

sub test_sync_reset_legacy
:DelayedDelete :min_version_3_5 :MailboxLegacyDirs
:needs_component_replication
{
my ($self) = @_;

Expand Down
1 change: 0 additions & 1 deletion cassandane/tiny-tests/FastMail/sync_reset_nolegacy
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ use Cassandane::Tiny;

sub test_sync_reset_nolegacy
:DelayedDelete :min_version_3_5 :NoMailboxLegacyDirs
:needs_component_replication
{
my ($self) = @_;

Expand Down
2 changes: 1 addition & 1 deletion cassandane/tiny-tests/Metadata/comment_repl
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
use Cassandane::Tiny;

sub test_comment_repl
:Replication :SyncLog :needs_component_replication
:Replication :SyncLog
{
my ($self) = @_;

Expand Down
1 change: 0 additions & 1 deletion cassandane/tiny-tests/Metadata/mbox_replication_new_mas
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
use Cassandane::Tiny;

sub test_mbox_replication_new_mas
:needs_component_replication
{
my ($self) = @_;

Expand Down
1 change: 0 additions & 1 deletion cassandane/tiny-tests/Metadata/msg_replication_exp_bot
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
use Cassandane::Tiny;

sub test_msg_replication_exp_bot
:needs_component_replication
{
my ($self) = @_;

Expand Down
1 change: 0 additions & 1 deletion cassandane/tiny-tests/Metadata/msg_replication_exp_mas
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
use Cassandane::Tiny;

sub test_msg_replication_exp_mas
:needs_component_replication
{
my ($self) = @_;

Expand Down
1 change: 0 additions & 1 deletion cassandane/tiny-tests/Metadata/msg_replication_exp_rep
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
use Cassandane::Tiny;

sub test_msg_replication_exp_rep
:needs_component_replication
{
my ($self) = @_;

Expand Down
1 change: 0 additions & 1 deletion cassandane/tiny-tests/Metadata/msg_replication_mod_bot_msh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
use Cassandane::Tiny;

sub test_msg_replication_mod_bot_msh
:needs_component_replication
{
my ($self) = @_;

Expand Down
1 change: 0 additions & 1 deletion cassandane/tiny-tests/Metadata/msg_replication_mod_bot_msl
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
use Cassandane::Tiny;

sub test_msg_replication_mod_bot_msl
:needs_component_replication
{
my ($self) = @_;

Expand Down
1 change: 0 additions & 1 deletion cassandane/tiny-tests/Metadata/msg_replication_mod_mas
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
use Cassandane::Tiny;

sub test_msg_replication_mod_mas
:needs_component_replication
{
my ($self) = @_;

Expand Down
1 change: 0 additions & 1 deletion cassandane/tiny-tests/Metadata/msg_replication_mod_rep
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
use Cassandane::Tiny;

sub test_msg_replication_mod_rep
:needs_component_replication
{
my ($self) = @_;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
use Cassandane::Tiny;

sub test_msg_replication_new_bot_mse_guh
:needs_component_replication
{
my ($self) = @_;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
use Cassandane::Tiny;

sub test_msg_replication_new_bot_mse_gul
:needs_component_replication
{
my ($self) = @_;

Expand Down
1 change: 0 additions & 1 deletion cassandane/tiny-tests/Metadata/msg_replication_new_mas
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
use Cassandane::Tiny;

sub test_msg_replication_new_mas
:needs_component_replication
{
my ($self) = @_;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
use Cassandane::Tiny;

sub test_msg_replication_new_mas_partial_wwd
:needs_component_replication
{
my ($self) = @_;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
use Cassandane::Tiny;

sub test_msg_replication_new_mas_partial_wwsw
:needs_component_replication
{
my ($self) = @_;

Expand Down
1 change: 0 additions & 1 deletion cassandane/tiny-tests/Metadata/msg_replication_new_rep
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
use Cassandane::Tiny;

sub test_msg_replication_new_rep
:needs_component_replication
{
my ($self) = @_;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ use Cassandane::Tiny;
#
sub test_private_global_annot_replication
:Replication :SyncLog :AnnotationAllowUndefined
:needs_component_replication
{
my ($self) = @_;

Expand Down
1 change: 0 additions & 1 deletion cassandane/tiny-tests/Quota/replication_annotstorage
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ use Cassandane::Tiny;

# Magic: the word 'replication' in the name enables a replica
sub test_replication_annotstorage
:needs_component_replication
{
my ($self) = @_;

Expand Down
1 change: 0 additions & 1 deletion cassandane/tiny-tests/Quota/replication_message
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ use Cassandane::Tiny;

# Magic: the word 'replication' in the name enables a replica
sub test_replication_message
:needs_component_replication
{
my ($self) = @_;

Expand Down
1 change: 0 additions & 1 deletion cassandane/tiny-tests/Quota/replication_storage
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ use Cassandane::Tiny;

# Magic: the word 'replication' in the name enables a replica
sub test_replication_storage
:needs_component_replication
{
my ($self) = @_;

Expand Down
Loading