[Asterisk-code-review] Get confbridge tests to pass on 13.12.0 (testsuite[master])

Mark Michelson asteriskteam at digium.com
Mon Sep 12 16:55:43 CDT 2016


Mark Michelson has uploaded a new change for review.

  https://gerrit.asterisk.org/3885

Change subject: Get confbridge tests to pass on 13.12.0
......................................................................

Get confbridge tests to pass on 13.12.0

A change made to app_confbridge recently made it so that announcements
could be played asynchronously into a confbridge. Prior to that change,
some sounds, such as the conference join sound, would be played twice.
First, the sound would be played to the initiator of the sound (e.g. the
channel joining the conference). Second, the sound would be played into
the entire conference so everyone else could hear it. With the ability
to play sounds asynchronously, we now only play the sound once to the
entire conference where everyone, including the initiator, can hear it.

Asynchronous sounds caused two different types of failures to occur in
tests. The most common failure was simple: tests would check for a sound
to be played to an individual channel, and that no longer happens. The
other type of failure was a failure due to the timing of channels
entering conferences.

For the first type of failure, this was fixed by only looking for the
sound playbacks depending on the version of Asterisk in use. apptest has
been altered to allow a minversion and maxversion to be specified on an
event so that we can decide whether to care about that event or not. The
following tests now make use of a 'maxversion' option:

* confbridge_end_marked
* confbridge_marked
* confbridge_marked_unmarked
* confbridge_triple_lindy
* confbridge_waitmarked_normal

The confbridge_triple_lindy test has one further adjustment. There was a
waitmarked user whose call was previously triggered upon receiving the
event that the join sound had played to a specific channel. That call is
now started when the ConfbridgeJoined event occurs instead.

The confbridge_nominal test was also affected by this failure, but since
it does not use apptest, the solution had to be hard-coded into its
run-test script.

The only test affected by the second type of failure was
confbridge_result. The test made some assumptions about the
synchronicity of the channels that were joining. Specifically, it
assumed that just because a channel called the Confbridge application
first, it would therefore be in the bridge first. This used to be the
case since all channels would block while waiting to get to play
announcements into the bridge. However, now they queue an asynchronous
sound and move on. The order they join the bridge is not predictable. In
order for the test to work in the intended way, the 'Darnell' channel
has to start its call after the 'Alice' channel is confirmed to have
entered the bridge. This is because Alice is endmarked and Darnell
is marked. The test assumes that when Darnell leaves the bridge, Alice
will be kicked out as well. However, in test runs, Darnell would enter
and leave the bridge before Alice ever entered.

Change-Id: I4bcaaf5b535c34f636d0ccc66a6772db7a062de2
---
M lib/python/asterisk/apptest.py
M tests/apps/confbridge/confbridge_end_marked/test-config.yaml
M tests/apps/confbridge/confbridge_marked/test-config.yaml
M tests/apps/confbridge/confbridge_marked_unmarked/test-config.yaml
M tests/apps/confbridge/confbridge_nominal/run-test
M tests/apps/confbridge/confbridge_result/test-config.yaml
M tests/apps/confbridge/confbridge_triple_lindy/test-config.yaml
M tests/apps/confbridge/confbridge_waitmarked_normal/test-config.yaml
8 files changed, 57 insertions(+), 235 deletions(-)


  git pull ssh://gerrit.asterisk.org:29418/testsuite refs/changes/85/3885/1

diff --git a/lib/python/asterisk/apptest.py b/lib/python/asterisk/apptest.py
index cc17b97..b865b83 100644
--- a/lib/python/asterisk/apptest.py
+++ b/lib/python/asterisk/apptest.py
@@ -20,6 +20,7 @@
 sys.path.append("lib/python")
 from test_case import TestCase
 from ami import AMIEventInstance
+from version import AsteriskVersion
 
 LOGGER = logging.getLogger(__name__)
 
@@ -84,6 +85,18 @@
         super(AppTest, self).run()
         self.create_ami_factory()
 
+    def _create_application_event_instances(self, channel_id, events):
+        for event_config in events:
+            minversion = event_config.get('minversion', '0.0.0')
+            maxversion = event_config.get('maxversion', '999.999.999')
+            if (AsteriskVersion() < AsteriskVersion(minversion) or
+                AsteriskVersion() >= AsteriskVersion(maxversion)):
+                continue
+            ae_instance = ApplicationEventInstance(channel_id,
+                                                   event_config,
+                                                   self)
+            self._event_instances.append(ae_instance)
+
     def _run_scenario(self, scenario):
         """Run some scenario
 
@@ -94,20 +107,14 @@
 
         # Create event instances not associated with a channel
         if 'events' in scenario:
-            for event_config in scenario['events']:
-                ae_instance = ApplicationEventInstance('', event_config, self)
-                self._event_instances.append(ae_instance)
+            self._create_application_event_instances('', scenario['events'])
 
         # Create the event instances associated with a channel and the
         # corresponding channel object
         for channel_config in scenario['channels']:
             channel_id = channel_config['channel-id']
-            for event_config in channel_config['events']:
-                ae_instance = ApplicationEventInstance(channel_id,
-                                                       event_config,
-                                                       self)
-                self._event_instances.append(ae_instance)
-
+            self._create_application_event_instances(channel_id,
+                                                     channel_config['events'])
             obj = ChannelObject(ami=self.ami[0],
                                 applications=self._applications,
                                 channel_def=channel_config)
diff --git a/tests/apps/confbridge/confbridge_end_marked/test-config.yaml b/tests/apps/confbridge/confbridge_end_marked/test-config.yaml
index 7ea6ad5..6f5a001 100644
--- a/tests/apps/confbridge/confbridge_end_marked/test-config.yaml
+++ b/tests/apps/confbridge/confbridge_end_marked/test-config.yaml
@@ -325,6 +325,7 @@
                   expected-result: 'Marked user left Conference'
             -
               type: 'headermatch'
+              maxversion: '13.12.0'
               conditions:
                 match:
                   Event: 'TestEvent'
diff --git a/tests/apps/confbridge/confbridge_marked/test-config.yaml b/tests/apps/confbridge/confbridge_marked/test-config.yaml
index 1758d78..0bc9af4 100644
--- a/tests/apps/confbridge/confbridge_marked/test-config.yaml
+++ b/tests/apps/confbridge/confbridge_marked/test-config.yaml
@@ -136,6 +136,7 @@
                   expected-result: 'Marked-1 Leave Event received'
             -
               type: 'headermatch'
+              maxversion: '13.12.0'
               conditions:
                 match:
                   Event: 'TestEvent'
@@ -319,6 +320,7 @@
                   expected-result: 'Marked-1 Leave Event received'
             -
               type: 'headermatch'
+              maxversion: '13.12.0'
               conditions:
                 match:
                   Event: 'TestEvent'
diff --git a/tests/apps/confbridge/confbridge_marked_unmarked/test-config.yaml b/tests/apps/confbridge/confbridge_marked_unmarked/test-config.yaml
index 1d9b4a5..e4fd3a6 100644
--- a/tests/apps/confbridge/confbridge_marked_unmarked/test-config.yaml
+++ b/tests/apps/confbridge/confbridge_marked_unmarked/test-config.yaml
@@ -139,6 +139,7 @@
                   expected-result: 'Marked-user Leave Event received'
             -
               type: 'headermatch'
+              maxversion: '13.12.0'
               conditions:
                 match:
                   Event: 'TestEvent'
@@ -190,6 +191,7 @@
                   expected-result: 'Normal-user Leave Event received'
             -
               type: 'headermatch'
+              maxversion: '13.12.0'
               conditions:
                 match:
                   Event: 'TestEvent'
@@ -330,6 +332,7 @@
                   expected-result: 'Marked-user Leave Event received'
             -
               type: 'headermatch'
+              maxversion: '13.12.0'
               conditions:
                 match:
                   Event: 'TestEvent'
@@ -381,6 +384,7 @@
                   expected-result: 'Normal-user Leave Event received'
             -
               type: 'headermatch'
+              maxversion: '13.12.0'
               conditions:
                 match:
                   Event: 'TestEvent'
@@ -522,6 +526,7 @@
                   expected-result: 'Marked-user Leave Event received'
             -
               type: 'headermatch'
+              maxversion: '13.12.0'
               conditions:
                 match:
                   Event: 'TestEvent'
@@ -573,6 +578,7 @@
                   expected-result: 'Normal-user Leave Event received'
             -
               type: 'headermatch'
+              maxversion: '13.12.0'
               conditions:
                 match:
                   Event: 'TestEvent'
diff --git a/tests/apps/confbridge/confbridge_nominal/run-test b/tests/apps/confbridge/confbridge_nominal/run-test
index 288d62c..5e795a6 100755
--- a/tests/apps/confbridge/confbridge_nominal/run-test
+++ b/tests/apps/confbridge/confbridge_nominal/run-test
@@ -23,6 +23,7 @@
 from asterisk.test_state import FailureTestState
 from asterisk.confbridge import ConfbridgeTestState
 from asterisk.confbridge import ConfbridgeChannelObject
+from asterisk.version import AsteriskVersion
 
 logger = logging.getLogger(__name__)
 
@@ -90,19 +91,27 @@
 
     def __handle_confbridge_join(self, channel):
         """ Handles when the ConfBridge notifies the users that someone has joined """
-
-        """ We'll hear this twice for each channel that joins """
         self.test_case.reset_timeout()
-        if channel == self.__bridge_channel:
-            self.__joined_bridges += 1
-            if (self.__joined_bridges == len(self.calls)):
-                self.test_case.expectedEvents['joinannouncetoall'] = True
+        if AsteriskVersion() < AsteriskVersion('13.12.0'):
+            # Prior to 13.12.0, the join sound was played once to the channel
+            # that joined and once to the entire bridge.
+            if channel == self.__bridge_channel:
+                self.__joined_bridges += 1
+            else:
+                self.__joined_channels += 1
         else:
+            # For 13.12.0 and up, the join sound is only played to the entire
+            # bridge. We just go ahead and bump both the joined_channels and
+            # joined_bridges counts together and "lie" about having the sound
+            # played to the individual channel
             self.__joined_channels += 1
-            if (self.__joined_channels == len(self.calls)):
-                self.test_case.expectedEvents['joinannouncetochannel'] = True
-        if (self.__joined_bridges == len(self.calls) and self.__joined_channels == len(self.calls)):
+            self.__joined_bridges += 1
+
+        if (self.__joined_bridges == len(self.calls)):
+            self.test_case.expectedEvents['joinannouncetoall'] = True
+        if (self.__joined_channels == len(self.calls)):
             """ Everyone has joined the conference! """
+            self.test_case.expectedEvents['joinannouncetochannel'] = True
             self.change_state(ActiveConfBridgeState(self.controller, self.test_case, self.calls))
 
     def get_state_name(self):
diff --git a/tests/apps/confbridge/confbridge_result/test-config.yaml b/tests/apps/confbridge/confbridge_result/test-config.yaml
index e78efd5..78db969 100644
--- a/tests/apps/confbridge/confbridge_result/test-config.yaml
+++ b/tests/apps/confbridge/confbridge_result/test-config.yaml
@@ -66,6 +66,9 @@
                                 -
                                     action-type: 'set-expected-result'
                                     expected-result: 'Alice Joined'
+                                -
+                                    action-type: 'start-call'
+                                    channel-id: 'Darnell'
                         -
                             type: 'headermatch'
                             conditions:
@@ -111,219 +114,6 @@
                                 -
                                     action-type: 'set-expected-result'
                                     expected-result: 'Carol Joined'
-                                -
-                                    action-type: 'start-call'
-                                    channel-id: 'Darnell'
-                                -
-                                    action-type: 'send-dtmf'
-                                    delay: '1'
-                                    dtmf: '*'
-                        -
-                            type: 'headermatch'
-                            conditions:
-                                match:
-                                    Event: 'ConfbridgeLeave'
-                                    Conference: '1'
-                                    Channel: 'Local/carol at default-.*'
-                                    ChanVariable: 'CONFBRIDGE_RESULT=DTMF'
-                            actions:
-                                -
-                                    action-type: 'set-expected-result'
-                                    expected-result: 'Carol Left (DTMF)'
-                -
-                    channel-id: 'Darnell'
-                    channel-name: 'Local/darnell at default'
-                    events:
-                        -
-                            type: 'headermatch'
-                            conditions:
-                                match:
-                                    Event: 'ConfbridgeJoin'
-                                    Conference: '1'
-                                    Channel: 'Local/darnell at default-.*'
-                            actions:
-                                -
-                                    action-type: 'set-expected-result'
-                                    expected-result: 'Darnell Joined'
-                                -
-                                    action-type: 'start-call'
-                                    channel-id: 'Egbert'
-                        -
-                            type: 'headermatch'
-                            conditions:
-                                match:
-                                    Event: 'ConfbridgeLeave'
-                                    Conference: '1'
-                                    Channel: 'Local/darnell at default-.*'
-                                    ChanVariable: 'CONFBRIDGE_RESULT=HANGUP'
-                            actions:
-                                -
-                                    action-type: 'set-expected-result'
-                                    expected-result: 'Darnell Left (Hangup)'
-                -
-                    channel-id: 'Egbert'
-                    channel-name: 'Local/egbert at default'
-                    events:
-                        -
-                            type: 'headermatch'
-                            conditions:
-                                match:
-                                    Event: 'ConfbridgeJoin'
-                                    Conference: '1'
-                                    Channel: 'Local/egbert at default-.*'
-                            actions:
-                                -
-                                    action-type: 'set-expected-result'
-                                    expected-result: 'Egbert Joined'
-                                -
-                                    action-type: 'send-dtmf'
-                                    delay: '1'
-                                    dtmf: '*'
-                                    channel-id: 'Darnell'
-
-                        -
-                            type: 'headermatch'
-                            conditions:
-                                match:
-                                    Event: 'ConfbridgeLeave'
-                                    Conference: '1'
-                                    Channel: 'Local/egbert at default-.*'
-                                    ChanVariable: 'CONFBRIDGE_RESULT=KICKED'
-                            actions:
-                                -
-                                    action-type: 'set-expected-result'
-                                    expected-result: 'Egbert Left (Kicked)'
-                                -
-                                    action-type: 'hangup'
-                                    channel-id: 'Darnell'
-
-
-properties:
-    minversion: '13.0.0'
-    tags:
-        - confbridge
-        - apps
-    dependencies:
-        - python: 'twisted'
-        - python: 'starpy'
-        - asterisk: 'app_confbridge'
-        - asterisk: 'app_senddtmf'
-testinfo:
-    summary: 'Basic tests of CONFBRIDGE_STATUS channel variable'
-    description: |
-        'Five channels are placed into a ConfBridge(). Each is removed from
-        the Confbridge in a way that results in their CONFBRIDGE_STATUS being
-        set to a different value. This ensures that the values are as expected.
-        Alice enters first. She has the endmarked option applied to him.
-        Bob attempts to enter next. He tries to use a non-existent user profile though.
-        Carol enters next. There is nothing special about her.
-        Darnell enters next. He is a marked user and an admin.
-        Egbert enters last. There is nothing special about him.
-        Darnell kicks Egbert from the conference.
-        Carol presses a DTMF sequence to exit the conference.
-        Darnell hangs up, causing Alice to be kicked from the conference.
-        In the end, their CONFBRIDGE_STATUS variables should be set as follows:
-        Alice: ENDMARKED
-        Bob: FAILED
-        Carol: DTMF
-        Darnell: HANGUP
-        Egbert: KICKED'
-
-test-modules:
-    test-object:
-        config-section: test-object-config
-        typename: 'apptest.AppTest'
-
-test-object-config:
-    app: 'ConfBridge'
-    scenarios:
-        -
-            events:
-                -
-                    type: 'headermatch'
-                    conditions:
-                        match:
-                            Event: 'ConfbridgeStart'
-                            Conference: '1'
-                    actions:
-                        -
-                            action-type: 'set-expected-result'
-                            expected-result: 'Conference Started'
-                -
-                    type: 'headermatch'
-                    conditions:
-                        match:
-                            Event: 'ConfbridgeEnd'
-                            Conference: '1'
-                    actions:
-                        -
-                            action-type: 'set-expected-result'
-                            expected-result: 'Conference Ended'
-            channels:
-                -
-                    channel-id: 'Alice'
-                    channel-name: 'Local/alice at default'
-                    start-on-create: True
-                    events:
-                        -
-                            type: 'headermatch'
-                            conditions:
-                                match:
-                                    Event: 'ConfbridgeJoin'
-                                    Conference: '1'
-                                    Channel: 'Local/alice at default-.*'
-                            actions:
-                                -
-                                    action-type: 'set-expected-result'
-                                    expected-result: 'Alice Joined'
-                        -
-                            type: 'headermatch'
-                            conditions:
-                                match:
-                                    Event: 'ConfbridgeLeave'
-                                    Conference: '1'
-                                    Channel: 'Local/alice at default-.*'
-                                    ChanVariable: 'CONFBRIDGE_RESULT=ENDMARKED'
-                            actions:
-                                -
-                                    action-type: 'set-expected-result'
-                                    expected-result: 'Alice Left (Endmarked)'
-                -
-                    channel-id: 'Bob'
-                    channel-name: 'Local/bob at default'
-                    start-on-create: True
-                    events:
-                        -
-                            type: 'headermatch'
-                            conditions:
-                                match:
-                                    Event: 'Hangup'
-                                    Channel: 'Local/bob at default-.*'
-                                    ChanVariable: 'CONFBRIDGE_RESULT=FAILED'
-                            actions:
-                                -
-                                    action-type: 'set-expected-result'
-                                    expected-result: 'Bob Failed to Join'
-
-                -
-                    channel-id: 'Carol'
-                    channel-name: 'Local/carol at default'
-                    start-on-create: True
-                    events:
-                        -
-                            type: 'headermatch'
-                            conditions:
-                                match:
-                                    Event: 'ConfbridgeJoin'
-                                    Conference: '1'
-                                    Channel: 'Local/carol at default-.*'
-                            actions:
-                                -
-                                    action-type: 'set-expected-result'
-                                    expected-result: 'Carol Joined'
-                                -
-                                    action-type: 'start-call'
-                                    channel-id: 'Darnell'
                                 -
                                     action-type: 'send-dtmf'
                                     delay: '1'
diff --git a/tests/apps/confbridge/confbridge_triple_lindy/test-config.yaml b/tests/apps/confbridge/confbridge_triple_lindy/test-config.yaml
index 0ca97af..79f6ad2 100644
--- a/tests/apps/confbridge/confbridge_triple_lindy/test-config.yaml
+++ b/tests/apps/confbridge/confbridge_triple_lindy/test-config.yaml
@@ -284,6 +284,7 @@
                   expected-result: 'Marked user left Conference'
             -
               type: 'headermatch'
+              maxversion: '13.12.0'
               conditions:
                 match:
                   Event: 'TestEvent'
@@ -541,6 +542,7 @@
                   expected-result: 'Marked user left Conference'
             -
               type: 'headermatch'
+              maxversion: '13.12.0'
               conditions:
                 match:
                   Event: 'TestEvent'
@@ -788,6 +790,7 @@
                   expected-result: 'Marked user left Conference'
             -
               type: 'headermatch'
+              maxversion: '13.12.0'
               conditions:
                 match:
                   Event: 'TestEvent'
@@ -946,6 +949,10 @@
                 -
                   action-type: 'set-expected-result'
                   expected-result: 'Marked user joined Conference'
+                -
+                  action-type: 'start-call'
+                  delay: 1
+                  channel-id: 'Waitmarked-user'
             -
               type: 'headermatch'
               conditions:
@@ -959,6 +966,7 @@
                   expected-result: 'Marked user left Conference'
             -
               type: 'headermatch'
+              maxversion: '13.12.0'
               conditions:
                 match:
                   Event: 'TestEvent'
@@ -969,10 +977,6 @@
                 -
                   action-type: 'set-expected-result'
                   expected-result: 'Marked user heard confbridge-join'
-                -
-                  action-type: 'start-call'
-                  delay: 1
-                  channel-id: 'Waitmarked-user'
         -
           channel-id: 'Waitmarked-user'
           channel-name: 'Local/waitmarked-user at confbridge'
diff --git a/tests/apps/confbridge/confbridge_waitmarked_normal/test-config.yaml b/tests/apps/confbridge/confbridge_waitmarked_normal/test-config.yaml
index 8ea8b9a..3d9c525 100644
--- a/tests/apps/confbridge/confbridge_waitmarked_normal/test-config.yaml
+++ b/tests/apps/confbridge/confbridge_waitmarked_normal/test-config.yaml
@@ -138,6 +138,7 @@
                   expected-result: 'Normal_user Leave Event Received'
             -
               type: 'headermatch'
+              maxversion: '13.12.0'
               conditions:
                 match:
                   Event: 'TestEvent'
@@ -306,6 +307,7 @@
                   expected-result: 'Normal_user Leave Event Received'
             -
               type: 'headermatch'
+              maxversion: '13.12.0'
               conditions:
                 match:
                   Event: 'TestEvent'
@@ -489,6 +491,7 @@
                   expected-result: 'Normal_user Leave Event Received'
             -
               type: 'headermatch'
+              maxversion: '13.12.0'
               conditions:
                 match:
                   Event: 'TestEvent'

-- 
To view, visit https://gerrit.asterisk.org/3885
To unsubscribe, visit https://gerrit.asterisk.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I4bcaaf5b535c34f636d0ccc66a6772db7a062de2
Gerrit-PatchSet: 1
Gerrit-Project: testsuite
Gerrit-Branch: master
Gerrit-Owner: Mark Michelson <mmichelson at digium.com>



More information about the asterisk-code-review mailing list