[Asterisk-code-review] testsuite: Copy tests/apps/mixmonitor files to mixmonitor rxtx. (testsuite[master])
Mark Michelson
asteriskteam at digium.com
Fri Aug 14 11:56:51 CDT 2015
Mark Michelson has submitted this change and it was merged.
Change subject: testsuite: Copy tests/apps/mixmonitor files to mixmonitor_rxtx.
......................................................................
testsuite: Copy tests/apps/mixmonitor files to mixmonitor_rxtx.
ASTERISK-25322
Reported by Sean Pimental
Change-Id: I36562256ccb1e39bf24f340ad7eb7cd7d8291094
---
A tests/apps/mixmonitor_rxtx/configs/ast1/extensions.conf
A tests/apps/mixmonitor_rxtx/run-test
A tests/apps/mixmonitor_rxtx/test-config.yaml
M tests/apps/tests.yaml
4 files changed, 207 insertions(+), 0 deletions(-)
Approvals:
Kevin Harwell: Looks good to me, but someone else must approve
Mark Michelson: Looks good to me, approved; Verified
Joshua Colp: Looks good to me, but someone else must approve
diff --git a/tests/apps/mixmonitor_rxtx/configs/ast1/extensions.conf b/tests/apps/mixmonitor_rxtx/configs/ast1/extensions.conf
new file mode 100644
index 0000000..6d3a4b9
--- /dev/null
+++ b/tests/apps/mixmonitor_rxtx/configs/ast1/extensions.conf
@@ -0,0 +1,36 @@
+[general]
+
+[globals]
+
+[listener]
+exten => s,1,Answer()
+exten => s,n,Echo()
+exten => s,n,HangUp()
+
+[test1]
+exten => s,1,Answer()
+exten => s,n,MixMonitor(${TESTAUDIO1})
+exten => s,n,Playback(${TALK_AUDIO})
+exten => s,n,StopMixMonitor()
+;If PlayBack fails, then StopMixMonitor has not yet let go of the file
+exten => s,n,PlayBack(${TESTAUDIO1})
+exten => s,n,GoToIf($[${PLAYBACKSTATUS} = SUCCESS]?domore:stopnow)
+; StopMixMonitor failed to let go of the file as we could not play it back
+exten => s,n(stopnow),HangUp()
+; StopMixMonitor worked, now test stopping on hangup
+exten => s,n(domore),MixMonitor(${TESTAUDIO2})
+exten => s,n,Playback(${TALK_AUDIO})
+exten => s,n,HangUp()
+
+exten => h,1,UserEvent(test1,status: ${PLAYBACKSTATUS})
+
+[test2]
+; Test 2 verifies the TESTAUDIO2 file was released during hangup of the previous test
+exten => s,1,PlayBack(${TESTAUDIO2})
+exten => s,n,GoToIf($[${PLAYBACKSTATUS} = SUCCESS]?domore2:stopnow2)
+exten => s,n(stopnow2),HangUp()
+exten => s,n(domore2),MixMonitor(${TESTAUDIO3})
+exten => s,n,Playback(${TALK_AUDIO})
+exten => s,n,HangUp()
+
+exten => h,1,UserEvent(test2,status: ${PLAYBACKSTATUS})
diff --git a/tests/apps/mixmonitor_rxtx/run-test b/tests/apps/mixmonitor_rxtx/run-test
new file mode 100755
index 0000000..816ee3a
--- /dev/null
+++ b/tests/apps/mixmonitor_rxtx/run-test
@@ -0,0 +1,153 @@
+#!/usr/bin/env python
+'''
+Copyright (C) 2010-2015, Digium, Inc.
+David Vossel <dvossel at digium.com>
+Matt Jordan <mjordan at digium.com>
+Richard Mudgett <rmudgett at digium.com>
+
+This program is free software, distributed under the terms of
+the GNU General Public License Version 2.
+'''
+
+import sys
+import os
+import math
+import logging
+
+from twisted.internet import reactor
+
+sys.path.append("lib/python/asterisk")
+from test_case import TestCase
+
+testdir = "tests/apps/mixmonitor"
+
+LOGGER = logging.getLogger(__name__)
+
+
+class MixMonitorTest(TestCase):
+ def __init__(self):
+ super(MixMonitorTest, self).__init__()
+
+ self.passed = False
+
+ # playback file is 2559 bytes of ulaw,
+ # that will come out to be ~41118 of wav
+ self.expectedfilesize = 41118
+ self.filesizetolerance = 5000
+
+ self.audiofile1 = os.path.join(os.getcwd(), testdir + "/testaudio1")
+ self.audiofile2 = os.path.join(os.getcwd(), testdir + "/testaudio2")
+ self.audiofile3 = os.path.join(os.getcwd(), testdir + "/testaudio3")
+
+ # Remove any output files from a previous run
+ self.unlink_file(self.audiofile1 + ".raw")
+ self.unlink_file(self.audiofile2 + ".raw")
+ self.unlink_file(self.audiofile3 + ".raw")
+
+ self.talkingaudio = os.path.join(os.getcwd(), testdir + "/sounds/talking")
+
+ self.create_asterisk()
+
+ def unlink_file(self, filename):
+ if os.path.exists(filename):
+ os.unlink(filename)
+
+ def check_file(self, name, filename):
+ if not os.path.exists(filename):
+ LOGGER.error(name + " does not exist.")
+ self.passed = False
+ return
+
+ filesize = os.path.getsize(filename)
+ LOGGER.debug("%s size is %d." % (name, filesize))
+ if math.fabs(filesize - self.expectedfilesize) > self.filesizetolerance:
+ # Fail: MixMonitor is not creating the correct
+ # file size we expect.
+ LOGGER.error(name + " size is not within the size tolerance.")
+ self.passed = False
+
+ def read_result(self):
+ self.passed = True
+ self.stop_reactor()
+ LOGGER.info("Checking MixMonitor recorded files...")
+
+ self.check_file("audiofile1", self.audiofile1 + ".raw")
+
+ # If this fails it is likely because StopMixMonitor never
+ # let go of audiofile1.
+ self.check_file("audiofile2", self.audiofile2 + ".raw")
+
+ # If this fails it is likely because MixMonitor never let
+ # go of audiofile2 on hangup.
+ self.check_file("audiofile3", self.audiofile3 + ".raw")
+
+ if self.passed:
+ LOGGER.info("Test Passed... All audio files are correct.")
+
+ def launch_test1(self):
+ LOGGER.info("Placing call to test1 exten")
+ self.ami.originate(channel="Local/s at listener",
+ context="test1",
+ exten="s",
+ priority="1")
+
+ def launch_test2(self):
+ LOGGER.info("Placing call to test2 exten")
+ self.ami.originate(channel="Local/s at listener",
+ context="test2",
+ exten="s",
+ priority="1")
+
+ def check_test1(self, ami, event):
+ LOGGER.info("Checking Userevent")
+ if event.get("userevent").lower() != "test1":
+ return
+ status = event.get("status")
+ LOGGER.debug("Status of test1 is %s" % (status))
+ if status != "SUCCESS":
+ self.stop_reactor()
+ return
+
+ self.ami.registerEvent("UserEvent", self.check_test2)
+ self.launch_test2()
+
+ def check_test2(self, ami, event):
+ LOGGER.info("Checking Userevent")
+ if event.get("userevent").lower() != "test2":
+ return
+ status = event.get("status")
+ LOGGER.debug("Status of test2 is %s" % (status))
+ if status != "SUCCESS":
+ self.stop_reactor()
+ return
+
+ self.read_result()
+
+ def ami_connect(self, ami):
+ self.ami = ami
+ self.ami.registerEvent("UserEvent", self.check_test1)
+
+ self.ami.setVar(channel="", variable="TESTAUDIO1", value=self.audiofile1)
+ self.ami.setVar(channel="", variable="TESTAUDIO2", value=self.audiofile2)
+ self.ami.setVar(channel="", variable="TESTAUDIO3", value=self.audiofile3)
+ self.ami.setVar(channel="", variable="TALK_AUDIO", value=self.talkingaudio)
+
+ self.launch_test1()
+
+ def run(self):
+ self.create_ami_factory()
+
+
+def main():
+ test = MixMonitorTest()
+ reactor.run()
+ if test.passed:
+ return 0
+ return 1
+
+
+if __name__ == "__main__":
+ sys.exit(main() or 0)
+
+
+# vim:sw=4:ts=4:expandtab:textwidth=79
diff --git a/tests/apps/mixmonitor_rxtx/test-config.yaml b/tests/apps/mixmonitor_rxtx/test-config.yaml
new file mode 100644
index 0000000..bbe2aef
--- /dev/null
+++ b/tests/apps/mixmonitor_rxtx/test-config.yaml
@@ -0,0 +1,17 @@
+testinfo:
+ summary: 'Test MixMonitor and StopMixMonitor applications'
+ description: |
+ 'This test verifies basic functionality of both the MixMonitor
+ and StopMixMonitor applications.'
+
+properties:
+ minversion: '1.8.0.0'
+ dependencies:
+ - python : 'twisted'
+ - python : 'starpy'
+ - asterisk : 'app_echo'
+ - asterisk : 'app_mixmonitor'
+ - asterisk : 'app_playback'
+ - asterisk : 'app_userevent'
+ tags:
+ - mixmonitor
diff --git a/tests/apps/tests.yaml b/tests/apps/tests.yaml
index ddcd185..19163d4 100644
--- a/tests/apps/tests.yaml
+++ b/tests/apps/tests.yaml
@@ -13,6 +13,7 @@
- dir: 'directed_pickup'
- dir: 'macro'
- test: 'mixmonitor'
+ - test: 'mixmonitor_rxtx'
- test: 'mixmonitor_audiohook_inherit'
- test: 'mixmonitor_func'
- dir: 'control_playback'
--
To view, visit https://gerrit.asterisk.org/1092
To unsubscribe, visit https://gerrit.asterisk.org/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I36562256ccb1e39bf24f340ad7eb7cd7d8291094
Gerrit-PatchSet: 1
Gerrit-Project: testsuite
Gerrit-Branch: master
Gerrit-Owner: Richard Mudgett <rmudgett at digium.com>
Gerrit-Reviewer: Joshua Colp <jcolp at digium.com>
Gerrit-Reviewer: Kevin Harwell <kharwell at digium.com>
Gerrit-Reviewer: Mark Michelson <mmichelson at digium.com>
Gerrit-Reviewer: Richard Mudgett <rmudgett at digium.com>
More information about the asterisk-code-review
mailing list