From 4a89c9f83b13015eb84a9c326fbbb2246515eefe Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Wed, 18 Jan 2023 14:32:23 +0100 Subject: [PATCH] Bug 32673: Remove misc/load_testing/ scripts see comment 0 for more info --- cpanfile | 1 - misc/load_testing/benchmark_circulation.pl | 194 ----------- misc/load_testing/benchmark_staff.pl | 388 --------------------- misc/load_testing/benchmark_webservices.pl | 54 --- 4 files changed, 637 deletions(-) delete mode 100755 misc/load_testing/benchmark_circulation.pl delete mode 100755 misc/load_testing/benchmark_staff.pl delete mode 100755 misc/load_testing/benchmark_webservices.pl diff --git a/cpanfile b/cpanfile index b5241e04755..8a37b70fa51 100644 --- a/cpanfile +++ b/cpanfile @@ -148,7 +148,6 @@ recommends 'File::Path', '2.07'; recommends 'File::Temp', '0.22'; recommends 'Graphics::Magick', 'v1.3.5'; recommends 'Gravatar::URL', '1.03'; -recommends 'HTTPD::Bench::ApacheBench', '0.73'; recommends 'Lingua::Ispell', '0.07'; recommends 'Locale::XGettext::TT2', '0.6'; recommends 'Module::Bundled::Files', '0.03'; diff --git a/misc/load_testing/benchmark_circulation.pl b/misc/load_testing/benchmark_circulation.pl deleted file mode 100755 index 0cedf19024a..00000000000 --- a/misc/load_testing/benchmark_circulation.pl +++ /dev/null @@ -1,194 +0,0 @@ -#!/usr/bin/perl -# This script implements a basic benchmarking and regression testing -# utility for Koha - -use strict; -use warnings; - -use HTTPD::Bench::ApacheBench; -use LWP::UserAgent; -use HTTP::Cookies; -use C4::Context; - -my $baseurl= C4::Context->preference("staffClientBaseURL")."/cgi-bin/koha/"; -my $max_tries = 200; -my $concurrency = 10; -my $debug; -my $user = 'kados'; -my $password = 'kados'; - -# Authenticate via our handy dandy RESTful services -# and grab a cookie -my $ua = LWP::UserAgent->new(); -my $cookie_jar = HTTP::Cookies->new(); -my $cookie; -$ua->cookie_jar($cookie_jar); -my $resp = $ua->post( "$baseurl"."/svc/authentication" , {userid =>$user, password => $password} ); -if( $resp->is_success ) { - $cookie_jar->extract_cookies( $resp ); - $cookie = $cookie_jar->as_string; - print "Authentication successful\n"; - print "Auth:\n $resp->content" if $debug; -} -# remove some unnecessary garbage from the cookie -$cookie =~ s/ path_spec; discard; version=0//; -$cookie =~ s/Set-Cookie3: //; - -# Get some data to work with -my $dbh=C4::Context->dbh(); -my $sth = $dbh->prepare("select max(borrowernumber) from borrowers"); -$sth->execute; -my ($borrowernumber_max) = $sth->fetchrow; - -$sth = $dbh->prepare("select max(biblionumber) from biblio"); -$sth->execute; -my ($biblionumber_max) = $sth->fetchrow; - -$sth = $dbh->prepare("select max(itemnumber) from items"); -$sth->execute; -my ($itemnumber_max) = $sth->fetchrow; - -$|=1; -# -# the global benchmark we do at the end... -# -my $b = HTTPD::Bench::ApacheBench->new; -$b->concurrency( $concurrency ); -# -# mainpage : (very) low RDBMS dependency -# -my $b0 = HTTPD::Bench::ApacheBench->new; -$b0->concurrency( $concurrency ); - -my @mainpage; -print "--------------\n"; -print "Koha circulation benchmarking utility\n"; -print "--------------\n"; -print "Benchmarking with $max_tries occurrences of each operation and $concurrency concurrent sessions \n"; -print "Load testing staff interface dashboard page"; -for (my $i=1;$i<=$max_tries;$i++) { - push @mainpage,"$baseurl/mainpage.pl"; -} -my $run0 = HTTPD::Bench::ApacheBench::Run->new - ({ urls => \@mainpage, - cookies => [$cookie], - }); -$b0->add_run($run0); -$b->add_run($run0); - -# send HTTP request sequences to server and time responses -my $ro = $b0->execute; -# calculate hits/sec -print ("\t".$b0->total_time."ms\t".(1000*$b0->total_requests/$b0->total_time)." pages/sec\n"); -print "ALERT : ".$b0->total_responses_failed." failures\n" if $b0->total_responses_failed; - -# -# biblios -# -my $b1 = HTTPD::Bench::ApacheBench->new; -$b1->concurrency( $concurrency ); - -my @biblios; -print "Load testing catalog detail page"; -for (my $i=1;$i<=$max_tries;$i++) { - my $rand_biblionumber = int(rand($biblionumber_max)+1); - push @biblios,"$baseurl/catalogue/detail.pl?biblionumber=$rand_biblionumber"; -} -my $run1 = HTTPD::Bench::ApacheBench::Run->new - ({ urls => \@biblios, - }); -$b1->add_run($run1); -$b->add_run($run1); - -# send HTTP request sequences to server and time responses -$ro = $b1->execute; -# calculate hits/sec -print ("\t".$b1->total_time."ms\t".(1000*$b1->total_requests/$b1->total_time)." biblios/sec\n"); -print "ALERT : ".$b1->total_responses_failed." failures\n" if $b1->total_responses_failed; - -# -# borrowers -# -my $b2 = HTTPD::Bench::ApacheBench->new; -$b2->concurrency( $concurrency ); - -my @borrowers; -print "Load testing patron detail page"; -for (my $i=1;$i<=$max_tries;$i++) { - my $rand_borrowernumber = int(rand($borrowernumber_max)+1); -# print "$baseurl/members/moremember.pl?borrowernumber=$rand_borrowernumber\n"; - push @borrowers,"$baseurl/members/moremember.pl?borrowernumber=$rand_borrowernumber"; -} -my $run2 = HTTPD::Bench::ApacheBench::Run->new - ({ urls => \@borrowers, - cookies => [$cookie], - }); -$b2->add_run($run2); -$b->add_run($run2); - -# send HTTP request sequences to server and time responses -$ro = $b2->execute; -# calculate hits/sec -print ("\t".$b2->total_time."ms\t".(1000*$b2->total_requests/$b2->total_time)." borrowers/sec\n"); - - -# -# issue (& then return) books -# -my $b3 = HTTPD::Bench::ApacheBench->new; -$b3->concurrency( $concurrency ); -my $b4 = HTTPD::Bench::ApacheBench->new; -$b4->concurrency( $concurrency ); - -my @issues; -my @returns; -print "Load testing circulation transaction (checkouts)"; -$sth = $dbh->prepare("SELECT barcode FROM items WHERE itemnumber=?"); -my $sth2 = $dbh->prepare("SELECT borrowernumber FROM borrowers WHERE borrowernumber=?"); -for (my $i=1;$i<=$max_tries;$i++) { - my $rand_borrowernumber; - # check that the borrowernumber exist - until ($rand_borrowernumber) { - $rand_borrowernumber = int(rand($borrowernumber_max)+1); - $sth2->execute($rand_borrowernumber); - ($rand_borrowernumber) = $sth2->fetchrow; - } - # find a barcode & check it exists - my $rand_barcode; - until ($rand_barcode) { - my $rand_itemnumber = int(rand($itemnumber_max)+1); - $sth->execute($rand_itemnumber); - ($rand_barcode) = $sth->fetchrow(); - } - print "borrowernumber=$rand_borrowernumber&barcode=$rand_barcode\n"; - push @issues,"$baseurl/circ/circulation.pl?borrowernumber=$rand_borrowernumber&barcode=$rand_barcode&issueconfirmed=1"; - push @returns,"$baseurl/circ/returns.pl?barcode=$rand_barcode"; -} -my $run3 = HTTPD::Bench::ApacheBench::Run->new - ({ urls => \@issues, - cookies => [$cookie], - }); -$b3->add_run($run3); -$b->add_run($run3); - -# send HTTP request sequences to server and time responses -$ro = $b3->execute; -# calculate hits/sec -print ("\t".$b3->total_time."ms\t".(1000*$b3->total_requests/$b3->total_time)." checkouts/sec\n"); - -print "Load testing circulation transaction (checkins)"; -my $run4 = HTTPD::Bench::ApacheBench::Run->new - ({ urls => \@returns, - cookies => [$cookie], - }); -$b4->add_run($run4); -$b->add_run($run4); - -# send HTTP request sequences to server and time responses -$ro = $b4->execute; -# calculate hits/sec -print ("\t".$b4->total_time."ms\t".(1000*$b4->total_requests/$b4->total_time)." checkins/sec\n"); - -print "Load testing all transactions at once"; -$ro = $b->execute; -print ("\t".$b->total_time."ms\t".(1000*$b->total_requests/$b->total_time)." operations/sec\n"); diff --git a/misc/load_testing/benchmark_staff.pl b/misc/load_testing/benchmark_staff.pl deleted file mode 100755 index 9ff8e9b6762..00000000000 --- a/misc/load_testing/benchmark_staff.pl +++ /dev/null @@ -1,388 +0,0 @@ -#!/usr/bin/perl -# This script implements a basic benchmarking and regression testing -# utility for Koha - -use strict; -use warnings; - -use Getopt::Long qw( GetOptions ); -use HTTPD::Bench::ApacheBench; -use LWP::UserAgent; -use HTTP::Cookies; -use C4::Context; -use URI::Escape qw( uri_escape_utf8 ); -use Koha::Patrons; - -my ($help, $steps, $baseurl, $max_tries, $user, $password,$short_print); -GetOptions( - 'help' => \$help, - 'steps:s' => \$steps, - 'url:s' => \$baseurl, - 'user:s' => \$user, - 'password:s' => \$password, - 'maxtries:s' => \$max_tries, - 'short' => \$short_print, -); -my $concurrency = 30; -$max_tries=20 unless $max_tries; -# if steps not provided, run all tests -$steps='0123456789' unless $steps; - -# if short is set, we will only give number for direct inclusion on the wiki -my $short_ms="|-\n|ON\n"; -my $short_psec="|-\n|ON\n"; - -if ($help || !$baseurl || !$user || !$password) { - print <new(); -my $cookie_jar = HTTP::Cookies->new(); -my $cookie; -$ua->cookie_jar($cookie_jar); -my $resp = $ua->post( "$baseurl"."/svc/authentication" , {userid =>$user, password => $password} ); -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"; - } -} 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 Koha::Patrons->find( { userid => $user } ); - -# remove some unnecessary garbage from the cookie -$cookie =~ s/ path_spec; discard; version=0//; -$cookie =~ s/Set-Cookie3: //; - -# Get some data to work with -my $dbh=C4::Context->dbh(); -# grab some borrowernumbers -my $sth = $dbh->prepare("select max(borrowernumber) from borrowers"); -$sth->execute; -my ($borrowernumber_max) = $sth->fetchrow; -my @borrowers; -for (my $i=1;$i<=$max_tries;$i++) { - my $rand_borrowernumber = int(rand($borrowernumber_max)+1); - push @borrowers,"$baseurl/members/moremember.pl?borrowernumber=$rand_borrowernumber"; -} - -# grab some biblionumbers -$sth = $dbh->prepare("select max(biblionumber) from biblio"); -$sth->execute; -my ($biblionumber_max) = $sth->fetchrow; -my @biblios; -for (my $i=1;$i<=$max_tries;$i++) { - my $rand_biblionumber = int(rand($biblionumber_max)+1); - push @biblios,"$baseurl/catalogue/detail.pl?biblionumber=$rand_biblionumber"; -} - -# grab some title and author, for random search -$sth = $dbh->prepare ("SELECT title, author FROM biblio LIMIT 10"); -$sth->execute; -my ($title,$author); -my @searchwords; -while (($title,$author)=$sth->fetchrow) { - push @searchwords,split / /, $author//''; - push @searchwords,split / /, $title//''; -} - -$sth = $dbh->prepare("select max(itemnumber) from items"); -$sth->execute; -# find the biggest itemnumber -my ($itemnumber_max) = $sth->fetchrow; - -$|=1; -unless ($short_print) { - print "--------------\n"; - print "Koha STAFF benchmarking utility\n"; - print "--------------\n"; - print "Benchmarking with $max_tries occurrences of each operation and $concurrency concurrent sessions \n"; -} -# -# the global benchmark we do at the end... -# -my $b = HTTPD::Bench::ApacheBench->new; -$b->concurrency( $concurrency ); -my $ro; -# -# STEP 1: mainpage : (very) low RDBMS dependency -# -if ($steps=~ /1/) { - my $b0 = HTTPD::Bench::ApacheBench->new; - $b0->concurrency( $concurrency ); my @mainpage; - unless ($short_print) { - print "Step 1: staff interface main page "; - } - for (my $i=1;$i<=$max_tries;$i++) { - push @mainpage,"$baseurl/mainpage.pl"; - } - my $run0 = HTTPD::Bench::ApacheBench::Run->new - ({ urls => \@mainpage, - cookies => [$cookie], - }); - $b0->add_run($run0); - $b->add_run($run0); - - # send HTTP request sequences to server and time responses - $ro = $b0->execute; - # calculate hits/sec - if ($short_print) { - $short_ms.= "|".$b0->total_time."\n"; - $short_psec.="|".(int((1000*$b0->total_requests/$b0->total_time)*1000)/1000)."\n"; - } else { - print ("\t".$b0->total_time."ms\t".(int((1000*$b0->total_requests/$b0->total_time)*1000)/1000)." pages/sec\n"); - print "ALERT : ".$b0->total_responses_failed." failures\n" if $b0->total_responses_failed; - } -} else { - print "Skipping step 1\n"; -} - -# -# STEP 2: biblios -# -if ($steps=~ /2/) { - my $b1 = HTTPD::Bench::ApacheBench->new; - $b1->concurrency( $concurrency ); - - unless ($short_print) { - print "Step 2: catalog detail page "; - } - my $run1 = HTTPD::Bench::ApacheBench::Run->new - ({ urls => \@biblios, - cookies => [$cookie], - }); - $b1->add_run($run1); - $b->add_run($run1); - - # send HTTP request sequences to server and time responses - $ro = $b1->execute; - # calculate hits/sec - if ($short_print) { - $short_ms.= "|".$b1->total_time."\n"; - $short_psec.="|".(int((1000*$b1->total_requests/$b1->total_time)*1000)/1000)."\n"; - } else { - print ("\t".$b1->total_time."ms\t".(int((1000*$b1->total_requests/$b1->total_time)*1000)/1000)." biblios/sec\n"); - print "ALERT : ".$b1->total_responses_failed." failures\n" if $b1->total_responses_failed; - } -} else { - print "Skipping step 2\n"; -} -# -# STEP 3: search -# -if ($steps=~ /3/) { - my $b1 = HTTPD::Bench::ApacheBench->new; - $b1->concurrency( $concurrency ); - unless ($short_print) { - print "Step 3: catalogue search "; - } - my @searches; - for (my $i=1;$i<=$max_tries;$i++) { - push @searches,"$baseurl/catalogue/search.pl?q=".@searchwords[int(rand(scalar @searchwords))]; - } - my $run1 = HTTPD::Bench::ApacheBench::Run->new - ({ urls => \@searches, - cookies => [$cookie], - }); - $b1->add_run($run1); - $b->add_run($run1); - - # send HTTP request sequences to server and time responses - $ro = $b1->execute; - # calculate hits/sec - if ($short_print) { - $short_ms.= "|".$b1->total_time."\n"; - $short_psec.="|".(int((1000*$b1->total_requests/$b1->total_time)*1000)/1000)."\n"; - } else { - print ("\t".$b1->total_time."ms\t".(int((1000*$b1->total_requests/$b1->total_time)*1000)/1000)." biblios/sec\n"); - print "ALERT : ".$b1->total_responses_failed." failures\n" if $b1->total_responses_failed; - } -} else { - print "Skipping step 3\n"; -} -# -# STEP 4: borrowers -# -if ($steps=~ /4/) { - my $b2 = HTTPD::Bench::ApacheBench->new; - $b2->concurrency( $concurrency ); - unless ($short_print) { - print "Step 4: patron detail page "; - } - my $run2 = HTTPD::Bench::ApacheBench::Run->new - ({ urls => \@borrowers, - cookies => [$cookie], - }); - $b2->add_run($run2); - $b->add_run($run2); - - # send HTTP request sequences to server and time responses - $ro = $b2->execute; - # calculate hits/sec - if ($short_print) { - $short_ms.= "|".$b2->total_time."\n"; - $short_psec.="|".(int((1000*$b2->total_requests/$b2->total_time)*1000)/1000)."\n"; - } else { - print ("\t".$b2->total_time."ms\t".(int((1000*$b2->total_requests/$b2->total_time)*1000)/1000)." borrowers/sec\n"); - } -} else { - print "Skipping step 4\n"; -} - -# -# STEP 5: borrowers search -# -if ($steps=~ /5/) { - my $b2 = HTTPD::Bench::ApacheBench->new; - $b2->concurrency( $concurrency ); - unless ($short_print) { - print "Step 5: patron search page "; - } - for (my $i=1;$i<=$max_tries;$i++) { - # print "$baseurl/members/moremember.pl?borrowernumber=$rand_borrowernumber\n"; - push @borrowers,"$baseurl/members/member.pl?member=jean"; - } - my $run2 = HTTPD::Bench::ApacheBench::Run->new - ({ urls => \@borrowers, - cookies => [$cookie], - }); - $b2->add_run($run2); - $b->add_run($run2); - - # send HTTP request sequences to server and time responses - $ro = $b2->execute; - if ($short_print) { - $short_ms.= "|".$b2->total_time."\n"; - $short_psec.="|".(int((1000*$b2->total_requests/$b2->total_time)*1000)/1000)."\n"; - } else { - print ("\t".$b2->total_time."ms\t".(int((1000*$b2->total_requests/$b2->total_time)*1000)/1000)." borrowers/sec\n"); - } -} else { - print "Skipping step 5\n"; -} - -# -# STEP 6: issue (& then return) books -# -if ($steps=~ /6/) { - my $b3 = HTTPD::Bench::ApacheBench->new; - $b3->concurrency( $concurrency ); - my $b4 = HTTPD::Bench::ApacheBench->new; - $b4->concurrency( $concurrency ); - - my @issues; - my @returns; - unless ($short_print) { - print "Step 6a circulation (checkouts) "; - } - $sth = $dbh->prepare("SELECT barcode FROM items WHERE itemnumber=?"); - my $sth2 = $dbh->prepare("SELECT borrowernumber FROM borrowers WHERE borrowernumber=?"); - for (my $i=1;$i<=$max_tries;$i++) { - my $rand_borrowernumber; - # check that the borrowernumber exist - until ($rand_borrowernumber) { - $rand_borrowernumber = int(rand($borrowernumber_max)+1); - $sth2->execute($rand_borrowernumber); - ($rand_borrowernumber) = $sth2->fetchrow; - } - # find a barcode & check it exists - my $rand_barcode; - until ($rand_barcode) { - my $rand_itemnumber = int(rand($itemnumber_max)+1); - $sth->execute($rand_itemnumber); - ($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"; - } - my $run3 = HTTPD::Bench::ApacheBench::Run->new - ({ urls => \@issues, - cookies => [$cookie], - }); - $b3->add_run($run3); - $b->add_run($run3); - - # send HTTP request sequences to server and time responses - $ro = $b3->execute; - # calculate hits/sec - if ($short_print) { - $short_ms.= "|".$b3->total_time."\n"; - $short_psec.="|".(int((1000*$b3->total_requests/$b3->total_time)*1000)/1000)."\n"; - } else { - print ("\t".$b3->total_time."ms\t".(int((1000*$b3->total_requests/$b3->total_time)*1000)/1000)." checkouts/sec\n"); - } - unless ($short_print) { - print "Step 6b circulation (checkins) "; - } - my $run4 = HTTPD::Bench::ApacheBench::Run->new - ({ urls => \@returns, - cookies => [$cookie], - }); - $b4->add_run($run4); - $b->add_run($run4); - - # send HTTP request sequences to server and time responses - $ro = $b4->execute; - # calculate hits/sec - if ($short_print) { - $short_ms.= "|".$b4->total_time."\n"; - $short_psec.="|".(int((1000*$b4->total_requests/$b4->total_time)*1000)/1000)."\n"; - } else { - print ("\t".$b4->total_time."ms\t".(int((1000*$b4->total_requests/$b4->total_time)*1000)/1000)." checkins/sec\n"); - } -} else { - print "Skipping step 6\n"; -} - -if ($steps=~ /0/) { - unless ($short_print) { - print "all transactions at once "; - } - $ro = $b->execute; - if ($short_print) { - $short_ms.= "|".$b->total_time."\n"; - $short_psec.="|".(int((1000*$b->total_requests/$b->total_time)*1000)/1000)."\n"; - } else { - print ("\t".$b->total_time."ms\t".(int((1000*$b->total_requests/$b->total_time)*1000)/1000)." operations/sec\n"); - } -} else { - print "Skipping 'testing all transactions at once'\n (step 0)"; -} - -if ($short_print) { -print $short_ms."\n=====\n".$short_psec."\n"; -} diff --git a/misc/load_testing/benchmark_webservices.pl b/misc/load_testing/benchmark_webservices.pl deleted file mode 100755 index 2ccd15bf731..00000000000 --- a/misc/load_testing/benchmark_webservices.pl +++ /dev/null @@ -1,54 +0,0 @@ -#!/usr/bin/perl -use strict; -use warnings; -#Usage: -# perl testKohaWS.pl http://eowyn.metavore.com:8001/cgi-bin/koha/svc cfc cfc 0.5 5 records/xml/xml-recs.xml -# -# POSTs to baseurl x number of times with y secs of delay between POSTs -# -# args: -# http://eowyn.metavore.com:8001/cgi-bin/koha/svc = baseurl -# 1st cfc = userid -# 2nd cfc = pw -# 0.5 = sleep(0.5) between POSTs -# 5 = number of times to poast -# records/xml/xml-recs.xml = file of 1 marcxml record to post -# -# Requires LWP::UserAgent, File::Slurp. -use LWP::UserAgent; -use File::Slurp qw( slurp ); -my $ua = LWP::UserAgent->new(); -$ua->cookie_jar({ file =>"cookies.txt" }); -my $baseurl = shift; -my $userid = shift; -my $password = shift; -my $timeout = shift; -my $timestopost = shift; -my $xmlfile = shift; - -my $xmldoc = slurp($xmlfile) or die $!; -# auth -my $resp = $ua->post( $baseurl . '/authentication' , {userid =>$userid, password => $password} ); -if( $resp->is_success ) { - print "Auth:\n"; - print $resp->content; -} -else { - die $resp->status_line; -} - -for( my $i = 0; $i < $timestopost; $i++) { - warn "posting a bib number $i\n"; - #warn "xmldoc to post: $xmldoc\n"; - my $resp = $ua->post( $baseurl . '/new_bib' , 'Content-type' => 'text/xml', Content => $xmldoc ); - if( $resp->is_success ) { - print "post to new_bib response:\n"; - print $resp->content; - } - else { - die $resp->status_line; - } - sleep($timeout); -} - - -- 2.25.1