Skip to content

Commit 03e7bf2

Browse files
committed
Merge pull request quattor#63 from ajf8/multiple_failovers
support for multiple profile failover urls
2 parents fdc45d0 + 8cf18fb commit 03e7bf2

File tree

3 files changed

+18
-3
lines changed

3 files changed

+18
-3
lines changed

src/main/perl/CCfg.pm

+1-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ Readonly::Array our @CONFIG_OPTIONS => (
6262
{
6363
option => 'profile_failover',
6464
suffix => '=s',
65-
HELP => 'URL of profile to fetch when --profile is not available',
65+
HELP => 'URL of profile to fetch when --profile is not available, can be comma separated',
6666
},
6767

6868
{

src/main/perl/Fetch.pm

+5-1
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,11 @@ sub download
329329

330330
my @st = stat($cache) or die "Unable to stat profile cache: $cache ($!)";
331331

332-
foreach my $u (($url, $self->{uc($type) . "_FAILOVER"})) {
332+
my @urls = ($url);
333+
push @urls, split(/,/, $self->{uc($type) . "_FAILOVER"})
334+
if defined($self->{uc($type) . "_FAILOVER"});
335+
336+
foreach my $u (@urls) {
333337
next if (!defined($u));
334338
for my $i (1 .. $self->{RETRIEVE_RETRIES}) {
335339
my $rt = $self->retrieve($u, $cache, $st[ST_MTIME]);

src/test/perl/fetch.t

+12-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ Script that tests the EDG::WP4::CCM::Fetch module.
1313

1414
use strict;
1515
use warnings;
16-
use Test::More tests => 63;
16+
use Test::More tests => 64;
1717
use EDG::WP4::CCM::Fetch qw($GLOBAL_LOCK_FN $FETCH_LOCK_FN
1818
$CURRENT_CID_FN $LATEST_CID_FN $DATA_DN
1919
$TABCOMPLETION_FN
@@ -242,6 +242,17 @@ isnt($pf, undef, "Non-existing URL with a failover retrieves something");
242242

243243
=pod
244244
245+
Multiple comma seperated failover URLs are supported. Try two failovers,
246+
the first of which doesn't work.
247+
248+
=cut
249+
250+
$f->{PROFILE_FAILOVER} = "http://afjbsabfaf.fadsfsagfsagagf.org,$url";
251+
$pf = $f->download("profile");
252+
isnt($pf, undef, "Non-existing URL with a non-existing first failover retrieves something");
253+
254+
=pod
255+
245256
=head2 Whatever happens to C<previous> and C<current>?
246257
247258
=cut

0 commit comments

Comments
 (0)