Bugzilla – Attachment 81582 Details for
Bug 21717
TestBuilder.t is failing randomly
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 21717: Fix generation of real's values
Bug-21717-Fix-generation-of-reals-values.patch (text/plain), 2.29 KB, created by
Jonathan Druart
on 2018-10-29 21:25:10 UTC
(
hide
)
Description:
Bug 21717: Fix generation of real's values
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2018-10-29 21:25:10 UTC
Size:
2.29 KB
patch
obsolete
>From e4aaa452b03b983ccc88e7f4761c749c7576fe59 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Mon, 29 Oct 2018 18:16:19 -0300 >Subject: [PATCH] Bug 21717: Fix generation of real's values > >With strict SQL modes we now have TestBuilder tests that fail randomly with: > Out of range value for column 'tax_rate_on_receiving' > Out of range value for column 'discount' > >We are trying to insert a value that is too high for the type defined at DB level. > >It happens for discount when a value > 100 is generated. The datatype is float(6,4). >From the MySQL Doc: >""" >MySQL permits a nonstandard syntax: FLOAT(M,D) or REAL(M,D) or DOUBLE PRECISION(M,D). >Here, (M,D) means than values can be stored with up to M digits in total, of which D digits may be after the decimal point. >""" > >So float(6,4) does not allow 100. > >To recreate easily the issue: > use t::lib::TestBuilder; > my $builder = t::lib::TestBuilder->new; > $builder->build( { source => 'Aqorder', value => { discount => 100 } } )->{discount}; > >To make sure this patch fixes the issue you can use this script: > use Modern::Perl; > use t::lib::TestBuilder; > my $builder = t::lib::TestBuilder->new; > my ( $real, $i ) = ( 0, 0 ); > while ( $real < 100 ) { > $real = $builder->_gen_real( { info => { size => [ 6, 4 ] } } ); > warn $i++; > } > warn "$i - $real"; > >Test plan: >0/ Does not apply this patch >1/ Run the snippet above >2/ Confirm that it fails quite quickly (constantly before 500 for me) >3/ Apply this patch >4/ Run again the script >5/ Confirm that it is stuck in an infinite loop >6/ CTRL-C :D > >QA Note: >Other _gen_* subroutine may need a fix, but we will wait for them to fail >TODO: >1. Add JS check to the interface to prevent the use to enter a value > 100 >2. Allow '100' as a valid value for discount (?) >--- > t/lib/TestBuilder.pm | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > >diff --git a/t/lib/TestBuilder.pm b/t/lib/TestBuilder.pm >index c44e8895ea..b01074c458 100644 >--- a/t/lib/TestBuilder.pm >+++ b/t/lib/TestBuilder.pm >@@ -417,7 +417,7 @@ sub _gen_real { > if( defined( $params->{info}->{size} ) ) { > $max = 10 ** ($params->{info}->{size}->[0] - $params->{info}->{size}->[1]); > } >- return sprintf("%.2f", rand($max)+1); >+ return sprintf("%.2f", rand($max-0.1)); > } > > sub _gen_date { >-- >2.11.0
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 21717
:
81582
|
81607
|
81834