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

Joe asteriskteam at digium.com
Sun Sep 19 11:04:32 CDT 2021


Joe has uploaded this change for review. ( https://gerrit.asterisk.org/c/testsuite/+/16491 )


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-ipv4-remove-existing-disabled.xml
A tests/channels/pjsip/registration/inbound/nominal/config_options/remove_unavailable/sipp/register-ipv4-remove-existing-enabled.xml
A tests/channels/pjsip/registration/inbound/nominal/config_options/remove_unavailable/sipp/register-ipv6-remove-existing-disabled.xml
A tests/channels/pjsip/registration/inbound/nominal/config_options/remove_unavailable/sipp/register-ipv6-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
7 files changed, 738 insertions(+), 0 deletions(-)



  git pull ssh://gerrit.asterisk.org:29418/testsuite refs/changes/91/16491/1

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..a48f623
--- /dev/null
+++ b/tests/channels/pjsip/registration/inbound/nominal/config_options/remove_unavailable/configs/ast1/pjsip.conf
@@ -0,0 +1,113 @@
+[system]
+type=system
+timer_t1=100
+timer_b=6400
+
+[local-transport-template](!)
+type=transport
+bind=127.0.0.1
+
+[local-transport6-template](!)
+type=transport
+bind=[::1]
+
+[local-transport-udp](local-transport-template)
+protocol=udp
+
+[local-transport-udp6](local-transport6-template)
+protocol=udp
+
+[local-transport-tcp](local-transport-template)
+protocol=tcp
+
+[local-transport-tcp6](local-transport6-template)
+protocol=tcp
+
+[endpoint-template](!)
+type=endpoint
+context=default
+allow=!all,ulaw
+
+[alice](endpoint-template)
+aors=alice
+
+[alice]
+type=aor
+max_contacts=2
+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
+
+[carol](endpoint-template)
+aors=carol
+
+[carol]
+type=aor
+max_contacts=2
+remove_existing=yes
+remove_unavailable=yes
+qualify_frequency=5
+qualify_timeout=3.0
+
+[daniel](endpoint-template)
+aors=daniel
+
+[daniel]
+type=aor
+max_contacts=2
+remove_unavailable=yes
+qualify_frequency=5
+qualify_timeout=3.0
+
+[edward](endpoint-template)
+aors=edward
+
+[edward]
+type=aor
+max_contacts=2
+remove_unavailable=yes
+qualify_frequency=5
+qualify_timeout=3.0
+
+[frank](endpoint-template)
+aors=frank
+
+[frank]
+type=aor
+max_contacts=2
+remove_existing=yes
+remove_unavailable=yes
+qualify_frequency=5
+qualify_timeout=3.0
+
+[gussie](endpoint-template)
+aors=gussie
+
+[gussie]
+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-ipv4-remove-existing-disabled.xml b/tests/channels/pjsip/registration/inbound/nominal/config_options/remove_unavailable/sipp/register-ipv4-remove-existing-disabled.xml
new file mode 100644
index 0000000..57a22ea
--- /dev/null
+++ b/tests/channels/pjsip/registration/inbound/nominal/config_options/remove_unavailable/sipp/register-ipv4-remove-existing-disabled.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:(alice|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:(alice|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:(alice|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="20000"/>
+
+	<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:(alice|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:(alice|bob)-1 at 127.0.0.2:5062>;expires=(580|57[5-9])" search_in="msg" check_it="true" assign_to="5"/>
+			<ereg regexp="Contact: <sip:(alice|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-ipv4-remove-existing-enabled.xml b/tests/channels/pjsip/registration/inbound/nominal/config_options/remove_unavailable/sipp/register-ipv4-remove-existing-enabled.xml
new file mode 100644
index 0000000..8d8ae82
--- /dev/null
+++ b/tests/channels/pjsip/registration/inbound/nominal/config_options/remove_unavailable/sipp/register-ipv4-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|carol)-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="20000"/>
+
+	<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|carol)-1 at 127.0.0.2:5062>;expires=(580|57[5-9])" search_in="msg" check_it="true" assign_to="2"/>
+			<ereg regexp="Contact: <sip:(charlie|carol)-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|carol)-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|carol)-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|carol)-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/sipp/register-ipv6-remove-existing-disabled.xml b/tests/channels/pjsip/registration/inbound/nominal/config_options/remove_unavailable/sipp/register-ipv6-remove-existing-disabled.xml
new file mode 100644
index 0000000..a1212eb
--- /dev/null
+++ b/tests/channels/pjsip/registration/inbound/nominal/config_options/remove_unavailable/sipp/register-ipv6-remove-existing-disabled.xml
@@ -0,0 +1,107 @@
+<?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@[customip1]: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:(daniel|edward)-1 at .::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@[customip2]: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:(daniel|edward)-1 at .::2.:5062>;expires=(600|59[5-9])" search_in="msg" check_it="true" assign_to="2"/>
+			<ereg regexp="Contact: <sip:(daniel|edward)-2 at .::3.:5063>;expires=(300|29[5-9])" search_in="msg" check_it="true" assign_to="3"/>
+		</action>
+	</recv>
+
+	<pause milliseconds="20000"/>
+
+	<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@[customip3]:5064>;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:(daniel|edward)-1 at .::2.:5062>;expires=(580|57[5-9])" search_in="msg" check_it="true" assign_to="4"/>
+			<ereg regexp="Contact: <sip:(daniel|edward)-3 at .::4.:5064>;expires=(60|5[5-9])" search_in="msg" check_it="true" assign_to="5"/>
+			<!-- Ensure the expected old contacts are *not* present -->
+			<ereg regexp="Contact: <sip:(daniel|edward)-2 at .::3.:5063>" search_in="msg" check_it_inverse="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@[customip4]:5065>;transport=[transport]
+			Contact: "[service]" <sip:[service]-5@[customip5]: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-ipv6-remove-existing-enabled.xml b/tests/channels/pjsip/registration/inbound/nominal/config_options/remove_unavailable/sipp/register-ipv6-remove-existing-enabled.xml
new file mode 100644
index 0000000..3552e99
--- /dev/null
+++ b/tests/channels/pjsip/registration/inbound/nominal/config_options/remove_unavailable/sipp/register-ipv6-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@[customip1]: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:(frank|gussie)-1 at .::2.:5062>;expires=(600|59[5-9])" search_in="msg" check_it="true" assign_to="1"/>
+		</action>
+	</recv>
+
+	<pause milliseconds="20000"/>
+
+	<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@[customip2]: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:(frank|gussie)-1 at .::2.:5062>;expires=(580|57[5-9])" search_in="msg" check_it="true" assign_to="2"/>
+			<ereg regexp="Contact: <sip:(frank|gussie)-2 at .::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@[customip3]: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:(frank|gussie)-2 at .::3.:5063>;expires=(60|5[5-9])" search_in="msg" check_it="true" assign_to="4"/>
+			<ereg regexp="Contact: <sip:(frank|gussie)-3 at .::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:(frank|gussie)-1 at .::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..ce185a7
--- /dev/null
+++ b/tests/channels/pjsip/registration/inbound/nominal/config_options/remove_unavailable/test-config.yaml
@@ -0,0 +1,239 @@
+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 all combinations of IPv4/IPv6 and UDP/TCP, run SIPp scenarios
+         that register contacts in a series of registrations per transport.
+         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 all combinations of IPv4/IPv6 and UDP/TCP, run SIPp scenarios
+         that register contacts in a series of registrations per transport.
+         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
+                - { 'key-args': {'scenario': 'register-ipv4-remove-existing-disabled.xml', '-i': '127.0.0.1', '-p': '5061', '-s': 'alice'} }
+
+                # IPv4 & TCP
+                - { 'key-args': {'scenario': 'register-ipv4-remove-existing-disabled.xml', '-i': '127.0.0.1', '-p': '5061', '-t': 't1', '-s': 'bob'} }
+
+               # IPv4 & UDP & remove_existing
+                - { 'key-args': {'scenario': 'register-ipv4-remove-existing-enabled.xml', '-i': '127.0.0.1', '-p': '5161', '-s': 'carol'} }
+
+                # IPv4 & TCP & remove_existing
+                - { 'key-args': {'scenario': 'register-ipv4-remove-existing-enabled.xml', '-i': '127.0.0.1', '-p': '5161', '-t': 't1', '-s': 'charlie'} }
+                # IPv6 & UDP
+                - { 'key-args': {'scenario': 'register-ipv6-remove-existing-disabled.xml',
+                                 'target': '[::1]', '-i': '[::1]', '-p': '5061', '-s': 'daniel'},
+                    'ordered-args': ['-key', 'customip1', '[::2]', '-key', 'customip2', '[::3]',
+                                     '-key', 'customip3', '[::4]', '-key', 'customip4', '[::5]',
+                                     '-key', 'customip5', '[::6]'] }
+                # IPv6 & TCP
+                - { 'key-args': {'scenario': 'register-ipv6-remove-existing-disabled.xml',
+                                 'target': '[::1]', '-i': '[::1]', '-p': '5061', '-t': 't1', '-s': 'edward'},
+                    'ordered-args': ['-key', 'customip1', '[::2]', '-key', 'customip2', '[::3]',
+                                     '-key', 'customip3', '[::4]', '-key', 'customip4', '[::5]',
+                                     '-key', 'customip5', '[::6]'] }
+                # IPv6 & UDP & remove_existing
+                - { 'key-args': {'scenario': 'register-ipv6-remove-existing-enabled.xml',
+                                 'target': '[::1]', '-i': '[::1]', '-p': '5161', '-s': 'frank'},
+                    'ordered-args': ['-key', 'customip1', '[::2]', '-key', 'customip2', '[::3]',
+                                     '-key', 'customip3', '[::4]'] }
+                # IPv6 & TCP & remove_existing
+                - { 'key-args': {'scenario': 'register-ipv6-remove-existing-enabled.xml',
+                                 'target': '[::1]', '-i': '[::1]', '-p': '5161', '-t': 't1', '-s': 'gussie'},
+                    'ordered-args': ['-key', 'customip1', '[::2]', '-key', 'customip2', '[::3]',
+                                     '-key', 'customip3', '[::4]'] }
+
+ami-config:
+    -
+        type: 'headermatch'
+        id: '0'
+        conditions:
+            match:
+                Event: 'TestEvent'
+                State: 'AOR_CONTACT_ADDED'
+                AOR: 'alice'
+        count: '3'
+    -
+        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'
+    -
+        type: 'headermatch'
+        id: '0'
+        conditions:
+            match:
+                Event: 'TestEvent'
+                State: 'AOR_CONTACT_ADDED'
+                AOR: 'carol'
+        count: '3'
+    -
+        type: 'headermatch'
+        id: '0'
+        conditions:
+            match:
+                Event: 'TestEvent'
+                State: 'AOR_CONTACT_REMOVED'
+                AOR: 'carol'
+        count: '1'
+    -
+        type: 'headermatch'
+        id: '0'
+        conditions:
+            match:
+                Event: 'TestEvent'
+                State: 'AOR_CONTACT_ADDED'
+                AOR: 'daniel'
+        count: '3'
+    -
+        type: 'headermatch'
+        id: '0'
+        conditions:
+            match:
+                Event: 'TestEvent'
+                State: 'AOR_CONTACT_REMOVED'
+                AOR: 'daniel'
+        count: '1'
+    -
+        type: 'headermatch'
+        id: '0'
+        conditions:
+            match:
+                Event: 'TestEvent'
+                State: 'AOR_CONTACT_ADDED'
+                AOR: 'edward'
+        count: '3'
+    -
+        type: 'headermatch'
+        id: '0'
+        conditions:
+            match:
+                Event: 'TestEvent'
+                State: 'AOR_CONTACT_REMOVED'
+                AOR: 'edward'
+        count: '1'
+    -
+        type: 'headermatch'
+        id: '0'
+        conditions:
+            match:
+                Event: 'TestEvent'
+                State: 'AOR_CONTACT_ADDED'
+                AOR: 'frank'
+        count: '3'
+    -
+        type: 'headermatch'
+        id: '0'
+        conditions:
+            match:
+                Event: 'TestEvent'
+                State: 'AOR_CONTACT_REMOVED'
+                AOR: 'frank'
+        count: '1'
+    -
+        type: 'headermatch'
+        id: '0'
+        conditions:
+            match:
+                Event: 'TestEvent'
+                State: 'AOR_CONTACT_ADDED'
+                AOR: 'gussie'
+        count: '3'
+    -
+        type: 'headermatch'
+        id: '0'
+        conditions:
+            match:
+                Event: 'TestEvent'
+                State: 'AOR_CONTACT_REMOVED'
+                AOR: 'gussie'
+        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/+/16491
To unsubscribe, or for help writing mail filters, visit https://gerrit.asterisk.org/settings

Gerrit-Project: testsuite
Gerrit-Branch: master
Gerrit-Change-Id: I336bd2bac512396b33407882066a8ec66a914f5c
Gerrit-Change-Number: 16491
Gerrit-PatchSet: 1
Gerrit-Owner: Joe <ynadiv at corpit.xyz>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20210919/0cb264eb/attachment-0001.html>


More information about the asterisk-code-review mailing list