[svn-commits] jrose: testsuite/asterisk/trunk r3633 - in /asterisk/trunk: lib/python/asteri...

SVN commits to the Digium repositories svn-commits at lists.digium.com
Fri Feb 8 11:56:12 CST 2013


Author: jrose
Date: Fri Feb  8 11:56:07 2013
New Revision: 3633

URL: http://svnview.digium.com/svn/testsuite?view=rev&rev=3633
Log:
Testsuite: Call Parking timeouts and failure tokens

For the parkcall timeout tests, there are two main categories hinging on
whether comebacktoorigin is enabled or disabled for a given parkinglot.

In the case of comebacktoorigin=no tests, the primary things checked are
that a dial extension is created in the park-dial context and that the
call proceeds to a predictable position in the dialplan based on what
the timeout context is as well as what extensions exist within it. Also
a number of parking based variables that are supposed to be set on timeout
are checked to see if they are consistent with the expectations.

For comebacktoorigin=yes tests, each call will automatically dial the
extension to call back the parker in park-dial. This being the case, what
is checked here is that the channel continues through the PBX in a
consistent manner based on how the parker responds to the timed out call.
The three possibe cases are an answer followed by a hangup (nominal),
letting the dial timeout, and sending a busy indication. These tests
currently test the functionality of dial more so than call parking, but
they are in anticipation of possible changes to bridging that may not
necessarily involve directly invoking the dial application from the PBX.

As a side note, to support these tests I added a new feature to TestCase
called a fail token. These are useful for multiple module tests because
it is possible for one module to set success, and from that point on
unless another module explicitly sets failure, the test is successful.
That's less than ideal since the idea is normally that a module should
explicitly set success when it is successful and otherwise it is a failed
module, so failure tokens allow a module to communicate to a testcase that
unless it explicitly removes that token that the test should be considered
failed.  This is especially useful when a module throws an exception or
just doesn't reach a condition for establishing success/failure for
whatever reason.

Review: https://reviewboard.asterisk.org/r/2306/
Review: https://reviewboard.asterisk.org/r/2302/
Review: https://reviewboard.asterisk.org/r/2301/


Added:
    asterisk/trunk/tests/bridge/parkcall_timeout/
    asterisk/trunk/tests/bridge/parkcall_timeout/comebacktoorigin_no/
    asterisk/trunk/tests/bridge/parkcall_timeout/comebacktoorigin_no/Executioner.py   (with props)
    asterisk/trunk/tests/bridge/parkcall_timeout/comebacktoorigin_no/configs/
    asterisk/trunk/tests/bridge/parkcall_timeout/comebacktoorigin_no/configs/ast1/
    asterisk/trunk/tests/bridge/parkcall_timeout/comebacktoorigin_no/configs/ast1/extensions.conf   (with props)
    asterisk/trunk/tests/bridge/parkcall_timeout/comebacktoorigin_no/configs/ast1/features.conf   (with props)
    asterisk/trunk/tests/bridge/parkcall_timeout/comebacktoorigin_no/test-config.yaml   (with props)
    asterisk/trunk/tests/bridge/parkcall_timeout/comebacktoorigin_yes/
    asterisk/trunk/tests/bridge/parkcall_timeout/comebacktoorigin_yes/Executioner.py   (with props)
    asterisk/trunk/tests/bridge/parkcall_timeout/comebacktoorigin_yes/configs/
    asterisk/trunk/tests/bridge/parkcall_timeout/comebacktoorigin_yes/configs/ast1/
    asterisk/trunk/tests/bridge/parkcall_timeout/comebacktoorigin_yes/configs/ast1/extensions.conf   (with props)
    asterisk/trunk/tests/bridge/parkcall_timeout/comebacktoorigin_yes/configs/ast1/features.conf   (with props)
    asterisk/trunk/tests/bridge/parkcall_timeout/comebacktoorigin_yes/configs/ast2/
    asterisk/trunk/tests/bridge/parkcall_timeout/comebacktoorigin_yes/configs/ast2/extensions.conf   (with props)
    asterisk/trunk/tests/bridge/parkcall_timeout/comebacktoorigin_yes/test-config.yaml   (with props)
    asterisk/trunk/tests/bridge/parkcall_timeout/tests.yaml   (with props)
Modified:
    asterisk/trunk/lib/python/asterisk/TestCase.py
    asterisk/trunk/tests/bridge/tests.yaml

Modified: asterisk/trunk/lib/python/asterisk/TestCase.py
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/lib/python/asterisk/TestCase.py?view=diff&rev=3633&r1=3632&r2=3633
==============================================================================
--- asterisk/trunk/lib/python/asterisk/TestCase.py (original)
+++ asterisk/trunk/lib/python/asterisk/TestCase.py Fri Feb  8 11:56:07 2013
@@ -14,6 +14,7 @@
 import datetime
 import time
 import traceback
+import uuid
 from twisted.internet import reactor, defer
 from twisted.python import failure
 from starpy import manager, fastagi
@@ -61,6 +62,7 @@
         self.fastagi = []
         self.reactor_timeout = 30
         self.passed = None
+        self.fail_tokens = []
         self.defaultLogLevel = "WARN"
         self.defaultLogFileName = "logger.conf"
         self.timeoutId = None
@@ -461,6 +463,11 @@
 
     def evaluate_results(self):
         """ Return whether or not the test has passed """
+        while len(self.fail_tokens):
+            fail_token = self.fail_tokens.pop(0)
+            logger.error("Fail token present: %s" % fail_token['message'])
+            self.passed = False
+
         return self.passed
 
     def register_stop_observer(self, callback):
@@ -483,6 +490,21 @@
         callback The deferred callback function to be called when AMI connects
         '''
         self._ami_callbacks.append(callback)
+
+    def create_fail_token(self, message):
+        fail_token = {'uuid' : uuid.uuid4(), 'message' : message}
+        self.fail_tokens.append(fail_token)
+        return fail_token
+
+    def remove_fail_token(self, fail_token):
+        if not fail_token in self.fail_tokens:
+            logger.error("Attempted to remove a fail token that isn't in the fail tokens list\n"
+                         "    => '%s'\n"
+                         "    This fail token was probably already removed." % fail_token['message'])
+            self.passed = False
+            return
+
+        self.fail_tokens.remove(fail_token)
 
     def set_passed(self, value):
         '''Accumulate pass/fail value. If a test module has already

Added: asterisk/trunk/tests/bridge/parkcall_timeout/comebacktoorigin_no/Executioner.py
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/bridge/parkcall_timeout/comebacktoorigin_no/Executioner.py?view=auto&rev=3633
==============================================================================
--- asterisk/trunk/tests/bridge/parkcall_timeout/comebacktoorigin_no/Executioner.py (added)
+++ asterisk/trunk/tests/bridge/parkcall_timeout/comebacktoorigin_no/Executioner.py Fri Feb  8 11:56:07 2013
@@ -1,0 +1,131 @@
+#!/usr/bin/env python
+'''
+Copyright (C) 2013, Digium, Inc.
+Jonathan Rose <jrose at digium.com>
+
+This program is free software, distributed under the terms of
+the GNU General Public License Version 2.
+'''
+
+import sys
+import logging
+import re
+
+sys.path.append("lib/python")
+
+LOGGER = logging.getLogger(__name__)
+
+class Executioner(object):
+    def __init__(self, module_config, test_object):
+        self.ami = None
+        self.parked_channel = None
+        test_object.register_ami_observer(self.ami_connect)
+        self.test_object = test_object
+
+        self.calls = []
+        self.calls.append({'test' : '1', 'parker' : 'SIP/alice', 'lot' : 'parkinglot_test1', 'slot' : '401'})
+        self.calls.append({'test' : '2', 'parker' : 'SIP/alice', 'lot' : 'parkinglot_test2', 'slot' : '501'})
+        self.calls.append({'test' : '3', 'parker' : 'SIP/alice', 'lot' : 'parkinglot_test3', 'slot' : '601'})
+        self.userevents_received = 0
+        self.passed_dialplan = 0
+        self.failures_logged = 0
+        self.fail_token = self.test_object.create_fail_token("No success indicated by Executioner.")
+        return
+
+    def ami_connect(self, ami):
+        # We only care about the UUT's AMI here
+        if ami.id != 0:
+            return
+
+        self.ami = ami
+        self.ami.registerEvent('UserEvent', self.check_user_event)
+        self.ami.registerEvent('ListDialplan', self.check_dialplan)
+
+    def check_dialplan(self, ami, event):
+        not_right = False
+        if event.get('priority') != '1':
+            not_right = True
+        if event.get('application') != 'Dial':
+            not_right = True
+        if event.get('appdata') != 'SIP/alice,3,Hk':
+            not_right = True
+        if event.get('registrar') != 'features':
+            not_right = True
+
+        if not_right:
+            # We don't handle failure here since the last check_user_event will simply see if one ever succeeded
+            LOGGER.info("Received a dialplan entry that didn't match the expected one.")
+            return
+
+        LOGGER.info("Received a dialplan entry that matched our expectations.")
+        self.passed_dialplan = 1
+
+    def check_user_event(self, ami, event):
+
+        # We are only interested in comebackexten userevents.
+        if event['userevent'] != 'comebackexten':
+            return
+
+        this_expectation = self.calls.pop(0)
+        self.userevents_received += 1
+
+        # Make sure we are looking at the right test.
+        if not event.get('test'):
+            LOGGER.error("Test received with no test number. Test failed.")
+            self.failures_logged += 1
+        else:
+            this_test = int(event.get('test'))
+
+        if this_test != self.userevents_received:
+            LOGGER.error("Got an out of order test.  Test failed.")
+            self.failures_logged += 1
+
+        # Make sure the test wasn't from a failure condition
+        if not event.get('success'):
+            LOGGER.error("Test Phase %d: User Event didn't include a success tag. Test Failed." % this_test)
+            self.failures_logged += 1
+
+        if event.get('success') != 'true':
+            LOGGER.error("Test Phase %d: User Event didn't indicate success. Test Failed." % this_test)
+            self.failures_logged += 1
+
+        # Make sure each variable that was supposed to be set matches our expectations.
+        mismatches = 0
+        if event.get('parker') != this_expectation['parker']:
+            LOGGER.error("Test Phase %d: User event condition mismatch on parker. Got '%s' but '%s' was expected." % (this_test, event.get('parker'), this_expectation['parker']))
+            mismatches += 1
+        if event.get('slot') != this_expectation['slot']:
+            LOGGER.error("Test Phase %d: User Event condition mismatch on slot. Got '%s' but '%s' was expected." % (this_test, event.get('slot'), this_expectation['slot']))
+            mismatches += 1
+        if event.get('lot') != this_expectation['lot']:
+            LOGGER.error("Test Phase %d: User Event condition mismatch on lot. Got '%s' but '%s' was expected." % (this_test, event.get('lot'), this_expectation['lot']))
+            mismatches += 1
+
+        if mismatches > 0:
+            LOGGER.error("Test Phase %d: Mismatches were present in the channel variables set by park call timeout. Test failed." % this_test)
+            self.failures_logged += 1
+
+        # For the first test, we should also make sure the park-dial extension was added. This will require another event.
+        if self.userevents_received == 1:
+            message = {'action': 'ShowDialPlan', 'context': 'park-dial', 'extension': 'SIP_alice'}
+            self.ami.sendMessage(message)
+
+        # Looks like the test was successful.  Yay.
+        LOGGER.info("Test Phase %d: Passed." % this_test)
+
+        # Once all the tests are complete, we need to check final pass conditions
+        if len(self.calls) == 0:
+            # clear the fail token since we have reached where we decide ultimately whether it failed or not.
+            self.test_object.remove_fail_token(self.fail_token)
+
+            if not self.passed_dialplan:
+                LOGGER.error("We never received a ListDialPlan event with the right extension data in it. Test failed.")
+                self.failures_logged += 1
+                self.test_object.set_passed(False)
+
+            if self.failures_logged == 0:
+                LOGGER.info("All phases complete and the dialplan check showed the proper entry. Yay. Test Passed.")
+                self.test_object.set_passed(True)
+            else:
+                LOGGER.error("Test failed with %d errors.\n", self.failures_logged)
+                self.test_object.set_passed(False)

Propchange: asterisk/trunk/tests/bridge/parkcall_timeout/comebacktoorigin_no/Executioner.py
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: asterisk/trunk/tests/bridge/parkcall_timeout/comebacktoorigin_no/Executioner.py
------------------------------------------------------------------------------
    svn:executable = *

Propchange: asterisk/trunk/tests/bridge/parkcall_timeout/comebacktoorigin_no/Executioner.py
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Rev URL"

Propchange: asterisk/trunk/tests/bridge/parkcall_timeout/comebacktoorigin_no/Executioner.py
------------------------------------------------------------------------------
    svn:mime-type = text/x-python

Added: asterisk/trunk/tests/bridge/parkcall_timeout/comebacktoorigin_no/configs/ast1/extensions.conf
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/bridge/parkcall_timeout/comebacktoorigin_no/configs/ast1/extensions.conf?view=auto&rev=3633
==============================================================================
--- asterisk/trunk/tests/bridge/parkcall_timeout/comebacktoorigin_no/configs/ast1/extensions.conf (added)
+++ asterisk/trunk/tests/bridge/parkcall_timeout/comebacktoorigin_no/configs/ast1/extensions.conf Fri Feb  8 11:56:07 2013
@@ -1,0 +1,34 @@
+[default]
+
+exten => uncaller,1,NoOp()
+same => n,Dial(SIP/test_call at alice,,Kh)
+same => n, Hangup
+
+exten => test1,1,NoOp(BAAA)
+same => n,Set(CHANNEL(parkinglot)=parkinglot_test1)
+same => n,Dial(SIP/test_call at bob,,Kh)
+same => n,Hangup
+
+exten => test2,1,NoOp(BAAB)
+same => n,Set(CHANNEL(parkinglot)=parkinglot_test2)
+same => n,Dial(SIP/test_call at bob,,Kh)
+same => n,Hangup
+
+exten => test3,1,NoOp(BAAC)
+same => n,Set(CHANNEL(parkinglot)=parkinglot_test3)
+same => n,Dial(SIP/test_call at bob,,Kh)
+same => n,Hangup
+
+exten => s,1,NoOp(AAAAC)
+exten => s,n,UserEvent(comebackexten,test: 3,success:true,parker: ${PARKER},slot: ${PARKINGSLOT},lot: ${PARKEDLOT})
+
+[park_context1]
+exten => SIP_alice,1,NoOp(Test Position AAAAA)
+exten => SIP_alice,n,UserEvent(comebackexten,test: 1,success: true,parker: ${PARKER},slot: ${PARKINGSLOT},lot: ${PARKEDLOT})
+exten => s,1,UserEvent(comebackexten,test: 1,success: false)
+
+[park_context2]
+exten => s,1,NoOp(Test Position AAAAB)
+exten => s,n,UserEvent(comebackexten,test: 2,success: true,parker: ${PARKER},slot: ${PARKINGSLOT},lot: ${PARKEDLOT})
+
+[park_context3]

Propchange: asterisk/trunk/tests/bridge/parkcall_timeout/comebacktoorigin_no/configs/ast1/extensions.conf
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: asterisk/trunk/tests/bridge/parkcall_timeout/comebacktoorigin_no/configs/ast1/extensions.conf
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Rev URL"

Propchange: asterisk/trunk/tests/bridge/parkcall_timeout/comebacktoorigin_no/configs/ast1/extensions.conf
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: asterisk/trunk/tests/bridge/parkcall_timeout/comebacktoorigin_no/configs/ast1/features.conf
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/bridge/parkcall_timeout/comebacktoorigin_no/configs/ast1/features.conf?view=auto&rev=3633
==============================================================================
--- asterisk/trunk/tests/bridge/parkcall_timeout/comebacktoorigin_no/configs/ast1/features.conf (added)
+++ asterisk/trunk/tests/bridge/parkcall_timeout/comebacktoorigin_no/configs/ast1/features.conf Fri Feb  8 11:56:07 2013
@@ -1,0 +1,36 @@
+[general]
+
+[parkinglot_test1]
+context => parkedcalls
+parkext => 400
+parkpos => 401-409
+parkingtime=5
+comebackdialtime=3
+comebacktoorigin=no
+comebackcontext=park_context1
+
+[parkinglot_test2]
+context => parkedcalls
+parkext => 500
+parkpos => 501-509
+parkingtime=5
+comebackdialtime=3
+comebacktoorigin=no
+comebackcontext=park_context2
+
+[parkinglot_test3]
+context => parkedcalls
+parkext => 600
+parkpos => 601-609
+parkingtime=5
+comebackdialtime=3
+comebacktoorigin=no
+comebackcontext=park_context3
+
+[featuremap]
+blindxfer => 1
+atxfer => 2
+disconnect => 3
+automon => 4
+automixmon => 5
+parkcall => 6

Propchange: asterisk/trunk/tests/bridge/parkcall_timeout/comebacktoorigin_no/configs/ast1/features.conf
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: asterisk/trunk/tests/bridge/parkcall_timeout/comebacktoorigin_no/configs/ast1/features.conf
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Rev URL"

Propchange: asterisk/trunk/tests/bridge/parkcall_timeout/comebacktoorigin_no/configs/ast1/features.conf
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: asterisk/trunk/tests/bridge/parkcall_timeout/comebacktoorigin_no/test-config.yaml
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/bridge/parkcall_timeout/comebacktoorigin_no/test-config.yaml?view=auto&rev=3633
==============================================================================
--- asterisk/trunk/tests/bridge/parkcall_timeout/comebacktoorigin_no/test-config.yaml (added)
+++ asterisk/trunk/tests/bridge/parkcall_timeout/comebacktoorigin_no/test-config.yaml Fri Feb  8 11:56:07 2013
@@ -1,0 +1,87 @@
+testinfo:
+    summary: 'Test call parking timeouts for comebacktoorigin off'
+    description: |
+        'This test builds on the more generic parkcall test. With comebacktoorigin disabled,
+         we are primarily interested in seeing where in the dialplan the parked channel gets
+         sent when it is placed back into the PBX and that all of the values we mention in
+         the sample configuration are set appropriately. Also we want to make sure the park-dial
+         extension to dial the parker is created.'
+
+test-modules:
+    add-test-to-search-path: 'True'
+    test-object:
+        config-section: bridge-config
+        typename: 'BridgeTestCase.BridgeTestCase'
+    modules:
+        -
+            config-section: 'cdr-config'
+            typename: 'cdr.CDRModule'
+
+        -
+            typename: 'Executioner.Executioner'
+
+bridge-config:
+    -
+        originate_channel: 'SIP/test1 at uut'
+        features:
+            -
+                who: 'alice'
+                what: 'parkcall'
+                success: 'true'
+    -
+        originate_channel: 'SIP/test2 at uut'
+        features:
+            -
+                who: 'alice'
+                what: 'parkcall'
+                success: 'true'
+    -
+        originate_channel: 'SIP/test3 at uut'
+        features:
+            -
+                who: 'alice'
+                what: 'parkcall'
+                success: 'true'
+
+cdr-config:
+    -
+        file: 'Master'
+        lines:
+            -
+                source: '1234'
+                destination: 'test1'
+                dcontext: 'default'
+                callerid: '"Alice" <1234>'
+                channel: '.*/alice-.*'
+                dchannel: '.*/bob-.*'
+                lastapp: 'Dial'
+                disposition: 'ANSWERED'
+                amaflags: 'DOCUMENTATION'
+            -
+                source: '1234'
+                destination: 'test2'
+                dcontext: 'default'
+                callerid: '"Alice" <1234>'
+                channel: '.*/alice-.*'
+                dchannel: '.*/bob-.*'
+                lastapp: 'Dial'
+                disposition: 'ANSWERED'
+                amaflags: 'DOCUMENTATION'
+            -
+                source: '1234'
+                destination: 'test3'
+                dcontext: 'default'
+                callerid: '"Alice" <1234>'
+                channel: '.*/alice-.*'
+                dchannel: '.*/bob-.*'
+                lastapp: 'Dial'
+                disposition: 'ANSWERED'
+                amaflags: 'DOCUMENTATION'
+
+properties:
+    minversion: '12.0.0'
+    dependencies:
+        - python : 'twisted'
+        - python : 'starpy'
+    tags:
+        - bridge

Propchange: asterisk/trunk/tests/bridge/parkcall_timeout/comebacktoorigin_no/test-config.yaml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: asterisk/trunk/tests/bridge/parkcall_timeout/comebacktoorigin_no/test-config.yaml
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Rev URL"

Propchange: asterisk/trunk/tests/bridge/parkcall_timeout/comebacktoorigin_no/test-config.yaml
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: asterisk/trunk/tests/bridge/parkcall_timeout/comebacktoorigin_yes/Executioner.py
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/bridge/parkcall_timeout/comebacktoorigin_yes/Executioner.py?view=auto&rev=3633
==============================================================================
--- asterisk/trunk/tests/bridge/parkcall_timeout/comebacktoorigin_yes/Executioner.py (added)
+++ asterisk/trunk/tests/bridge/parkcall_timeout/comebacktoorigin_yes/Executioner.py Fri Feb  8 11:56:07 2013
@@ -1,0 +1,116 @@
+#!/usr/bin/env python
+'''
+Copyright (C) 2013, Digium, Inc.
+Jonathan Rose <jrose at digium.com>
+
+This program is free software, distributed under the terms of
+the GNU General Public License Version 2.
+'''
+
+import sys
+import logging
+
+sys.path.append("lib/python")
+
+LOGGER = logging.getLogger(__name__)
+
+class Executioner(object):
+    def __init__(self, module_config, test_object):
+        self.ami = None
+        self.alice_ami = None
+        self.parked_channel = None
+        test_object.register_ami_observer(self.ami_connect)
+        self.test_object = test_object
+
+        self.calls = []
+        self.calls.append({'parker' : 'SIP/alice', 'lot' : 'parkinglot_test1', 'slot' : '401', 'status' : 'ANSWER', 'post' : False})
+        self.calls.append({'parker' : 'SIP/alice', 'lot' : 'parkinglot_test1', 'slot' : '402', 'status' : 'NOANSWER', 'post' : True})
+        self.calls.append({'parker' : 'SIP/alice', 'lot' : 'parkinglot_test1', 'slot' : '403', 'status' : 'BUSY', 'post' : True})
+        self.current_call = None
+        self.current_call_post = False
+
+        # Automatically fail if we don't remove this token.
+        self.fail_token = self.test_object.create_fail_token("This test should fail all the time right now.")
+
+        self.userevents_received = 0
+        self.failures_logged = 0
+        self.parks_received = 0
+
+    def ami_connect(self, ami):
+        # We need to grab a reference to Alice's AMI if it's that one.
+        if ami.id == 1:
+            self.alice_ami = ami
+
+        # UUT's AMI is the one we are watching.
+        if ami.id != 0:
+            return
+
+        self.ami = ami
+        self.ami.registerEvent('UserEvent', self.check_user_event)
+        self.ami.registerEvent('ParkedCall', self.respond_to_park)
+
+    def respond_to_park(self, ami, event):
+        self.parks_received += 1
+        new_db_value = self.parks_received
+        message = {'action': 'DBPut', 'Family': 'test', 'Key': 'position', 'Val': new_db_value}
+        self.alice_ami.sendMessage(message)
+        self.current_call = self.calls.pop(0)
+
+        # Reset the call_post flag with each new test
+        self.current_call_post = False
+
+    def user_event_match(self, event):
+        num_failures = 0
+        if (event.get('parker') != self.current_call['parker']):
+            num_failures += 1
+        if (event.get('slot') != self.current_call['slot']):
+            num_failures += 1
+        if (event.get('lot') != self.current_call['lot']):
+            num_failures += 1
+        if (event.get('status') != self.current_call['status']):
+            num_failures += 1
+
+        if (num_failures):
+            LOGGER.info("Failing event: %s" % event)
+            LOGGER.info("Expected values: %s" % self.current_call)
+
+        return num_failures
+
+    def check_parkhangup(self, ami, event):
+        match_failures = self.user_event_match(event)
+        if (match_failures):
+            LOGGER.error("Test Phase %d: %d Mismatches were observed in a park_postcall event. Test failed." % (self.parks_received, match_failures))
+            self.failures_logged += 1
+
+        # Check if a call received a post test user event against whether or not it was supposed to.
+        if (self.current_call['post'] == True and not self.current_call_post):
+            LOGGER.error("Test Phase %d: Test failed because this phase should have received a post call user event and didn't." % self.parks_received)
+            self.failures_logged += 1
+
+        if (self.current_call['post'] == False and self.current_call_post):
+            LOGGER.error("Test Phase %d: Test failed because this phase should not have received a post call user event and did." % self.parks_received)
+            self.failures_logged += 1
+
+        # Once all the tests are complete, we need to check final pass conditions
+        if len(self.calls) == 0:
+            self.test_object.remove_fail_token(self.fail_token)
+            if self.failures_logged == 0:
+                LOGGER.info("All phases complete and the dialplan check showed the proper entry. Yay. Test Passed.")
+                self.test_object.set_passed(True)
+            else:
+                LOGGER.error("Test failed with %d errors.\n", self.failures_logged)
+
+    def check_parkpostcall(self, ami, event):
+        match_failures = self.user_event_match(event)
+        if (match_failures):
+            LOGGER.error("Test Phase %d: %d mismatches were observed in a park_postcall event. Test failed." % (self.parks_received, match_failures))
+            self.failures_logged += 1
+
+        self.current_call_post = True
+
+    def check_user_event(self, ami, event):
+        if event['userevent'] == 'park_hangup':
+            self.check_parkhangup(ami, event)
+
+        elif event['userevent'] == 'park_postcall':
+            self.check_parkpostcall(ami, event)

Propchange: asterisk/trunk/tests/bridge/parkcall_timeout/comebacktoorigin_yes/Executioner.py
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: asterisk/trunk/tests/bridge/parkcall_timeout/comebacktoorigin_yes/Executioner.py
------------------------------------------------------------------------------
    svn:executable = *

Propchange: asterisk/trunk/tests/bridge/parkcall_timeout/comebacktoorigin_yes/Executioner.py
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Rev URL"

Propchange: asterisk/trunk/tests/bridge/parkcall_timeout/comebacktoorigin_yes/Executioner.py
------------------------------------------------------------------------------
    svn:mime-type = text/x-python

Added: asterisk/trunk/tests/bridge/parkcall_timeout/comebacktoorigin_yes/configs/ast1/extensions.conf
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/bridge/parkcall_timeout/comebacktoorigin_yes/configs/ast1/extensions.conf?view=auto&rev=3633
==============================================================================
--- asterisk/trunk/tests/bridge/parkcall_timeout/comebacktoorigin_yes/configs/ast1/extensions.conf (added)
+++ asterisk/trunk/tests/bridge/parkcall_timeout/comebacktoorigin_yes/configs/ast1/extensions.conf Fri Feb  8 11:56:07 2013
@@ -1,0 +1,11 @@
+[default]
+exten => test,1,NoOp(BAAA)
+same => n,Set(CHANNEL(parkinglot)=parkinglot_test1)
+same => n,Dial(SIP/test_call at bob,,Kh)
+same => n,Hangup
+
+[park-dial]
+exten => h,1,NoOp(park-dial hangup)
+exten => h,n,UserEvent(park_hangup,parker: ${PARKER},slot: ${PARKINGSLOT},lot: ${PARKEDLOT},status: ${DIALSTATUS})
+
+exten => SIP_alice,2,UserEvent(park_postcall,parker: ${PARKER},slot: ${PARKINGSLOT},lot: ${PARKEDLOT},status: ${DIALSTATUS})

Propchange: asterisk/trunk/tests/bridge/parkcall_timeout/comebacktoorigin_yes/configs/ast1/extensions.conf
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: asterisk/trunk/tests/bridge/parkcall_timeout/comebacktoorigin_yes/configs/ast1/extensions.conf
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Rev URL"

Propchange: asterisk/trunk/tests/bridge/parkcall_timeout/comebacktoorigin_yes/configs/ast1/extensions.conf
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: asterisk/trunk/tests/bridge/parkcall_timeout/comebacktoorigin_yes/configs/ast1/features.conf
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/bridge/parkcall_timeout/comebacktoorigin_yes/configs/ast1/features.conf?view=auto&rev=3633
==============================================================================
--- asterisk/trunk/tests/bridge/parkcall_timeout/comebacktoorigin_yes/configs/ast1/features.conf (added)
+++ asterisk/trunk/tests/bridge/parkcall_timeout/comebacktoorigin_yes/configs/ast1/features.conf Fri Feb  8 11:56:07 2013
@@ -1,0 +1,18 @@
+[general]
+
+[parkinglot_test1]
+context => parkedcalls
+parkext => 400
+parkpos => 401-409
+parkingtime=5
+comebackdialtime=3
+comebacktoorigin=yes
+findslot => next
+
+[featuremap]
+blindxfer => 1
+atxfer => 2
+disconnect => 3
+automon => 4
+automixmon => 5
+parkcall => 6

Propchange: asterisk/trunk/tests/bridge/parkcall_timeout/comebacktoorigin_yes/configs/ast1/features.conf
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: asterisk/trunk/tests/bridge/parkcall_timeout/comebacktoorigin_yes/configs/ast1/features.conf
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Rev URL"

Propchange: asterisk/trunk/tests/bridge/parkcall_timeout/comebacktoorigin_yes/configs/ast1/features.conf
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: asterisk/trunk/tests/bridge/parkcall_timeout/comebacktoorigin_yes/configs/ast2/extensions.conf
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/bridge/parkcall_timeout/comebacktoorigin_yes/configs/ast2/extensions.conf?view=auto&rev=3633
==============================================================================
--- asterisk/trunk/tests/bridge/parkcall_timeout/comebacktoorigin_yes/configs/ast2/extensions.conf (added)
+++ asterisk/trunk/tests/bridge/parkcall_timeout/comebacktoorigin_yes/configs/ast2/extensions.conf Fri Feb  8 11:56:07 2013
@@ -1,0 +1,39 @@
+;Alice's dialplan
+
+#include extensions-extra.conf
+
+[default]
+; Originated call is linked to this extension
+exten => test_call,1,NoOp()
+same => n,Playback(${TALK_AUDIO})
+same => n,SendDTMF(#)
+same => n,Record(alice_audio_%d.wav,,,k)
+same => n,UserEvent(Connected, Channel: ${CHANNEL(name)})
+same => n,BackgroundDetect(${RECORDED_FILE},1,20,,20000)
+same => n,GoToIf($[${TALK_DETECTED}=0]?talkdetectfail:talkdetectpass)
+same => n(talkdetectfail),NoOp()
+same => n,UserEvent(TalkDetect, result: fail)
+same => n,Hangup()
+same => n(talkdetectpass),NoOp()
+same => n,UserEvent(TalkDetect, result: pass)
+same => n,Wait(10000)
+same => n,Hangup()
+
+exten => s,1,NoOp(Jump Position)
+same => n,GotoIf($["${DB(test/position)}" = "1"]?position1)
+same => n,GotoIf($["${DB(test/position)}" = "2"]?position2)
+same => n,GotoIf($["${DB(test/position)}" = "3"]?position3)
+same => n,Hangup
+
+same => n(position1),NoOp(Pick up and hangup)
+same => n,Playback(tt-weasels)
+same => n,Playback(tt-weasels)
+same => n,Hangup()
+
+same => n(position2),NoOp(Wait without answering)
+same => n,Wait(30)
+same => n,Hangup()
+
+same => n(position3),NoOp(Send busy)
+same => n,Busy()
+

Propchange: asterisk/trunk/tests/bridge/parkcall_timeout/comebacktoorigin_yes/configs/ast2/extensions.conf
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: asterisk/trunk/tests/bridge/parkcall_timeout/comebacktoorigin_yes/configs/ast2/extensions.conf
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Rev URL"

Propchange: asterisk/trunk/tests/bridge/parkcall_timeout/comebacktoorigin_yes/configs/ast2/extensions.conf
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: asterisk/trunk/tests/bridge/parkcall_timeout/comebacktoorigin_yes/test-config.yaml
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/bridge/parkcall_timeout/comebacktoorigin_yes/test-config.yaml?view=auto&rev=3633
==============================================================================
--- asterisk/trunk/tests/bridge/parkcall_timeout/comebacktoorigin_yes/test-config.yaml (added)
+++ asterisk/trunk/tests/bridge/parkcall_timeout/comebacktoorigin_yes/test-config.yaml Fri Feb  8 11:56:07 2013
@@ -1,0 +1,116 @@
+testinfo:
+    summary: 'Test call parking timeouts for comebacktoorigin off'
+    description: |
+        'This test builds on the more generic parkcall test. With comebacktoorigin enabled,
+         we are checking to make sure that the call is placed into the correct extension in
+         park-dial as well as where the call ends up after the call is over whether it ends
+         in hangup after being answered or if it is ignored or given a busy signal'
+
+test-modules:
+    add-test-to-search-path: 'True'
+    test-object:
+        config-section: bridge-config
+        typename: 'BridgeTestCase.BridgeTestCase'
+    modules:
+        -
+            config-section: 'cdr-config'
+            typename: 'cdr.CDRModule'
+
+        -
+            typename: 'Executioner.Executioner'
+
+bridge-config:
+    -
+        originate_channel: 'SIP/test at uut'
+        features:
+            -
+                who: 'alice'
+                what: 'parkcall'
+                success: 'true'
+    -
+        originate_channel: 'SIP/test at uut'
+        features:
+            -
+                who: 'alice'
+                what: 'parkcall'
+                success: 'true'
+    -
+        originate_channel: 'SIP/test at uut'
+        features:
+            -
+                who: 'alice'
+                what: 'parkcall'
+                success: 'true'
+
+cdr-config:
+    -
+        file: 'Master'
+        lines:
+            -
+                source: '1234'
+                destination: 'test'
+                dcontext: 'default'
+                callerid: '"Alice" <1234>'
+                channel: '.*/alice-.*'
+                dchannel: '.*/bob-.*'
+                lastapp: 'Dial'
+                disposition: 'ANSWERED'
+                amaflags: 'DOCUMENTATION'
+            -
+                source: '4321'
+                destination: 'SIP_alice'
+                dcontext: 'park-dial'
+                callerid: '"Bob" <4321>'
+                channel: '.*/bob-.*'
+                dchannel: '.*/alice-.*'
+                lastapp: 'Dial'
+                disposition: 'ANSWERED'
+                amaflags: 'DOCUMENTATION'
+            -
+                source: '1234'
+                destination: 'test'
+                dcontext: 'default'
+                callerid: '"Alice" <1234>'
+                channel: '.*/alice-.*'
+                dchannel: '.*/bob-.*'
+                lastapp: 'Dial'
+                disposition: 'ANSWERED'
+                amaflags: 'DOCUMENTATION'
+            -
+                source: '4321'
+                destination: 'SIP_alice'
+                dcontext: 'park-dial'
+                callerid: '"Bob" <4321>'
+                channel: '.*/bob-.*'
+                dchannel: '.*/alice-.*'
+                lastapp: 'UserEvent'
+                disposition: 'NO ANSWER'
+                amaflags: 'DOCUMENTATION'
+            -
+                source: '1234'
+                destination: 'test'
+                dcontext: 'default'
+                callerid: '"Alice" <1234>'
+                channel: '.*/alice-.*'
+                dchannel: '.*/bob-.*'
+                lastapp: 'Dial'
+                disposition: 'ANSWERED'
+                amaflags: 'DOCUMENTATION'
+            -
+                source: '4321'
+                destination: 'SIP_alice'
+                dcontext: 'park-dial'
+                callerid: '"Bob" <4321>'
+                channel: '.*/bob-.*'
+                dchannel: '.*/alice-.*'
+                lastapp: 'UserEvent'
+                disposition: 'BUSY'
+                amaflags: 'DOCUMENTATION'
+
+properties:
+    minversion: '12.0.0'
+    dependencies:
+        - python : 'twisted'
+        - python : 'starpy'
+    tags:
+        - bridge

Propchange: asterisk/trunk/tests/bridge/parkcall_timeout/comebacktoorigin_yes/test-config.yaml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: asterisk/trunk/tests/bridge/parkcall_timeout/comebacktoorigin_yes/test-config.yaml
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Rev URL"

Propchange: asterisk/trunk/tests/bridge/parkcall_timeout/comebacktoorigin_yes/test-config.yaml
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: asterisk/trunk/tests/bridge/parkcall_timeout/tests.yaml
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/bridge/parkcall_timeout/tests.yaml?view=auto&rev=3633
==============================================================================
--- asterisk/trunk/tests/bridge/parkcall_timeout/tests.yaml (added)
+++ asterisk/trunk/tests/bridge/parkcall_timeout/tests.yaml Fri Feb  8 11:56:07 2013
@@ -1,0 +1,3 @@
+tests:
+    - test: 'comebacktoorigin_no'
+    - test: 'comebacktoorigin_yes'

Propchange: asterisk/trunk/tests/bridge/parkcall_timeout/tests.yaml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: asterisk/trunk/tests/bridge/parkcall_timeout/tests.yaml
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Rev URL"

Propchange: asterisk/trunk/tests/bridge/parkcall_timeout/tests.yaml
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: asterisk/trunk/tests/bridge/tests.yaml
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/bridge/tests.yaml?view=diff&rev=3633&r1=3632&r2=3633
==============================================================================
--- asterisk/trunk/tests/bridge/tests.yaml (original)
+++ asterisk/trunk/tests/bridge/tests.yaml Fri Feb  8 11:56:07 2013
@@ -6,5 +6,6 @@
     - test: 'automon'
     - test: 'automixmon'
     - test: 'parkcall'
+    - dir: 'parkcall_timeout'
     - test: 'dial_LS_options'
     - test: 'connected_line_update'




More information about the svn-commits mailing list