[Asterisk-code-review] fax/pjsip/t38 fast reject: Fix logs left in testsuite tree (testsuite[13])

Richard Mudgett asteriskteam at digium.com
Mon Jul 30 16:56:14 CDT 2018


Richard Mudgett has uploaded this change for review. ( https://gerrit.asterisk.org/9788


Change subject: fax/pjsip/t38_fast_reject: Fix logs left in testsuite tree
......................................................................

fax/pjsip/t38_fast_reject: Fix logs left in testsuite tree

We don't need to pollute the testsuite tree with log files that are not
needed.

In run-test:
* Don't generate log files that are not needed.
* Fix to use a temp file out of the testsuite tree on the only SIPp log
file needed so it is not left in the testsuite tree.
* Fixed PEP8 errors

In A_PARTY.xml
* Removed extra optional recv 100 msgs.
* Fixed indention

In B_PARTY.xml
* Fix <CR><LF> line endings to <LF>.
* Fixed indention

In check_reinvite_rtt.py:
* Fixed type mismatch error when a slow 488 T.38 rejection is detected.
* Fixed PEP8 errors

Change-Id: Ic8e4d71f841627479c943c3b8a25e4776534258d
---
M tests/fax/pjsip/t38_fast_reject/check_reinvite_rtt.py
M tests/fax/pjsip/t38_fast_reject/run-test
M tests/fax/pjsip/t38_fast_reject/sipp/A_PARTY.xml
M tests/fax/pjsip/t38_fast_reject/sipp/B_PARTY.xml
M tests/fax/pjsip/t38_fast_reject/test-config.yaml
5 files changed, 236 insertions(+), 261 deletions(-)



  git pull ssh://gerrit.asterisk.org:29418/testsuite refs/changes/88/9788/1

diff --git a/tests/fax/pjsip/t38_fast_reject/check_reinvite_rtt.py b/tests/fax/pjsip/t38_fast_reject/check_reinvite_rtt.py
index c67da51..3cd087a 100755
--- a/tests/fax/pjsip/t38_fast_reject/check_reinvite_rtt.py
+++ b/tests/fax/pjsip/t38_fast_reject/check_reinvite_rtt.py
@@ -8,17 +8,17 @@
 with open(sys.argv[1]) as csvfile:
     reader = csv.DictReader(csvfile, delimiter=';')
     for row in reader:
-        if not row.has_key('ResponseTimereinvite(P)'):
+        if 'ResponseTimereinvite(P)' not in row:
             print "column not found! make sure scenario is correct!\n"
-            exit(-1);
+            exit(-1)
         parts = regex.match(row['ResponseTimereinvite(P)'])
         hours = int(parts.group(1))
         minutes = (hours * 60) + int(parts.group(2))
         seconds = (minutes * 60) + int(parts.group(3))
         milliseconds = (seconds * 1000) + int(parts.group(4))
         if (milliseconds > 500):
-            print "Slow 488 Rejection detected (" + milliseconds + ")!\n";
+            print "Slow 488 Rejection detected (" + str(milliseconds) + " ms)!\n"
             exit(-2)
 
 csvfile.close()
-exit(0)
\ No newline at end of file
+exit(0)
diff --git a/tests/fax/pjsip/t38_fast_reject/run-test b/tests/fax/pjsip/t38_fast_reject/run-test
index 7db6898..72e9693 100755
--- a/tests/fax/pjsip/t38_fast_reject/run-test
+++ b/tests/fax/pjsip/t38_fast_reject/run-test
@@ -21,6 +21,7 @@
 
 sys.path.append("lib/python")
 sys.path.append("utils")
+from tempfile import NamedTemporaryFile
 from asterisk.asterisk import Asterisk
 from asterisk.sipp import SIPpTest
 
@@ -29,53 +30,42 @@
 TEST_DIR = os.path.dirname(os.path.realpath(__file__))
 
 e164 = "3200000000"
-sippA_logfile = WORKING_DIR + "/A_PARTY.log"
-sippA_errfile = WORKING_DIR + "/A_PARTY_ERR.log"
-sippA_statfile = WORKING_DIR + "/A_PARTY_STAT.log"
 
-sippB_logfile = WORKING_DIR + "/B_PARTY.log"
-sippB_errfile = WORKING_DIR + "/B_PARTY_ERR.log"
-
-SIPP_SCENARIOS = [
-    {
-        'scenario' : 'B_PARTY.xml',
-        '-i' : '127.0.0.1',
-        '-p' : '5700',
-        '-message_file' : sippB_logfile,
-        '-error_file' : sippB_errfile,
-        '-trace_msg' : '-trace_err',
-    },
-    {
-        'scenario' : 'A_PARTY.xml',
-        '-i' : '127.0.0.1',
-        '-p' : '5061',
-        '-m' : '1',
-        '-s' : e164,
-        '-message_file' : sippA_logfile,
-        '-error_file' : sippA_errfile,
-        '-trace_msg' : '-trace_err',
-        '-trace_stat' : '-trace_stat',
-        '-stf' : sippA_statfile,
-    }
-]
 
 def main():
+    sippA_statfile = NamedTemporaryFile(delete=True)
+
+    SIPP_SCENARIOS = [
+        {
+            'scenario': 'B_PARTY.xml',
+            '-i': '127.0.0.1',
+            '-p': '5700',
+        },
+        {
+            'scenario': 'A_PARTY.xml',
+            '-i': '127.0.0.1',
+            '-p': '5061',
+            '-m': '1',
+            '-s': e164,
+            '-trace_stat': '-trace_stat',
+            '-stf': sippA_statfile.name,
+        }
+    ]
+
     test = SIPpTest(WORKING_DIR, TEST_DIR, SIPP_SCENARIOS)
-    test.reactor_timeout = 100;
+    test.reactor_timeout = 100
 
     reactor.run()
 
     if not test.passed:
         return 1
 
-    ret_A = subprocess.call([WORKING_DIR + "/check_reinvite_rtt.py", WORKING_DIR+"/A_PARTY_STAT.log"])
-
+    ret_A = subprocess.call([WORKING_DIR + "/check_reinvite_rtt.py", sippA_statfile.name])
     if (ret_A != 0):
-	    logger.debug("Slow ReInvite Detected!")
-	    return 1
+        logger.debug("Slow ReInvite Detected!")
+        return 1
 
     return 0
 
 if __name__ == "__main__":
     sys.exit(main() or 0)
-
diff --git a/tests/fax/pjsip/t38_fast_reject/sipp/A_PARTY.xml b/tests/fax/pjsip/t38_fast_reject/sipp/A_PARTY.xml
index 118d2f9..f19324e 100644
--- a/tests/fax/pjsip/t38_fast_reject/sipp/A_PARTY.xml
+++ b/tests/fax/pjsip/t38_fast_reject/sipp/A_PARTY.xml
@@ -1,153 +1,136 @@
 <?xml version="1.0" encoding="ISO-8859-1" ?>
 <!DOCTYPE scenario SYSTEM "sipp.dtd">
 
-<scenario name="T38 REINVTE">
-  <send retrans="500">
-    <![CDATA[
+<scenario name="T38 REINVITE UAC">
+	<send retrans="500">
+		<![CDATA[
+			INVITE sip:[service]@[remote_ip]:[remote_port] SIP/2.0
+			Via: SIP/2.0/UDP [local_ip]:[local_port];branch=[branch]
+			From: <sip:390415094280@[local_ip]:[local_port]>;tag=[pid]SIPpTag00[call_number]
+			To: <sip:[service]@[remote_ip]:[remote_port]>
+			Call-ID: [call_id]
+			Supported: rel1xx,timer,replaces
+			Min-SE:  181
+			User-Agent: Cisco-SIPGateway/IOS-12.x
+			Allow: INVITE, OPTIONS, BYE, CANCEL, ACK, PRACK, COMET, REFER, SUBSCRIBE, NOTIFY, INFO, UPDATE, REGISTER
+			CSeq: 101 INVITE
+			Max-Forwards: 69
+			Contact: <sip:390415094280@[local_ip]:[local_port]>
+			Expires: 180
+			Allow-Events: telephone-event
+			Content-Type: application/sdp
+			Content-Length: [len]
 
-      INVITE sip:[service]@[remote_ip]:[remote_port] SIP/2.0
-      Via: SIP/2.0/UDP [local_ip]:[local_port];branch=[branch]
-      From: <sip:390415094280@[local_ip]:[local_port]>;tag=[pid]SIPpTag00[call_number]
-      To: <sip:[service]@[remote_ip]:[remote_port]>
-      Call-ID: [call_id]
-      Supported: rel1xx,timer,replaces
-      Min-SE:  181
-      User-Agent: Cisco-SIPGateway/IOS-12.x
-      Allow: INVITE, OPTIONS, BYE, CANCEL, ACK, PRACK, COMET, REFER, SUBSCRIBE, NOTIFY, INFO, UPDATE, REGISTER
-      CSeq: 101 INVITE
-      Max-Forwards: 69
-      Contact: <sip:390415094280@[local_ip]:[local_port]>
-      Expires: 180
-      Allow-Events: telephone-event
-      Content-Type: application/sdp
-      Content-Length: [len]
-      
-      v=0
-      o=CiscoSystemsSIP-GW-UserAgent 9624 5279 IN IP4 [local_ip]
-      s=SIP Call
-      c=IN IP4 [media_ip]
-      t=0 0
-      m=audio 9000 RTP/AVP 0 18 101
-      c=IN IP[local_ip_type] [local_ip]
-      a=rtpmap:101 telephone-event/101
+			v=0
+			o=CiscoSystemsSIP-GW-UserAgent 9624 5279 IN IP4 [local_ip]
+			s=SIP Call
+			c=IN IP4 [media_ip]
+			t=0 0
+			m=audio 9000 RTP/AVP 0 18 101
+			c=IN IP[local_ip_type] [local_ip]
+			a=rtpmap:101 telephone-event/101
+		]]>
+	</send>
 
-    ]]>
-  </send>
+	<recv response="100" optional="true">
+	</recv>
 
-  <recv response="100">
-  </recv>
+	<recv response="180" optional="true">
+	</recv>
+	<recv response="183" optional="true">
+	</recv>
 
-  <recv response="100" optional="true">
-  </recv>
+	<recv response="200" rrs="true">
+		<action>
+			<ereg regexp="[[:punct:]](.*)[[:punct:]]" search_in="hdr" header="Contact:" check_it="true" assign_to="6,1" />
+			<ereg regexp=".*" search_in="hdr" header="From:" check_it="true" assign_to="2" />
+			<ereg regexp=".*" search_in="hdr" header="To:" check_it="true" assign_to="3" />
+			<log message="Log to avoid the problem of not using $6 [$6]"/>
+		</action>
+	</recv>
 
-  <recv response="100" optional="true">
-  </recv>
-
-  <recv response="180" optional="true">
-  </recv>
-  <recv response="183" optional="true">
-  </recv>
-
-  <recv response="200" rrs="true">
-    <action>
-    	<ereg regexp="[[:punct:]](.*)[[:punct:]]" search_in="hdr" header="Contact:" check_it="true" assign_to="6,1" />
-    	<ereg regexp=".*" search_in="hdr" header="From:" check_it="true" assign_to="2" />
-    	<ereg regexp=".*" search_in="hdr" header="To:" check_it="true" assign_to="3" />
-    	<log message="Log to avoid the problem of not using $6 [$6]"/>
-    </action>
-  </recv>
-
-  <send>
-    <![CDATA[
-
-      ACK [next_url] SIP/2.0
-      [routes]
-      Via: SIP/2.0/UDP [local_ip]:[local_port];branch=[branch]
-      From: [$2]
-      To: [$3]
-      Call-ID: [call_id]
-      Max-Forwards: 69
-      CSeq: 101 ACK
-      Content-Length: [len]
-
-    ]]>
-  </send>
+	<send crlf="true">
+		<![CDATA[
+			ACK [next_url] SIP/2.0
+			[routes]
+			Via: SIP/2.0/UDP [local_ip]:[local_port];branch=[branch]
+			From: [$2]
+			To: [$3]
+			Call-ID: [call_id]
+			Max-Forwards: 69
+			CSeq: 101 ACK
+			Content-Length: [len]
+		]]>
+	</send>
 
 
-  <!--Send the T38 REINVITE -->
-  <send retrans="500" start_rtd="reinvite">
-    <![CDATA[
-
-      INVITE [$1] SIP/2.0
-      Via: SIP/2.0/UDP [local_ip]:[local_port];branch=[branch]
-      From: [$2]
-      To: [$3]
-      Call-ID: [call_id]
-      User-Agent: Cisco-SIPGateway/IOS-12.x
-      CSeq: 102 INVITE
-      Max-Forwards: 69
-      Contact: <sip:390415094280@[local_ip]:[local_port]>
-      Allow-Events: telephone-event
-      Content-Type: application/sdp
-      Content-Length: [len]
+	<!--Send the T38 REINVITE -->
+	<send retrans="500" start_rtd="reinvite">
+		<![CDATA[
+			INVITE [$1] SIP/2.0
+			Via: SIP/2.0/UDP [local_ip]:[local_port];branch=[branch]
+			From: [$2]
+			To: [$3]
+			Call-ID: [call_id]
+			User-Agent: Cisco-SIPGateway/IOS-12.x
+			CSeq: 102 INVITE
+			Max-Forwards: 69
+			Contact: <sip:390415094280@[local_ip]:[local_port]>
+			Allow-Events: telephone-event
+			Content-Type: application/sdp
+			Content-Length: [len]
             
-      v=0
-      o=CiscoSystemsSIP-GW-UserAgent 9624 5280 IN IP4 [local_ip]
-      s=Asterisk PBX 1.6.2.0
-      c=IN IP[local_ip_type] [local_ip]
-      t=0 0
-      m=image 4389 udptl t38
-      a=T38FaxVersion:0
-      a=T38MaxBitRate:14400
-      a=T38FaxRateManagement:transferredTCF
-      a=T38FaxMaxDatagram:1400
-      a=T38FaxUdpEC:t38UDPRedundancy
+			v=0
+			o=CiscoSystemsSIP-GW-UserAgent 9624 5280 IN IP4 [local_ip]
+			s=Asterisk PBX 1.6.2.0
+			c=IN IP[local_ip_type] [local_ip]
+			t=0 0
+			m=image 4389 udptl t38
+			a=T38FaxVersion:0
+			a=T38MaxBitRate:14400
+			a=T38FaxRateManagement:transferredTCF
+			a=T38FaxMaxDatagram:1400
+			a=T38FaxUdpEC:t38UDPRedundancy
+		]]>
+	</send>
 
-    ]]>
-  </send>
+	<recv response="100" optional="true">
+	</recv>
 
-  <recv response="100" optional="true">
-  </recv>
+	<recv response="488" rtd="reinvite">
+	</recv>
 
-  <recv response="488" rtd="reinvite" crlf="true">
-  </recv>
+	<send crlf="true">
+		<![CDATA[
+			ACK [$1] SIP/2.0
+			Via: SIP/2.0/[transport] [local_ip]:[local_port];branch=[branch]
+			[last_Call-ID:]
+			From: [$2]
+			To: [$3]
+			CSeq: 102 ACK
+			Max-Forwards: 69
+			Content-Length: 0
+		]]>
+	</send>
 
-  <send>
-  <![CDATA[
+	<!-- Wait to see if Asterisk drops the call after rejecting the T.38 request -->
+	<pause milliseconds="50000" crlf="true" />
 
-  ACK [$1] SIP/2.0
-  Via: SIP/2.0/[transport] [local_ip]:[local_port];branch=[branch]
-  [last_Call-ID:]
-  From: [$2]
-  To: [$3]
-  CSeq: 102 ACK
-  Max-Forwards: 69
-  Content-Length: 0
+	<send retrans="500">
+		<![CDATA[
+			BYE [$1] SIP/2.0
+			Via: SIP/2.0/UDP [local_ip]:[local_port];branch=[branch]
+			From: [$2]
+			To: [$3]
+			Call-ID: [call_id]
+			User-Agent: Cisco-SIPGateway/IOS-12.x
+			Max-Forwards: 69
+			CSeq: 104 BYE
+			Content-Length: 0
+		]]>
+	</send>
 
-  ]]>
-  </send>
-
-  <pause milliseconds="50000" />
-
-  <send retrans="500">
-    <![CDATA[
-
-      BYE [$1] SIP/2.0
-      Via: SIP/2.0/UDP [local_ip]:[local_port];branch=[branch]
-      From: [$2]
-      To: [$3]
-      Call-ID: [call_id]
-      User-Agent: Cisco-SIPGateway/IOS-12.x
-      Max-Forwards: 69
-      CSeq: 104 BYE
-      Content-Length: 0
-
-    ]]>
-  </send>
-
-  <recv response="200">
-  </recv>
-
-
+	<recv response="200">
+	</recv>
 </scenario>
 
diff --git a/tests/fax/pjsip/t38_fast_reject/sipp/B_PARTY.xml b/tests/fax/pjsip/t38_fast_reject/sipp/B_PARTY.xml
index 3262911..eb84efd 100644
--- a/tests/fax/pjsip/t38_fast_reject/sipp/B_PARTY.xml
+++ b/tests/fax/pjsip/t38_fast_reject/sipp/B_PARTY.xml
@@ -1,87 +1,79 @@
-<?xml version="1.0" encoding="ISO-8859-1" ?>
-<!DOCTYPE scenario SYSTEM "sipp.dtd">
-
-<scenario name="T38 REINVITE">
-
-<recv request="INVITE" crlf="true" rrs="true">
-</recv>
-
-
-
-<send>
-<![CDATA[
-
-SIP/2.0 100 Trying
-[last_Via:]
-[last_Call-ID:]
-[last_From:]
-[last_To:]
-[last_CSeq:]
-Content-Length: 0
-
-]]>
-</send>
-
-<send retrans="500">
-<![CDATA[
-
-SIP/2.0 200 OK
-[last_Via:]
-[last_Call-ID:]
-[last_From:]
-[last_To:];tag=[call_number]
-[last_CSeq:]
-[last_Record-Route]
-Contact: <sip:bansallaptop@[local_ip]:[local_port];user=phone>
-Content-Type: application/sdp
-Content-Length: [len]
-
-v=0
-o=HuaweiSoftX3000 6644052 6644052 IN IP[local_ip_type] [local_ip]
-s=Sip Call
-c=IN IP[media_ip_type] [media_ip]
-t=0 0
-m=audio 8000 RTP/AVP 0 100 101
-a=rtpmap:0 PCMU/8000
-a=rtpmap:100 NSE/8000
-a=rtpmap:101 telephone-event/101
-
-]]>
-</send>
-
-<recv request="ACK"
-      rtd="true"
-      crlf="true">
-</recv>
-
-<recv request="BYE">
-</recv>
-
-<send>
-    <![CDATA[
-
-      SIP/2.0 200 OK
-      [last_Via:]
-      [last_From:]
-      [last_To:]
-      [last_Call-ID:]
-      [last_CSeq:]
-      Contact: <sip:[local_ip]:[local_port];transport=[transport]>
-      Content-Length: 0
-
-    ]]>
-</send>
-
-<!-- Keep the call open for a while in case the 200 is lost to be     -->
-<!-- able to retransmit it if we receive the BYE again.               -->
-<pause milliseconds="4000"/>
-
-
-<!-- definition of the response time repartition table (unit is ms)   -->
-<ResponseTimeRepartition value="10, 20, 30, 40, 50, 100, 150, 200"/>
-
-<!-- definition of the call length repartition table (unit is ms)     -->
-<CallLengthRepartition value="10, 50, 100, 500, 1000, 5000, 10000"/>
-
-</scenario>
-
+<?xml version="1.0" encoding="ISO-8859-1" ?>
+<!DOCTYPE scenario SYSTEM "sipp.dtd">
+
+<scenario name="T38 REINVITE UAS">
+	<recv request="INVITE">
+	</recv>
+
+	<send>
+		<![CDATA[
+
+			SIP/2.0 100 Trying
+			[last_Via:]
+			[last_Call-ID:]
+			[last_From:]
+			[last_To:]
+			[last_CSeq:]
+			Content-Length: 0
+
+		]]>
+	</send>
+
+	<send retrans="500">
+		<![CDATA[
+
+			SIP/2.0 200 OK
+			[last_Via:]
+			[last_Call-ID:]
+			[last_From:]
+			[last_To:];tag=[call_number]
+			[last_CSeq:]
+			Contact: <sip:bansallaptop@[local_ip]:[local_port];user=phone>
+			Content-Type: application/sdp
+			Content-Length: [len]
+
+			v=0
+			o=HuaweiSoftX3000 6644052 6644052 IN IP[local_ip_type] [local_ip]
+			s=Sip Call
+			c=IN IP[media_ip_type] [media_ip]
+			t=0 0
+			m=audio 8000 RTP/AVP 0 100 101
+			a=rtpmap:0 PCMU/8000
+			a=rtpmap:100 NSE/8000
+			a=rtpmap:101 telephone-event/101
+
+		]]>
+	</send>
+
+	<recv request="ACK" crlf="true">
+	</recv>
+
+	<recv request="BYE">
+	</recv>
+
+	<send>
+		<![CDATA[
+
+			SIP/2.0 200 OK
+			[last_Via:]
+			[last_From:]
+			[last_To:]
+			[last_Call-ID:]
+			[last_CSeq:]
+			Contact: <sip:[local_ip]:[local_port];transport=[transport]>
+			Content-Length: 0
+
+		]]>
+	</send>
+
+	<!-- Keep the call open for a while in case the 200 is lost to be     -->
+	<!-- able to retransmit it if we receive the BYE again.               -->
+	<pause milliseconds="4000"/>
+
+	<!-- definition of the response time repartition table (unit is ms)   -->
+	<ResponseTimeRepartition value="10, 20, 30, 40, 50, 100, 150, 200"/>
+
+	<!-- definition of the call length repartition table (unit is ms)     -->
+	<CallLengthRepartition value="10, 50, 100, 500, 1000, 5000, 10000"/>
+</scenario>
+
diff --git a/tests/fax/pjsip/t38_fast_reject/test-config.yaml b/tests/fax/pjsip/t38_fast_reject/test-config.yaml
index 90eddc0..1bbb28b 100644
--- a/tests/fax/pjsip/t38_fast_reject/test-config.yaml
+++ b/tests/fax/pjsip/t38_fast_reject/test-config.yaml
@@ -1,12 +1,22 @@
 testinfo:
-    summary: 'Test that asterisk does not drop the call after it rejects the T38 reinvite from the carrier side because customer does not suport it.  It also makes sure that the rejection happends quickly'
+    summary: 'Do not drop call after T38 rejected because callee does not suport it.  Checks the rejection happends quickly'
     description: |
-        'Test that asterisk does not drop the call after it rejects the T38 reinvite from the carrier side because customer does not suport it.  I also measures the 488 response time and make sure it happends quckly'
+        'Test that asterisk does not drop the call after it rejects the T38
+        reinvite from the carrier side because customer does not suport it.
+        The 488 response time is measured to make sure it happends quckly.'
+
+# You might think that this test can easily be converted to a sipp.SIPpTestCase
+# pluggable test.  After all, SIPp has this timeout attribute feature to required
+# <recv> messages.  Unfortunately it didn't abort the call and exit with an error
+# code when the 488 came in after the timeout.  In fact it didn't seem to make
+* any difference in the SIPp scenario behavior.
 
 properties:
     dependencies:
         - python : 'twisted'
         - python : 'starpy'
+        - asterisk : 'chan_pjsip'
+        - asterisk : 'app_dial'
 
     tags:
         - PJSIP

-- 
To view, visit https://gerrit.asterisk.org/9788
To unsubscribe, or for help writing mail filters, visit https://gerrit.asterisk.org/settings

Gerrit-Project: testsuite
Gerrit-Branch: 13
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ic8e4d71f841627479c943c3b8a25e4776534258d
Gerrit-Change-Number: 9788
Gerrit-PatchSet: 1
Gerrit-Owner: Richard Mudgett <rmudgett at digium.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20180730/4545e2b7/attachment-0001.html>


More information about the asterisk-code-review mailing list