commit aa6f381f9937d51437be8a2f720652f7a79d28a2 Author: Petr Písař <ppisar@xxxxxxxxxx> Date: Mon Jul 21 17:18:25 2014 +0200 Fix a race in tests that depends on a time frame really ...me-test-if-run-time-execeeds-a-time-frame.patch | 27 +++++++++++--------- perl-CGI-Application-Plugin-RateLimit.spec | 5 +++- 2 files changed, 19 insertions(+), 13 deletions(-) --- diff --git a/CGI-Application-Plugin-RateLimit-1.0-Skip-some-test-if-run-time-execeeds-a-time-frame.patch b/CGI-Application-Plugin-RateLimit-1.0-Skip-some-test-if-run-time-execeeds-a-time-frame.patch index f543a03..fd3fa4f 100644 --- a/CGI-Application-Plugin-RateLimit-1.0-Skip-some-test-if-run-time-execeeds-a-time-frame.patch +++ b/CGI-Application-Plugin-RateLimit-1.0-Skip-some-test-if-run-time-execeeds-a-time-frame.patch @@ -1,4 +1,4 @@ -From 179def78f6adf6546dc2f4e8f9619fe8babf1d16 Mon Sep 17 00:00:00 2001 +From 9d16171dcccea3f4994a404f1780351e454bc018 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20P=C3=ADsa=C5=99?= <ppisar@xxxxxxxxxx> Date: Thu, 5 Jun 2014 09:43:10 +0200 Subject: [PATCH] Skip some test if run-time execeeds a time frame @@ -13,12 +13,12 @@ the tests would fail. This patch skips these test in such case. Signed-off-by: Petr Písař <ppisar@xxxxxxxxxx> --- - t/02simple.t | 40 ++++++++++++++++++++++++++++------------ - t/03complex.t | 21 ++++++++++++++++----- - 2 files changed, 44 insertions(+), 17 deletions(-) + t/02simple.t | 41 +++++++++++++++++++++++++++++------------ + t/03complex.t | 23 ++++++++++++++++++----- + 2 files changed, 47 insertions(+), 17 deletions(-) diff --git a/t/02simple.t b/t/02simple.t -index 4a49a42..7251909 100644 +index 4a49a42..7c6bb5d 100644 --- a/t/02simple.t +++ b/t/02simple.t @@ -45,6 +45,7 @@ my ($count) = $dbh->selectrow_array('SELECT COUNT(*) FROM rate_limit_hits'); @@ -38,11 +38,12 @@ index 4a49a42..7251909 100644 max_hits => 1 }, two => {timeframe => '10s', -@@ -93,32 +94,47 @@ my $start = time; +@@ -93,32 +94,48 @@ my $start = time; { my $query = CGI->new({rm => 'one'}); my $app = TestApp->new(QUERY => $query); - like($app->run(), qr/TOO FAST FOR TestApp::one/); ++ my $output = $app->run(); + SKIP: { + skip "Test did not run less than $one_timeframe s", 2 + unless (time - $start < $one_timeframe); @@ -50,7 +51,7 @@ index 4a49a42..7251909 100644 - # should be a second row for it in the DB - ($count) = $dbh->selectrow_array('SELECT COUNT(*) FROM rate_limit_hits'); - is($count, 2, 'second hit recorded'); -+ like($app->run(), qr/TOO FAST FOR TestApp::one/); ++ like($output, qr/TOO FAST FOR TestApp::one/); + + # should be a second row for it in the DB + ($count) = $dbh->selectrow_array('SELECT COUNT(*) FROM rate_limit_hits'); @@ -98,7 +99,7 @@ index 4a49a42..7251909 100644 + } } diff --git a/t/03complex.t b/t/03complex.t -index 45b9277..bf1c201 100644 +index 45b9277..eb88681 100644 --- a/t/03complex.t +++ b/t/03complex.t @@ -42,6 +42,8 @@ $dbh->do( @@ -136,15 +137,16 @@ index 45b9277..bf1c201 100644 my $query = CGI->new({rm => 'one', revoke_me => 1}); my $app = TestApp->new(QUERY => $query); like($app->run(), qr/ONE/); -@@ -104,11 +106,16 @@ my $start = time; +@@ -104,11 +106,17 @@ my $start = time; like($app->run(), qr/ONE/); $app = TestApp->new(QUERY => $query); - like($app->run(), qr/TOO FAST/); ++ my $output = $app->run(); + SKIP: { + skip "Test did not run less than $one_timeframe s", 1 + unless (time - $start < $one_timeframe); -+ like($app->run(), qr/TOO FAST/); ++ like($output, qr/TOO FAST/); + } } @@ -154,15 +156,16 @@ index 45b9277..bf1c201 100644 $ENV{REMOTE_USER} = $user; for (1 .. 3) { my $query = CGI->new({rm => 'login', failed => 1}); -@@ -118,5 +125,9 @@ for my $user (qw(eenie meenie moe)) { +@@ -118,5 +126,10 @@ for my $user (qw(eenie meenie moe)) { my $query = CGI->new({rm => 'login', failed => 1}); my $app = TestApp->new(QUERY => $query); - like($app->run(), qr/TOO FAST FOR failed_login/); ++ my $output = $app->run(); + SKIP: { + skip "Test did not run less than $failed_login_timeframe s", 1 + unless (time - $start < $failed_login_timeframe); -+ like($app->run(), qr/TOO FAST FOR failed_login/); ++ like($output, qr/TOO FAST FOR failed_login/); + } } -- diff --git a/perl-CGI-Application-Plugin-RateLimit.spec b/perl-CGI-Application-Plugin-RateLimit.spec index 3953fba..bf426a6 100644 --- a/perl-CGI-Application-Plugin-RateLimit.spec +++ b/perl-CGI-Application-Plugin-RateLimit.spec @@ -1,6 +1,6 @@ Name: perl-CGI-Application-Plugin-RateLimit Version: 1.0 -Release: 12%{?dist} +Release: 13%{?dist} Summary: Limits runmode call rate per user License: GPL+ or Artistic @@ -56,6 +56,9 @@ make test %{_mandir}/man3/* %changelog +* Mon Jul 21 2014 Petr Pisar <ppisar@xxxxxxxxxx> - 1.0-13 +- Fix a race in tests that depends on a time frame really (bug #1104721) + * Sat Jun 07 2014 Fedora Release Engineering <rel-eng@xxxxxxxxxxxxxxxxxxxxxxx> - 1.0-12 - Rebuilt for https://fedoraproject.org/wiki/Fedora_21_Mass_Rebuild -- Fedora Extras Perl SIG http://www.fedoraproject.org/wiki/Extras/SIGs/Perl perl-devel mailing list perl-devel@xxxxxxxxxxxxxxxxxxxxxxx https://admin.fedoraproject.org/mailman/listinfo/perl-devel