[svn-commits] mjordan: testsuite/asterisk/trunk r4833 - in /asterisk/trunk: lib/python/aste...

SVN commits to the Digium repositories svn-commits at lists.digium.com
Tue Mar 11 11:06:59 CDT 2014


Author: mjordan
Date: Tue Mar 11 11:06:53 2014
New Revision: 4833

URL: http://svnview.digium.com/svn/testsuite?view=rev&rev=4833
Log:
agents/agent_request/nominal: Add a basic AgentRequest test

This test logs an agent in, and then tests the following:
- Agent state changes to NOT_INUSE.
- Agent receives an AgentRequest.
- Agent state changes to INUSE.
- Requesting channel hangs up while in bridge with agent.
- Agent is moved back to pool.
- Agent state changes back to NOT_INUSE.

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

ASTERISK-23230 #close #resolve #comment patches rb311.patch uploaded by bford (license 6580)

(closes issue ASTERISK-23230)
Reported by: Matt Jordan
patches:
  rb3311.patch uploaded by bford (License 6580)

Added:
    asterisk/trunk/tests/apps/agents/agent_request/
    asterisk/trunk/tests/apps/agents/agent_request/nominal/
    asterisk/trunk/tests/apps/agents/agent_request/nominal/configs/
    asterisk/trunk/tests/apps/agents/agent_request/nominal/configs/ast1/
    asterisk/trunk/tests/apps/agents/agent_request/nominal/configs/ast1/agents.conf   (with props)
    asterisk/trunk/tests/apps/agents/agent_request/nominal/configs/ast1/extensions.conf   (with props)
    asterisk/trunk/tests/apps/agents/agent_request/nominal/test-config.yaml   (with props)
    asterisk/trunk/tests/apps/agents/agent_request/tests.yaml   (with props)
Modified:
    asterisk/trunk/lib/python/asterisk/apptest.py
    asterisk/trunk/tests/apps/agents/tests.yaml

Modified: asterisk/trunk/lib/python/asterisk/apptest.py
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/lib/python/asterisk/apptest.py?view=diff&rev=4833&r1=4832&r2=4833
==============================================================================
--- asterisk/trunk/lib/python/asterisk/apptest.py (original)
+++ asterisk/trunk/lib/python/asterisk/apptest.py Tue Mar 11 11:06:53 2014
@@ -58,7 +58,13 @@
         self._event_instances = []      # The ApplicationEventInstance objects
 
         self.raw_test_config = test_config
-        self._application = self.raw_test_config['app']
+        if 'app' in self.raw_test_config:
+            self._applications = [ self.raw_test_config['app'] ]
+        elif 'apps' in self.raw_test_config:
+            self._applications = self.raw_test_config['apps']
+        else:
+            raise Exception("No 'app' or 'apps' defined in test-config")
+
         self._scenarios = self.raw_test_config['scenarios']
 
         self.register_ami_observer(self._ami_connect_handler)
@@ -102,7 +108,7 @@
                 self._event_instances.append(ae_instance)
 
             obj = ChannelObject(ami=self.ami[0],
-                                application=self._application,
+                                applications=self._applications,
                                 channel_def=channel_config)
             self._channel_objects[channel_id] = obj
             LOGGER.debug("Created channel object for %s" % channel_id)
@@ -202,20 +208,20 @@
     default_audio_exten = 'sendAudio'
 
     def __init__(self, ami,
-                 application,
+                 applications,
                  channel_def):
         ''' Create a new ChannelObject
 
         Keywords:
         ami The AMI instance to spawn the channel in
-        application The application name to test
+        applications The application names to test
         channel_def A dictionary of parameters to extract that will configure
             the channel object
         '''
 
         self._channel_id = channel_def['channel-id']
         self._channel_name = channel_def['channel-name']
-        self._application = application
+        self._applications = applications
         self._controller_context = channel_def.get('context') or \
                                    ChannelObject.default_context
         self._controller_initial_exten = channel_def.get('exten') or \
@@ -524,7 +530,7 @@
 
         if 'channel' not in event or 'application' not in event:
             return
-        if event['application'] != self._application:
+        if event['application'] not in self._applications:
             return
         if event['channel'] not in self._candidate_channels:
             # Whatever channel just entered isn't one of our channels.  This

Added: asterisk/trunk/tests/apps/agents/agent_request/nominal/configs/ast1/agents.conf
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/apps/agents/agent_request/nominal/configs/ast1/agents.conf?view=auto&rev=4833
==============================================================================
--- asterisk/trunk/tests/apps/agents/agent_request/nominal/configs/ast1/agents.conf (added)
+++ asterisk/trunk/tests/apps/agents/agent_request/nominal/configs/ast1/agents.conf Tue Mar 11 11:06:53 2014
@@ -1,0 +1,3 @@
+[1000]
+
+fullname=James Bond

Propchange: asterisk/trunk/tests/apps/agents/agent_request/nominal/configs/ast1/agents.conf
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: asterisk/trunk/tests/apps/agents/agent_request/nominal/configs/ast1/agents.conf
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Propchange: asterisk/trunk/tests/apps/agents/agent_request/nominal/configs/ast1/agents.conf
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: asterisk/trunk/tests/apps/agents/agent_request/nominal/configs/ast1/extensions.conf
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/apps/agents/agent_request/nominal/configs/ast1/extensions.conf?view=auto&rev=4833
==============================================================================
--- asterisk/trunk/tests/apps/agents/agent_request/nominal/configs/ast1/extensions.conf (added)
+++ asterisk/trunk/tests/apps/agents/agent_request/nominal/configs/ast1/extensions.conf Tue Mar 11 11:06:53 2014
@@ -1,0 +1,70 @@
+; Tests basic AgentRequest functionality and agent state.
+[default]
+
+; ----------------------------------------------------------------------
+; ***Required***
+; ----------------------------------------------------------------------
+
+exten => sendDTMF,1,NoOp()
+	same => n,Verbose(1, Sending DTMF Signal ${DTMF_TO_SEND})
+	same => n,SendDTMF(${DTMF_TO_SEND})
+	same => n,Goto(caller,wait,1)
+
+exten => sendAudio,1,NoOp()
+	same => n,Verbose(1, Sending audio file ${TALK_AUDIO})
+	same => n,Playback(${TALK_AUDIO})
+	same => n,Goto(caller,wait,1)
+
+exten => sendAudioWithDTMF,1,NoOp()
+	same => n,Verbose(1, Sending audio file ${TALK_AUDIO})
+	same => n,Playback(${TALK_AUDIO})
+	same => n,Verbose(1, Sending DTMF Signal ${DTMF_TO_SEND})
+	same => n,SendDTMF(${DTMF_TO_SEND})
+	same => n,Goto(caller,wait,1)
+
+exten => hangup,1,NoOp()
+	same => n,Verbose(1, Hanging up)
+	same => n,Hangup()
+
+exten => wait,1,NoOp()
+	same => n,Wait(10000)
+
+; ----------------------------------------------------------------------
+; Logs the agent in.
+; ----------------------------------------------------------------------
+exten => login,hint,Agent:1000
+exten => login,1,NoOp()
+    same => n,Answer()
+    same => n,AgentLogin(1000)
+
+; ----------------------------------------------------------------------
+; Sends an agent request to the agent.
+; ----------------------------------------------------------------------
+exten => request,1,NoOp()
+    same => n,Answer()
+    same => n,AgentRequest(1000)
+
+; ----------------------------------------------------------------------
+; Tests to see if the current state of the agent is NOT_INUSE.
+; ----------------------------------------------------------------------
+exten => status-avail,1,NoOp()
+    same => n,Answer()
+    same => n,ExecIf($[${DEVICE_STATE(Agent:1000)}=NOT_INUSE]?UserEvent(AvailableAgent,result:pass))
+    same => n,Hangup()
+
+; ----------------------------------------------------------------------
+; Tests to see if the current state of the agent after returning to the
+; pool is NOT_INUSE.
+; ----------------------------------------------------------------------
+exten => status-avail2,1,NoOp()
+    same => n,Answer()
+    same => n,ExecIf($[${DEVICE_STATE(Agent:1000)}=NOT_INUSE]?UserEvent(AvailableAgent2,result:pass))
+    same => n,Hangup()
+
+; ----------------------------------------------------------------------
+; Tests to see if the current state of the agent is INUSE.
+; ----------------------------------------------------------------------
+exten => status-inuse,1,NoOp()
+    same => n,Answer()
+    same => n,ExecIf($[${DEVICE_STATE(Agent:1000)}=INUSE]?UserEvent(InuseAgent,result:pass))
+    same => n,Hangup()

Propchange: asterisk/trunk/tests/apps/agents/agent_request/nominal/configs/ast1/extensions.conf
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: asterisk/trunk/tests/apps/agents/agent_request/nominal/configs/ast1/extensions.conf
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Propchange: asterisk/trunk/tests/apps/agents/agent_request/nominal/configs/ast1/extensions.conf
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: asterisk/trunk/tests/apps/agents/agent_request/nominal/test-config.yaml
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/apps/agents/agent_request/nominal/test-config.yaml?view=auto&rev=4833
==============================================================================
--- asterisk/trunk/tests/apps/agents/agent_request/nominal/test-config.yaml (added)
+++ asterisk/trunk/tests/apps/agents/agent_request/nominal/test-config.yaml Tue Mar 11 11:06:53 2014
@@ -1,0 +1,194 @@
+testinfo:
+    summary: 'Tests AgentRequest and agent state.'
+    description:
+        This test verifies that once an agent logs in, that agent is placed in a
+        pool with status NOT_INUSE. When a channel requests the agent, they are placed
+        into a basic bridge and the agent's status changes to INUSE. Once the requesting
+        channel hangs up, the agent is then returned to the pool, and that agent's
+        status changes to NOT_INUSE again.
+
+test-modules:
+    test-object:
+        config-section: test-object-config
+        typename: 'apptest.AppTest'
+
+test-object-config:
+  apps:
+    - 'AgentRequest'
+    - 'AgentLogin'
+  scenarios:
+    -
+      # Scenario
+      # An agent logs in. This spawns a second channel that requests the agent.
+      # The two should then be bridged together, and the agent's status should change
+      # to INUSE. Afterwards, the requesting channel hangs up, and the agent's
+      # status should change back to available.
+      channels:
+        -
+          channel-id: 'Agent-login'
+          channel-name: 'Local/login at default'
+          context: 'default'
+          exten: 'wait'
+          start-on-create: True
+          events:
+            -
+              type: 'headermatch'
+              conditions:
+                match:
+                  Event: 'AgentLogin'
+                  Agent: '1000'
+              actions:
+                -
+                  action-type: 'set-expected-result'
+                  expected-result: 'Agent 1000 logged in.'
+            -
+              type: 'headermatch'
+              conditions:
+                match:
+                  Event: 'BridgeEnter'
+                  Channel: 'Local/login at default-.*'
+                  BridgeType: 'agent_hold'
+              actions:
+                -
+                  action-type: 'set-expected-result'
+                  expected-result: 'Agent 1000 entered pool.'
+            -
+              type: 'headermatch'
+              conditions:
+                match:
+                  Event: 'BridgeEnter'
+                  Channel: 'Local/login at default-.*'
+                  BridgeType: 'basic'
+              actions:
+                -
+                  action-type: 'set-expected-result'
+                  expected-result: 'Agent channel connected to bridge.'
+            -
+              type: 'headermatch'
+              conditions:
+                match:
+                  Event: 'MusicOnHoldStart'
+                  Channel: 'Local/login at default-.*'
+              actions:
+                -
+                  action-type: 'set-expected-result'
+                  expected-result: 'Agent 1000 received MusicOnHoldStart event.'
+                -
+                  # Delay to work around ASTERISK-23259
+                  action-type: 'start-call'
+                  delay: 8
+                  channel-id: 'Status-AVAILABLE'
+        -
+          channel-id: 'Agent-request'
+          channel-name: 'Local/request at default'
+          context: 'default'
+          exten: 'wait'
+          events:
+            -
+              type: 'headermatch'
+              conditions:
+                match:
+                  Event: 'Newexten'
+                  Channel: 'Local/request at default-.*'
+                  Application: 'AgentRequest'
+                  AppData: '1000'
+              actions:
+                -
+                  action-type: 'set-expected-result'
+                  expected-result: 'Agent 1000 received an agent request.'
+            -
+              type: 'headermatch'
+              conditions:
+                match:
+                  Event: 'BridgeEnter'
+                  Channel: 'Local/request at default-.*'
+                  BridgeType: 'basic'
+              actions:
+                -
+                  action-type: 'set-expected-result'
+                  expected-result: 'The requesting channel entered the bridge.'
+                -
+                  action-type: 'start-call'
+                  delay: 2
+                  channel-id: 'Status-INUSE'
+
+        -
+          channel-id: 'Status-AVAILABLE'
+          channel-name: 'Local/status-avail at default'
+          context: 'default'
+          exten: 'wait'
+          events:
+            -
+              type: 'headermatch'
+              conditions:
+                match:
+                  Event: 'UserEvent'
+                  UserEvent: 'AvailableAgent'
+              requirements:
+                match:
+                  Result: 'pass'
+              actions:
+                -
+                  action-type: 'set-expected-result'
+                  expected-result: 'Agent is available.'
+                -
+                  action-type: 'start-call'
+                  channel-id: 'Agent-request'
+        -
+          channel-id: 'Status-end'
+          channel-name: 'Local/status-avail2 at default'
+          context: 'default'
+          exten: 'wait'
+          events:
+            -
+              type: 'headermatch'
+              conditions:
+                match:
+                  Event: 'UserEvent'
+                  UserEvent: 'AvailableAgent2'
+              requirements:
+                match:
+                  Result: 'pass'
+              actions:
+                -
+                  action-type: 'set-expected-result'
+                  expected-result: 'Agent is available.'
+                -
+                  action-type: 'hangup'
+                  channel-id: 'Agent-login'
+                -
+                  action-type: 'end-scenario'
+        -
+          channel-id: 'Status-INUSE'
+          channel-name: 'Local/status-inuse at default'
+          context: 'default'
+          exten: 'wait'
+          events:
+            -
+              type: 'headermatch'
+              conditions:
+                match:
+                  Event: 'UserEvent'
+                  UserEvent: 'InuseAgent'
+              requirements:
+                match:
+                  Result: 'pass'
+              actions:
+                -
+                  action-type: 'set-expected-result'
+                  expected-result: 'Agent is in use.'
+                -
+                  action-type: 'hangup'
+                  channel-id: 'Agent-request'
+                -
+                  action-type: 'start-call'
+                  channel-id: 'Status-end'
+
+properties:
+    minversion: '12.0.0'
+    dependencies:
+        - python : 'starpy'
+        - python : 'twisted'
+    tags:
+        - agents
+        - apps

Propchange: asterisk/trunk/tests/apps/agents/agent_request/nominal/test-config.yaml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: asterisk/trunk/tests/apps/agents/agent_request/nominal/test-config.yaml
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Propchange: asterisk/trunk/tests/apps/agents/agent_request/nominal/test-config.yaml
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: asterisk/trunk/tests/apps/agents/agent_request/tests.yaml
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/apps/agents/agent_request/tests.yaml?view=auto&rev=4833
==============================================================================
--- asterisk/trunk/tests/apps/agents/agent_request/tests.yaml (added)
+++ asterisk/trunk/tests/apps/agents/agent_request/tests.yaml Tue Mar 11 11:06:53 2014
@@ -1,0 +1,3 @@
+# Enter tests here in the order they should be considered for execution:
+tests:
+    - test: 'nominal'

Propchange: asterisk/trunk/tests/apps/agents/agent_request/tests.yaml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: asterisk/trunk/tests/apps/agents/agent_request/tests.yaml
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Propchange: asterisk/trunk/tests/apps/agents/agent_request/tests.yaml
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: asterisk/trunk/tests/apps/agents/tests.yaml
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/apps/agents/tests.yaml?view=diff&rev=4833&r1=4832&r2=4833
==============================================================================
--- asterisk/trunk/tests/apps/agents/tests.yaml (original)
+++ asterisk/trunk/tests/apps/agents/tests.yaml Tue Mar 11 11:06:53 2014
@@ -1,3 +1,5 @@
 # Enter tests here in the order they should be considered for execution:
 tests:
     - dir: 'agent_login'
+    - dir: 'agent_request'
+




More information about the svn-commits mailing list