Skip to content

Commit 7dd7b08

Browse files
committed
Info: test cyr_info conf-lint with bad partitions
1 parent 86e3801 commit 7dd7b08

File tree

1 file changed

+94
-0
lines changed

1 file changed

+94
-0
lines changed

cassandane/Cassandane/Cyrus/Info.pm

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,100 @@ sub test_lint_partitions
271271
);
272272
}
273273

274+
sub test_lint_partitions_dups
275+
:NoStartInstances
276+
{
277+
my ($self) = @_;
278+
279+
$self->config_set(
280+
# each has its own disk path: good
281+
'partition-good' => '/tmp/pgood',
282+
'metapartition-good' => '/tmp/mgood',
283+
'archivepartition-good' => '/tmp/agood',
284+
'foosearchpartition-good' => '/tmp/sgood',
285+
286+
# reusing disk paths for same-named partition: bad
287+
'partition-bad1' => '/tmp/bad',
288+
'metapartition-bad1' => '/tmp/bad',
289+
290+
# reusing disk paths for other-named partition: bad
291+
'partition-bad2' => '/tmp/bad',
292+
);
293+
294+
# master should fail to start
295+
eval {
296+
$self->_start_instances();
297+
};
298+
my $e = $@;
299+
$self->assert_not_null($e);
300+
301+
xlog $self, "test 'cyr_info conf-lint' with duplicated partitions configured";
302+
303+
my @output = $self->{instance}->run_cyr_info('conf-lint');
304+
@output = grep { !m/_db: / } @output; # skip database types
305+
306+
$self->assert_deep_equals(
307+
[ sort(
308+
"partition-bad1: /tmp/bad\n",
309+
"metapartition-bad1: /tmp/bad\n",
310+
"partition-bad2: /tmp/bad\n",
311+
) ],
312+
[ sort @output ]
313+
);
314+
315+
$self->assert_syslog_matches($self->{instance},
316+
qr{disk path used by multiple partitions});
317+
}
318+
319+
sub test_lint_partitions_subdirs
320+
:NoStartInstances
321+
{
322+
my ($self) = @_;
323+
324+
$self->config_set(
325+
# each has its own disk path: good
326+
'partition-good' => '/tmp/pgood',
327+
'metapartition-good' => '/tmp/mgood',
328+
'archivepartition-good' => '/tmp/agood',
329+
'foosearchpartition-good' => '/tmp/sgood',
330+
331+
# disk paths that are children of other's disk paths: bad
332+
'partition-bad1' => '/tmp/bad1',
333+
'metapartition-bad1' => '/tmp/bad1/meta',
334+
# XXX it can't currently report more than one bad child per parent
335+
336+
# disk paths that are descendents of other's disk paths: bad
337+
'partition-bad2' => '/tmp/bad2',
338+
'metapartition-bad2' => '/tmp/bad2/blah/meta',
339+
# XXX it can't currently report more than one bad child per parent
340+
);
341+
342+
# master should fail to start
343+
eval {
344+
$self->_start_instances();
345+
};
346+
my $e = $@;
347+
$self->assert_not_null($e);
348+
349+
xlog $self, "test 'cyr_info conf-lint' with subdir partitions configured";
350+
351+
my @output = $self->{instance}->run_cyr_info('conf-lint');
352+
@output = grep { !m/_db: / } @output; # skip database types
353+
354+
$self->assert_deep_equals(
355+
[ sort(
356+
"partition-bad1: /tmp/bad1\n",
357+
"metapartition-bad1: /tmp/bad1/meta\n",
358+
"partition-bad2: /tmp/bad2\n",
359+
"metapartition-bad2: /tmp/bad2/blah/meta\n",
360+
) ],
361+
[ sort @output ]
362+
);
363+
364+
$self->assert_syslog_matches($self->{instance},
365+
qr{disk path is a prefix of others});
366+
}
367+
274368
sub test_lint_services
275369
:want_service_http :needs_component_httpd :NoStartInstances
276370
{

0 commit comments

Comments
 (0)