Script 'mail_helper' called by obssrc Hello community, here is the log from the commit of package MirrorCache for openSUSE:Factory checked in at 2022-02-17 23:40:24 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/MirrorCache (Old) and /work/SRC/openSUSE:Factory/.MirrorCache.new.1958 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "MirrorCache" Thu Feb 17 23:40:24 2022 rev:9 rq:955618 version:1.025 Changes: -------- --- /work/SRC/openSUSE:Factory/MirrorCache/MirrorCache.changes 2022-01-27 23:18:36.414298341 +0100 +++ /work/SRC/openSUSE:Factory/.MirrorCache.new.1958/MirrorCache.changes 2022-02-17 23:41:58.859700192 +0100 @@ -1,0 +2,15 @@ +Thu Feb 10 11:27:57 UTC 2022 - Andrii Nikitin <andrii.niki...@suse.com> + +- Update to version 1.025: + * Allow headquarter be in HA subsidiary handling (#255) + * Stat log after render (#256) + * Add SMALL_FILE_SIZE to serve small files directly from ROOT_NFS (#254) + +------------------------------------------------------------------- +Thu Feb 03 09:23:28 UTC 2022 - Andrii Nikitin <andrii.niki...@suse.com> + +- Update to version 1.024: + * Allow multiple subsidiaries per region (#250) + * Add internal timeouts for mirror checks and rendering (#249, #252) + +------------------------------------------------------------------- Old: ---- MirrorCache-1.023.obscpio New: ---- MirrorCache-1.025.obscpio ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ MirrorCache.spec ++++++ --- /var/tmp/diff_new_pack.cgG94d/_old 2022-02-17 23:41:59.427700187 +0100 +++ /var/tmp/diff_new_pack.cgG94d/_new 2022-02-17 23:41:59.435700187 +0100 @@ -22,7 +22,7 @@ %define main_requires %{assetpack_requires} perl(Carp) perl(DBD::Pg) >= 3.7.4 perl(DBI) >= 1.632 perl(DBIx::Class) >= 0.082801 perl(DBIx::Class::DynamicDefault) perl(DateTime) perl(Encode) perl(Time::Piece) perl(Time::Seconds) perl(Time::ParseDate) perl(DateTime::Format::Pg) perl(Exporter) perl(File::Basename) perl(LWP::UserAgent) perl(Mojo::Base) perl(Mojo::ByteStream) perl(Mojo::IOLoop) perl(Mojo::JSON) perl(Mojo::Pg) perl(Mojo::URL) perl(Mojo::Util) perl(Mojolicious::Commands) perl(Mojolicious::Plugin) perl(Mojolicious::Plugin::RenderFile) perl(Mojolicious::Static) perl(Net::OpenID::Consumer) perl(POSIX) perl(Sort::Versions) perl(URI::Escape) perl(XML::Writer) perl(base) perl(constant) perl(diagnostics) perl(strict) perl(warnings) shadow rubygem(sass) perl(Net::DNS) perl(LWP::Protocol::https) perl(Digest::SHA) %define build_requires %{assetpack_requires} rubygem(sass) tidy sysuser-shadow sysuser-tools Name: MirrorCache -Version: 1.023 +Version: 1.025 Release: 0 Summary: WebApp to redirect and manage mirrors License: GPL-2.0-or-later ++++++ MirrorCache-1.023.obscpio -> MirrorCache-1.025.obscpio ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/MirrorCache-1.023/lib/MirrorCache/Schema/Result/Subsidiary.pm new/MirrorCache-1.025/lib/MirrorCache/Schema/Result/Subsidiary.pm --- old/MirrorCache-1.023/lib/MirrorCache/Schema/Result/Subsidiary.pm 2022-01-14 23:02:13.000000000 +0100 +++ new/MirrorCache-1.025/lib/MirrorCache/Schema/Result/Subsidiary.pm 2022-02-10 11:37:36.000000000 +0100 @@ -50,5 +50,7 @@ { data_type => "varchar", is_nullable => 0, size => 128 }, "local", { data_type => "boolean", is_nullable => 0 }, + "weight", + { data_type => "int", is_nullable => 0 }, ); 1; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/MirrorCache-1.023/lib/MirrorCache/Task/FolderSyncScheduleFromMisses.pm new/MirrorCache-1.025/lib/MirrorCache/Task/FolderSyncScheduleFromMisses.pm --- old/MirrorCache-1.023/lib/MirrorCache/Task/FolderSyncScheduleFromMisses.pm 2022-01-14 23:02:13.000000000 +0100 +++ new/MirrorCache-1.025/lib/MirrorCache/Task/FolderSyncScheduleFromMisses.pm 2022-02-10 11:37:36.000000000 +0100 @@ -36,13 +36,17 @@ my $minion = $app->minion; # prevent multiple scheduling tasks to run in parallel return $job->finish('Previous schedule_from_misses job is still active') - unless my $guard = $minion->guard('folder_sync_schedule_from_misses', 60); + unless my $guard = $minion->guard('folder_sync_schedule_from_misses', 180); + + # Cannot lock schedule_from_misses lock + return $job->retry({delay => 10}) + unless my $common_guard = $minion->guard('schedule_from_misses', 60); my $schema = $app->schema; my $limit = $prev_stat_id? 50 : 10; my ($stat_id, $folders, $country_list) = $schema->resultset('Stat')->path_misses($prev_stat_id, $limit); - + $common_guard = undef; my $rs = $schema->resultset('Folder'); my $last_run = 0; while (scalar(@$folders)) { diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/MirrorCache-1.023/lib/MirrorCache/Task/MirrorScanScheduleFromMisses.pm new/MirrorCache-1.025/lib/MirrorCache/Task/MirrorScanScheduleFromMisses.pm --- old/MirrorCache-1.023/lib/MirrorCache/Task/MirrorScanScheduleFromMisses.pm 2022-01-14 23:02:13.000000000 +0100 +++ new/MirrorCache-1.025/lib/MirrorCache/Task/MirrorScanScheduleFromMisses.pm 2022-02-10 11:37:36.000000000 +0100 @@ -36,12 +36,17 @@ my $minion = $app->minion; # prevent multiple scheduling tasks to run in parallel return $job->finish('Previous job is still active') - unless my $guard = $minion->guard('mirror_scan_schedule_from_misses', 60); + unless my $guard = $minion->guard('mirror_scan_schedule_from_misses', 180); + + # Cannot lock schedule_from_misses lock + return $job->retry({delay => 10}) + unless my $common_guard = $minion->guard('schedule_from_misses', 60); my $schema = $app->schema; my $limit = $prev_stat_id ? 1000 : 10; my ($stat_id, $folder_ids, $country_list) = $schema->resultset('Stat')->mirror_misses($prev_stat_id, $limit); + $common_guard = undef; my $rs = $schema->resultset('Folder'); my $last_run = 0; while (scalar(@$folder_ids)) { diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/MirrorCache-1.023/lib/MirrorCache/WebAPI/Plugin/Dir.pm new/MirrorCache-1.025/lib/MirrorCache/WebAPI/Plugin/Dir.pm --- old/MirrorCache-1.023/lib/MirrorCache/WebAPI/Plugin/Dir.pm 2022-01-14 23:02:13.000000000 +0100 +++ new/MirrorCache-1.025/lib/MirrorCache/WebAPI/Plugin/Dir.pm 2022-02-10 11:37:36.000000000 +0100 @@ -1,4 +1,4 @@ -# Copyright (C) 2020 SUSE LLC +# Copyright (C) 2020,2020 SUSE LLC # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -68,6 +68,7 @@ return $c if _render_hashes($dm) + || _render_small($dm) || _redirect_geo($dm) || _redirect_normalized($dm) || _render_stats($dm) @@ -92,6 +93,9 @@ } # render_dir_remote tries to render dir when RootRemote cannot find it in DB + +my $RENDER_DIR_REMOTE_PROMISE_TIMEOUT = 15; + sub render_dir_remote { my $dm = shift; my $dir = shift; @@ -114,11 +118,11 @@ my $reftx = $tx; }; - $c->minion->result_p($job_id)->catch($handle_error)->then(sub { + $c->minion->result_p($job_id)->timeout($RENDER_DIR_REMOTE_PROMISE_TIMEOUT)->catch($handle_error)->then(sub { $c->emit_event('mc_debug', "promiseok: $job_id"); _render_dir($dm, $dir); my $reftx = $tx; - })->catch($handle_error)->timeout(15)->wait; + })->timeout($RENDER_DIR_REMOTE_PROMISE_TIMEOUT)->catch($handle_error)->timeout($RENDER_DIR_REMOTE_PROMISE_TIMEOUT)->wait; } sub _render_dir { @@ -474,6 +478,22 @@ return $c->render( 'dir', files => \@items, cur_path => $dir, folder_id => $id ); } +my $SMALL_FILE_SIZE = int($ENV{MIRRORCACHE_SMALL_FILE_SIZE} // 0); +my $ROOT_NFS = $ENV{MIRRORCACHE_ROOT_NFS}; + +sub _render_small { + return undef unless $SMALL_FILE_SIZE && $ROOT_NFS; + my $dm = shift; + my ($path, undef) = $dm->path; + my $full = $ROOT_NFS . $path; + my $size; + eval { $size = -s $full if -f $full; }; + return undef unless $size && $size le $SMALL_FILE_SIZE; + my $c = $dm->c; + $c->render_file(filepath => $full); + return 1; +} + sub _render_hashes { my $dm = shift; my $c = $dm->c; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/MirrorCache-1.023/lib/MirrorCache/WebAPI/Plugin/RenderFileFromMirror.pm new/MirrorCache-1.025/lib/MirrorCache/WebAPI/Plugin/RenderFileFromMirror.pm --- old/MirrorCache-1.023/lib/MirrorCache/WebAPI/Plugin/RenderFileFromMirror.pm 2022-01-14 23:02:13.000000000 +0100 +++ new/MirrorCache-1.025/lib/MirrorCache/WebAPI/Plugin/RenderFileFromMirror.pm 2022-02-10 11:37:36.000000000 +0100 @@ -251,7 +251,7 @@ } my $tx = $c->render_later->tx; - my $ua = Mojo::UserAgent->new->max_redirects(8); + my $ua = Mojo::UserAgent->new->connect_timeout(1)->request_timeout(2)->max_redirects(8); my $recurs1; my $expected_size = $file->{size}; my $expected_mtime = $file->{mtime}; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/MirrorCache-1.023/lib/MirrorCache/WebAPI/Plugin/Stat.pm new/MirrorCache-1.025/lib/MirrorCache/WebAPI/Plugin/Stat.pm --- old/MirrorCache-1.023/lib/MirrorCache/WebAPI/Plugin/Stat.pm 2022-01-14 23:02:13.000000000 +0100 +++ new/MirrorCache-1.025/lib/MirrorCache/WebAPI/Plugin/Stat.pm 2022-02-10 11:37:36.000000000 +0100 @@ -60,7 +60,10 @@ return $self->redirect_to_mirror(-3, $dm); } +my $ONLY_MISS = $ENV{MIRRORCACHE_STAT_LOG_ONLY_MISSES}; + sub redirect_to_mirror($self, $mirror_id, $dm) { + return undef if $ONLY_MISS && $mirror_id != -1; my ($path, $trailing_slash) = $dm->path; $path = $dm->root_subtree . $path; my $rows = $self->rows; @@ -69,7 +72,10 @@ my $cnt = @rows; if ($cnt >= $FLUSH_COUNT) { $self->rows(undef); - return $self->flush(\@rows); + $dm->c->tx->on(finish => sub ($tx) { + $self->flush(\@rows); + }); + return 1; } $self->rows(\@rows); return if $self->timer; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/MirrorCache-1.023/lib/MirrorCache/WebAPI/Plugin/Subsidiary.pm new/MirrorCache-1.025/lib/MirrorCache/WebAPI/Plugin/Subsidiary.pm --- old/MirrorCache-1.023/lib/MirrorCache/WebAPI/Plugin/Subsidiary.pm 2022-01-14 23:02:13.000000000 +0100 +++ new/MirrorCache-1.025/lib/MirrorCache/WebAPI/Plugin/Subsidiary.pm 2022-02-10 11:37:36.000000000 +0100 @@ -1,4 +1,4 @@ -# Copyright (C) 2021 SUSE LLC +# Copyright (C) 2021,2022 SUSE LLC # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -43,8 +43,19 @@ my $region = lc($s->region); next unless $region; push @regions, $region; + my $weight = int($s->weight) // 1; my $obj = Mojo::URL->new($url)->to_abs; - $subsidiary_urls{$region} = $obj; + my $arr = $subsidiary_urls{$region}; + + if (!$arr) { + my @arr; + push @arr, $obj; + $subsidiary_urls{$region} = \@arr; + } else { + for (my $i = 0; $i < $weight; $i++) { + push @$arr, $obj; + } + } $subsidiary_local{$region} = 1 if $s->local; $app->routes->get("/rest/$region" => sub { @@ -90,8 +101,12 @@ sub _has_subsidiary { return undef unless keys %subsidiary_urls; my ($c, $region, $origin_url) = @_; - my $region_url = $subsidiary_urls{$region}; + my $arr = $subsidiary_urls{$region}; + return undef if !$arr || 'ARRAY' ne ref $arr; + my $region_url = $arr->[rand @$arr]; # this how we respect weight of each node + return $region_url unless $region_url && $origin_url; + return undef unless $region_url->host; my $url = $origin_url->to_abs->clone; $url->host($region_url->host); $url->port($region_url->port); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/MirrorCache-1.023/lib/MirrorCache/resources/migrations/pg.sql new/MirrorCache-1.025/lib/MirrorCache/resources/migrations/pg.sql --- old/MirrorCache-1.023/lib/MirrorCache/resources/migrations/pg.sql 2022-01-14 23:02:13.000000000 +0100 +++ new/MirrorCache-1.025/lib/MirrorCache/resources/migrations/pg.sql 2022-02-10 11:37:36.000000000 +0100 @@ -257,3 +257,9 @@ alter table stat add column if not exists pid int, add column if not exists execution_time int; +-- 19 up +alter table subsidiary + drop constraint subsidiary_pkey, + add column weight int default '1'; +-- 20 up +CREATE INDEX if not exists folder_diff_id_index ON folder_diff_file(folder_diff_id); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/MirrorCache-1.023/t/environ/01-smoke-mirror-hasall.sh new/MirrorCache-1.025/t/environ/01-smoke-mirror-hasall.sh --- old/MirrorCache-1.023/t/environ/01-smoke-mirror-hasall.sh 2022-01-14 23:02:13.000000000 +0100 +++ new/MirrorCache-1.025/t/environ/01-smoke-mirror-hasall.sh 2022-02-10 11:37:36.000000000 +0100 @@ -20,13 +20,14 @@ $ap8/start $ap8/curl /folder1/ | grep file1.1.dat +FAKEURL="notexists${RANDOM}.com" $mc/db/sql "insert into server(hostname,urldir,enabled,country,region) select '$($ap7/print_address)','','t','us','na'" $mc/db/sql "insert into server(hostname,urldir,enabled,country,region) select '$($ap8/print_address)','','t','de','eu'" -$mc/db/sql "insert into server(hostname,urldir,enabled,country,region) select 'notexists.com','','t','it','eu'" +$mc/db/sql "insert into server(hostname,urldir,enabled,country,region) select '$FAKEURL','','t','it','eu'" -$mc/db/sql "insert into server_capability_declaration(server_id, capability, enabled) select id, 'hasall', 't' from server where hostname = 'notexists.com'"; +$mc/db/sql "insert into server_capability_declaration(server_id, capability, enabled) select id, 'hasall', 't' from server where hostname = '${FAKEURL}'"; $mc/curl -Is /download/folder1/file1.1.dat.mirrorlist @@ -36,10 +37,10 @@ $mc/backstage/job mirror_scan_schedule $mc/backstage/shoot -$mc/curl -I /download/folder1/file1.1.dat?COUNTRY=it | grep -C10 302 | grep "notexists.com" -$mc/curl /download/folder1/file1.1.dat.mirrorlist | grep "notexists.com" +$mc/curl -I /download/folder1/file1.1.dat?COUNTRY=it | grep -C10 302 | grep "${FAKEURL}" +$mc/curl /download/folder1/file1.1.dat.mirrorlist | grep "${FAKEURL}" # with pedantic we ignore it though rc=0 -$mc/curl -I /download/folder1/file1.1.dat?"COUNTRY=it&PEDANTIC=1" | grep "notexists.com" || rc=$? +$mc/curl -I /download/folder1/file1.1.dat?"COUNTRY=it&PEDANTIC=1" | grep "${FAKEURL}" || rc=$? test $rc -gt 0 echo success diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/MirrorCache-1.023/t/environ/03-headquarter-subsidiaries-remote.sh new/MirrorCache-1.025/t/environ/03-headquarter-subsidiaries-remote.sh --- old/MirrorCache-1.023/t/environ/03-headquarter-subsidiaries-remote.sh 2022-01-14 23:02:13.000000000 +0100 +++ new/MirrorCache-1.025/t/environ/03-headquarter-subsidiaries-remote.sh 2022-02-10 11:37:36.000000000 +0100 @@ -14,6 +14,9 @@ echo $root/dt/{folder1,folder2,folder3}/{file1.1,file2.1}.dat | xargs -n 1 touch mkdir $root/dt/folder1/repodata/ touch $root/dt/folder1/repodata/file1.dat +SMALL_FILE_SIZE=3 +echo -n 1234 > $root/dt/folder1/repodata/filebig1.1.dat +echo -n 123 > $root/dt/folder1/repodata/filesmall1.1.dat echo repomdcontent > $root/dt/folder1/repodata/repomd.xml touch $root/dt/folder1/repodata/repomd.xml.asc @@ -23,6 +26,7 @@ $mc9/gen_env "MIRRORCACHE_TOP_FOLDERS='folder1 folder2 folder3'" \ MIRRORCACHE_SCHEDULE_RETRY_INTERVAL=0 \ MIRRORCACHE_ROOT=http://$($root/print_address) \ + MIRRORCACHE_SMALL_FILE_SIZE=$SMALL_FILE_SIZE \ MIRRORCACHE_ROOT_NFS=$root/dt # deploy db @@ -53,3 +57,8 @@ $mc9/db/start $mc9/curl --interface 127.0.0.5 /folder1/repodata/file1.dat.metalink | grep 'origin="http://127.0.0.1:3190/folder1/repodata/file1.dat.metalink"' + +# filebig is redirected to EU +$mc9/curl -I --interface $eu_interface /folder1/repodata/filebig1.1.dat | grep '302' +# filesmall is served right away +$mc9/curl -I --interface $eu_interface /folder1/repodata/filesmall1.1.dat | grep '200 OK' diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/MirrorCache-1.023/t/environ/03-headquarter-subsidiaries-weight.sh new/MirrorCache-1.025/t/environ/03-headquarter-subsidiaries-weight.sh --- old/MirrorCache-1.023/t/environ/03-headquarter-subsidiaries-weight.sh 1970-01-01 01:00:00.000000000 +0100 +++ new/MirrorCache-1.025/t/environ/03-headquarter-subsidiaries-weight.sh 2022-02-10 11:37:36.000000000 +0100 @@ -0,0 +1,72 @@ +#!lib/test-in-container-environ.sh +set -ex + +# environ by number: +# 9 - headquarter +# 5 - NA subsidiary weight 2 +# 6 - NA subsidiary weight 1 +# 7 - EU subsidiary +# 8 - ASIA subsidiary + +for i in 5 6 7 8 9; do + x=$(environ mc$i $(pwd)) + mkdir -p $x/dt/{folder1,folder2,folder3} + echo $x/dt/{folder1,folder2,folder3}/{file1.1,file2.1}.dat | xargs -n 1 touch + eval mc$i=$x +done + +hq_address=$($mc9/print_address) +na_address1=$($mc5/print_address) +na_address2=$($mc6/print_address) +na_interface=127.0.0.2 +eu_address=$($mc7/print_address) +eu_interface=127.0.0.3 +as_address=$($mc8/print_address) +as_interface=127.0.0.4 + +# deploy db +$mc9/gen_env MIRRORCACHE_TOP_FOLDERS='folder1 folder2 folder3' +$mc9/backstage/shoot + +$mc9/sql "insert into subsidiary(hostname,region,weight) select '$na_address1','na',1" +$mc9/sql "insert into subsidiary(hostname,region,weight) select '$na_address2','na',3" +$mc9/sql "insert into subsidiary(hostname,region) select '$eu_address','eu'" +$mc9/sql "insert into subsidiary(hostname,region) select '$as_address','as'" + +$mc9/start +$mc5/gen_env MIRRORCACHE_REGION=na +$mc5/start +$mc6/gen_env MIRRORCACHE_REGION=na +$mc6/start +$mc7/gen_env MIRRORCACHE_REGION=eu +$mc7/start +$mc8/gen_env MIRRORCACHE_REGION=as +$mc8/start + +echo the root folder is not redirected +curl --interface $eu_interface -Is http://$hq_address/ | grep '200 OK' + +echo check redirection from headquarter +curl --interface $na_interface -Is http://$hq_address/download/folder1/file1.1.dat | grep -E "Location: http:\/\/($na_address1|$na_address2)\/download\/folder1\/file1.1.dat" + + +# do requests and check that both na instances are being used and instance 2 is used more frequently +out=$( +counter=30 + +while test $counter -gt 0 +do + curl --interface $na_interface -Is http://$hq_address/download/folder1/file1.1.dat + ((counter--)) +done +) + +out1=$(echo "$out" | grep "Location: http://$na_address1/download/folder1/file1.1.dat" | wc -l) +out2=$(echo "$out" | grep "Location: http://$na_address2/download/folder1/file1.1.dat" | wc -l) + +test $out1 -gt 0 +test $out2 -gt 0 +test $out2 -gt $out1 + + + diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/MirrorCache-1.023/t/environ/03-headquarter-subsidiaries-weight1.sh new/MirrorCache-1.025/t/environ/03-headquarter-subsidiaries-weight1.sh --- old/MirrorCache-1.023/t/environ/03-headquarter-subsidiaries-weight1.sh 1970-01-01 01:00:00.000000000 +0100 +++ new/MirrorCache-1.025/t/environ/03-headquarter-subsidiaries-weight1.sh 2022-02-10 11:37:36.000000000 +0100 @@ -0,0 +1,75 @@ +#!lib/test-in-container-environ.sh +set -ex + +# environ by number: +# 9 - headquarter +# 5 - NA subsidiary weight 2 +# 6 - NA subsidiary weight 1 +# 7 - EU subsidiary +# 8 - ASIA subsidiary + +for i in 5 6 7 8 9; do + x=$(environ mc$i $(pwd)) + mkdir -p $x/dt/{folder1,folder2,folder3} + echo $x/dt/{folder1,folder2,folder3}/{file1.1,file2.1}.dat | xargs -n 1 touch + eval mc$i=$x +done + +hq_address=$($mc9/print_address) +na_address1=$($mc5/print_address) +na_address2=$($mc6/print_address) +na_interface=127.0.0.2 +eu_address=$($mc7/print_address) +eu_interface=127.0.0.3 +as_address=$($mc8/print_address) +as_interface=127.0.0.4 + +# deploy db +$mc9/gen_env MIRRORCACHE_TOP_FOLDERS='folder1 folder2 folder3' +$mc9/backstage/shoot + +$mc9/sql "insert into subsidiary(hostname,region,weight) select '$na_address1','na',1" +$mc9/sql "insert into subsidiary(hostname,region,weight) select '$na_address2','na',3" +$mc9/sql "insert into subsidiary(hostname,region,weight) select '','na',2" +$mc9/sql "insert into subsidiary(hostname,region) select '$eu_address','eu'" +$mc9/sql "insert into subsidiary(hostname,region) select '$as_address','as'" + +$mc9/start +$mc5/gen_env MIRRORCACHE_REGION=na +$mc5/start +$mc6/gen_env MIRRORCACHE_REGION=na +$mc6/start +$mc7/gen_env MIRRORCACHE_REGION=eu +$mc7/start +$mc8/gen_env MIRRORCACHE_REGION=as +$mc8/start + +echo the root folder is not redirected +curl --interface $eu_interface -Is http://$hq_address/ | grep '200 OK' + +echo check redirection from headquarter +curl --interface $na_interface -Is http://$hq_address/download/folder1/file1.1.dat | grep -E "Location: http:\/\/($na_address1|$na_address2)\/download\/folder1\/file1.1.dat" + + +# do requests and check that both na instances are being used and instance 2 is used more frequently +out=$( +counter=90 + +while test $counter -gt 0 +do + curl --interface $na_interface -Is http://$hq_address/download/folder1/file1.1.dat + ((counter--)) +done +) + +out1=$(echo "$out" | grep "Location: http://$na_address1/download/folder1/file1.1.dat" | wc -l) +out2=$(echo "$out" | grep "Location: http://$na_address2/download/folder1/file1.1.dat" | wc -l) +out3=$(echo "$out" | grep "200 OK" | wc -l) + +test $out1 -gt 0 +test $out2 -gt 0 +test $out3 -gt 0 +test $out2 -gt $out1 +test $out2 -gt $out3 +test $out3 -gt $out1 + diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/MirrorCache-1.023/t/lib/Dockerfile.environ new/MirrorCache-1.025/t/lib/Dockerfile.environ --- old/MirrorCache-1.023/t/lib/Dockerfile.environ 2022-01-14 23:02:13.000000000 +0100 +++ new/MirrorCache-1.025/t/lib/Dockerfile.environ 2022-02-10 11:37:36.000000000 +0100 @@ -13,7 +13,7 @@ apache2 perl-Digest-MD4 tidy nginx bbe # optional dependencies used in testing -RUN zypper -vvv -n install perl-Geo-IP2Location perl-Inline-C +RUN zypper -vvv -n install perl-Geo-IP2Location perl-Inline-C gcc RUN zypper -vvv -n install make rsync ++++++ MirrorCache.obsinfo ++++++ --- /var/tmp/diff_new_pack.cgG94d/_old 2022-02-17 23:41:59.779700184 +0100 +++ /var/tmp/diff_new_pack.cgG94d/_new 2022-02-17 23:41:59.783700184 +0100 @@ -1,5 +1,5 @@ name: MirrorCache -version: 1.023 -mtime: 1642197733 -commit: 7c9c68a96f6b49d5e97670f57e64aa252a9af22a +version: 1.025 +mtime: 1644489456 +commit: a025a68eac1adc2c1bdaf5df1c45dbc011bf94bd