From e62dac75154f6705c8ab15d1f7a1036b7d268be3 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Fri, 21 Oct 2016 07:01:30 +0000 Subject: [PATCH] [PASSED QA] Bug 17476: Add a way to bypass dt_from_string processing time for slow servers We already change this value from 1 to 2 but apparently it's not enough So let's switch it back to on and add a flag (env var SLOW_SERVER) and skip these tests if set Test plan: prove t/DateUtils.t and SLOW_SERVER=1 prove t/DateUtils.t should return green Signed-off-by: Mirko Tietgen Signed-off-by: Katrin Fischer --- t/DateUtils.t | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/t/DateUtils.t b/t/DateUtils.t index eede4a0..47cf1c5 100755 --- a/t/DateUtils.t +++ b/t/DateUtils.t @@ -75,16 +75,19 @@ isa_ok( $new_dt, 'DateTime', 'Create DateTime with different timezone' ); cmp_ok( $new_dt->ymd(), 'eq', $testdate_iso, 'Returned Dublin object matches input' ); -for ( qw/ 2014-01-01 2100-01-01 9999-01-01 / ) { - my $duration = gettimeofday(); - $new_dt = dt_from_string($_, 'iso', $dear_dirty_dublin); - $duration = gettimeofday() - $duration; - cmp_ok $duration, '<', 2, "Create DateTime with dt_from_string() for $_ with TZ in less than 2s"; - $duration = gettimeofday(); - output_pref( { dt => $new_dt } ); - $duration = gettimeofday() - $duration; - cmp_ok $duration, '<', 2, "Create DateTime with output_pref() for $_ with TZ in less than 2s"; -} +SKIP: { + skip "Don't test execution time of dt_from_string on slow servers", 6 if $ENV{SLOW_SERVER}; + for ( qw/ 2014-01-01 2100-01-01 9999-01-01 / ) { + my $duration = gettimeofday(); + $new_dt = dt_from_string($_, 'iso', $dear_dirty_dublin); + $duration = gettimeofday() - $duration; + cmp_ok $duration, '<', 1, "Create DateTime with dt_from_string() for $_ with TZ in less than 1s"; + $duration = gettimeofday(); + output_pref( { dt => $new_dt } ); + $duration = gettimeofday() - $duration; + cmp_ok $duration, '<', 1, "Create DateTime with output_pref() for $_ with TZ in less than 1s"; + } +}; $new_dt = dt_from_string( '2011-06-16 12:00', 'sql' ); isa_ok( $new_dt, 'DateTime', 'Create DateTime from (mysql) sql' ); -- 2.1.4