[svn-commits] mmichelson: testsuite/asterisk/trunk r5386 - in /asterisk/trunk/tests/manager...

SVN commits to the Digium repositories svn-commits at lists.digium.com
Thu Aug 7 14:33:02 CDT 2014


Author: mmichelson
Date: Thu Aug  7 14:32:59 2014
New Revision: 5386

URL: http://svnview.digium.com/svn/testsuite?view=rev&rev=5386
Log:
Add test that ensures AMI UserEvent action performs correctly given arbitrary header order.

Review: https://reviewboard.asterisk.org/r/3866


Added:
    asterisk/trunk/tests/manager/userevent/
    asterisk/trunk/tests/manager/userevent/event.py   (with props)
    asterisk/trunk/tests/manager/userevent/test-config.yaml   (with props)
Modified:
    asterisk/trunk/tests/manager/tests.yaml

Modified: asterisk/trunk/tests/manager/tests.yaml
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/manager/tests.yaml?view=diff&rev=5386&r1=5385&r2=5386
==============================================================================
--- asterisk/trunk/tests/manager/tests.yaml (original)
+++ asterisk/trunk/tests/manager/tests.yaml Thu Aug  7 14:32:59 2014
@@ -15,5 +15,6 @@
     - test: 'presence_state_list'
     - test: 'manager_vars'
     - test: 'status'
+    - test: 'userevent'
     # Temporarily disabled while failures are debugged
     #- test: 'response-time'

Added: asterisk/trunk/tests/manager/userevent/event.py
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/manager/userevent/event.py?view=auto&rev=5386
==============================================================================
--- asterisk/trunk/tests/manager/userevent/event.py (added)
+++ asterisk/trunk/tests/manager/userevent/event.py Thu Aug  7 14:32:59 2014
@@ -1,0 +1,46 @@
+#!/usr/bin/env python
+"""
+Copyright (C) 2014, Digium, Inc.
+Mark Michelson <mmichelson at digium.com>
+
+This program is free software, distributed under the terms of
+the GNU General Public License Version 2.
+"""
+
+
+class UserEventGenerator(object):
+    def __init__(self, instance_config, test_object):
+        self.test_object = test_object
+        self.userevents_received = 0
+        test_object.register_ami_observer(self.ami_connect)
+
+    def ami_connect(self, ami):
+        ami.registerEvent('UserEvent', self.userevent)
+        message = [
+            'FootBoneConnectedToThe: AnkleBone',
+            'AnkleBoneConnectedToThe: ShinBone',
+            'Action: UserEvent',
+            'ShinBoneConnectedToThe: KneeBone',
+            'UserEvent: AnatomyLesson',
+            'KneeBoneConnectedToThe: ThighBone',
+        ]
+        # We have to forego the typical methods of sending an AMI command
+        # because the order the headers are sent in matters for this test.
+        #
+        # Using sendMessage or sendDeferred using the repeatedArgs param seems
+        # like a potential alternative, but those methods automatically insert
+        # an ActionId header as the first header. We want exactly the headers
+        # we are sending in exactly the order we have them here in order to
+        # verify proper operation.
+        for _ in range(0, len(message)):
+            message.append(message.pop(0))
+            for line in message:
+                ami.sendLine(line)
+            ami.sendLine('')
+
+    def userevent(self, ami, event):
+        # This isn't strictly necessary, but without it, the test will take 30
+        # seconds each run. With this, it's closer to ~6 seconds.
+        self.userevents_received += 1
+        if (self.userevents_received == 6):
+            self.test_object.stop_reactor()

Propchange: asterisk/trunk/tests/manager/userevent/event.py
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: asterisk/trunk/tests/manager/userevent/event.py
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Propchange: asterisk/trunk/tests/manager/userevent/event.py
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: asterisk/trunk/tests/manager/userevent/test-config.yaml
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/manager/userevent/test-config.yaml?view=auto&rev=5386
==============================================================================
--- asterisk/trunk/tests/manager/userevent/test-config.yaml (added)
+++ asterisk/trunk/tests/manager/userevent/test-config.yaml Thu Aug  7 14:32:59 2014
@@ -1,0 +1,43 @@
+testinfo:
+    summary: 'Ensure that UserEvent AMI command generates expected UserEvent'
+    description: |
+        'This sends a UserEvent with the headers in an odd order. This test ensures that
+        the headers from the command (except the "Action" header) are echoed.'
+
+test-modules:
+    add-test-to-search-path: 'True'
+    test-object:
+        config-section: 'test-config'
+        typename: 'test_case.TestCaseModule'
+    modules:
+        -
+            config-section: 'userevent-checker'
+            typename: 'ami.AMIEventModule'
+        -
+            typename: 'event.UserEventGenerator'
+
+test-config:
+    connect-ami: True
+
+userevent-checker:
+    -
+        type: 'headermatch'
+        conditions:
+            match:
+                Event: 'UserEvent'
+        requirements:
+            match:
+                'UserEvent': 'AnatomyLesson'
+                'FootBoneConnectedToThe': 'AnkleBone'
+                'AnkleBoneConnectedToThe': 'ShinBone'
+                'ShinBoneConnectedToThe': 'KneeBone'
+                'KneeBoneConnectedToThe': 'ThighBone'
+        count: '6'
+
+properties:
+    minversion: '13.0.0'
+    dependencies:
+        - python: 'twisted'
+        - python: 'starpy'
+    tags:
+        - AMI

Propchange: asterisk/trunk/tests/manager/userevent/test-config.yaml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: asterisk/trunk/tests/manager/userevent/test-config.yaml
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Propchange: asterisk/trunk/tests/manager/userevent/test-config.yaml
------------------------------------------------------------------------------
    svn:mime-type = text/plain




More information about the svn-commits mailing list