[Asterisk-code-review] tests/apps/mixmonitor: Fix sporadic test failures. (testsuite[master])

Joshua Colp asteriskteam at digium.com
Mon Apr 25 10:22:54 CDT 2016


Joshua Colp has uploaded a new change for review.

  https://gerrit.asterisk.org/2697

Change subject: tests/apps/mixmonitor: Fix sporadic test failures.
......................................................................

tests/apps/mixmonitor: Fix sporadic test failures.

The tests/app/mixmonitor test executes MixMonitor on
some channels and then checks the resulting file size to
ensure they are within tolerance. This fails sometimes.
After looking at the output and the test there is a race
condition where the check occurs before the MixMonitor
thread has ended and finished writing out the file,
causing the file to be incomplete and the test to fail.

The test now waits for the 3 expected AMI events indicating
the MixMonitor thread has ended before checking the size of
the recorded files.

ASTERISK-25958 #close

Change-Id: I0b87c02b5728615755cd15a551f1cb8e40e4ad17
---
M tests/apps/mixmonitor/run-test
1 file changed, 13 insertions(+), 4 deletions(-)


  git pull ssh://gerrit.asterisk.org:29418/testsuite refs/changes/97/2697/1

diff --git a/tests/apps/mixmonitor/run-test b/tests/apps/mixmonitor/run-test
index 784bd9b..27995f7 100755
--- a/tests/apps/mixmonitor/run-test
+++ b/tests/apps/mixmonitor/run-test
@@ -27,7 +27,8 @@
     def __init__(self):
         super(MixMonitorTest, self).__init__()
 
-        self.passed = False
+        # How many MixMonitor instances have ended, all 3 must end before checking file sizes
+        self.mixmonitor_ended = 0
 
         # playback file is 2559 bytes of ulaw,
         # that will come out to be ~41118 of wav
@@ -65,7 +66,16 @@
             LOGGER.error(name + " size is not within the size tolerance.")
             self.passed = False
 
-    def read_result(self):
+    def state_mixmonitor_end(self, ami, event):
+        if event.get("state") != "MIXMONITOR_END":
+            return
+
+        self.mixmonitor_ended += 1
+
+        if self.mixmonitor_ended != 3:
+            LOGGER.info("All MixMonitor applications have not yet ended.")
+            return
+
         self.passed = True
         self.stop_reactor()
         LOGGER.info("Checking MixMonitor recorded files...")
@@ -120,11 +130,10 @@
             self.stop_reactor()
             return
 
-        self.read_result()
-
     def ami_connect(self, ami):
         self.ami = ami
         self.ami.registerEvent("UserEvent", self.check_test1)
+        self.ami.registerEvent("TestEvent", self.state_mixmonitor_end)
 
         self.ami.setVar(channel="", variable="TESTAUDIO1", value=self.audiofile1)
         self.ami.setVar(channel="", variable="TESTAUDIO2", value=self.audiofile2)

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I0b87c02b5728615755cd15a551f1cb8e40e4ad17
Gerrit-PatchSet: 1
Gerrit-Project: testsuite
Gerrit-Branch: master
Gerrit-Owner: Joshua Colp <jcolp at digium.com>



More information about the asterisk-code-review mailing list