Skip to content

Commit 3ecf2a6

Browse files
author
Jean Deruelle
committedJan 12, 2016
Adding new test app and script for testing SIP Message inbound over TCP (cherry picked from commit ea6f59c8755a1584479f11ff297c3468bd71a4d7) Conflicts: sip-servlets-test-suite/sipp-scenarios/performance/performance-test.sh
1 parent b1f166d commit 3ecf2a6

File tree

6 files changed

+260
-4
lines changed

6 files changed

+260
-4
lines changed
 
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
MESSAGE: ("org.mobicents.servlet.sip.example.MessagingSipServlet", "DAR:From", "ORIGINATING", "", "NO_ROUTE", "0")
2+
REGISTER: ("org.mobicents.servlet.sip.example.MessagingSipServlet", "DAR:From", "ORIGINATING", "", "NO_ROUTE", "0")
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
2+
<modelVersion>4.0.0</modelVersion>
3+
<parent>
4+
<groupId>org.mobicents.servlet.sip.examples</groupId>
5+
<artifactId>sip-servlets-examples-parent</artifactId>
6+
<version>7.0.3-TelScale-SNAPSHOT</version>
7+
<relativePath>../pom.xml</relativePath>
8+
</parent>
9+
<artifactId>messaging-perf-test</artifactId>
10+
<packaging>war</packaging>
11+
<name>Messaging Perf Sip Servlet Test</name>
12+
<url>http://www.mobicents.org/examples.html</url>
13+
<build>
14+
<plugins>
15+
<plugin>
16+
<artifactId>maven-compiler-plugin</artifactId>
17+
<configuration>
18+
<source>1.5</source>
19+
<target>1.5</target>
20+
</configuration>
21+
</plugin>
22+
<plugin>
23+
<artifactId>maven-war-plugin</artifactId>
24+
<configuration>
25+
<failOnMissingWebXml>false</failOnMissingWebXml>
26+
<warSourceDirectory>${basedir}/src/main/sipapp</warSourceDirectory>
27+
</configuration>
28+
</plugin>
29+
</plugins>
30+
</build>
31+
32+
<!-- repositories -->
33+
<repositories>
34+
<repository>
35+
<id>maven2-repository.dev.java.net</id>
36+
<name>Java.net Repository for Maven</name>
37+
<url>http://download.java.net/maven/2/</url>
38+
<layout>default</layout>
39+
</repository>
40+
<repository>
41+
<id>mobicents-public-repository-group</id>
42+
<name>Mobicens Public Maven Repository Group</name>
43+
<url>https://oss.sonatype.org/content/groups/public</url>
44+
<layout>default</layout>
45+
<releases>
46+
<enabled>true</enabled>
47+
<updatePolicy>never</updatePolicy>
48+
</releases>
49+
<snapshots>
50+
<enabled>true</enabled>
51+
<updatePolicy>never</updatePolicy>
52+
</snapshots>
53+
</repository>
54+
<repository>
55+
<id>jboss-public-repository-group</id>
56+
<name>JBoss Public Maven Repository Group</name>
57+
<url>https://repository.jboss.org/nexus/content/groups/public/</url>
58+
<layout>default</layout>
59+
<releases>
60+
<enabled>true</enabled>
61+
<updatePolicy>never</updatePolicy>
62+
</releases>
63+
<snapshots>
64+
<enabled>true</enabled>
65+
<updatePolicy>never</updatePolicy>
66+
</snapshots>
67+
</repository>
68+
</repositories>
69+
</project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,139 @@
1+
/*
2+
* JBoss, Home of Professional Open Source
3+
* Copyright 2011, Red Hat, Inc. and individual contributors
4+
* by the @authors tag. See the copyright.txt in the distribution for a
5+
* full listing of individual contributors.
6+
*
7+
* This is free software; you can redistribute it and/or modify it
8+
* under the terms of the GNU Lesser General Public License as
9+
* published by the Free Software Foundation; either version 2.1 of
10+
* the License, or (at your option) any later version.
11+
*
12+
* This software is distributed in the hope that it will be useful,
13+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15+
* Lesser General Public License for more details.
16+
*
17+
* You should have received a copy of the GNU Lesser General Public
18+
* License along with this software; if not, write to the Free
19+
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20+
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
21+
*/
22+
23+
package org.mobicents.servlet.sip.example;
24+
25+
import java.io.IOException;
26+
27+
import javax.servlet.ServletConfig;
28+
import javax.servlet.ServletContext;
29+
import javax.servlet.ServletException;
30+
import javax.servlet.sip.AuthInfo;
31+
import javax.servlet.sip.Parameterable;
32+
import javax.servlet.sip.ServletParseException;
33+
import javax.servlet.sip.SipApplicationSession;
34+
import javax.servlet.sip.SipFactory;
35+
import javax.servlet.sip.SipServlet;
36+
import javax.servlet.sip.SipServletContextEvent;
37+
import javax.servlet.sip.SipServletListener;
38+
import javax.servlet.sip.SipServletRequest;
39+
import javax.servlet.sip.SipServletResponse;
40+
import javax.servlet.sip.SipURI;
41+
import javax.servlet.sip.annotation.SipListener;
42+
43+
import org.apache.log4j.Logger;
44+
45+
/**
46+
* This Sip Servlet acts as as a UAC registering to callwithus
47+
* @author Jean Deruelle
48+
*
49+
*/
50+
@SipListener
51+
@javax.servlet.sip.annotation.SipServlet(name="MessagingSipServlet", loadOnStartup=1)
52+
public class MessagingSipServlet extends SipServlet implements SipServletListener {
53+
private static final long serialVersionUID = 1L;
54+
private static transient final Logger logger = Logger.getLogger(MessagingSipServlet.class);
55+
56+
@Override
57+
public void init(ServletConfig servletConfig) throws ServletException {
58+
logger.info("the Messaging sip servlet has been started");
59+
super.init(servletConfig);
60+
}
61+
62+
@Override
63+
protected void doErrorResponse(SipServletResponse response)
64+
throws ServletException, IOException {
65+
66+
logger.info("Got response: " + response);
67+
SipFactory sipFactory = (SipFactory) getServletContext().getAttribute(SIP_FACTORY);
68+
if(response.getStatus() == SipServletResponse.SC_UNAUTHORIZED ||
69+
response.getStatus() == SipServletResponse.SC_PROXY_AUTHENTICATION_REQUIRED) {
70+
// Avoid re-sending if the auth repeatedly fails.
71+
if(!"true".equals(getServletContext().getAttribute("FirstResponseRecieved")))
72+
{
73+
getServletContext().setAttribute("FirstResponseRecieved", "true");
74+
AuthInfo authInfo = sipFactory.createAuthInfo();
75+
authInfo.addAuthInfo(
76+
response.getStatus(),
77+
response.getChallengeRealms().next(),
78+
getServletContext().getInitParameter("user.name"),
79+
getServletContext().getInitParameter("password"));
80+
81+
SipServletRequest challengeRequest = response.getSession().createRequest(
82+
response.getRequest().getMethod());
83+
84+
challengeRequest.addAuthHeader(response, authInfo);
85+
logger.info("Sending the challenge request " + challengeRequest);
86+
challengeRequest.send();
87+
}
88+
} else {
89+
super.doErrorResponse(response);
90+
}
91+
92+
}
93+
94+
@Override
95+
protected void doSuccessResponse(SipServletResponse resp)
96+
throws ServletException, IOException {
97+
98+
logger.info("GOT SUCESS RESPONSE HURRAH ! : " + resp);
99+
}
100+
101+
@Override
102+
protected void doMessage(SipServletRequest req) throws ServletException,
103+
IOException {
104+
req.createResponse(200).send();
105+
}
106+
107+
/*
108+
* (non-Javadoc)
109+
* @see javax.servlet.sip.SipServletListener#servletInitialized(javax.servlet.sip.SipServletContextEvent)
110+
*/
111+
public void servletInitialized(SipServletContextEvent ce) {
112+
// ServletContext servletContext = ce.getServletContext();
113+
// SipFactory sipFactory = (SipFactory) servletContext.getAttribute(SIP_FACTORY);
114+
// String userName = servletContext.getInitParameter("user.name");
115+
// String domainName = servletContext.getInitParameter("domain.name");
116+
//
117+
// SipApplicationSession sipApplicationSession = sipFactory.createApplicationSession();
118+
// // for REGISTER the from and the to headers are one and the same
119+
// SipURI fromToURI = sipFactory.createSipURI(userName, domainName);
120+
// SipServletRequest sipServletRequest =
121+
// sipFactory.createRequest(sipApplicationSession, "REGISTER", fromToURI, fromToURI);
122+
// sipServletRequest.setHeader("Expires", "3600");
123+
// sipServletRequest.setHeader("User-Agent", "MobicentsSipServlets");
124+
// SipURI requestURI = sipFactory.createSipURI(null, domainName);
125+
// try {
126+
// Parameterable parameterable = sipServletRequest.getParameterableHeader("Contact");
127+
// parameterable.setParameter("expires", "0");
128+
// } catch (ServletParseException e1) {
129+
// logger.error("Impossible to set the expires on the contact header",e1);
130+
// }
131+
// try {
132+
// sipServletRequest.setRequestURI(requestURI);
133+
// sipServletRequest.send();
134+
// } catch (IOException e) {
135+
// logger.error("An unexpected exception occured while sending the REGISTER request",e);
136+
// }
137+
}
138+
139+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
3+
<sip-app>
4+
<app-name>
5+
org.mobicents.servlet.sip.example.MessagingSipServlet
6+
</app-name>
7+
</sip-app>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<?xml version="1.0" encoding="ISO-8859-1"?>
2+
<!DOCTYPE scenario SYSTEM "sipp.dtd">
3+
4+
<scenario name="UAC for SIP-Servlets Tests">
5+
6+
<send retrans="500">
7+
<![CDATA[
8+
9+
MESSAGE sip:[service]@[remote_ip]:[remote_port] SIP/2.0
10+
Via: SIP/2.0/[transport] [local_ip]:[local_port];branch=[branch]
11+
From: sipp <sip:sipp@[local_ip]:[local_port]>;tag=[call_number]
12+
To: sut <sip:[service]@[remote_ip]:[remote_port]>
13+
Call-ID: [call_id]
14+
CSeq: 1 MESSAGE
15+
Contact: sip:sipp@[local_ip]:[local_port]
16+
Max-Forwards: 70
17+
Content-Type: text/plain
18+
Content-Length: [len]
19+
20+
Hello World!
21+
22+
]]>
23+
</send>
24+
25+
<recv response="100" optional="true">
26+
</recv>
27+
28+
<recv response="200" rtd="true" rrs="true">
29+
</recv>
30+
31+
<pause milliseconds="3000"/>
32+
33+
</scenario>

‎sip-servlets-test-suite/sipp-scenarios/performance/performance-test.sh

+10-4
Original file line numberDiff line numberDiff line change
@@ -2,28 +2,34 @@ killall sipp
22
rm *.log
33
#export TEST_IP=192.168.0.12
44
export TEST_IP=127.0.0.1
5+
export TEST_PORT=5080
56
echo "IP Address for the test is $TEST_IP"
67

78
if [ $# -ne 0 ]; then
89
case $1 in
10+
messaging)
11+
rm ./messaging/*.log
12+
echo "Example used is messaging perf test";
13+
./sipp $TEST_IP:$TEST_PORT -s yousendbye -sf messaging/performance-messaging.xml -t t1 -trace_err -i $TEST_IP -p 5055 -r 1000 -m 10000000 -nd
14+
;;
915
proxy)
1016
rm ./proxy/*.log
1117
echo "Distributed example used is proxy";
1218
./sipp $TEST_IP:5055 -sf proxy-scenario/performance-proxy-uas.xml -trace_err -i $TEST_IP -p 5090 -bg -nd
13-
./sipp $TEST_IP:5090 -sf proxy-scenario/performance-proxy-uac.xml -trace_err -i $TEST_IP -p 5055 -rsa $TEST_IP:5080 -r 50 -m 250000 -nd
19+
./sipp $TEST_IP:5090 -sf proxy-scenario/performance-proxy-uac.xml -trace_err -i $TEST_IP -p 5055 -rsa $TEST_IP:$TEST_PORT -r 10 -m 250000 -nd
1420
sleep 10
1521
;;
1622
b2bua)
1723
rm ./b2bua/*.log
1824
echo "Distributed example used is b2bua";
19-
./sipp $TEST_IP:5080 -sf b2bua/call-forwarding-receiver.xml -trace_err -i $TEST_IP -p 5090 -bg
20-
./sipp $TEST_IP:5080 -s receiver -sf b2bua/call-forwarding-sender.xml -trace_err -i $TEST_IP -p 5050 -r 100 -m 250000
25+
./sipp $TEST_IP:$TEST_PORT -sf b2bua/call-forwarding-receiver.xml -trace_err -i $TEST_IP -p 5090 -bg
26+
./sipp $TEST_IP:$TEST_PORT -s receiver -sf b2bua/call-forwarding-sender.xml -trace_err -i $TEST_IP -p 5050 -r 10 -m 250000
2127
sleep 10
2228
;;
2329
*)
2430
rm ./uas/*.log
2531
echo "Distributed example used is uas";
26-
./sipp $TEST_IP:5080 -s yousendbye -sf simple-flow/performance-uac.xml -trace_err -i $TEST_IP -p 5055 -r 200 -m 250000
32+
./sipp $TEST_IP:$TEST_PORT -s yousendbye -sf simple-flow/performance-uac.xml -trace_err -i $TEST_IP -p 5055 -r 10 -m 250000
2733
;;
2834
esac
2935
fi

0 commit comments

Comments
 (0)