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-04-06 21:52:19 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/MirrorCache (Old) and /work/SRC/openSUSE:Factory/.MirrorCache.new.1900 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "MirrorCache" Wed Apr 6 21:52:19 2022 rev:12 rq:967358 version:1.028 Changes: -------- --- /work/SRC/openSUSE:Factory/MirrorCache/MirrorCache.changes 2022-03-23 20:21:16.478561074 +0100 +++ /work/SRC/openSUSE:Factory/.MirrorCache.new.1900/MirrorCache.changes 2022-04-06 21:52:53.470608747 +0200 @@ -1,0 +2,10 @@ +Wed Mar 30 15:00:05 UTC 2022 - Andrii Nikitin <andrii.niki...@suse.com> + +- Update to version 1.028: + * Introduce in-application load balancing read queries to DB replica (#262) + * Fix bigint DB error when inserting hash for big files (#262) + * Move initialization code from before_server_start to execute earlier (#262) + * t: Fix unstable test 03-headquarter-subsidiaries-weight1 by correcting expected values (#262) + * spec: Fix renamed README in the spec file (#262) + +------------------------------------------------------------------- Old: ---- MirrorCache-1.027.obscpio New: ---- MirrorCache-1.028.obscpio ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ MirrorCache.spec ++++++ --- /var/tmp/diff_new_pack.8j1gH5/_old 2022-04-06 21:52:54.086601717 +0200 +++ /var/tmp/diff_new_pack.8j1gH5/_new 2022-04-06 21:52:54.090601672 +0200 @@ -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.027 +Version: 1.028 Release: 0 Summary: WebApp to redirect and manage mirrors License: GPL-2.0-or-later ++++++ MirrorCache-1.027.obscpio -> MirrorCache-1.028.obscpio ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/MirrorCache-1.027/dist/rpm/MirrorCache.spec new/MirrorCache-1.028/dist/rpm/MirrorCache.spec --- old/MirrorCache-1.027/dist/rpm/MirrorCache.spec 2022-03-16 15:24:45.000000000 +0100 +++ new/MirrorCache-1.028/dist/rpm/MirrorCache.spec 2022-03-30 16:57:14.000000000 +0200 @@ -79,7 +79,7 @@ %service_del_postun_without_restart mirrorcache-hypnotoad.service %files -%doc README.asciidoc +%doc README.md %license LICENSE %{_sbindir}/rcmirrorcache %{_sbindir}/rcmirrorcache-hypnotoad diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/MirrorCache-1.027/lib/MirrorCache/Schema/ResultSet/Hash.pm new/MirrorCache-1.028/lib/MirrorCache/Schema/ResultSet/Hash.pm --- old/MirrorCache-1.027/lib/MirrorCache/Schema/ResultSet/Hash.pm 2022-03-16 15:24:45.000000000 +0100 +++ new/MirrorCache-1.028/lib/MirrorCache/Schema/ResultSet/Hash.pm 2022-03-30 16:57:14.000000000 +0200 @@ -46,9 +46,9 @@ dt = now() END_SQL my $prep = $dbh->prepare($sql); - $prep->bind_param( 1, $file_id, SQL_INTEGER); - $prep->bind_param( 2, $mtime, SQL_INTEGER); - $prep->bind_param( 3, $size, SQL_INTEGER); + $prep->bind_param( 1, $file_id, SQL_BIGINT); + $prep->bind_param( 2, $mtime, SQL_BIGINT); + $prep->bind_param( 3, $size, SQL_BIGINT); $prep->bind_param( 4, $md5hex, SQL_CHAR); $prep->bind_param( 5, $sha1hex, SQL_CHAR); $prep->bind_param( 6, $sha256hex, SQL_CHAR); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/MirrorCache-1.027/lib/MirrorCache/Schema.pm new/MirrorCache-1.028/lib/MirrorCache/Schema.pm --- old/MirrorCache-1.027/lib/MirrorCache/Schema.pm 2022-03-16 15:24:45.000000000 +0100 +++ new/MirrorCache-1.028/lib/MirrorCache/Schema.pm 2022-03-30 16:57:14.000000000 +0200 @@ -11,6 +11,7 @@ __PACKAGE__->load_namespaces; my $SINGLETON; +my $SINGLETONR; sub connect_db { my %args = @_; @@ -37,11 +38,38 @@ return $SINGLETON; } +sub connect_replica_db { + my %args = @_; + + unless ($SINGLETONR) { + my $dsn; + my $user = $ENV{MIRRORCACHE_DBUSER}; + my $pass = $ENV{MIRRORCACHE_DBPASS}; + if ($ENV{MIRRORCACHE_DSN_REPLICA}) { + $dsn = $ENV{MIRRORCACHE_DSN_REPLICA}; + } else { + my $db = $ENV{MIRRORCACHE_DB} // 'mirrorcache'; + my $host = $ENV{MIRRORCACHE_DBREPLICA}; + my $port = $ENV{MIRRORCACHE_DBPORT}; + $dsn = "DBI:Pg:dbname=$db"; + $dsn = "$dsn;host=$host" if $host; + $dsn = "$dsn;port=$port" if $port; + } + $SINGLETONR = __PACKAGE__->connect($dsn, $user, $pass); + } + + return $SINGLETONR; +} + sub disconnect_db { if ($SINGLETON) { $SINGLETON->storage->disconnect; $SINGLETON = undef; } + if ($SINGLETONR) { + $SINGLETONR->storage->disconnect; + $SINGLETONR = undef; + } } sub dsn { @@ -55,6 +83,12 @@ sub singleton { $SINGLETON || connect_db() } +sub singletonR { + return singleton() unless $ENV{MIRRORCACHE_DBREPLICA}; + + $SINGLETONR || connect_replica_db(); +} + sub has_table { my ($self,$table_name) = @_; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/MirrorCache-1.027/lib/MirrorCache/WebAPI/Plugin/Helpers.pm new/MirrorCache-1.028/lib/MirrorCache/WebAPI/Plugin/Helpers.pm --- old/MirrorCache-1.027/lib/MirrorCache/WebAPI/Plugin/Helpers.pm 2022-03-16 15:24:45.000000000 +0100 +++ new/MirrorCache-1.028/lib/MirrorCache/WebAPI/Plugin/Helpers.pm 2022-03-30 16:57:14.000000000 +0200 @@ -51,6 +51,7 @@ }); $app->helper(schema => sub { MirrorCache::Schema->singleton }); + $app->helper(schemaR => sub { MirrorCache::Schema->singletonR }); $app->helper( # emit_event helper, adds user to events diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/MirrorCache-1.027/lib/MirrorCache/WebAPI/Plugin/RenderFileFromMirror.pm new/MirrorCache-1.028/lib/MirrorCache/WebAPI/Plugin/RenderFileFromMirror.pm --- old/MirrorCache-1.027/lib/MirrorCache/WebAPI/Plugin/RenderFileFromMirror.pm 2022-03-16 15:24:45.000000000 +0100 +++ new/MirrorCache-1.028/lib/MirrorCache/WebAPI/Plugin/RenderFileFromMirror.pm 2022-03-30 16:57:14.000000000 +0200 @@ -479,7 +479,7 @@ my $ipvstrict = $dm->ipvstrict; my $metalink = $dm->metalink; my $limit = $mirrorlist ? 100 : (( $metalink || $dm->pedantic )? 10 : 1); - my $rs = $dm->c->schema->resultset('Server'); + my $rs = $dm->c->schemaR->resultset('Server'); my $m; $m = $rs->mirrors_query( diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/MirrorCache-1.027/lib/MirrorCache/WebAPI.pm new/MirrorCache-1.028/lib/MirrorCache/WebAPI.pm --- old/MirrorCache-1.027/lib/MirrorCache/WebAPI.pm 2022-03-16 15:24:45.000000000 +0100 +++ new/MirrorCache-1.028/lib/MirrorCache/WebAPI.pm 2022-03-30 16:57:14.000000000 +0200 @@ -21,10 +21,32 @@ use MirrorCache::Schema; use MirrorCache::Utils 'random_string'; +has 'version'; +has 'root'; +has '_geodb'; + sub new { my $self = shift->SUPER::new; # setting pid_file in startup will not help, need to set it earlier $self->config->{hypnotoad}{pid_file} = $ENV{MIRRORCACHE_HYPNOTOAD_PID} // '/run/mirrorcache/hypnotoad.pid'; + + # I wasn't able to find reliable way in Mojolicious to detect when WebUI is started + # (e.g. in daemon or hypnotoad in contrast to other commands like backend start / shoot) + # so the code below tries to detect if _setup_ui is needed to be called + + my $started = 0; + for (my $i = 0; my @r = caller($i); $i++) { + next unless $r[3] =~ m/Hypnotoad/; + $self->_setup_webui; + $started = 1; + last; + } + + $self->hook(before_command => sub { + my ($command, $arg) = @_; + $self->_setup_webui if ref($command) =~ m/daemon|prefork/; + }) unless $started; + $self; } @@ -45,7 +67,7 @@ eval { MirrorCache::Schema->singleton->migrate(); 1; - } or die("Automatic migration failed: $@\nFix table structure and insert into mojo_migrations select 'mirrorcache',version"); + } or die("Automatic migration failed: $@\nFix table structure and insert into mojo_migrations select 'mirrorcache', version"); my $secret = random_string(16); $self->config->{hypnotoad}{listen} = [$ENV{MOJO_LISTEN} // 'http://*:8080']; $self->config->{hypnotoad}{proxy} = $ENV{MOJO_REVERSE_PROXY} // 0, @@ -61,90 +83,10 @@ my $current_version = $self->detect_current_version() || "unknown"; $self->defaults(current_version => $current_version); $self->log->info("initializing $current_version"); + $self->version($current_version); $self->defaults(branding => $ENV{MIRRORCACHE_BRANDING}); - $self->app->hook(before_server_start => sub { - die("MIRRORCACHE_ROOT is not set") unless $root; - if ((-1 == rindex($root, 'http', 0)) && (-1 == rindex($root, 'rsync://', 0)) ) { - my $i = index($root, ':'); - my $dir = ($i > -1 ? substr($root, 0, $i) : $root); - die("MIRRORCACHE_ROOT is not a directory ($root)") unless -d $dir; - } - - # Optional initialization with access to the app - my $r = $self->routes->namespaces(['MirrorCache::WebAPI::Controller']); - $r->get('/favicon.ico' => sub { my $c = shift; $c->render_static('favicon.ico') }); - - $r->get('/version')->to(cb => sub { - shift->render(text => $current_version); - }) if $current_version; - $r->post('/session')->to('session#create'); - $r->delete('/session')->to('session#destroy'); - $r->get('/login')->name('login')->to('session#create'); - $r->post('/login')->to('session#create'); - $r->post('/logout')->name('logout')->to('session#destroy'); - $r->get('/response')->to('session#response'); - $r->post('/response')->to('session#response'); - - my $rest = $r->any('/rest'); - my $rest_r = $rest->any('/')->to(namespace => 'MirrorCache::WebAPI::Controller::Rest'); - $rest_r->get('/server')->name('rest_server')->to('table#list', table => 'Server'); - $rest_r->get('/server/:id')->to('table#list', table => 'Server'); - $rest_r->get('/project/:name')->to('project#show'); - $rest_r->get('/project/:name/mirror_summary')->to('project#mirror_summary'); - $rest_r->get('/project/:name/mirror_list')->to('project#mirror_list'); - - my $rest_operator_auth; - $rest_operator_auth = $rest->under('/')->to('session#ensure_operator'); - my $rest_operator_r = $rest_operator_auth->any('/')->to(namespace => 'MirrorCache::WebAPI::Controller::Rest'); - $rest_operator_r->post('/server')->to('table#create', table => 'Server'); - $rest_operator_r->post('/server/:id')->name('post_server')->to('table#update', table => 'Server'); - $rest_operator_r->delete('/server/:id')->to('table#destroy', table => 'Server'); - $rest_operator_r->put('/server/location/:id')->name('rest_put_server_location')->to('server_location#update_location'); - $rest_operator_r->post('/sync_tree')->name('rest_post_sync_tree')->to('folder_jobs#sync_tree'); - - $rest_r->get('/folder')->name('rest_folder')->to('table#list', table => 'Folder'); - - $rest_r->get('/folder_jobs/:id')->name('rest_folder_jobs')->to('folder_jobs#list'); - $rest_r->get('/myip')->name('rest_myip')->to('my_ip#show') if $geodb; - - $rest_r->get('/stat')->name('rest_stat')->to('stat#list'); - $rest_r->get('/mystat')->name('rest_mystat')->to('stat#mylist'); - - my $app_r = $r->any('/app')->to(namespace => 'MirrorCache::WebAPI::Controller::App'); - - $app_r->get('/server')->name('server')->to('server#index'); - $app_r->get('/folder')->name('folder')->to('folder#index'); - $app_r->get('/folder/<id:num>')->name('folder_show')->to('folder#show'); - - my $admin = $r->any('/admin'); - my $admin_auth = $admin->under('/')->to('session#ensure_admin')->name('ensure_admin'); - my $admin_r = $admin_auth->any('/')->to(namespace => 'MirrorCache::WebAPI::Controller::Admin'); - - $admin_r->delete('/folder/<id:num>')->to('folder#delete_cascade'); - $admin_r->delete('/folder_diff/<id:num>')->to('folder#delete_diff'); - - $admin_r->get('/user')->name('get_user')->to('user#index'); - $admin_r->post('/user/:userid')->name('post_user')->to('user#update'); - - my $rest_user_r = $admin_auth->any('/')->to(namespace => 'MirrorCache::WebAPI::Controller::Rest'); - $rest_user_r->delete('/user/<id:num>')->name('delete_user')->to('user#delete'); - - $admin_r->get('/auditlog')->name('audit_log')->to('audit_log#index'); - $admin_r->get('/auditlog/ajax')->name('audit_ajax')->to('audit_log#ajax'); - - $r->get('/index' => sub { shift->render('main/index') }); - $r->get('/' => sub { shift->render('main/index') })->name('index'); - - $self->plugin(AssetPack => {pipes => [qw(Sass Css JavaScript Fetch Combine)]}); - $self->asset->process; - $self->plugin('Stat'); - $self->plugin('Dir'); - $self->log->info("server started: $current_version"); - }); - - $self->plugin('RenderFile'); push @{$self->plugins->namespaces}, 'MirrorCache::WebAPI::Plugin'; @@ -170,6 +112,7 @@ else { $self->plugin('Mmdb', { reader => $geodb }); } + $self->_geodb($geodb) if $geodb; $self->plugin('Helpers', root => $root, route => '/download'); $self->plugin('Subsidiary'); @@ -182,9 +125,93 @@ } else { $self->plugin('RootRemote'); } + $self->root($root) } } +sub _setup_webui { + my $self = shift; + my $root = $self->root; + die("MIRRORCACHE_ROOT is not set") unless $root; + if ((-1 == rindex($root, 'http', 0)) && (-1 == rindex($root, 'rsync://', 0)) ) { + my $i = index($root, ':'); + my $dir = ($i > -1 ? substr($root, 0, $i) : $root); + die("MIRRORCACHE_ROOT is not a directory ($root)") unless -d $dir; + } + + # Optional initialization with access to the app + my $r = $self->routes->namespaces(['MirrorCache::WebAPI::Controller']); + $r->get('/favicon.ico' => sub { my $c = shift; $c->render_static('favicon.ico') }); + + my $current_version = $self->version; + $r->get('/version')->to(cb => sub { + shift->render(text => $current_version); + }) if $current_version; + $r->post('/session')->to('session#create'); + $r->delete('/session')->to('session#destroy'); + $r->get('/login')->name('login')->to('session#create'); + $r->post('/login')->to('session#create'); + $r->post('/logout')->name('logout')->to('session#destroy'); + $r->get('/response')->to('session#response'); + $r->post('/response')->to('session#response'); + + my $rest = $r->any('/rest'); + my $rest_r = $rest->any('/')->to(namespace => 'MirrorCache::WebAPI::Controller::Rest'); + $rest_r->get('/server')->name('rest_server')->to('table#list', table => 'Server'); + $rest_r->get('/server/:id')->to('table#list', table => 'Server'); + $rest_r->get('/project/:name')->to('project#show'); + $rest_r->get('/project/:name/mirror_summary')->to('project#mirror_summary'); + $rest_r->get('/project/:name/mirror_list')->to('project#mirror_list'); + + my $rest_operator_auth; + $rest_operator_auth = $rest->under('/')->to('session#ensure_operator'); + my $rest_operator_r = $rest_operator_auth->any('/')->to(namespace => 'MirrorCache::WebAPI::Controller::Rest'); + $rest_operator_r->post('/server')->to('table#create', table => 'Server'); + $rest_operator_r->post('/server/:id')->name('post_server')->to('table#update', table => 'Server'); + $rest_operator_r->delete('/server/:id')->to('table#destroy', table => 'Server'); + $rest_operator_r->put('/server/location/:id')->name('rest_put_server_location')->to('server_location#update_location'); + $rest_operator_r->post('/sync_tree')->name('rest_post_sync_tree')->to('folder_jobs#sync_tree'); + + $rest_r->get('/folder')->name('rest_folder')->to('table#list', table => 'Folder'); + + $rest_r->get('/folder_jobs/:id')->name('rest_folder_jobs')->to('folder_jobs#list'); + $rest_r->get('/myip')->name('rest_myip')->to('my_ip#show') if $self->_geodb; + + $rest_r->get('/stat')->name('rest_stat')->to('stat#list'); + $rest_r->get('/mystat')->name('rest_mystat')->to('stat#mylist'); + + my $app_r = $r->any('/app')->to(namespace => 'MirrorCache::WebAPI::Controller::App'); + + $app_r->get('/server')->name('server')->to('server#index'); + $app_r->get('/folder')->name('folder')->to('folder#index'); + $app_r->get('/folder/<id:num>')->name('folder_show')->to('folder#show'); + + my $admin = $r->any('/admin'); + my $admin_auth = $admin->under('/')->to('session#ensure_admin')->name('ensure_admin'); + my $admin_r = $admin_auth->any('/')->to(namespace => 'MirrorCache::WebAPI::Controller::Admin'); + + $admin_r->delete('/folder/<id:num>')->to('folder#delete_cascade'); + $admin_r->delete('/folder_diff/<id:num>')->to('folder#delete_diff'); + + $admin_r->get('/user')->name('get_user')->to('user#index'); + $admin_r->post('/user/:userid')->name('post_user')->to('user#update'); + + my $rest_user_r = $admin_auth->any('/')->to(namespace => 'MirrorCache::WebAPI::Controller::Rest'); + $rest_user_r->delete('/user/<id:num>')->name('delete_user')->to('user#delete'); + + $admin_r->get('/auditlog')->name('audit_log')->to('audit_log#index'); + $admin_r->get('/auditlog/ajax')->name('audit_ajax')->to('audit_log#ajax'); + + $r->get('/index' => sub { shift->render('main/index') }); + $r->get('/' => sub { shift->render('main/index') })->name('index'); + + $self->plugin(AssetPack => {pipes => [qw(Sass Css JavaScript Fetch Combine)]}); + $self->asset->process; + $self->plugin('Stat'); + $self->plugin('Dir'); + $self->log->info("server started: $current_version"); +} + sub detect_current_version() { my $self = shift; eval { @@ -196,6 +223,8 @@ sub schema { MirrorCache::Schema->singleton } +sub schemaR { MirrorCache::Schema->singletonR } + sub run { __PACKAGE__->new->start } 1; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/MirrorCache-1.027/t/environ/03-headquarter-subsidiaries-weight1.sh new/MirrorCache-1.028/t/environ/03-headquarter-subsidiaries-weight1.sh --- old/MirrorCache-1.027/t/environ/03-headquarter-subsidiaries-weight1.sh 2022-03-16 15:24:45.000000000 +0100 +++ new/MirrorCache-1.028/t/environ/03-headquarter-subsidiaries-weight1.sh 2022-03-30 16:57:14.000000000 +0200 @@ -48,7 +48,8 @@ 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" +curl --interface $na_interface -Is http://$hq_address/download/folder1/file1.1.dat +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)|(200 OK)" # do requests and check that both na instances are being used and instance 2 is used more frequently diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/MirrorCache-1.027/t/environ/07-async-recurs.sh new/MirrorCache-1.028/t/environ/07-async-recurs.sh --- old/MirrorCache-1.027/t/environ/07-async-recurs.sh 2022-03-16 15:24:45.000000000 +0100 +++ new/MirrorCache-1.028/t/environ/07-async-recurs.sh 2022-03-30 16:57:14.000000000 +0200 @@ -34,10 +34,12 @@ $mc/backstage/job mirror_scan_schedule $mc/backstage/start -sleep 1 - $mc/curl -I /download/folder1/file1.1.dat | grep 302 \ - || ( sleep 1 && $mc/curl -I /download/folder1/file1.1.dat | grep 302 ) || ( sleep 10 && $mc/curl -I /download/folder1/file1.1.dat | grep 302 ) + || ( sleep 1 ; $mc/curl -I /download/folder1/file1.1.dat | grep 302 ) \ + || ( sleep 5 ; $mc/curl -I /download/folder1/file1.1.dat | grep 302 ) \ + || ( sleep 5 ; $mc/curl -I /download/folder1/file1.1.dat | grep 302 ) \ + || ( sleep 5 ; $mc/curl -I /download/folder1/file1.1.dat | grep 302 ) \ + || ( sleep 5 ; $mc/curl -I /download/folder1/file1.1.dat | grep 302 ) $mc/db/sql "select count(*) from minion_jobs where task='folder_sync'" diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/MirrorCache-1.027/t/environ/07-async-replica.sh new/MirrorCache-1.028/t/environ/07-async-replica.sh --- old/MirrorCache-1.027/t/environ/07-async-replica.sh 1970-01-01 01:00:00.000000000 +0100 +++ new/MirrorCache-1.028/t/environ/07-async-replica.sh 2022-03-30 16:57:14.000000000 +0200 @@ -0,0 +1,72 @@ +#!lib/test-in-container-environ.sh +set -ex + +mc=$(environ mc $(pwd)) + +pg=$(environ pg) + +MIRRORCACHE_SCHEDULE_RETRY_INTERVAL=3 +$mc/gen_env MIRRORCACHE_SCHEDULE_RETRY_INTERVAL=$MIRRORCACHE_SCHEDULE_RETRY_INTERVAL \ + MIRRORCACHE_DBREPLICA=$pg/dt MIRRORCACHE_DB=mc_test + +# deploy DB +$mc/backstage/shoot + +$pg/replicate $mc/db + +$mc/start +$mc/status + +ap8=$(environ ap8) +ap7=$(environ ap7) + +for x in $mc $ap7 $ap8; do + mkdir -p $x/dt/{folder1,folder2,folder3} + echo $x/dt/{folder1,folder2,folder3}/{file1.1,file2.1}.dat | xargs -n 1 touch +done + +$ap7/start +$ap7/curl /folder1/ | grep file1.1.dat + +$ap8/start +$ap8/curl /folder1/ | grep file1.1.dat + + +$mc/sql "insert into server(hostname,urldir,enabled,country,region) select '$($ap7/print_address)','','t','us','na'" +$mc/sql "insert into server(hostname,urldir,enabled,country,region) select '$($ap8/print_address)','','t','de','eu'" + +$mc/backstage/job folder_sync_schedule_from_misses +$mc/backstage/job folder_sync_schedule +$mc/backstage/start +$mc/backstage/job mirror_scan_schedule +$mc/backstage/start + +$mc/curl -I /download/folder1/file1.1.dat + +sleep $((MIRRORCACHE_SCHEDULE_RETRY_INTERVAL+1)) +$mc/db/sql "select * from minion_jobs order by id" + +$mc/curl -I /download/folder1/file1.1.dat | grep 302 \ + || ( sleep 1 ; $mc/curl -I /download/folder1/file1.1.dat | grep 302 ) \ + || ( sleep 5 ; $mc/curl -I /download/folder1/file1.1.dat | grep 302 ) \ + || ( sleep 5 ; $mc/curl -I /download/folder1/file1.1.dat | grep 302 ) \ + || ( sleep 5 ; $mc/curl -I /download/folder1/file1.1.dat | grep 302 ) \ + || ( sleep 5 ; $mc/curl -I /download/folder1/file1.1.dat | grep 302 ) + +$mc/db/sql "select count(*) from minion_jobs where task='folder_sync'" + +# check the main server log doesn't have the main select query +rc=0 +grep -Fq '( 6371 * acos( cos( radians' $mc/db/dt/log/*.log || rc=$? +test $rc -gt 0 || ( + echo 'FAIL: The query must present only in the replica log' + exit 1 +) + +# check replica log has the main select query +grep -Fq '( 6371 * acos( cos( radians' $pg/dt/log/*.log || ( + echo 'FAIL: Cannot find query in the replica log' + exit 1 +) + +echo PASS diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/MirrorCache-1.027/t/environ/07-async.sh new/MirrorCache-1.028/t/environ/07-async.sh --- old/MirrorCache-1.027/t/environ/07-async.sh 2022-03-16 15:24:45.000000000 +0100 +++ new/MirrorCache-1.028/t/environ/07-async.sh 2022-03-30 16:57:14.000000000 +0200 @@ -38,6 +38,10 @@ $mc/db/sql "select * from minion_jobs order by id" $mc/curl -I /download/folder1/file1.1.dat | grep 302 \ - || ( sleep 1 && $mc/curl -I /download/folder1/file1.1.dat | grep 302 ) || ( sleep 10 && $mc/curl -I /download/folder1/file1.1.dat | grep 302 ) + || ( sleep 1 ; $mc/curl -I /download/folder1/file1.1.dat | grep 302 ) \ + || ( sleep 5 ; $mc/curl -I /download/folder1/file1.1.dat | grep 302 ) \ + || ( sleep 5 ; $mc/curl -I /download/folder1/file1.1.dat | grep 302 ) \ + || ( sleep 5 ; $mc/curl -I /download/folder1/file1.1.dat | grep 302 ) \ + || ( sleep 5 ; $mc/curl -I /download/folder1/file1.1.dat | grep 302 ) $mc/db/sql "select count(*) from minion_jobs where task='folder_sync'" diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/MirrorCache-1.027/t/manual/01-download.o.o-replication.sh new/MirrorCache-1.028/t/manual/01-download.o.o-replication.sh --- old/MirrorCache-1.027/t/manual/01-download.o.o-replication.sh 1970-01-01 01:00:00.000000000 +0100 +++ new/MirrorCache-1.028/t/manual/01-download.o.o-replication.sh 2022-03-30 16:57:14.000000000 +0200 @@ -0,0 +1,36 @@ +#!lib/test-in-container-environ.sh +set -ex + +mc=$(environ mc $(pwd)) + +pg=$(environ pg) + +$mc/gen_env MIRRORCACHE_RECKLESS=0 \ + MIRRORCACHE_ROOT=http://download.opensuse.org \ + MIRRORCACHE_REDIRECT=downloadcontent.opensuse.org \ + MIRRORCACHE_HYPNOTOAD=1 \ + MIRRORCACHE_PERMANENT_JOBS="'folder_sync_schedule_from_misses folder_sync_schedule mirror_scan_schedule_from_misses mirror_scan_schedule_from_path_errors mirror_scan_schedule cleanup stat_agg_schedule mirror_check_from_stat'" \ + MIRRORCACHE_TOP_FOLDERS="'debug distribution tumbleweed factory repositories'" \ + MIRRORCACHE_AUTH_URL=https://www.opensuse.org/openid/user/ \ + MIRRORCACHE_TRUST_AUTH=127.0.0.2 \ + MIRRORCACHE_PROXY_URL=http://127.0.0.1:3110 \ + MIRRORCACHE_BACKSTAGE_WORKERS=32 + MIRRORCACHE_DBREPLICA=$pg/dt + +$mc/backstage/shoot + +$mc/db/sql -f dist/salt/profile/mirrorcache/files/usr/share/mirrorcache/sql/mirrors-eu.sql mc_test + +$mc/backstage/job -e folder_tree -a '["/distribution"]' +$mc/backstage/job -e folder_tree -a '["/tumbleweed"]' + +$mc/backstage/start +$pg/replicate $mc/db + +$mc/start +$pg/status + + +# $pg/sql select + +echo PASS ++++++ MirrorCache.obsinfo ++++++ --- /var/tmp/diff_new_pack.8j1gH5/_old 2022-04-06 21:52:54.386598294 +0200 +++ /var/tmp/diff_new_pack.8j1gH5/_new 2022-04-06 21:52:54.390598248 +0200 @@ -1,5 +1,5 @@ name: MirrorCache -version: 1.027 -mtime: 1647440685 -commit: 03f526436269ca999368a284b236f05f2eee2599 +version: 1.028 +mtime: 1648652234 +commit: 39d3a412b5f94dd54826be1913fffc4d9fcb2515