[Asterisk-code-review] tests/pjsip/config_options/remove_unavailable: Test new config option (testsuite[18])

Friendly Automation asteriskteam at digium.com
Fri Sep 24 12:52:05 CDT 2021


Friendly Automation has submitted this change. ( https://gerrit.asterisk.org/c/testsuite/+/16544 )

Change subject: tests/pjsip/config_options/remove_unavailable: Test new config option
......................................................................

tests/pjsip/config_options/remove_unavailable: Test new config option

A new PJSIP option to remove unavailable contacts when an inbound
registration exceeds max_contacts has been added.  A new test is
added to the testsuite to test the behavior of this option.

ASTERISK-29525

Change-Id: I336bd2bac512396b33407882066a8ec66a914f5c
---
A tests/channels/pjsip/registration/inbound/nominal/config_options/remove_unavailable/configs/ast1/pjsip.conf
A tests/channels/pjsip/registration/inbound/nominal/config_options/remove_unavailable/sipp/register-remove-existing-disabled-1.xml
A tests/channels/pjsip/registration/inbound/nominal/config_options/remove_unavailable/sipp/register-remove-existing-disabled-2.xml
A tests/channels/pjsip/registration/inbound/nominal/config_options/remove_unavailable/sipp/register-remove-existing-enabled.xml
A tests/channels/pjsip/registration/inbound/nominal/config_options/remove_unavailable/test-config.yaml
M tests/channels/pjsip/registration/inbound/nominal/config_options/tests.yaml
6 files changed, 440 insertions(+), 0 deletions(-)

Approvals:
  Kevin Harwell: Looks good to me, approved
  Friendly Automation: Approved for Submit



diff --git a/tests/channels/pjsip/registration/inbound/nominal/config_options/remove_unavailable/configs/ast1/pjsip.conf b/tests/channels/pjsip/registration/inbound/nominal/config_options/remove_unavailable/configs/ast1/pjsip.conf
new file mode 100644
index 0000000..e2c82fe
--- /dev/null
+++ b/tests/channels/pjsip/registration/inbound/nominal/config_options/remove_unavailable/configs/ast1/pjsip.conf
@@ -0,0 +1,47 @@
+[system]
+type=system
+timer_t1=100
+timer_b=6400
+
+[local-transport-template](!)
+type=transport
+bind=127.0.0.1
+
+[local-transport-udp](local-transport-template)
+protocol=udp
+
+[endpoint-template](!)
+type=endpoint
+context=default
+allow=!all,ulaw
+
+[alice](endpoint-template)
+aors=alice
+
+[alice]
+type=aor
+max_contacts=1
+remove_unavailable=yes
+qualify_frequency=5
+qualify_timeout=3.0
+
+[bob](endpoint-template)
+aors=bob
+
+[bob]
+type=aor
+max_contacts=2
+remove_unavailable=yes
+qualify_frequency=5
+qualify_timeout=3.0
+
+[charlie](endpoint-template)
+aors=charlie
+
+[charlie]
+type=aor
+max_contacts=2
+remove_existing=yes
+remove_unavailable=yes
+qualify_frequency=5
+qualify_timeout=3.0
diff --git a/tests/channels/pjsip/registration/inbound/nominal/config_options/remove_unavailable/sipp/register-remove-existing-disabled-1.xml b/tests/channels/pjsip/registration/inbound/nominal/config_options/remove_unavailable/sipp/register-remove-existing-disabled-1.xml
new file mode 100644
index 0000000..0a65a3c
--- /dev/null
+++ b/tests/channels/pjsip/registration/inbound/nominal/config_options/remove_unavailable/sipp/register-remove-existing-disabled-1.xml
@@ -0,0 +1,78 @@
+<?xml version="1.0" encoding="ISO-8859-1" ?>
+<!DOCTYPE scenario SYSTEM "sipp.dtd">
+
+<scenario name="Basic Sipstone UAC">
+	<send retrans="500">
+		<![CDATA[
+			REGISTER sip:[remote_ip]:[remote_port] SIP/2.0
+			Via: SIP/2.0/[transport] [local_ip]:[local_port];branch=[branch]
+			From: "[service]" <sip:[service]@[local_ip]:[local_port]>;tag=[pid]SIPpTag00[call_number]-1
+			To: "[service]" <sip:[service]@[remote_ip]:[remote_port]>
+			Call-ID: [call_id]
+			CSeq: 1 REGISTER
+			Max-Forwards: 70
+			Contact: "[service]" <sip:[service]-1 at 127.0.0.2:5062>;transport=[transport]
+			Subject: Performance Test
+			Expires: 600
+			Content-Length: 0
+		]]>
+	</send>
+
+	<recv response="200" rtd="true">
+		<action>
+			<!-- Ensure the expected contacts are present and that the expires is correct with a 5 second tolerance -->
+			<ereg regexp="Contact: <sip:alice-1 at 127.0.0.2:5062>;expires=(600|59[5-9])" search_in="msg" check_it="true" assign_to="1"/>
+		</action>
+	</recv>
+
+	<pause milliseconds="15000"/>
+
+	<send retrans="500">
+		<![CDATA[
+			REGISTER sip:[remote_ip]:[remote_port] SIP/2.0
+			Via: SIP/2.0/[transport] [local_ip]:[local_port];branch=[branch]
+			From: "[service]" <sip:[service]@[local_ip]:[local_port]>;tag=[pid]SIPpTag00[call_number]-2
+			To: "[service]" <sip:[service]@[remote_ip]:[remote_port]>
+			Call-ID: [call_id]
+			CSeq: 1 REGISTER
+			Max-Forwards: 70
+			Contact: "[service]" <sip:[service]-2 at 127.0.0.3:5063>;transport=[transport]
+			Subject: Performance Test
+			Expires: 300
+			Content-Length: 0
+		]]>
+	</send>
+
+	<recv response="200" rtd="true">
+		<action>
+			<!-- Ensure the expected contacts are present and that the expires is correct with a 5 second tolerance -->
+			<ereg regexp="Contact: <sip:alice-2 at 127.0.0.3:5063>;expires=(300|29[5-9])" search_in="msg" check_it="true" assign_to="2"/>
+			<!-- Ensure the expected old contacts are *not* present -->
+			<ereg regexp="Contact: <sip:alice-1 at 127.0.0.2:5062>" search_in="msg" check_it_inverse="true" assign_to="3" />
+		</action>
+	</recv>
+
+
+	<send retrans="500">
+		<![CDATA[
+			REGISTER sip:[remote_ip]:[remote_port] SIP/2.0
+			Via: SIP/2.0/[transport] [local_ip]:[local_port];branch=[branch]
+			From: "[service]" <sip:[service]@[local_ip]:[local_port]>;tag=[pid]SIPpTag00[call_number]-3
+			To: "[service]" <sip:[service]@[remote_ip]:[remote_port]>
+			Call-ID: [call_id]
+			CSeq: 1 REGISTER
+			Max-Forwards: 70
+			Contact: "[service]" <sip:[service]-3 at 127.0.0.4:5064>;transport=[transport]
+			Subject: Performance Test
+			Expires: 60
+			Content-Length: 0
+		]]>
+	</send>
+
+	<recv response="403" rtd="true">
+	</recv>
+
+	<Reference variables="1" />
+	<Reference variables="2" />
+	<Reference variables="3" />
+</scenario>
diff --git a/tests/channels/pjsip/registration/inbound/nominal/config_options/remove_unavailable/sipp/register-remove-existing-disabled-2.xml b/tests/channels/pjsip/registration/inbound/nominal/config_options/remove_unavailable/sipp/register-remove-existing-disabled-2.xml
new file mode 100644
index 0000000..ee932d9
--- /dev/null
+++ b/tests/channels/pjsip/registration/inbound/nominal/config_options/remove_unavailable/sipp/register-remove-existing-disabled-2.xml
@@ -0,0 +1,106 @@
+<?xml version="1.0" encoding="ISO-8859-1" ?>
+<!DOCTYPE scenario SYSTEM "sipp.dtd">
+
+<scenario name="Basic Sipstone UAC">
+	<send retrans="500">
+		<![CDATA[
+			REGISTER sip:[remote_ip]:[remote_port] SIP/2.0
+			Via: SIP/2.0/[transport] [local_ip]:[local_port];branch=[branch]
+			From: "[service]" <sip:[service]@[local_ip]:[local_port]>;tag=[pid]SIPpTag00[call_number]-1
+			To: "[service]" <sip:[service]@[remote_ip]:[remote_port]>
+			Call-ID: [call_id]
+			CSeq: 1 REGISTER
+			Max-Forwards: 70
+			Contact: "[service]" <sip:[service]-1 at 127.0.0.2:5062>;transport=[transport]
+			Subject: Performance Test
+			Expires: 600
+			Content-Length: 0
+		]]>
+	</send>
+
+	<recv response="200" rtd="true">
+		<action>
+			<!-- Ensure the expected contacts are present and that the expires is correct with a 5 second tolerance -->
+			<ereg regexp="Contact: <sip:bob-1 at 127.0.0.2:5062>;expires=(600|59[5-9])" search_in="msg" check_it="true" assign_to="1"/>
+		</action>
+	</recv>
+
+	<send retrans="500">
+		<![CDATA[
+			REGISTER sip:[remote_ip]:[remote_port] SIP/2.0
+			Via: SIP/2.0/[transport] [local_ip]:[local_port];branch=[branch]
+			From: "[service]" <sip:[service]@[local_ip]:[local_port]>;tag=[pid]SIPpTag00[call_number]-2
+			To: "[service]" <sip:[service]@[remote_ip]:[remote_port]>
+			Call-ID: [call_id]
+			CSeq: 1 REGISTER
+			Max-Forwards: 70
+			Contact: "[service]" <sip:[service]-2 at 127.0.0.3:5063>;transport=[transport]
+			Subject: Performance Test
+			Expires: 300
+			Content-Length: 0
+		]]>
+	</send>
+
+	<recv response="200" rtd="true">
+		<action>
+			<!-- Ensure the expected contacts are present and that the expires is correct with a 5 second tolerance -->
+			<ereg regexp="Contact: <sip:bob-1 at 127.0.0.2:5062>;expires=(600|59[5-9])" search_in="msg" check_it="true" assign_to="2"/>
+			<ereg regexp="Contact: <sip:bob-2 at 127.0.0.3:5063>;expires=(300|29[5-9])" search_in="msg" check_it="true" assign_to="3"/>
+		</action>
+	</recv>
+
+	<pause milliseconds="15000"/>
+
+	<send retrans="500">
+		<![CDATA[
+			REGISTER sip:[remote_ip]:[remote_port] SIP/2.0
+			Via: SIP/2.0/[transport] [local_ip]:[local_port];branch=[branch]
+			From: "[service]" <sip:[service]@[local_ip]:[local_port]>;tag=[pid]SIPpTag00[call_number]-3
+			To: "[service]" <sip:[service]@[remote_ip]:[remote_port]>
+			Call-ID: [call_id]
+			CSeq: 1 REGISTER
+			Max-Forwards: 70
+			Contact: "[service]" <sip:[service]-3 at 127.0.0.4:5064>;transport=[transport]
+			Subject: Performance Test
+			Expires: 60
+			Content-Length: 0
+		]]>
+	</send>
+
+	<recv response="200" rtd="true">
+		<action>
+			<!-- Ensure the expected old contacts are *not* present -->
+			<ereg regexp="Contact: <sip:bob-2 at 127.0.0.3:5063>" search_in="msg" check_it_inverse="true" assign_to="4" />
+			<!-- Ensure the expected contacts are present and that the expires is correct with a 5 second tolerance -->
+			<ereg regexp="Contact: <sip:bob-1 at 127.0.0.2:5062>;expires=(58[0-5])" search_in="msg" check_it="true" assign_to="5"/>
+			<ereg regexp="Contact: <sip:bob-3 at 127.0.0.4:5064>;expires=(60|5[5-9])" search_in="msg" check_it="true" assign_to="6"/>
+		</action>
+	</recv>
+
+	<send retrans="500">
+		<![CDATA[
+			REGISTER sip:[remote_ip]:[remote_port] SIP/2.0
+			Via: SIP/2.0/[transport] [local_ip]:[local_port];branch=[branch]
+			From: "[service]" <sip:[service]@[local_ip]:[local_port]>;tag=[pid]SIPpTag00[call_number]-4
+			To: "[service]" <sip:[service]@[remote_ip]:[remote_port]>
+			Call-ID: [call_id]
+			CSeq: 1 REGISTER
+			Max-Forwards: 70
+			Contact: "[service]" <sip:[service]-4 at 127.0.0.5:5065>;transport=[transport]
+			Contact: "[service]" <sip:[service]-5 at 127.0.0.6:5066>;transport=[transport]
+			Subject: Performance Test
+			Expires: 60
+			Content-Length: 0
+		]]>
+	</send>
+
+	<recv response="403" rtd="true">
+	</recv>
+
+	<Reference variables="1" />
+	<Reference variables="2" />
+	<Reference variables="3" />
+	<Reference variables="4" />
+	<Reference variables="5" />
+	<Reference variables="6" />
+</scenario>
diff --git a/tests/channels/pjsip/registration/inbound/nominal/config_options/remove_unavailable/sipp/register-remove-existing-enabled.xml b/tests/channels/pjsip/registration/inbound/nominal/config_options/remove_unavailable/sipp/register-remove-existing-enabled.xml
new file mode 100644
index 0000000..333af6e
--- /dev/null
+++ b/tests/channels/pjsip/registration/inbound/nominal/config_options/remove_unavailable/sipp/register-remove-existing-enabled.xml
@@ -0,0 +1,86 @@
+<?xml version="1.0" encoding="ISO-8859-1" ?>
+<!DOCTYPE scenario SYSTEM "sipp.dtd">
+
+<scenario name="Basic Sipstone UAC">
+	<send retrans="500">
+		<![CDATA[
+			REGISTER sip:[remote_ip]:[remote_port] SIP/2.0
+			Via: SIP/2.0/[transport] [local_ip]:[local_port];branch=[branch]
+			From: "[service]" <sip:[service]@[local_ip]:[local_port]>;tag=[pid]SIPpTag00[call_number]-1
+			To: "[service]" <sip:[service]@[remote_ip]:[remote_port]>
+			Call-ID: [call_id]
+			CSeq: 1 REGISTER
+			Max-Forwards: 70
+			Contact: "[service]" <sip:[service]-1 at 127.0.0.2:5062>;transport=[transport]
+			Subject: Performance Test
+			Expires: 600
+			Content-Length: 0
+		]]>
+	</send>
+
+	<recv response="200" rtd="true">
+		<action>
+			<!-- Ensure the expected contacts are present and that the expires is correct with a 5 second tolerance -->
+			<ereg regexp="Contact: <sip:charlie-1 at 127.0.0.2:5062>;expires=(600|59[5-9])" search_in="msg" check_it="true" assign_to="1"/>
+		</action>
+	</recv>
+
+	<pause milliseconds="15000"/>
+
+	<send retrans="500">
+		<![CDATA[
+			REGISTER sip:[remote_ip]:[remote_port] SIP/2.0
+			Via: SIP/2.0/[transport] [local_ip]:[local_port];branch=[branch]
+			From: "[service]" <sip:[service]@[local_ip]:[local_port]>;tag=[pid]SIPpTag00[call_number]-2
+			To: "[service]" <sip:[service]@[remote_ip]:[remote_port]>
+			Call-ID: [call_id]
+			CSeq: 1 REGISTER
+			Max-Forwards: 70
+			Contact: "[service]" <sip:[service]-2 at 127.0.0.3:5063>;transport=[transport]
+			Subject: Performance Test
+			Expires: 60
+			Content-Length: 0
+		]]>
+	</send>
+
+	<recv response="200" rtd="true">
+		<action>
+			<!-- Ensure the expected contacts are present and that the expires is correct with a 5 second tolerance -->
+			<ereg regexp="Contact: <sip:charlie-1 at 127.0.0.2:5062>;expires=(58[0-5])" search_in="msg" check_it="true" assign_to="2"/>
+			<ereg regexp="Contact: <sip:charlie-2 at 127.0.0.3:5063>;expires=(60|5[5-9])" search_in="msg" check_it="true" assign_to="3"/>
+		</action>
+	</recv>
+
+	<send retrans="500">
+		<![CDATA[
+			REGISTER sip:[remote_ip]:[remote_port] SIP/2.0
+			Via: SIP/2.0/[transport] [local_ip]:[local_port];branch=[branch]
+			From: "[service]" <sip:[service]@[local_ip]:[local_port]>;tag=[pid]SIPpTag00[call_number]-3
+			To: "[service]" <sip:[service]@[remote_ip]:[remote_port]>
+			Call-ID: [call_id]
+			CSeq: 1 REGISTER
+			Max-Forwards: 70
+			Contact: "[service]" <sip:[service]-3 at 127.0.0.4:5064>;transport=[transport]
+			Subject: Performance Test
+			Expires: 70
+			Content-Length: 0
+		]]>
+	</send>
+
+	<recv response="200" rtd="true">
+		<action>
+			<!-- Ensure the expected contacts are present and that the expires is correct with a 5 second tolerance -->
+			<ereg regexp="Contact: <sip:charlie-2 at 127.0.0.3:5063>;expires=(60|5[5-9])" search_in="msg" check_it="true" assign_to="4"/>
+			<ereg regexp="Contact: <sip:charlie-3 at 127.0.0.4:5064>;expires=(70|6[5-9])" search_in="msg" check_it="true" assign_to="5"/>
+			<!-- Ensure the expected old contacts are *not* present -->
+			<ereg regexp="Contact: <sip:charlie-1 at 127.0.0.2:5062>" search_in="msg" check_it_inverse="true" assign_to="6" />
+		</action>
+	</recv>
+
+	<Reference variables="1" />
+	<Reference variables="2" />
+	<Reference variables="3" />
+	<Reference variables="4" />
+	<Reference variables="5" />
+	<Reference variables="6" />
+</scenario>
diff --git a/tests/channels/pjsip/registration/inbound/nominal/config_options/remove_unavailable/test-config.yaml b/tests/channels/pjsip/registration/inbound/nominal/config_options/remove_unavailable/test-config.yaml
new file mode 100644
index 0000000..97da1f2
--- /dev/null
+++ b/tests/channels/pjsip/registration/inbound/nominal/config_options/remove_unavailable/test-config.yaml
@@ -0,0 +1,122 @@
+testinfo:
+    summary:     'Register contacts to test the remove_unavailable option'
+    description: |
+        'When remove_existing is enabled:
+         When remove_unavailable is enabled, any existing AOR contacts not
+         affected by the new registration and are unavailable are removed
+         if they push the number of contacts over the max_contacts setting.
+         If there are no unavailable contacts for this AOR, then default back
+         to the regular remove_existing behavior and remove the contact that
+         is soonest to expire.
+         A single registration still cannot try to add more contacts than
+         the max_contacts setting.  The number of contacts cannot go over the
+         max_contacts setting.
+
+         Using IPv4 and UDP, run SIPp scenarios that register contacts in a
+         series of registrations. This ensures that with the remove_unavailable
+         pjsip.conf configuration option enabled, the unavailable contacts are
+         removed and the new contacts are added as expected.
+
+         When remove_existing is not enabled:
+         When remove_unavailable is enabled, search the AOR for any unavailable
+         contacts not involved in this registration, and remove enough contacts
+         so that the total number of registered contacts remains at or below
+         max_contacts.
+
+         Using IPv4 and UDP, run SIPp scenarios that register contacts in a
+         series of registrations. This ensures that with the remove_unavailable
+         pjsip.conf configuration option enabled, the unavailable contacts are
+         removed and the new contacts are added as expected.'
+
+test-modules:
+    test-object:
+        -
+            config-section: 'test-object-config'
+            typename: 'sipp.SIPpTestCase'
+    modules:
+        -
+            config-section: 'ami-config'
+            typename: 'ami.AMIEventModule'
+
+test-object-config:
+    memcheck-delay-stop: 7
+    fail-on-any: False
+    test-iterations:
+        -
+            scenarios:
+                # IPv4 & UDP & 1 existing contact
+                - { 'key-args': {'scenario': 'register-remove-existing-disabled-1.xml', '-i': '127.0.0.1', '-p': '5061', '-s': 'alice'} }
+
+                # IPv4 & UDP & 2 existing contacts
+                - { 'key-args': {'scenario': 'register-remove-existing-disabled-2.xml', '-i': '127.0.0.1', '-p': '5161', '-s': 'bob'} }
+
+               # IPv4 & UDP & remove_existing
+                - { 'key-args': {'scenario': 'register-remove-existing-enabled.xml', '-i': '127.0.0.1', '-p': '5261', '-s': 'charlie'} }
+
+ami-config:
+    -
+        type: 'headermatch'
+        id: '0'
+        conditions:
+            match:
+                Event: 'TestEvent'
+                State: 'AOR_CONTACT_ADDED'
+                AOR: 'alice'
+        count: '2'
+    -
+        type: 'headermatch'
+        id: '0'
+        conditions:
+            match:
+                Event: 'TestEvent'
+                State: 'AOR_CONTACT_REMOVED'
+                AOR: 'alice'
+        count: '1'
+    -
+        type: 'headermatch'
+        id: '0'
+        conditions:
+            match:
+                Event: 'TestEvent'
+                State: 'AOR_CONTACT_ADDED'
+                AOR: 'bob'
+        count: '3'
+    -
+        type: 'headermatch'
+        id: '0'
+        conditions:
+            match:
+                Event: 'TestEvent'
+                State: 'AOR_CONTACT_REMOVED'
+                AOR: 'bob'
+        count: '1'
+    -
+        type: 'headermatch'
+        id: '0'
+        conditions:
+            match:
+                Event: 'TestEvent'
+                State: 'AOR_CONTACT_ADDED'
+                AOR: 'charlie'
+        count: '3'
+    -
+        type: 'headermatch'
+        id: '0'
+        conditions:
+            match:
+                Event: 'TestEvent'
+                State: 'AOR_CONTACT_REMOVED'
+                AOR: 'charlie'
+        count: '1'
+
+properties:
+    dependencies:
+        - buildoption: 'TEST_FRAMEWORK'
+        - python: 'twisted'
+        - python: 'starpy'
+        - sipp:
+            version: 'v3.3'
+        - asterisk: 'res_pjsip'
+    tags:
+        - pjsip
+
diff --git a/tests/channels/pjsip/registration/inbound/nominal/config_options/tests.yaml b/tests/channels/pjsip/registration/inbound/nominal/config_options/tests.yaml
index 6542018..5dda52e 100644
--- a/tests/channels/pjsip/registration/inbound/nominal/config_options/tests.yaml
+++ b/tests/channels/pjsip/registration/inbound/nominal/config_options/tests.yaml
@@ -3,3 +3,4 @@
     - test: 'minimum_expiration'
     - test: 'maximum_expiration'
     - test: 'remove_existing'
+    - test: 'remove_unavailable'

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

Gerrit-Project: testsuite
Gerrit-Branch: 18
Gerrit-Change-Id: I336bd2bac512396b33407882066a8ec66a914f5c
Gerrit-Change-Number: 16544
Gerrit-PatchSet: 1
Gerrit-Owner: Joe <ynadiv at corpit.xyz>
Gerrit-Reviewer: Friendly Automation
Gerrit-Reviewer: Kevin Harwell <kharwell at digium.com>
Gerrit-MessageType: merged
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20210924/212f6141/attachment-0001.html>


More information about the asterisk-code-review mailing list