[svn-commits] tilghman: branch tilghman/callparking_retrieval r804 - in /asterisk/team/tilg...

SVN commits to the Digium repositories svn-commits at lists.digium.com
Mon Oct 11 16:49:59 CDT 2010


Author: tilghman
Date: Mon Oct 11 16:49:57 2010
New Revision: 804

URL: http://svnview.digium.com/svn/testsuite?view=rev&rev=804
Log:
Save my shell script test

Added:
    asterisk/team/tilghman/callparking_retrieval/tests/callparking_retrieval/   (props changed)
      - copied from r788, asterisk/trunk/tests/callparking/
    asterisk/team/tilghman/callparking_retrieval/tests/callparking_retrieval/userA/
    asterisk/team/tilghman/callparking_retrieval/tests/callparking_retrieval/userA/extensions.conf   (with props)
    asterisk/team/tilghman/callparking_retrieval/tests/callparking_retrieval/userA/iax.conf   (with props)
    asterisk/team/tilghman/callparking_retrieval/tests/callparking_retrieval/userB/
    asterisk/team/tilghman/callparking_retrieval/tests/callparking_retrieval/userB/extensions.conf   (with props)
    asterisk/team/tilghman/callparking_retrieval/tests/callparking_retrieval/userB/iax.conf   (with props)
Removed:
    asterisk/team/tilghman/callparking_retrieval/tests/callparking_retrieval/configs/
    asterisk/team/tilghman/callparking_retrieval/tests/callparking_retrieval/configs2/
    asterisk/team/tilghman/callparking_retrieval/tests/callparking_retrieval/configs3/
Modified:
    asterisk/team/tilghman/callparking_retrieval/lib/python/asterisk/asterisk.py
    asterisk/team/tilghman/callparking_retrieval/tests/callparking_retrieval/run-test
    asterisk/team/tilghman/callparking_retrieval/tests/callparking_retrieval/test-config.yaml

Modified: asterisk/team/tilghman/callparking_retrieval/lib/python/asterisk/asterisk.py
URL: http://svnview.digium.com/svn/testsuite/asterisk/team/tilghman/callparking_retrieval/lib/python/asterisk/asterisk.py?view=diff&rev=804&r1=803&r2=804
==============================================================================
--- asterisk/team/tilghman/callparking_retrieval/lib/python/asterisk/asterisk.py (original)
+++ asterisk/team/tilghman/callparking_retrieval/lib/python/asterisk/asterisk.py Mon Oct 11 16:49:57 2010
@@ -107,7 +107,8 @@
         asterisk.start()
         """
         cmd = [
-            "asterisk",
+			"valgrind", "--log-file=/tmp/valgrind.%p.log",
+            "/usr/sbin/asterisk",
             "-f", "-g", "-q", "-m", "-n",
             "-C", "%s" % os.path.join(self.astetcdir, "asterisk.conf")
         ]

Propchange: asterisk/team/tilghman/callparking_retrieval/tests/callparking_retrieval/
------------------------------------------------------------------------------
    svn:mergeinfo = 

Modified: asterisk/team/tilghman/callparking_retrieval/tests/callparking_retrieval/run-test
URL: http://svnview.digium.com/svn/testsuite/asterisk/team/tilghman/callparking_retrieval/tests/callparking_retrieval/run-test?view=diff&rev=804&r1=788&r2=804
==============================================================================
--- asterisk/team/tilghman/callparking_retrieval/tests/callparking_retrieval/run-test (original)
+++ asterisk/team/tilghman/callparking_retrieval/tests/callparking_retrieval/run-test Mon Oct 11 16:49:57 2010
@@ -1,189 +1,112 @@
-#!/usr/bin/env python
-'''
-Copyright (C) 2010, Digium, Inc.
-Matthias Nick <mnick86 at gmail.com>
+#!/bin/sh
 
-This program is free software, distributed under the terms of
-the GNU General Public License Version 2.
-'''
+case `uname -s` in
+	solaris*|sunos*)
+		PS="ps -ef"
+		KILLALL="pkill"
+		;;
+	*)
+		PS="ps auxwww"
+		KILLALL="killall"
+		;;
+esac
 
-import sys
-import os
-import math
-from optparse import OptionParser
-from twisted.application import service, internet
-from twisted.internet import reactor
-from starpy import fastagi
+testdir=${0%%runtest}
 
-sys.path.append("lib/python")
-from asterisk.asterisk import Asterisk
-from asterisk.version import AsteriskVersion
+cleanup() {
+	if test "x$userA_tmpdir" = "x"; then : ; else
+		asterisk -C $userA_tmpdir/asterisk.conf -rx "core stop now" >/dev/null 2>&1
+	fi
+	if test "x$userB_tmpdir" = "x"; then : ; else
+		asterisk -C /tmp/callparking_retrieval/userB/config/asterisk.conf -rx "core stop now" >/dev/null 2>&1
+	fi
+	rm -rf /tmp/callparking_retrieval
+	sleep 2
+	$KILLALL asterisk
+	sleep 1
+	$KILLALL -9 asterisk
+}
 
+for user in userA userB; do
+	${user}_tmpdir=`mktemp -t -d callparking_retrieval_$user.XXXXXX`
+	if $?; then : ; else
+		echo " *** Unable to create temporary directory for $user"
+		cleanup()
+		exit 1
+	fi
 
-class CallParkingTest:
-    def __init__(self, argv):
-        self.passed = False
-        self.done = False
+	eval "conf=\${${user}_tmpdir}"
 
-        # Test timeout in seconds
-        self.timeout = 60
-        self.last_step = ""
+	for i in ../configs/*.sample; do
+		dst=$conf/`basename $i .sample`
+		install -m 644 $i $dst
+	done
+	for i in $testdir$user/*; do
+		dst=$conf/`basename $i`
+		install -m 644 $i $dst
+	done
+	( echo "[directories]"; echo "astetcdir => $conf"; echo "[options]"; echo "verbose = 10"; echo "documentation_language = en_US" ) > $conf/asterisk.conf
 
-        # get version info
-        parser = OptionParser()
-        parser.add_option("-v", "--version", dest="ast_version",
-         help="Asterisk version string")
-        (options, args) = parser.parse_args(argv)
-        self.ast_version = AsteriskVersion(options.ast_version)
-        print self.ast_version
+	# Verify that files got created properly
+	if test -s $conf/asterisk.conf ; then : ; else
+		cleanup()
+		echo " *** Unable to create test configuration files in $conf"
+		exit 1
+	fi
+	asterisk -C $conf/asterisk.conf
+	sleep 1
+	# Asterisk is running, right?
+	if test `$PS | grep $conf[/] | wc -l` = "0"; then
+		cleanup()
+		echo " *** Unable to start asterisk for $user"
+		exit 1
+	fi
+done
 
-        # FastAGI, listen for results from dialplan
-        self.agi_b = fastagi.FastAGIFactory(self.get_result_b)
-        reactor.listenTCP(4574, self.agi_b, self.timeout, '127.0.0.1')
+echo " >>> User A is calling user B, who will park the call."
+asterisk -C $userA_tmpdir/asterisk.conf -rx "channel originate Local/wait at parking extension callb at parking"
+sleep 2
 
-        self.agi_c = fastagi.FastAGIFactory(self.get_result_c)
-        reactor.listenTCP(4575, self.agi_c, self.timeout, '127.0.0.1')
+# Verify that the call is up
+count=`asterisk -C $userA_tmpdir/asterisk.conf -rx "core show channels" | wc -l`
+if test $count -lt 4; then # 4 = header line + channel A linked to B + channel B linked to A + summary line
+	cleanup()
+	echo " *** Call generation from user A to user B failed"
+	exit 1
+fi
 
-        self.agi_retrieve_A = fastagi.FastAGIFactory(
-          self.get_result_retrieve_A)
-        reactor.listenTCP(4576, self.agi_retrieve_A, self.timeout, '127.0.0.1')
+sleep 10
 
-        self.agi_retrieve_B = fastagi.FastAGIFactory(
-         self.get_result_retrieve_B)
-        reactor.listenTCP(4577, self.agi_retrieve_B, self.timeout, '127.0.0.1')
+# Verify that the call is up
+count=`asterisk -C $userA_tmpdir/asterisk.conf -rx "core show channels" | wc -l`
+if test $count -lt 3; then # 3 = header line + channel A linked to parking + summary line
+	cleanup()
+	echo " *** User B failed to park the call from user A"
+	exit 1
+fi
 
-        reactor.callWhenRunning(self.run)
+echo " >>> User B is retrieving user A from parking, then will attempt to repark it."
+asterisk -C $userB_tmpdir/asterisk.conf -rx "channel originate IAX2/usera/701 at parking extension parka at parking"
+sleep 2
 
-        self.asterisk1 = Asterisk(
-         base="/tmp/asterisk-testsuite/callparking/asterisk1")
-        self.asterisk1.install_configs("tests/callparking/configs")
+# Verify that the call is up
+count=`asterisk -C $userA_tmpdir/asterisk.conf -rx "core show channels" | wc -l`
+if test $count -lt 4; then # 4 = header line + channel A linked to B + channel B linked to A + summary line
+	cleanup()
+	echo " *** User B failed to retrieve the call from parking"
+	exit 1
+fi
 
-        self.asterisk2 = Asterisk(
-         base="/tmp/asterisk-testsuite/callparking/asterisk2")
-        self.asterisk2.install_configs("tests/callparking/configs2")
+sleep 10
 
-        self.asterisk3 = Asterisk(
-         base="/tmp/asterisk-testsuite/callparking/asterisk3")
-        self.asterisk3.install_configs("tests/callparking/configs3")
+a_parked=`asterisk -C $userA_tmpdir/asterisk.conf -rx "core show channels" | wc -l`
+if test $a_parked -lt 3; then
+	echo " *** Failed.  When user B hung up, user A was not parked and thus hungup as well."
+	cleanup()
+	exit 1
+fi
 
-    # This gets invoked by the dialplan when userB has parked userA to 701.
-    # Initiate new call userB <--> userC now.
-    def get_result_b(self, agi):
-        self.log_last_step("got AGI connection from userB. "
-         "Initiate new call between userB and userC now")
-        self.asterisk1.cli_originate(
-         "IAX2/userB at 127.0.0.1:4572/c_exten extension bridge_to_B at parking")
-        return agi.finish()
+cleanup()
 
-    # This gets invoked by the dialplan when userC has parked userB to 702.
-    # Initiate new call between userC and parked userA (@701) now.
-    def get_result_c(self, agi):
-        self.log_last_step("got AGI connection from userC. "
-         "Now retrieve userA -> call 701")
-        self.asterisk3.cli_originate(
-         "IAX2/userA at 127.0.0.1:4570/701 extension retrieve_A at parking")
-        return agi.finish()
+exit 0
 
-    # This gets invoked by the dialplan when userC has retrieved userA.
-    # Initiate new call between userC and parked userB (@702) now.
-    def get_result_retrieve_A(self, agi):
-        self.log_last_step("got AGI connection from userC. "
-         "userA retrieved successfully, now retrieve userB")
-        self.asterisk3.cli_originate(
-         "IAX2/userA at 127.0.0.1:4570/702 extension retrieve_B at parking")
-        return agi.finish()
-
-    # This gets invoked by the dialplan when userC has retrieved userB.
-    # Test successful!
-    def get_result_retrieve_B(self, agi):
-        self.log_last_step("got AGI connection from userC. "
-         "userB retrieved successfully -> Test successful")
-        self.passed = True
-        reactor.callLater(2, self.read_result)
-        return agi.finish()
-
-    def read_result(self):
-        if self.done:
-            return
-        self.done = True
-
-        self.log_last_step("Reading results")
-
-        # get lock output in case of deadlock before tearing down.
-        self.asterisk1.cli_exec("core show locks")
-        self.asterisk2.cli_exec("core show locks")
-        self.asterisk3.cli_exec("core show locks")
-
-        # if channels are still up for some reason, we want to know that
-        self.asterisk1.cli_exec("core show channels")
-        self.asterisk2.cli_exec("core show channels")
-        self.asterisk3.cli_exec("core show channels")
-
-        if (self.passed):
-            self.log_last_step("Test Passed...")
-        else:
-            self.log_last_step("Test Failed... view result of "
-             "'core show globals' in log for more detailed failure results.")
-
-        if reactor.running:
-            print "Stopping Reactor ..."
-            reactor.stop()
-
-    # This is a callparking test.
-    # 1.  userA calls userB
-    # 2.  userB dials # -> 700, to park userA (701).
-    # 3.  userB calls userC
-    # 4.  userC dials # -> 700, to park userB (702).
-    # 5.  userC dials 701 and retrieves userA
-    # 6.  userC dials 702 and retrieves userB
-
-    def launch_test(self):
-        self.asterisk1.cli_exec("core set verbose 10")
-        self.asterisk2.cli_exec("core set verbose 10")
-        self.asterisk3.cli_exec("core set verbose 10")
-
-        self.log_last_step("Originating call to begin test")
-        self.asterisk1.cli_originate(
-         "IAX2/userA at 127.0.0.1:4571/b_exten extension bridge_to_A at parking")
-
-    def start_asterisk(self):
-        self.log_last_step("Starting Asterisk")
-        self.asterisk1.start()
-        self.asterisk2.start()
-        self.asterisk3.start()
-
-    def stop_asterisk(self):
-        self.asterisk1.stop()
-        self.asterisk2.stop()
-        self.asterisk3.stop()
-
-    def log_last_step(self, step):
-        print step
-        self.last_step = step
-
-    def run(self):
-        self.start_asterisk()
-
-        # start test in 5 seconds
-        reactor.callLater(5, self.launch_test)
-
-        # stop and read results after timeout
-        reactor.callLater(self.timeout, self.read_result)
-
-
-def main(argv=None):
-    if argv is None:
-        argv = sys.argv
-
-    # Run CallParking Test
-    call_parking_test = CallParkingTest(argv)
-    reactor.run()
-    call_parking_test.stop_asterisk()
-    if call_parking_test.passed != True:
-        return 1
-    return 0
-
-if __name__ == "__main__":
-    sys.exit(main() or 0)
-
-# vim:sw=4:ts=4:expandtab:textwidth=79

Modified: asterisk/team/tilghman/callparking_retrieval/tests/callparking_retrieval/test-config.yaml
URL: http://svnview.digium.com/svn/testsuite/asterisk/team/tilghman/callparking_retrieval/tests/callparking_retrieval/test-config.yaml?view=diff&rev=804&r1=788&r2=804
==============================================================================
--- asterisk/team/tilghman/callparking_retrieval/tests/callparking_retrieval/test-config.yaml (original)
+++ asterisk/team/tilghman/callparking_retrieval/tests/callparking_retrieval/test-config.yaml Mon Oct 11 16:49:57 2010
@@ -1,10 +1,7 @@
 testinfo:
     summary:     'Test Call Parking'
     description: |
-        'This test verifies the Call Parking routine used in the feature code.'
+        'This test verifies that retrieving a parked call does not hamper the ability to park it once again.'
 
 properties:
     minversion: '1.4'
-    dependencies:
-        - python : 'twisted'
-        - python : 'starpy'

Added: asterisk/team/tilghman/callparking_retrieval/tests/callparking_retrieval/userA/extensions.conf
URL: http://svnview.digium.com/svn/testsuite/asterisk/team/tilghman/callparking_retrieval/tests/callparking_retrieval/userA/extensions.conf?view=auto&rev=804
==============================================================================
--- asterisk/team/tilghman/callparking_retrieval/tests/callparking_retrieval/userA/extensions.conf (added)
+++ asterisk/team/tilghman/callparking_retrieval/tests/callparking_retrieval/userA/extensions.conf Mon Oct 11 16:49:57 2010
@@ -1,0 +1,15 @@
+[general]
+static=yes
+writeprotect=no
+lastaction=""
+
+[parking]
+include => parkedcalls
+
+; User A starts out by calling user B, with inband DTMF activated for transfer
+exten => callb,1,Dial(IAX2/userb/userb at parking,,t)
+; What channel A will be doing
+exten => wait,1,Wait(100)
+
+; When user B calls in, we will go directly to the parkedcalls context, so nothing else is needed here.
+

Propchange: asterisk/team/tilghman/callparking_retrieval/tests/callparking_retrieval/userA/extensions.conf
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: asterisk/team/tilghman/callparking_retrieval/tests/callparking_retrieval/userA/extensions.conf
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision Yoyo

Propchange: asterisk/team/tilghman/callparking_retrieval/tests/callparking_retrieval/userA/extensions.conf
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: asterisk/team/tilghman/callparking_retrieval/tests/callparking_retrieval/userA/iax.conf
URL: http://svnview.digium.com/svn/testsuite/asterisk/team/tilghman/callparking_retrieval/tests/callparking_retrieval/userA/iax.conf?view=auto&rev=804
==============================================================================
--- asterisk/team/tilghman/callparking_retrieval/tests/callparking_retrieval/userA/iax.conf (added)
+++ asterisk/team/tilghman/callparking_retrieval/tests/callparking_retrieval/userA/iax.conf Mon Oct 11 16:49:57 2010
@@ -1,0 +1,14 @@
+[general]
+bindport=4571
+bindaddr=127.0.0.1
+transfer=yes
+disallow=all
+allow=ulaw
+jitterbuffer=no
+forcejitterbuffer=no
+
+[userb]
+type=friend
+host=127.0.0.1
+port=4572
+context=parking

Propchange: asterisk/team/tilghman/callparking_retrieval/tests/callparking_retrieval/userA/iax.conf
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: asterisk/team/tilghman/callparking_retrieval/tests/callparking_retrieval/userA/iax.conf
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision Yoyo

Propchange: asterisk/team/tilghman/callparking_retrieval/tests/callparking_retrieval/userA/iax.conf
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: asterisk/team/tilghman/callparking_retrieval/tests/callparking_retrieval/userB/extensions.conf
URL: http://svnview.digium.com/svn/testsuite/asterisk/team/tilghman/callparking_retrieval/tests/callparking_retrieval/userB/extensions.conf?view=auto&rev=804
==============================================================================
--- asterisk/team/tilghman/callparking_retrieval/tests/callparking_retrieval/userB/extensions.conf (added)
+++ asterisk/team/tilghman/callparking_retrieval/tests/callparking_retrieval/userB/extensions.conf Mon Oct 11 16:49:57 2010
@@ -1,0 +1,14 @@
+[parking]
+
+; When user A calls user B, user B will attempt to callpark user A.
+exten => callb,1,Answer
+exten => callb,n(park),Wait(1)
+exten => callb,n,SendDTMF(#)
+exten => callb,n,Wait(3)
+exten => callb,n,SendDTMF(700)
+exten => callb,n,Wait(1)
+exten => callb,n,Hangup
+
+; After retrieving the parked call, try parking it again
+exten => parka,1,Goto(callb,park)
+

Propchange: asterisk/team/tilghman/callparking_retrieval/tests/callparking_retrieval/userB/extensions.conf
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: asterisk/team/tilghman/callparking_retrieval/tests/callparking_retrieval/userB/extensions.conf
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision Yoyo

Propchange: asterisk/team/tilghman/callparking_retrieval/tests/callparking_retrieval/userB/extensions.conf
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: asterisk/team/tilghman/callparking_retrieval/tests/callparking_retrieval/userB/iax.conf
URL: http://svnview.digium.com/svn/testsuite/asterisk/team/tilghman/callparking_retrieval/tests/callparking_retrieval/userB/iax.conf?view=auto&rev=804
==============================================================================
--- asterisk/team/tilghman/callparking_retrieval/tests/callparking_retrieval/userB/iax.conf (added)
+++ asterisk/team/tilghman/callparking_retrieval/tests/callparking_retrieval/userB/iax.conf Mon Oct 11 16:49:57 2010
@@ -1,0 +1,15 @@
+[general]
+bindport=4572
+bindaddr=127.0.0.1
+transfer=yes
+disallow=all
+allow=ulaw
+jitterbuffer=no
+forcejitterbuffer=no
+
+[usera]
+type=friend
+host=127.0.0.1
+port=4571
+context=parking
+

Propchange: asterisk/team/tilghman/callparking_retrieval/tests/callparking_retrieval/userB/iax.conf
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: asterisk/team/tilghman/callparking_retrieval/tests/callparking_retrieval/userB/iax.conf
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision Yoyo

Propchange: asterisk/team/tilghman/callparking_retrieval/tests/callparking_retrieval/userB/iax.conf
------------------------------------------------------------------------------
    svn:mime-type = text/plain




More information about the svn-commits mailing list