Making a SIP GUI Test Harness – Part I
Introduction
Part I will cover:
- The Introduction
- Setting up SIPP scenarios
- Creating a Grails project
- Creating Grails Domain Classes and Controllers
In VOIP, the term SIP refers to Session Initiation Protocol. It’s a protocol that allows voice communication via online connections. Many phone calls are themselves SIP at some point.
If you currently test SIP, you probably use tools like SIPP. SIPP is the most common tool I know of. It’s open source, very diverse in functionality, and has a large following of contributors. SIPP is typically used to generate load tests – like driving 50 calls per second, to a switch. But SIPP can also be used for functional tests as well.
Audience for this Tutorial
- SIPP is installed and running
- Familiar with some scripting/programming (I’ll be very detailed on basics of groovy/grails)
- A basic understanding of automation
- A basic understanding of VOIP
- You have an environment with a soft switch (FreeSwitch, Asterix… or a sip server like Berkeke, OpenSIPS, etc.) that we can route calls through.
End Results
By the end of this tutorial, you should have a working UI that will take a phone number and proxy (sip server) – dial the number via the proxy on submit and validate if the call passed or failed. You will also have the foundation on which to build other test criteria, such as voice analysis and load testing.
Basically by the end of this demonstration you should be able to do this with Grails:
- Be able to create a Grails Project
- Know how to create controllers
- Know how to create services and why they’re cool
- Set up Domain Classes
- Create SIPP XML scenarios for Outbound carrier tests
- Run SIPP as a Functional Test Tool
SIPP Basics
While SIPP automates these phone calls, it’s use is manual. That is, you create a XML file that builds the scenario. You then type a command line, like:
sipp [phone number] [switch] -sf [path to xml scenario file] -l [limit the amount of calls to this value] -r [limit the rate of calls] -trace_err
SIP Automation
That’s great for one off tests, what if you want something run often by a chron job or by other people who may not know SIPP’s depth of command line properties?
What if you wanted to integrate functionality with SIPP to do things like Audio Analysis, or to iterate through a collection of tests?
That’s why I created a test harness.
My first SIP Test Harness was written with shell scripts. It worked, but it put my work all over the place. I had one shell script to do a phone call, another to do complex audio analysis, another to do packet captures, etc.
I’ve improved on this, and in the process got a UI thrown in for free.
What is Grails and Why Use It
Grails is a MVC architecture for Groovy. MVC stands for Model View and Controller. It’s a design system that offers a quick way to generate code. It makes use of domain models, hibernate, plugins and much more – to give a rich tool set.
You’ll get the UI for free. Grails will generate UI’s for you and we can modify the static scaffolding to suite our needs.
Groovy and Grails (much like Ruby and Rails) is very simplistic and will allow you to write complex applications with very little code. You can parse JSON with a line of code, or generate CRUD (create, read, update, delete) actions instantly with a command line. It’s fast and rapid development that truly suits tools development.
Why Grails? Why not Rails?
No particular reason. The benefit of Grails is that it compiles down to Java Byte Code so it runs where there is Java. Also Java developers can easily read it … and there is the benefit of having more people who can update the code as needed.
Technology Used
- SIPP (make sure you have that installed – you’ll need linux or MacOSX
- Tomcat (I’ll use Tomcat, but you can feel free to use Jetty or something else)
- Grails (For grails you’ll need Java installed, as well as groovy, and you’ll want to have an IDE. A free IDE is the Groovy Grails Tools Suite from SpringSource: http://www.springsource.org/groovy-grails-tool-suite-download A better choice IMO is the commercial version of Intellij. But either will work. This tutorial will use Intellij.
- SoftSwitch that we can route calls through (Asterix, FreeSwitch, etc.)
Test Harness Requirements
- place calls
- validate if the call is a pass or failure.
- Then we’ll build from there to iterate through a list of different call scenarios (like calling different carriers.)
- Make a test call with SIPP (dial a DNIS/phone number with an installed soft switch)
- Verify you have Tomcat or Jetty up and running
- Verify you have Grails avail., in a command prompt do a grails -version.
- Verify your IDE is integrated with Grails (I.e. you can make a grails project)
Create a Grails Project
grails create-app siptesting
class OutboundCall { static constraints = { } }
Date dateCreated String carrier String results String ipProxy String phone String pass
dateCreated nullable: true carrier inList: ['Sprint','Verizon','Tcast'] results maxSize: 50000, nullable: true, display: false ipProxy blank: false phone blank: false pass nullable: true, display: false
Basically the Domain Class should look like this:
class OutboundCall{ Date dateCreated String carrier String results String ipProxy String phone String pass static constraints = { dateCreated nullable: true carrier inList: ['Sprint','TCast','Verizon'] results maxSize: 5000000, nullable: true, display: false ipProxy blank: false phone blank: false pass nullable: true, display: false } static mapping = { results type: 'text' } }
Generating the Static Scaffolding
At this point, we’ve created the domain. Lets do our first generation of code. We want Grails to generate the Controllers (the part of the code that will route logic) and Views (the display portion of the code.)
In Intellij, you can do a control+alt+G (windows) or Mac equivalent to pull up a command line for grails. In the box you will send:
grails generate-all [packag name].[class name]
For example:
grails generate-all siptests.OutboundCall
This will generate a controller for you called OutboundCallController (under the controllers folder in the project tree) and a set of views in a folder called “outboundCall.”
Run the App
Controller
Go ahead and open up the controller we generated.
You’ll see a lot of code. There will be all your crud actions in there. You’ll see things like
def create()
def save()
def show()
This is the basic functionality of creating, saving, showing your data….
Our goal here is to take a user’s input, and pass it to SIPP and validate the results we get. So we want to
One response
[…] Development Grails sipp test tools prevnext […]