Bug 22394: Remove C4::Accounts::manualinvoice
[koha.git] / misc / load_testing / benchmark_webservices.pl
blobe79067d0ea7d5b06e70d8b8fa66c8a0049cb7c74
1 #!/usr/bin/perl
2 use strict;
3 use warnings;
4 #Usage:
5 # perl testKohaWS.pl http://eowyn.metavore.com:8001/cgi-bin/koha/svc cfc cfc 0.5 5 records/xml/xml-recs.xml
7 # POSTs to baseurl x number of times with y secs of delay between POSTs
9 # args:
10 # http://eowyn.metavore.com:8001/cgi-bin/koha/svc = baseurl
11 # 1st cfc = userid
12 # 2nd cfc = pw
13 # 0.5 = sleep(0.5) between POSTs
14 # 5 = number of times to poast
15 # records/xml/xml-recs.xml = file of 1 marcxml record to post
17 # Requires LWP::UserAgent, File::Slurp.
18 use LWP::UserAgent;
19 use File::Slurp qw(slurp);
20 use Carp;
21 my $ua = LWP::UserAgent->new();
22 $ua->cookie_jar({ file =>"cookies.txt" });
23 my $baseurl = shift;
24 my $userid = shift;
25 my $password = shift;
26 my $timeout = shift;
27 my $timestopost = shift;
28 my $xmlfile = shift;
30 my $xmldoc = slurp($xmlfile) or die $!;
31 # auth
32 my $resp = $ua->post( $baseurl . '/authentication' , {userid =>$userid, password => $password} );
33 if( $resp->is_success ) {
34 print "Auth:\n";
35 print $resp->content;
37 else {
38 die $resp->status_line;
41 for( my $i = 0; $i < $timestopost; $i++) {
42 warn "posting a bib number $i\n";
43 #warn "xmldoc to post: $xmldoc\n";
44 my $resp = $ua->post( $baseurl . '/new_bib' , 'Content-type' => 'text/xml', Content => $xmldoc );
45 if( $resp->is_success ) {
46 print "post to new_bib response:\n";
47 print $resp->content;
49 else {
50 die $resp->status_line;
52 sleep($timeout);