Debian Codegraph @

cassandane/Cassandane/Cyrus/Replication.pm

raw
1 #!/usr/bin/perl
2 #
3 # Copyright (c) 2011-2017 FastMail Pty Ltd. All rights reserved.
4 #
5 # Redistribution and use in source and binary forms, with or without
6 # modification, are permitted provided that the following conditions
7 # are met:
8 #
9 # 1. Redistributions of source code must retain the above copyright
10 # notice, this list of conditions and the following disclaimer.
11 #
12 # 2. Redistributions in binary form must reproduce the above copyright
13 # notice, this list of conditions and the following disclaimer in
14 # the documentation and/or other materials provided with the
15 # distribution.
16 #
17 # 3. The name "Fastmail Pty Ltd" must not be used to
18 # endorse or promote products derived from this software without
19 # prior written permission. For permission or any legal
20 # details, please contact
21 # FastMail Pty Ltd
22 # PO Box 234
23 # Collins St West 8007
24 # Victoria
25 # Australia
26 #
27 # 4. Redistributions of any form whatsoever must retain the following
28 # acknowledgment:
29 # "This product includes software developed by Fastmail Pty. Ltd."
30 #
31 # FASTMAIL PTY LTD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
32 # INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
33 # EVENT SHALL OPERA SOFTWARE AUSTRALIA BE LIABLE FOR ANY SPECIAL, INDIRECT
34 # OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF
35 # USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
36 # TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
37 # OF THIS SOFTWARE.
38 #
39
40 package Cassandane::Cyrus::Replication;
41 use strict;
42 use warnings;
43 use Data::Dumper;
44 use DateTime;
45
46 use lib '.';
47 use base qw(Cassandane::Cyrus::TestCase);
48 use Cassandane::Util::Log;
49 use Cassandane::Util::Slurp;
50 use Cassandane::Service;
51 use Cassandane::Config;
52
53 sub new
54 {
55 my $class = shift;
56 my $self = $class->SUPER::new({ replica => 1, adminstore => 1 }, @_);
57
58 $self->needs('component', 'replication');
59 return $self;
60 }
61
62 sub set_up
63 {
64 my ($self) = @_;
65 $self->SUPER::set_up();
66 }
67
68 sub tear_down
69 {
70 my ($self) = @_;
71 $self->SUPER::tear_down();
72 }
73
74 # XXX need a test for version 10 mailbox without guids in it!
75
76 #* create mailbox on master with no messages
77 #* sync_client to get it copied to replica
78 #* create a message in the mailbox on replica (imaptalk on replica_store)
79 #* delete the message from the replica (with expunge_mode default or expunge_mode immediate... try both)
80 #* run sync_client on the master again and make sure it successfully syncs up
81
82 sub assert_user_sub_exists
83 {
84 my ($self, $instance, $user) = @_;
85
86 my $subs = $instance->get_conf_user_file($user, 'sub');
87 $self->assert_not_null($subs);
88
89 xlog $self, "Looking for subscriptions file $subs";
90
91 $self->assert_file_test($subs, '-f');
92 }
93
94 sub assert_user_sub_not_exists
95 {
96 my ($self, $instance, $user) = @_;
97
98 my $subs = $instance->get_conf_user_file($user, 'sub');
99 return unless $subs; # user might not exist
100
101 xlog $self, "Looking for subscriptions file $subs";
102
103 $self->assert_not_file_test($subs, '-f');
104 }
105
106 use Cassandane::Tiny::Loader 'tiny-tests/Replication';
107
108 1;