Bugzilla – Attachment 68217 Details for
Bug 19463
TestBuilder.t is failing randomly
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 19463: Reduce the chance to have TestBuilder generate twice the same value
Bug-19463-Reduce-the-chance-to-have-TestBuilder-ge.patch (text/plain), 1.72 KB, created by
Jonathan Druart
on 2017-10-17 14:31:57 UTC
(
hide
)
Description:
Bug 19463: Reduce the chance to have TestBuilder generate twice the same value
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2017-10-17 14:31:57 UTC
Size:
1.72 KB
patch
obsolete
>From 8b7fa5915d2beda41719e904417541f374e5e3a9 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Tue, 17 Oct 2017 11:29:06 -0300 >Subject: [PATCH] Bug 19463: Reduce the chance to have TestBuilder generate > twice the same value > >When an id is generated by TestBuilder (branchcode for instance) and the >size of the generated string is 1, we have too many chances to get >"Violation of unique constraint in Branch". > >This patch will enforce the size of the string to be > 1 and the number >of tries to get a different strings will be 5 (instead of 3). >--- > t/lib/TestBuilder.pm | 13 ++++++++++--- > 1 file changed, 10 insertions(+), 3 deletions(-) > >diff --git a/t/lib/TestBuilder.pm b/t/lib/TestBuilder.pm >index 4dab4235ba..63c3119d91 100644 >--- a/t/lib/TestBuilder.pm >+++ b/t/lib/TestBuilder.pm >@@ -188,8 +188,8 @@ sub _buildColumnValues { > my @columns = $self->schema->source($source)->columns; > my %unique_constraints = $self->schema->source($source)->unique_constraints(); > >- my $build_value = 3; >- # we try max three times if there are unique constraints >+ my $build_value = 5; >+ # we try max $build_value times if there are unique constraints > BUILD_VALUE: while ( $build_value ) { > # generate random values for all columns > for my $col_name( @columns ) { >@@ -442,7 +442,14 @@ sub _gen_text { > $regex = '[A-Za-z]'; > } > my $random = String::Random->new( max => $size ); >- return $random->randregex($regex); >+ my $text = $random->randregex($regex); >+ >+ if ( $size ) { >+ while ( $size and length($text) == 1 and $size > 1 ) { >+ $text = $random->randregex($regex); >+ } >+ } >+ return $text; > } > > sub _gen_set_enum { >-- >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 19463
:
68217
|
68218
|
68219
|
68244