[asterisk-commits] mjordan: testsuite/asterisk/trunk r4796 - in /asterisk/trunk/tests/pbx/ast_db...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Thu Mar 6 13:32:01 CST 2014


Author: mjordan
Date: Thu Mar  6 13:31:56 2014
New Revision: 4796

URL: http://svnview.digium.com/svn/testsuite?view=rev&rev=4796
Log:
tests/pbx/ast_db: Solve race conditions from UserEvents in AstDB test

This patch migrates the tests/pbx/ast_db test over to the AppTest test object.
Previously, this test used SimpleTestCase, but the sheer volume of UserEvents
became difficult for that test to track. Since SimpleTestCase can intercept
the UserEvents, the author decided that this approach would be easier.

patches:
  ast_db uploaded by Benjamin Ford (license 6580)

Modified:
    asterisk/trunk/tests/pbx/ast_db/configs/ast1/extensions.conf
    asterisk/trunk/tests/pbx/ast_db/test-config.yaml

Modified: asterisk/trunk/tests/pbx/ast_db/configs/ast1/extensions.conf
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/pbx/ast_db/configs/ast1/extensions.conf?view=diff&rev=4796&r1=4795&r2=4796
==============================================================================
--- asterisk/trunk/tests/pbx/ast_db/configs/ast1/extensions.conf (original)
+++ asterisk/trunk/tests/pbx/ast_db/configs/ast1/extensions.conf Thu Mar  6 13:31:56 2014
@@ -1,4 +1,32 @@
 ; Tests the AstDB.
+
+; ----------------------------------------------------------------------
+; ***Required***
+; ----------------------------------------------------------------------
+[default]
+exten => sendDTMF,1,NoOp()
+    same => n,Verbose(1, Sending DTMF Signal ${DTMF_TO_SEND})
+    same => n,SendDTMF(${DTMF_TO_SEND})
+    same => n,Goto(default,wait,1)
+
+exten => sendAudio,1,NoOp()
+    same => n,Verbose(1, Sending audio file ${TALK_AUDIO})
+    same => n,Playback(${TALK_AUDIO})
+    same => n,Goto(default,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(default,wait,1)
+
+exten => hangup,1,NoOp()
+    same => n,Verbose(1, Hanging up)
+    same => n,Hangup()
+
+exten => wait,1,NoOp()
+    same => n,Wait(10000)
 
 [test]
 
@@ -9,15 +37,15 @@
 exten => s1,1,NoOp()
     same => n,Answer()
     same => n,Set(DB(test/count)=100)
-    same => n,ExecIf($[${DB(test/count)}=100&${DB_RESULT}=100]?UserEvent(Test1,result:pass))
+    same => n,ExecIf($[${DB(test/count)}=100&${DB_RESULT}=100]?UserEvent(Test1,result:pass):UserEvent(Test1,result:fail))
     same => n,Set(DB(test/count2)=200)
-    same => n,ExecIf($[${DB(test/count)}=100&${DB(test/count2)}=200]?UserEvent(Test1,result:pass))
+    same => n,ExecIf($[${DB(test/count)}=100&${DB(test/count2)}=200]?UserEvent(Test1,result:pass):UserEvent(Test1,result:fail))
     same => n,Set(DB(test/count)=300)
-    same => n,ExecIf($[${DB(test/count)}=300]?UserEvent(Test1,result:pass))
+    same => n,ExecIf($[${DB(test/count)}=300]?UserEvent(Test1,result:pass):UserEvent(Test1,result:fail))
     same => n,Set(DB(othertest/count)=400)
-    same => n,ExecIf($[${DB(test/count)}=300&${DB(othertest/count)}=400]?UserEvent(Test1,result:pass))
+    same => n,ExecIf($[${DB(test/count)}=300&${DB(othertest/count)}=400]?UserEvent(Test1,result:pass):UserEvent(Test1,result:fail))
     same => n,Set(COUNT=${DB(notest/count)})
-    same => n,ExecIf($[${LEN(${COUNT})}=0]?UserEvent(Test1,result:pass))
+    same => n,ExecIf($[${LEN(${COUNT})}=0]?UserEvent(Test1,result:pass):UserEvent(Test1,result:fail))
     same => n,Hangup()
 
 ; ----------------------------------------------------------------------
@@ -26,17 +54,17 @@
 
 exten => s2,1,NoOp()
     same => n,Answer()
-    same => n,ExecIf($[${DB_EXISTS(thistest/count)}=0]?UserEvent(Test2,result:pass))
+    same => n,ExecIf($[${DB_EXISTS(thistest/count)}=0]?UserEvent(Test2,result:pass):UserEvent(Test2,result:fail))
     same => n,Set(KEY_LIST=${DB_KEYS(thistest)})
-    same => n,ExecIf($[${LEN(${KEY_LIST})}=0]?UserEvent(Test2,result:pass))
+    same => n,ExecIf($[${LEN(${KEY_LIST})}=0]?UserEvent(Test2,result:pass):UserEvent(Test2,result:fail))
     same => n,Set(DB(thistest/count)=100)
-    same => n,ExecIf($[${DB_EXISTS(thistest/count)}=1]?UserEvent(Test2,result:pass))
-    same => n,ExecIf($[${DB_RESULT}=100]?UserEvent(Test2,result:pass))
+    same => n,ExecIf($[${DB_EXISTS(thistest/count)}=1]?UserEvent(Test2,result:pass):UserEvent(Test2,result:fail))
+    same => n,ExecIf($[${DB_RESULT}=100]?UserEvent(Test2,result:pass):UserEvent(Test2,result:fail))
     same => n,Set(KEY_LIST=${DB_KEYS(thistest)})
-    same => n,ExecIf($[${KEY_LIST}=count]?UserEvent(Test2,result:pass))
+    same => n,ExecIf($["${KEY_LIST}"="count"]?UserEvent(Test2,result:pass):UserEvent(Test2,result:fail))
     same => n,Set(DB(thistest/count2)=200)
     same => n,Set(KEY_LIST=${DB_KEYS(thistest)})
-    same => n,ExecIf($[${KEY_LIST}=count,count2]?UserEvent(Test2,result:pass))
+    same => n,ExecIf($["${KEY_LIST}"="count,count2"]?UserEvent(Test2,result:pass):UserEvent(Test2,result:fail))
     same => n,Hangup()
 
 ; ----------------------------------------------------------------------
@@ -46,10 +74,10 @@
 exten => s3,1,NoOp()
     same => n,Answer()
     same => n,Set(COUNT=${DB_DELETE(sometest/count)})
-    same => n,ExecIf($[${LEN(${COUNT})}=0]?UserEvent(Test3,result:pass))
+    same => n,ExecIf($[${LEN(${COUNT})}=0]?UserEvent(Test3,result:pass):UserEvent(Test3,result:fail))
     same => n,Set(DB(sometest/count)=100)
     same => n,Set(COUNT=${DB_DELETE(sometest/count)})
-    same => n,ExecIf($[${COUNT}=100&${DB_RESULT}=100]?UserEvent(Test3,result:pass))
+    same => n,ExecIf($[${COUNT}=100&${DB_RESULT}=100]?UserEvent(Test3,result:pass):UserEvent(Test3,result:fail))
     same => n,Set(COUNT=${DB(sometest/count)})
-    same => n,ExecIf($[${LEN(${COUNT})}=0]?UserEvent(Test3,result:pass))
+    same => n,ExecIf($[${LEN(${COUNT})}=0]?UserEvent(Test3,result:pass):UserEvent(Test3,result:fail))
     same => n,Hangup()

Modified: asterisk/trunk/tests/pbx/ast_db/test-config.yaml
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/pbx/ast_db/test-config.yaml?view=diff&rev=4796&r1=4795&r2=4796
==============================================================================
--- asterisk/trunk/tests/pbx/ast_db/test-config.yaml (original)
+++ asterisk/trunk/tests/pbx/ast_db/test-config.yaml Thu Mar  6 13:31:56 2014
@@ -14,62 +14,151 @@
 
 test-modules:
     test-object:
-        config-section: test-config
-        typename: 'test_case.SimpleTestCase'
-    modules:
-      -
-        config-section: 'ami-config'
-        typename: 'ami.AMIEventModule'
+        config-section: test-object-config
+        typename: 'apptest.AppTest'
 
-test-config:
-  spawn-after-hangup: True
-  expected_events: 14
-  test-iterations:
+test-object-config:
+  app: 'DB'
+  scenarios:
     -
-      channel: 'Local/s1 at test'
-      application: 'Echo'
-    -
-      channel: 'Local/s2 at test'
-      application: 'Echo'
-    -
-      channel: 'Local/s3 at test'
-      application: 'Echo'
-
-ami-config:
-  -
-    type: 'headermatch'
-    conditions:
-        match:
-            Event: 'UserEvent'
-            UserEvent: 'Test1'
-    requirements:
-        match:
-            Result: 'pass'
-    count: '5'
-  -
-    type: 'headermatch'
-    conditions:
-        match:
-            Event: 'UserEvent'
-            UserEvent: 'Test2'
-    requirements:
-        match:
-            Result: 'pass'
-    count: '6'
-  -
-    type: 'headermatch'
-    conditions:
-        match:
-            Event: 'UserEvent'
-            UserEvent: 'Test3'
-    requirements:
-        match:
-            Result: 'pass'
-    count: '3'
+      # Scenario 1
+      # Runs through the tests in the description. Once a channel hangs up,
+      # the next channel will be called.
+      channels:
+        -
+          channel-id: 'S1'
+          channel-name: 'Local/s1 at test'
+          context: 'default'
+          exten: 'wait'
+          start-on-create: 'True'
+          events:
+            -
+              type: 'headermatch'
+              conditions:
+                match:
+                  Event: 'UserEvent'
+                  UserEvent: 'Test1'
+              requirements:
+                match:
+                  Result: 'pass'
+              actions:
+                -
+                  action-type: 'set-expected-result'
+                  expected-result: 'UserEvent Test1 passed'
+            -
+              type: 'headermatch'
+              conditions:
+                match:
+                  Event: 'UserEvent'
+                  UserEvent: 'Test1'
+                  Result: 'fail'
+              actions:
+                -
+                  action-type: 'fail-test'
+                  message: 'UserEvent Test1 came up with result fail'
+            -
+              type: 'headermatch'
+              conditions:
+                match:
+                  Event: 'Hangup'
+                  Channel: 'Local/s1 at test-.*'
+              actions:
+                -
+                  action-type: 'set-expected-result'
+                  expected-result: 'S1 is hanging up'
+                -
+                  action-type: 'start-call'
+                  channel-id: 'S2'
+        -
+          channel-id: 'S2'
+          channel-name: 'Local/s2 at test'
+          context: 'default'
+          exten: 'wait'
+          events:
+            -
+              type: 'headermatch'
+              conditions:
+                match:
+                  Event: 'UserEvent'
+                  UserEvent: 'Test2'
+              requirements:
+                match:
+                  Result: 'pass'
+              actions:
+                -
+                  action-type: 'set-expected-result'
+                  expected-result: 'UserEvent Test2 passed'
+            -
+              type: 'headermatch'
+              conditions:
+                match:
+                  Event: 'UserEvent'
+                  UserEvent: 'Test2'
+                  Result: 'fail'
+              actions:
+                -
+                  action-type: 'fail-test'
+                  message: 'UserEvent Test2 came up with result fail'
+            -
+              type: 'headermatch'
+              conditions:
+                match:
+                  Event: 'Hangup'
+                  Channel: 'Local/s2 at test-.*'
+              actions:
+                -
+                  action-type: 'set-expected-result'
+                  expected-result: 'S2 is hanging up'
+                -
+                  action-type: 'start-call'
+                  channel-id: 'S3'
+        -
+          channel-id: 'S3'
+          channel-name: 'Local/s3 at test'
+          context: 'default'
+          exten: 'wait'
+          events:
+            -
+              type: 'headermatch'
+              conditions:
+                match:
+                  Event: 'UserEvent'
+                  UserEvent: 'Test3'
+              requirements:
+                match:
+                  Result: 'pass'
+              actions:
+                -
+                  action-type: 'set-expected-result'
+                  expected-result: 'UserEvent Test3 passed'
+            -
+              type: 'headermatch'
+              conditions:
+                match:
+                  Event: 'UserEvent'
+                  UserEvent: 'Test3'
+                  Result: 'fail'
+              actions:
+                -
+                  action-type: 'fail-test'
+                  message: 'UserEvent Test3 came up with result fail'
+            -
+              type: 'headermatch'
+              conditions:
+                match:
+                  Event: 'Hangup'
+                  Channel: 'Local/s3 at test-.*'
+              actions:
+                -
+                  action-type: 'set-expected-result'
+                  expected-result: 'S3 is hanging up'
+                -
+                  action-type: 'end-scenario'
 
 properties:
     minversion: '11.0.0'
     dependencies:
+        - buildoption: 'TEST_FRAMEWORK'
         - python : 'twisted'
         - python : 'starpy'
     tags:




More information about the asterisk-commits mailing list