X-Git-Url: http://git.rot13.org/?a=blobdiff_plain;f=misc%2Fload_testing%2Fbenchmark_staff.pl;h=56085c82b78722481b1ae4dc9d90ad3262d3a9af;hb=f15eb9d5f534489585f2819ccbce43e6ddc95511;hp=ba659c926f48052a34249dee370af23a785acc20;hpb=c0234dd9b9649063acf2617fecf5c6efda38a532;p=koha.git diff --git a/misc/load_testing/benchmark_staff.pl b/misc/load_testing/benchmark_staff.pl index ba659c926f..56085c82b7 100644 --- a/misc/load_testing/benchmark_staff.pl +++ b/misc/load_testing/benchmark_staff.pl @@ -18,6 +18,8 @@ use Data::Dumper; use HTTP::Cookies; use C4::Context; use C4::Debug; +use C4::Members qw ( GetMember ); +use URI::Escape; my ($help, $steps, $baseurl, $max_tries, $user, $password,$short_print); GetOptions( @@ -40,10 +42,10 @@ my $short_psec="|-\n|ON\n"; if ($help || !$baseurl || !$user || !$password) { print <new(); my $cookie; $ua->cookie_jar($cookie_jar); my $resp = $ua->post( "$baseurl"."/svc/authentication" , {userid =>$user, password => $password} ); -if( $resp->is_success ) { +if( $resp->is_success and $resp->content =~ m|ok| ) { $cookie_jar->extract_cookies( $resp ); $cookie = $cookie_jar->as_string; unless ($short_print) { print "Authentication successful\n"; print "Auth:\n $resp->content" if $debug; } +} elsif ( $resp->is_success ) { + die "Authentication failure: bad login/password"; +} else { + die "Authentication failure: \n\t" . $resp->status_line; } +die "You cannot use the database administrator account to launch this script" + unless defined C4::Members::GetMember(userid => $user); + # remove some unnecessary garbage from the cookie $cookie =~ s/ path_spec; discard; version=0//; $cookie =~ s/Set-Cookie3: //; @@ -116,8 +125,8 @@ $sth->execute; my ($title,$author); my @searchwords; while (($title,$author)=$sth->fetchrow) { - push @searchwords,split / /, $author; - push @searchwords,split / /, $title; + push @searchwords,split / /, $author//''; + push @searchwords,split / /, $title//''; } $sth = $dbh->prepare("select max(itemnumber) from items"); @@ -130,7 +139,7 @@ unless ($short_print) { print "--------------\n"; print "Koha STAFF benchmarking utility\n"; print "--------------\n"; - print "Benchmarking with $max_tries occurences of each operation and $concurrency concurrent sessions \n"; + print "Benchmarking with $max_tries occurrences of each operation and $concurrency concurrent sessions \n"; } # # the global benchmark we do at the end... @@ -241,7 +250,7 @@ if ($steps=~ /4/) { my $b2 = HTTPD::Bench::ApacheBench->new; $b2->concurrency( $concurrency ); unless ($short_print) { - print "Step 5: patron detail page "; + print "Step 4: patron detail page "; } my $run2 = HTTPD::Bench::ApacheBench::Run->new ({ urls => \@borrowers, @@ -324,7 +333,7 @@ if ($steps=~ /6/) { until ($rand_barcode) { my $rand_itemnumber = int(rand($itemnumber_max)+1); $sth->execute($rand_itemnumber); - ($rand_barcode) = $sth->fetchrow(); + ($rand_barcode) = uri_escape_utf8($sth->fetchrow()); } push @issues,"$baseurl/circ/circulation.pl?borrowernumber=$rand_borrowernumber&barcode=$rand_barcode&issueconfirmed=1"; push @returns,"$baseurl/circ/returns.pl?barcode=$rand_barcode";