[Bug 21717] New: TestBuilder.t is failing randomly
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=21717 Bug ID: 21717 Summary: TestBuilder.t is failing randomly Change sponsored?: --- Product: Koha Version: unspecified Hardware: All OS: All Status: ASSIGNED Severity: normal Priority: P5 - low Component: Test Suite Assignee: jonathan.druart@bugs.koha-community.org Reporter: jonathan.druart@bugs.koha-community.org QA Contact: testopia@bugs.koha-community.org Depends on: 21613 This has been highlighted by the strict SQL modes (bug 21613), TestBuilder is not generating correctly values for decimals: Out of range value for column 'tax_rate_on_receiving' Out of range value for column 'discount' I am expecting other tests to fail randomly. Referenced Bugs: https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=21613 [Bug 21613] Turn strict SQL modes on for tests -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=21717 Jonathan Druart <jonathan.druart@bugs.koha-community.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|ASSIGNED |Needs Signoff -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=21717 --- Comment #1 from Jonathan Druart <jonathan.druart@bugs.koha-community.org> --- Created attachment 81582 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=81582&action=edit 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 (?) -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=21717 Alex Buckley <alexbuckley@catalyst.net.nz> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |alexbuckley@catalyst.net.nz Attachment #81582|0 |1 is obsolete| | -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=21717 --- Comment #2 from Alex Buckley <alexbuckley@catalyst.net.nz> --- Created attachment 81607 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=81607&action=edit 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 (?) Followed test plan, patch worked as described Signed-off-by: Alex Buckley <alexbuckley@catalyst.net.nz> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=21717 Alex Buckley <alexbuckley@catalyst.net.nz> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|Needs Signoff |Signed Off -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=21717 Tomás Cohen Arazi <tomascohen@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|Signed Off |Passed QA -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=21717 Tomás Cohen Arazi <tomascohen@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #81607|0 |1 is obsolete| | --- Comment #3 from Tomás Cohen Arazi <tomascohen@gmail.com> --- Created attachment 81834 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=81834&action=edit 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 (?) Followed test plan, patch worked as described Signed-off-by: Alex Buckley <alexbuckley@catalyst.net.nz> Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=21717 Nick Clemens <nick@bywatersolutions.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |nick@bywatersolutions.com Status|Passed QA |Pushed to Master --- Comment #4 from Nick Clemens <nick@bywatersolutions.com> --- Awesome work all! Pushed to master for 18.11 -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=21717 Bug 21717 depends on bug 21613, which changed state. Bug 21613 Summary: Turn strict SQL modes on for tests https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=21613 What |Removed |Added ---------------------------------------------------------------------------- Status|Pushed to Master |RESOLVED Resolution|--- |FIXED -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=21717 Martin Renvoize <martin.renvoize@ptfs-europe.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |martin.renvoize@ptfs-europe | |.com Status|Pushed to Master |Pushed to Stable --- Comment #5 from Martin Renvoize <martin.renvoize@ptfs-europe.com> --- Pushed to 18.05.x for 18.05.06 -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=21717 Fridolin SOMERS <fridolin.somers@biblibre.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Resolution|--- |FIXED CC| |fridolin.somers@biblibre.co | |m Status|Pushed to Stable |RESOLVED --- Comment #6 from Fridolin SOMERS <fridolin.somers@biblibre.com> --- Depends on Bug 21613 not in 17.11.x -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=21717 Jonathan Druart <jonathan.druart@bugs.koha-community.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Blocks| |25551 Referenced Bugs: https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=25551 [Bug 25551] [OMNIBUS] Some tests are failing randomly -- You are receiving this mail because: You are watching all bug changes.
participants (1)
-
bugzilla-daemon@bugs.koha-community.org