Bug 9288

Summary: Add a script to test SIP from the command line
Product: Koha Reporter: Kyle M Hall <kyle>
Component: SIP2Assignee: Kyle M Hall <kyle>
Status: CLOSED FIXED QA Contact:
Severity: enhancement    
Priority: P5 - low CC: adrien.saurat, colin.campbell, fridolin.somers, gmcharlt, katrin.fischer, olli-antti.kivilahti, robin
Version: Main   
Hardware: All   
OS: All   
Change sponsored?: --- Patch complexity: Small patch
Documentation contact: Documentation submission:
Text to go in the release notes:
Version(s) released in:
Attachments: Bug 9288 - Add a script to test SIP from the command line
Bug 9288 - Add a script to test SIP from the command line
Bug 9288 - Add a script to test SIP from the command line
Bug 9288 - Add a script to test SIP from the command line
Bug 9288 - Add a script to test SIP from the command line
Bug 9288 - Add a script to test SIP from the command line
Bug 9288 - Add a script to test SIP from the command line
Bug 9288 - Add a script to test SIP from the command line
Bug 9288 - Add a script to test SIP from the command line
Bug 9288 - Add a script to test SIP from the command line
Bug 9288 - Add a script to test SIP from the command line - QA Followup
Bug 9288 - Add a script to test SIP from the command line - QA Followup 2
Bug 9288 - Add a script to test SIP from the command line - QA Followup 3
[PASSED QA] Bug 9288 - Add a script to test SIP from the command line
[PASSED QA] Bug 9288 - Add a script to test SIP from the command line - QA Followup
[PASSED QA] Bug 9288 - Add a script to test SIP from the command line - QA Followup 2
[PASSED QA] Bug 9288 - Add a script to test SIP from the command line - QA Followup 3
Bug 9288 - Add a script to test SIP from the command line - QA Followup 4

Description Kyle M Hall 2012-12-14 16:57:52 UTC

    
Comment 1 Kyle M Hall 2012-12-14 16:58:31 UTC Comment hidden (obsolete)
Comment 2 Kyle M Hall 2012-12-14 16:59:26 UTC Comment hidden (obsolete)
Comment 3 Kyle M Hall 2012-12-14 16:59:53 UTC Comment hidden (obsolete)
Comment 4 Kyle M Hall 2012-12-14 17:02:19 UTC Comment hidden (obsolete)
Comment 5 Kyle M Hall 2012-12-14 17:03:13 UTC Comment hidden (obsolete)
Comment 6 Kyle M Hall 2013-01-16 20:11:25 UTC Comment hidden (obsolete)
Comment 7 Kyle M Hall 2013-01-16 20:53:06 UTC Comment hidden (obsolete)
Comment 8 Adrien SAURAT 2013-03-19 09:43:14 UTC
I tried the script and managed to have a successfull connection. An interactive script simulating a self checkout machine will indeed be very useful!

Still, I have a few remarks :
1/ I had to manually set the file as executable, the patch should include the exec permission.
2/ At firt, I executed the script without argument, this results in an error message, it would be nice to have a little help display (like with cleanup_database.pl for example).
3/ If a help text is included, maybe should it also be related to the -h and --help options? But that would mean changing the --host parameter (maybe it could become -a --address?)

The 1st point seems mandatory to me for a sign off, I'd sign without pts 2 and 3 being included but it could give a better consistency to our scripts.
Comment 9 Adrien SAURAT 2013-03-21 14:26:19 UTC
It may be good also to give this script a more explicit name. Something like "sip_sc_emulator.pl" or anything explaining exactly what it is intented to be.

Saying this because I developped a small testing script too. They won't do the same thing so we may end up using both of them. The script I'm working on will simply send/receive SIP messages based on a list of commands stored in a text file. Useful when I want to quickly test several time the same command chain.
Comment 10 Kyle M Hall 2013-05-17 13:51:45 UTC Comment hidden (obsolete)
Comment 11 Adrien SAURAT 2013-05-21 14:52:09 UTC Comment hidden (obsolete)
Comment 12 Chris Cormack 2013-06-18 09:24:05 UTC Comment hidden (obsolete)
Comment 13 Galen Charlton 2013-06-18 16:16:52 UTC
This looks like this could become the core of a Nagios check for the SIP server.

However, it doesn't work for me, as it hangs after sending the 93 login message, never receiving the response.  I tested with both an Evergreen SIP server and a Koha one.

Tacking on the following line will probably make it work:

    $/ = "\r";

However, since not all SIP devices agree on the terminator character, even better would be to use something other than <$socket> to fetch from the socket.

Also, this patch would introduce new code that violates PERL2:

http://wiki.koha-community.org/wiki/Coding_Guidelines#PERL2:_Modern::Perl.

While perhaps a little laxity on the coding guidelines might be OK for test code, I'm drawing a firm line in the sand regarding PERL2: all new code *must* have strictures and warnings enabled.

Or be accompanied by a note signed by Larry Wall _and_ Damien Conway explaining in detail why strictures and warnings should be turned off. :)
Comment 14 Kyle M Hall 2013-07-08 13:21:41 UTC Comment hidden (obsolete)
Comment 15 Kyle M Hall 2013-07-08 13:23:44 UTC
Galen, is this what you are looking for? I have no idea why strictures weren't enabled, my bad! I've also made the message terminator configurable from the command line, defaulting to CRLF.
Comment 16 Katrin Fischer 2013-08-08 21:15:14 UTC
Hi Kyle,

i am trying to figure out SIP right now and was hoping to use your script. But I am running into problems - with your follow up, it looks like this:

patron admin --password admin
main::help() called too early to check prototype at ./sip_cli_emulator.pl line 46.
Use of uninitialized value $terminator in string eq at ./sip_cli_emulator.pl line 50.

OUTBOUND: 9300CNsip|COsip|CPMPL|
Use of uninitialized value $data in concatenation (.) or string at ./sip_cli_emulator.pl line 69.

INBOUND: 
Use of uninitialized value $data in pattern match (m//) at ./sip_cli_emulator.pl line 71.

Login Failed!

Without, the warns are gone, but my login still fails?
Comment 17 Kyle M Hall 2013-08-09 12:39:15 UTC
Katrin, it looks like the full set of parameters you passed to the script didn't get pasted in correctly. Can you please repost your parameters?

Kyle
Comment 18 Katrin Fischer 2013-08-09 12:42:39 UTC
Ah, I see. I used the same paraemters with and without the follow up - one time with errors, the other now. I had all parameters in the sequence suggested and always the long form -- as the short form seemed to give me some trouble.
Comment 19 Katrin Fischer 2013-08-17 16:20:33 UTC
Kyle, could you give an example on how to call the script that works for you?
Comment 20 Katrin Fischer 2013-09-02 20:47:06 UTC
Setting to failed to get Kyle's attention to comment#18
Comment 21 Kyle M Hall 2013-09-20 13:55:23 UTC
Try it like this:

misc/sip_cli_emulator.pl --address my.library.org --port 6001 --sip_user my_sip_user --sip_pass MyPassw0rd --location MPL --patron kylemhall --password letmein --terminator CRLF
Comment 22 Kyle M Hall 2013-09-20 14:05:14 UTC Comment hidden (obsolete)
Comment 23 Katrin Fischer 2013-09-22 18:46:38 UTC
Hi Kyle,

it works now - using this line:
misc/sip_cli_emulator.pl --a localhost --port 6001 --sip_user xxx --sip_pass xxx --location CPL --patron xxx --password xxx

But I see 2 warnings, could you please fix those?

main::help() called too early to check prototype at misc/sip_cli_emulator.pl line 46.
Use of uninitialized value $terminator in string eq at misc/sip_cli_emulator.pl line 50.
Comment 24 Kyle M Hall 2013-10-22 16:33:12 UTC Comment hidden (obsolete)
Comment 25 Katrin Fischer 2013-10-27 09:04:46 UTC
Created attachment 22443 [details] [review]
[PASSED QA] Bug 9288 - Add a script to test SIP from the command line

This is a very basic start to a sip server testing script.
I imagine we will want to make it interactive in end,
essentially replicating what a SIP based self-checkout machine does.

Signed-off-by: Adrien Saurat <adrien.saurat@biblibre.com>
Signed-off-by: Chris Cormack <chris@bigballofwax.co.nz>
Signed-off-by: Katrin Fischer <Katrin.Fischer.83@web.de>
Passes all tests and QA script.
Comment 26 Katrin Fischer 2013-10-27 09:05:05 UTC
Created attachment 22444 [details] [review]
[PASSED QA] Bug 9288 - Add a script to test SIP from the command line - QA Followup

Signed-off-by: Katrin Fischer <Katrin.Fischer.83@web.de>
Comment 27 Katrin Fischer 2013-10-27 09:05:20 UTC
Created attachment 22445 [details] [review]
[PASSED QA] Bug 9288 - Add a script to test SIP from the command line - QA Followup 2

Signed-off-by: Katrin Fischer <Katrin.Fischer.83@web.de>
Comment 28 Katrin Fischer 2013-10-27 09:05:32 UTC
Created attachment 22446 [details] [review]
[PASSED QA] Bug 9288 - Add a script to test SIP from the command line - QA Followup 3

Signed-off-by: Katrin Fischer <Katrin.Fischer.83@web.de>
Comment 29 Katrin Fischer 2013-10-27 09:06:42 UTC
Works now ok for me, no more warnings.

Started SIP server and used: 
misc/sip_cli_emulator.pl --a 127.0.0.1 --port 6001 --sip_user sip --sip_pass sip --location MPL --patron sip --password sip
Comment 30 Katrin Fischer 2013-10-27 09:13:53 UTC
Sorry Kyle, I missed this from the QA script:

 FAIL	misc/sip_cli_emulator.pl
   OK	  pod
   OK	  forbidden patterns
   OK	  valid
   FAIL	  critic
		Subroutine prototypes used at line 115, column 1. See page 194 of PBP.
Comment 31 Kyle M Hall 2013-12-09 13:02:49 UTC
That's odd. I'm not getting that fail!
08:01 ~/kohaclone (bug9288-qa $% u+4)$ koha-qa.pl -v 2 -c 1
testing 1 commit(s) (applied to 4d3558a 'Bug 9288 - Add a script to test SIP f')

 OK     misc/sip_cli_emulator.pl
   OK     pod
   OK     forbidden patterns
   OK     valid
                0
   OK     critic


(In reply to Katrin Fischer from comment #30)
> Sorry Kyle, I missed this from the QA script:
> 
>  FAIL	misc/sip_cli_emulator.pl
>    OK	  pod
>    OK	  forbidden patterns
>    OK	  valid
>    FAIL	  critic
> 		Subroutine prototypes used at line 115, column 1. See page 194 of PBP.
Comment 32 Katrin Fischer 2013-12-29 21:38:45 UTC
Hi Kyle,
I reran the test, the result is the same:

testing 4 commit(s) (applied to e815131 'Bug 10138: (follow-up) FIX sql errors')

 FAIL	misc/sip_cli_emulator.pl
   OK	  pod
   OK	  forbidden patterns
   OK	  valid
   FAIL	  critic
		Subroutine prototypes used at line 115, column 1. See page 194 of PBP.

Maybe someone else can test - did you check line 115?
Comment 33 Kyle M Hall 2013-12-30 13:23:30 UTC
Created attachment 23873 [details] [review]
Bug 9288 - Add a script to test SIP from the command line - QA Followup 4
Comment 34 Kyle M Hall 2013-12-30 13:24:21 UTC
Setting to passed qa on the assumption that this was the only remaining issue. If I am wrong please update the status!
Comment 35 Katrin Fischer 2014-01-11 21:54:24 UTC
The QA script passes now for me.
Comment 36 Galen Charlton 2014-04-20 20:21:09 UTC
Pushed to master.  You may be amused to hear that I tested it successfully with an Evergreen SIP server.

Thanks, Kyle!
Comment 37 Fridolin Somers 2014-08-13 08:39:17 UTC
Pushed to 3.14.x, will be in 3.14.10
Comment 38 Kyle M Hall 2014-08-13 18:39:53 UTC
Picked for 3.12.15!
Comment 39 Olli-Antti Kivilahti 2014-09-10 14:26:20 UTC
This is very cool!