[asterisk-commits] Convert Lua RFC 2833 DTMF test to Python. (testsuite[master])
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Wed Jul 15 07:34:48 CDT 2015
Joshua Colp has submitted this change and it was merged.
Change subject: Convert Lua RFC 2833 DTMF test to Python.
......................................................................
Convert Lua RFC 2833 DTMF test to Python.
This is a straightforward conversion to use the SIPp test case and the
AMI event module in order to convert the Lua test to Python. The biggest
changes were that the SIPp scenario had to have paths for PCAP files
altered in order for them to be opened properly.
ASTERISK-25225
Reported by Matt Jordan
Change-Id: I2f00155be9810bbeffb69820b5b055c736305bb4
---
D tests/channels/SIP/rfc2833_dtmf_detect/run-test
M tests/channels/SIP/rfc2833_dtmf_detect/sipp/broken_dtmf.xml
M tests/channels/SIP/rfc2833_dtmf_detect/sipp/dtmf_baseline.xml
M tests/channels/SIP/rfc2833_dtmf_detect/sipp/dtmf_noend.xml
M tests/channels/SIP/rfc2833_dtmf_detect/test-config.yaml
D tests/channels/SIP/rfc2833_dtmf_detect/test.lua
6 files changed, 58 insertions(+), 130 deletions(-)
Approvals:
Matt Jordan: Looks good to me, but someone else must approve
Joshua Colp: Looks good to me, approved; Verified
diff --git a/tests/channels/SIP/rfc2833_dtmf_detect/run-test b/tests/channels/SIP/rfc2833_dtmf_detect/run-test
deleted file mode 100755
index 67c4b14..0000000
--- a/tests/channels/SIP/rfc2833_dtmf_detect/run-test
+++ /dev/null
@@ -1,5 +0,0 @@
-#!/usr/bin/env bash
-set -e
-
-asttest -a /$AST_TEST_ROOT -s tests/channels/SIP/rfc2833_dtmf_detect
-
diff --git a/tests/channels/SIP/rfc2833_dtmf_detect/sipp/broken_dtmf.xml b/tests/channels/SIP/rfc2833_dtmf_detect/sipp/broken_dtmf.xml
index c0053cd..c682a06 100755
--- a/tests/channels/SIP/rfc2833_dtmf_detect/sipp/broken_dtmf.xml
+++ b/tests/channels/SIP/rfc2833_dtmf_detect/sipp/broken_dtmf.xml
@@ -61,7 +61,7 @@
<nop>
<action>
- <exec play_pcap_audio="sipp/broken_dtmf.pcap" />
+ <exec play_pcap_audio="tests/channels/SIP/rfc2833_dtmf_detect/sipp/broken_dtmf.pcap" />
</action>
</nop>
diff --git a/tests/channels/SIP/rfc2833_dtmf_detect/sipp/dtmf_baseline.xml b/tests/channels/SIP/rfc2833_dtmf_detect/sipp/dtmf_baseline.xml
index c149df8..52483a6 100755
--- a/tests/channels/SIP/rfc2833_dtmf_detect/sipp/dtmf_baseline.xml
+++ b/tests/channels/SIP/rfc2833_dtmf_detect/sipp/dtmf_baseline.xml
@@ -61,7 +61,7 @@
<nop>
<action>
- <exec play_pcap_audio="sipp/dtmf_2833_1.pcap" />
+ <exec play_pcap_audio="tests/channels/SIP/rfc2833_dtmf_detect/sipp/dtmf_2833_1.pcap" />
</action>
</nop>
@@ -70,7 +70,7 @@
<nop>
<action>
- <exec play_pcap_audio="sipp/dtmf_2833_2.pcap" />
+ <exec play_pcap_audio="tests/channels/SIP/rfc2833_dtmf_detect/sipp/dtmf_2833_2.pcap" />
</action>
</nop>
@@ -79,7 +79,7 @@
<nop>
<action>
- <exec play_pcap_audio="sipp/dtmf_2833_3.pcap" />
+ <exec play_pcap_audio="tests/channels/SIP/rfc2833_dtmf_detect/sipp/dtmf_2833_3.pcap" />
</action>
</nop>
@@ -88,7 +88,7 @@
<nop>
<action>
- <exec play_pcap_audio="sipp/dtmf_2833_4.pcap" />
+ <exec play_pcap_audio="tests/channels/SIP/rfc2833_dtmf_detect/sipp/dtmf_2833_4.pcap" />
</action>
</nop>
@@ -97,7 +97,7 @@
<nop>
<action>
- <exec play_pcap_audio="sipp/dtmf_2833_5.pcap" />
+ <exec play_pcap_audio="tests/channels/SIP/rfc2833_dtmf_detect/sipp/dtmf_2833_5.pcap" />
</action>
</nop>
@@ -106,7 +106,7 @@
<nop>
<action>
- <exec play_pcap_audio="sipp/dtmf_2833_6.pcap" />
+ <exec play_pcap_audio="tests/channels/SIP/rfc2833_dtmf_detect/sipp/dtmf_2833_6.pcap" />
</action>
</nop>
@@ -115,7 +115,7 @@
<nop>
<action>
- <exec play_pcap_audio="sipp/dtmf_2833_7.pcap" />
+ <exec play_pcap_audio="tests/channels/SIP/rfc2833_dtmf_detect/sipp/dtmf_2833_7.pcap" />
</action>
</nop>
@@ -124,7 +124,7 @@
<nop>
<action>
- <exec play_pcap_audio="sipp/dtmf_2833_8.pcap" />
+ <exec play_pcap_audio="tests/channels/SIP/rfc2833_dtmf_detect/sipp/dtmf_2833_8.pcap" />
</action>
</nop>
@@ -133,7 +133,7 @@
<nop>
<action>
- <exec play_pcap_audio="sipp/dtmf_2833_9.pcap" />
+ <exec play_pcap_audio="tests/channels/SIP/rfc2833_dtmf_detect/sipp/dtmf_2833_9.pcap" />
</action>
</nop>
@@ -142,7 +142,7 @@
<nop>
<action>
- <exec play_pcap_audio="sipp/dtmf_2833_star.pcap" />
+ <exec play_pcap_audio="tests/channels/SIP/rfc2833_dtmf_detect/sipp/dtmf_2833_star.pcap" />
</action>
</nop>
diff --git a/tests/channels/SIP/rfc2833_dtmf_detect/sipp/dtmf_noend.xml b/tests/channels/SIP/rfc2833_dtmf_detect/sipp/dtmf_noend.xml
index eb9a01f..ecdbfc5 100644
--- a/tests/channels/SIP/rfc2833_dtmf_detect/sipp/dtmf_noend.xml
+++ b/tests/channels/SIP/rfc2833_dtmf_detect/sipp/dtmf_noend.xml
@@ -61,7 +61,7 @@
<nop>
<action>
- <exec play_pcap_audio="sipp/dtmf_2833_1_noend.pcap" />
+ <exec play_pcap_audio="tests/channels/SIP/rfc2833_dtmf_detect/sipp/dtmf_2833_1_noend.pcap" />
</action>
</nop>
@@ -70,7 +70,7 @@
<nop>
<action>
- <exec play_pcap_audio="sipp/dtmf_2833_2_noend.pcap" />
+ <exec play_pcap_audio="tests/channels/SIP/rfc2833_dtmf_detect/sipp/dtmf_2833_2_noend.pcap" />
</action>
</nop>
@@ -79,7 +79,7 @@
<nop>
<action>
- <exec play_pcap_audio="sipp/dtmf_2833_3_noend.pcap" />
+ <exec play_pcap_audio="tests/channels/SIP/rfc2833_dtmf_detect/sipp/dtmf_2833_3_noend.pcap" />
</action>
</nop>
@@ -88,7 +88,7 @@
<nop>
<action>
- <exec play_pcap_audio="sipp/dtmf_2833_4.pcap" />
+ <exec play_pcap_audio="tests/channels/SIP/rfc2833_dtmf_detect/sipp/dtmf_2833_4.pcap" />
</action>
</nop>
diff --git a/tests/channels/SIP/rfc2833_dtmf_detect/test-config.yaml b/tests/channels/SIP/rfc2833_dtmf_detect/test-config.yaml
index 3310709..57fa1f3 100644
--- a/tests/channels/SIP/rfc2833_dtmf_detect/test-config.yaml
+++ b/tests/channels/SIP/rfc2833_dtmf_detect/test-config.yaml
@@ -21,16 +21,56 @@
issues:
- mantis : '15811'
+test-modules:
+ test-object:
+ config-section: sipp-config
+ typename: 'sipp.SIPpTestCase'
+ modules:
+ -
+ typename: 'ami.AMIEventModule'
+ config-section: 'ami-config'
+
+sipp-config:
+ fail-on-any: True
+ test-iterations:
+ -
+ scenarios:
+ - { 'key-args': {'scenario': 'dtmf_baseline.xml', '-p': '5061'} }
+ - { 'key-args': {'scenario': 'broken_dtmf.xml', '-p': '5062'} }
+ - { 'key-args': {'scenario': 'dtmf_noend.xml', '-p': '5063'} }
+ami-config:
+ -
+ type: 'headermatch'
+ conditions:
+ match:
+ Event: 'VarSet'
+ Variable: 'READRESULT'
+ Value: '1234567890*'
+ -
+ type: 'headermatch'
+ conditions:
+ match:
+ Event: 'VarSet'
+ Variable: 'READRESULT'
+ Value: '1000'
+ -
+ type: 'headermatch'
+ conditions:
+ match:
+ Event: 'VarSet'
+ Variable: 'READRESULT'
+ Value: '1234'
+
+
properties:
minversion: '1.8.0.0'
dependencies:
- - app : 'bash'
- - app : 'asttest'
+ - python : 'twisted'
+ - python : 'starpy'
- sipp :
version : 'v3.0'
feature : 'PCAP'
- asterisk : 'chan_sip'
- - custom : 'rawsocket'
tags:
- SIP
- DTMF
diff --git a/tests/channels/SIP/rfc2833_dtmf_detect/test.lua b/tests/channels/SIP/rfc2833_dtmf_detect/test.lua
deleted file mode 100644
index 4f6b955..0000000
--- a/tests/channels/SIP/rfc2833_dtmf_detect/test.lua
+++ /dev/null
@@ -1,107 +0,0 @@
-function sipp_exec(scenario, name, local_port)
- return proc.exec_io("sipp",
- "127.0.0.1",
- "-m", "1",
- "-sf", scenario,
- "-i", "127.0.0.1",
- "-p", local_port,
- "-timeout", "30",
- "-trace_err"
- )
-end
-
-function sipp_exec_and_wait(scenario, name, local_port)
- return sipp_check_error(sipp_exec(scenario, name, local_port), scenario)
-end
-
-function sipp_check_error(p, scenario)
- local res, err = p:wait()
-
- if not res then error(err) end
- if res ~= 0 then
- error("error while executing " .. scenario .. " sipp scenario (sipp exited with status " .. res .. ")\n" .. p.stderr:read("*a"))
- end
-
- return res, err
-end
-
-function varset_event_one(event)
- if (event["Variable"] == "READRESULT") then
- if (event["Value"] ~= "123456789*") then
- fail("DTMF not detected properly. Expected '123456789*' but received " .. event["Value"])
- end
- end
-end
-
-function varset_event_two(event)
- if (event["Variable"] == "READRESULT") then
- if (event["Value"] ~= "1000") then
- fail("DTMF not detected properly. Expected '1000' but received " .. event["Value"])
- end
- end
-end
-
-function varset_event_three(event)
- if (event["Variable"] == "READRESULT") then
- if (event["Value"] ~= "1234") then
- fail("DTMF not detected properly. Expected '1234' but received " .. event["Value"])
- end
- end
-end
-
-function manager_setup(a)
- m,err = a:manager_connect()
- if not m then
- fail("error connecting to asterisk: " .. err)
- end
-
- login = ast.manager.action:new("login")
- login["Username"] = "asttest"
- login["Secret"] = "asttest"
-
- local r = m(login)
- if not r then
- fail("error logging in to the manager: " .. err)
- end
-
- if r["Response"] ~= "Success" then
- fail("error authenticating: " .. r["Message"])
- end
-end
-
-function test_call(scenario, handler, name, local_port)
- m:register_event("VarSet", handler)
- local t1 = sipp_exec(scenario, name, local_port)
-
- --wait for everything to finish
- sipp_check_error(t1, scenario)
- posix.sleep(1)
- local res, err = m:pump_messages()
- if not res then
- fail("error pumping manager messages: " .. err)
- end
- m:process_events()
- m:unregister_event("VarSet", handler)
-end
-
-function do_dtmf_and_check_results(name)
- local a = ast.new()
- a:load_config("configs/ast1/sip.conf")
- a:load_config("configs/ast1/extensions.conf")
- a:load_config("configs/ast1/rtp.conf")
- a:generate_manager_conf()
- a:spawn()
-
- manager_setup(a)
-
- --register our peer
- sipp_exec_and_wait("sipp/register.xml", name, "5061")
-
- test_call("sipp/dtmf_baseline.xml", varset_event_one, name, "5061")
- test_call("sipp/broken_dtmf.xml", varset_event_two, name, "5061")
- test_call("sipp/dtmf_noend.xml", varset_event_three, name, "5061")
-
- a:term_or_kill()
-end
-
-do_dtmf_and_check_results("test1")
--
To view, visit https://gerrit.asterisk.org/882
To unsubscribe, visit https://gerrit.asterisk.org/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I2f00155be9810bbeffb69820b5b055c736305bb4
Gerrit-PatchSet: 1
Gerrit-Project: testsuite
Gerrit-Branch: master
Gerrit-Owner: Mark Michelson <mmichelson at digium.com>
Gerrit-Reviewer: Joshua Colp <jcolp at digium.com>
Gerrit-Reviewer: Matt Jordan <mjordan at digium.com>
More information about the asterisk-commits
mailing list