[Asterisk-code-review] Add NAPTR preference failover test. (testsuite[master])

Mark Michelson asteriskteam at digium.com
Thu Jun 11 14:41:30 CDT 2015


Mark Michelson has uploaded a new change for review.

  https://gerrit.asterisk.org/636

Change subject: Add NAPTR preference failover test.
......................................................................

Add NAPTR preference failover test.

This test has two NAPTR records. The one with the lower preference value
points to a TCP SRV record that does not exist. The one with the higher
preference value points to a UDP SRV record that will resolve properly.

A SIPp scenario is running on a UDP port and receives the call since
Asterisk fails over to UDP after the TCP SRV lookup fails.

ASTERISK-25015 #close
Reported by Matt Jordan

Change-Id: I000cd05d489c98c6b49ad9690d40d0db697b52da
---
A tests/channels/pjsip/resolver/naptr/preference_failover/configs/ast1/extensions.conf
A tests/channels/pjsip/resolver/naptr/preference_failover/configs/ast1/pjsip.conf
A tests/channels/pjsip/resolver/naptr/preference_failover/configs/ast1/resolver_unbound.conf
A tests/channels/pjsip/resolver/naptr/preference_failover/dns_zones/example.com
A tests/channels/pjsip/resolver/naptr/preference_failover/sipp/uas.xml
A tests/channels/pjsip/resolver/naptr/preference_failover/test-config.yaml
M tests/channels/pjsip/resolver/naptr/tests.yaml
7 files changed, 177 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.asterisk.org:29418/testsuite refs/changes/36/636/1

diff --git a/tests/channels/pjsip/resolver/naptr/preference_failover/configs/ast1/extensions.conf b/tests/channels/pjsip/resolver/naptr/preference_failover/configs/ast1/extensions.conf
new file mode 100644
index 0000000..4a2d2ba
--- /dev/null
+++ b/tests/channels/pjsip/resolver/naptr/preference_failover/configs/ast1/extensions.conf
@@ -0,0 +1,6 @@
+[default]
+
+exten => s,1,NoOp()
+ same => n,Wait(1)
+ same => n,Dial(PJSIP/rick/sip:example.com)
+ same => n,Hangup()
diff --git a/tests/channels/pjsip/resolver/naptr/preference_failover/configs/ast1/pjsip.conf b/tests/channels/pjsip/resolver/naptr/preference_failover/configs/ast1/pjsip.conf
new file mode 100644
index 0000000..4f2b4e1
--- /dev/null
+++ b/tests/channels/pjsip/resolver/naptr/preference_failover/configs/ast1/pjsip.conf
@@ -0,0 +1,14 @@
+[transport-tcp]
+type=transport
+protocol=tcp
+bind=0.0.0.0:5060
+
+[transport=udp]
+type=transport
+protocol=udp
+bind=0.0.0.0:5060
+
+[rick]
+type=endpoint
+context=default
+allow=!all,ulaw,alaw,g722
diff --git a/tests/channels/pjsip/resolver/naptr/preference_failover/configs/ast1/resolver_unbound.conf b/tests/channels/pjsip/resolver/naptr/preference_failover/configs/ast1/resolver_unbound.conf
new file mode 100644
index 0000000..38ef153
--- /dev/null
+++ b/tests/channels/pjsip/resolver/naptr/preference_failover/configs/ast1/resolver_unbound.conf
@@ -0,0 +1,3 @@
+[general]
+nameserver = 127.0.0.1 at 10053
+resolv =
diff --git a/tests/channels/pjsip/resolver/naptr/preference_failover/dns_zones/example.com b/tests/channels/pjsip/resolver/naptr/preference_failover/dns_zones/example.com
new file mode 100644
index 0000000..aabb875
--- /dev/null
+++ b/tests/channels/pjsip/resolver/naptr/preference_failover/dns_zones/example.com
@@ -0,0 +1,32 @@
+zone = [
+    SOA(
+        # For whom we are the authority
+        'example.com',
+
+        # This nameserver's name
+        mname = "ns1.example.com",
+
+        # Mailbox of individual who handles this
+        rname = "root.example.com",
+
+        # Unique serial identifying this SOA data
+        serial = 2003010601,
+
+        # Time interval before zone should be refreshed
+        refresh = "1H",
+
+        # Interval before failed refresh should be retried
+        retry = "1H",
+
+        # Upper limit on time interval before expiry
+        expire = "1H",
+
+        # Minimum TTL
+        minimum = "1H"
+    ),
+
+    NAPTR('example.com', 50, 50, 'S', 'SIP+D2T', '', '_sip._tcp.example.com'),
+    NAPTR('example.com', 50, 90, 'S', 'SIP+D2U', '', '_sip._udp.example.com'),
+    SRV('_sip._udp.example.com', 0, 1, 5061, 'pbx.example.com'),
+    A('pbx.example.com', '127.0.0.1'),
+]
diff --git a/tests/channels/pjsip/resolver/naptr/preference_failover/sipp/uas.xml b/tests/channels/pjsip/resolver/naptr/preference_failover/sipp/uas.xml
new file mode 100644
index 0000000..e72519e
--- /dev/null
+++ b/tests/channels/pjsip/resolver/naptr/preference_failover/sipp/uas.xml
@@ -0,0 +1,65 @@
+<?xml version="1.0" encoding="ISO-8859-1" ?>
+<!DOCTYPE scenario SYSTEM "sipp.dtd">
+
+<scenario name="Receive INVITE with audio, immediately answer, and then hangup">
+  <Global variables="remote_tag" />
+  <recv request="INVITE" crlf="true">
+      <action>
+          <!-- Save the from tag. We'll need it when we send our BYE -->
+          <ereg regexp=".*(;tag=.*)"
+              header="From:"
+              search_in="hdr"
+              check_it="true"
+              assign_to="remote_tag"/>
+      </action>
+  </recv>
+
+  <send retrans="500">
+    <![CDATA[
+
+      SIP/2.0 200 OK
+      [last_Via:]
+      [last_From:]
+      [last_To:];tag=[call_number]
+      [last_Call-ID:]
+      [last_CSeq:]
+      Contact: <sip:[local_ip]:[local_port];transport=[transport]>
+      Content-Type: application/sdp
+      Content-Length: [len]
+
+      v=0
+      o=- 1324901698 1324901698 IN IP4 [local_ip]
+      s=-
+      c=IN IP4 [local_ip]
+      t=0 0
+      m=audio 2226 RTP/AVP 0 101
+      a=sendrecv
+      a=rtpmap:0 PCMU/8000
+      a=rtpmap:101 telephone-event/8000
+
+    ]]>
+  </send>
+
+  <recv request="ACK" rtd="true" crlf="true">
+  </recv>
+
+  <send retrans="500">
+    <![CDATA[
+
+      BYE sip:[service]@[remote_ip]:[remote_port] SIP/2.0
+      Via: SIP/2.0/[transport] [local_ip]:[local_port];branch=[branch]
+      From: ua1 <sip:ua1@[local_ip]:[local_port]>;tag=[call_number]
+      To: [$remote_tag]
+      [last_Call-ID:]
+      CSeq: [cseq] BYE
+      Contact: <sip:[local_ip]:[local_port];transport=[transport]>
+      Max-Forwards: 70
+      Content-Length: 0
+
+    ]]>
+  </send>
+
+  <recv response="200">
+  </recv>
+
+</scenario>
diff --git a/tests/channels/pjsip/resolver/naptr/preference_failover/test-config.yaml b/tests/channels/pjsip/resolver/naptr/preference_failover/test-config.yaml
new file mode 100644
index 0000000..e725cfb
--- /dev/null
+++ b/tests/channels/pjsip/resolver/naptr/preference_failover/test-config.yaml
@@ -0,0 +1,56 @@
+testinfo:
+    summary: 'Test NAPTR record order to ensure lowest order is used.'
+    description: |
+        'This test verifies that when a NAPTR record results in a failed SRV
+        lookup, that Asterisk fails over to the NAPTR record with the next
+        highest preference value.
+
+        A call is placed to example.com without a transport specified resulting
+        in a NAPTR lookup. The lowest preference record points to an SRV entry
+        that does not exist. Asterisk should attempt to look up this SRV record,
+        and fail. The next lowest preference NAPTR record points to an SRV entry
+        that does exist, and that SRV record points to a UDP transport. A SIPp
+        instance is listening on UDP, so the test will succeed if UDP is used
+        due to the wrong NAPTR record being used.'
+
+test-modules:
+    test-object:
+        config-section: test-object-config
+        typename: 'sipp.SIPpTestCase'
+    modules:
+        -
+            config-section: originator
+            typename: 'pluggable_modules.Originator'
+        -
+            config-section: dns-server-config
+            typename: 'dns_server.DNSServer'
+
+test-object-config:
+    test-iterations:
+        -
+            scenarios:
+                - { 'key-args': {'scenario': 'uas.xml', '-i': '127.0.0.1',
+                                 '-p': '5061'} }
+
+originator:
+    trigger: 'ami_connect'
+    ignore-originate-failure: 'no'
+    id: '0'
+    channel: 'Local/s at default'
+    application: 'Echo'
+    async: 'True'
+
+dns-server-config:
+    port: 10053
+    python-zones:
+        -
+            example.com
+
+properties:
+    minversion: '14.0.0'
+    dependencies:
+        - app : 'sipp'
+        - asterisk : 'res_pjsip'
+        - asterisk : 'res_resolver_unbound'
+    tags:
+        - pjsip
diff --git a/tests/channels/pjsip/resolver/naptr/tests.yaml b/tests/channels/pjsip/resolver/naptr/tests.yaml
index 77ef509..e19e6f1 100644
--- a/tests/channels/pjsip/resolver/naptr/tests.yaml
+++ b/tests/channels/pjsip/resolver/naptr/tests.yaml
@@ -5,3 +5,4 @@
     - test: 'transport_unspecified'
     - test: 'order'
     - test: 'preference'
+    - test: 'preference_failover'

-- 
To view, visit https://gerrit.asterisk.org/636
To unsubscribe, visit https://gerrit.asterisk.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I000cd05d489c98c6b49ad9690d40d0db697b52da
Gerrit-PatchSet: 1
Gerrit-Project: testsuite
Gerrit-Branch: master
Gerrit-Owner: Mark Michelson <mmichelson at digium.com>



More information about the asterisk-code-review mailing list