[svn-commits] mnicholson: testsuite/asterisk/trunk r359 - /asterisk/trunk/asttest/lib/lua/

SVN commits to the Digium repositories svn-commits at lists.digium.com
Mon Jun 7 11:32:04 CDT 2010


Author: mnicholson
Date: Mon Jun  7 11:32:00 2010
New Revision: 359

URL: http://svnview.digium.com/svn/testsuite?view=rev&rev=359
Log:
Execute 'core waitfullybooted' to ensure asterisk is fully booted from asterisk:spawn()

Modified:
    asterisk/trunk/asttest/lib/lua/astlib.lua

Modified: asterisk/trunk/asttest/lib/lua/astlib.lua
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/asttest/lib/lua/astlib.lua?view=diff&rev=359&r1=358&r2=359
==============================================================================
--- asterisk/trunk/asttest/lib/lua/astlib.lua (original)
+++ asterisk/trunk/asttest/lib/lua/astlib.lua Mon Jun  7 11:32:00 2010
@@ -75,7 +75,31 @@
 	self:generate_essential_configs()
 	self:write_configs()
 	self:_spawn()
-	posix.sleep(3)
+
+	-- wait for asterisk to be fully booted.  We do this by reading the
+	-- output of the 'core waitfullybooted' command and looking for the
+	-- string 'fully booted'.  We will try 5 times before completely giving
+	-- up with a one second delay in between each try.  We need to loop
+	-- like this in order to give asterisk time to start the CLI socket.
+	local booted
+	for _=1,5 do
+		local err
+		booted, err = self:cli("core waitfullybooted")
+		if not booted then
+			if err then
+				error("error waiting for asterisk to fully boot: " .. err)
+			else
+				error("error waiting for asterisk to fully boot")
+			end
+		end
+		if booted:find("fully booted") then
+			break
+		end
+		posix.sleep(1)
+	end
+	if not booted:find("fully booted") then
+		error("error waiting for asterisk to fully boot: " .. booted)
+	end
 end
 
 function asterisk:spawn_and_wait()




More information about the svn-commits mailing list