From b38f67b7162f7d3e5ca75eae58be06163879d22c Mon Sep 17 00:00:00 2001 From: Triatmoko Date: Fri, 18 Nov 2011 02:44:10 +0100 Subject: found error on the smart test --- Under-Testing/Server-Code-New/gsmselftest.py | 5 +- Under-Testing/Server-Code-New/truthtableClass.py | 3 +- Under-Testing/Website/mutexSmartTest.php | 13 +- Under-Testing/Website/mutexTry.php | 358 +++++++++++------------ 4 files changed, 184 insertions(+), 195 deletions(-) diff --git a/Under-Testing/Server-Code-New/gsmselftest.py b/Under-Testing/Server-Code-New/gsmselftest.py index 1aeaa16..0824cf4 100644 --- a/Under-Testing/Server-Code-New/gsmselftest.py +++ b/Under-Testing/Server-Code-New/gsmselftest.py @@ -209,8 +209,7 @@ def smartTest(): testDest(callFrom, callTo, 1) gsmRZList.remove(callTo) destList.remove(callTo) - - + for callFrom in gsmRZList: i = random.randint(0, len(destList)-1) #Check whether the caller and dest are same @@ -356,7 +355,7 @@ def doSmartTest(status): if status == 'NAGIOS': initNagiosString(result) - elif status == True: + elif status == False: initTrueTable(result) if status == True: diff --git a/Under-Testing/Server-Code-New/truthtableClass.py b/Under-Testing/Server-Code-New/truthtableClass.py index cf20bc8..3195dee 100644 --- a/Under-Testing/Server-Code-New/truthtableClass.py +++ b/Under-Testing/Server-Code-New/truthtableClass.py @@ -85,7 +85,7 @@ class trueTable: if status[2] == 'OK': self.OK = self.OK+1 - elif status[2] == 'NOT OK: + elif status[2] == 'NOT OK': self.FAILED = self.FAILED+1 else: self.handlerError = self.handlerError+1 @@ -102,6 +102,7 @@ class trueTable: if device[0:5] == 'GSMEx' or device == 'landline': externalRZList.append(device) # fetch into the list self.db.closeDBConn() + lists = self.resultsList self.nanoBts = list() gsmResultList = list() diff --git a/Under-Testing/Website/mutexSmartTest.php b/Under-Testing/Website/mutexSmartTest.php index 26e51dc..a44b121 100644 --- a/Under-Testing/Website/mutexSmartTest.php +++ b/Under-Testing/Website/mutexSmartTest.php @@ -125,7 +125,18 @@ if ($locking == '1') '; - ob_implicit_flush(1); + ob_implicit_flush(1); + sleep(6); + $pings = mysql_query("select * from PingResultTable where taskNo=(select max(taskNo) from PingResultTable)"); + + while($row = mysql_fetch_array($pings)) + { + $SIPP = $row['sipServer']; + $LANDLINEP = $row['sipGate']; + $UNISIPP = $row['unisip']; + $NANOBTS1P = $row['gsmBox1']; + $NANOBTS2P = $row['gsmBox2']; + } } elseif ($received == "TEST DONE\n") { diff --git a/Under-Testing/Website/mutexTry.php b/Under-Testing/Website/mutexTry.php index 584c4cc..b09c702 100644 --- a/Under-Testing/Website/mutexTry.php +++ b/Under-Testing/Website/mutexTry.php @@ -10,19 +10,17 @@ d> @apache_setenv('no-gzip',1); @ini_set('zlib.output_compression',0); @ini_set('implicit_flush',1); -//Connection stuff -//DB + include 'dbconnection.php'; -//Socket +#Socket Config $port = 34500; $ip = 'localhost'; $conn = mysql_connect($dbhost, $dbuser, $dbpass) or die('Error connecting to mysql'); -//$dbname = 'gsmselftesting'; mysql_select_db($dbname); -//End of connection stuff + include 'mutexFunctions.php'; //mutex functions, isfree, lock and release include 'insertData.php'; //insert task functions @@ -33,139 +31,123 @@ $locking = isLocked($nameOfLock);//Check if the webpage is already open if ($locking == '1') //1 means nobody is on the website { - $lockMe = Lock($nameOfLock,$timeToKeepTheMutex); //Set a mutex for the webpage - if ($lockMe == '1') //1 means a successful lock - { - - include 'post.php'; // read posted data and add them to the database -// echo 'WE had errors: '. $errorAdding; - //stuff to do here - //check if the software is running! - $softwareLock = 'SoftwareStarted'; - - //$taskAmount= 1 - if($taskAmount != 0) - { - $softwareRunning = isLocked($softwareLock); - if($softwareRunning == '1') //1 means software is not started yet, start it - { - $startApp = fsockopen($ip, 34600, $errno, $error, 5); - if (!$startApp) - { - printf('THE SOFTWARE THAT SHOULD RUN IN BACKGROUND IS NOT RUNNING!'); - } - else - { - socket_set_timeout( $startApp, 50); //one should set the number of the longest test, so we can define the timeout - fwrite($startApp, "START APP"); - usleep(2500); - fclose($startApp); - } - - //exec("/usr/bin/python /var/www/tricode/gsmselftest2.py > /dev/null 2>&1 &"); //start the software in background and don't wait for any output - sleep(6); //sleep half second till the software starts - //the software should be running already and set the lock, now we test it and then connect to it! + $lockMe = Lock($nameOfLock,$timeToKeepTheMutex); //Set a mutex for the webpage + if ($lockMe == '1') //1 means a successful lock + { + + include 'post.php'; // read posted data and add them to the database + $softwareLock = 'SoftwareStarted'; + + if($taskAmount != 0) + { + $softwareRunning = isLocked($softwareLock); + if($softwareRunning == '1') //1 means software is not started yet, start it + { + $startApp = fsockopen($ip, 34600, $errno, $error, 5); + if (!$startApp) + { + printf('THE SOFTWARE THAT SHOULD RUN IN BACKGROUND IS NOT RUNNING!'); + } + else + { + socket_set_timeout( $startApp, 50); //one should set the number of the longest test, so we can define the timeout + fwrite($startApp, "START APP"); + usleep(2500); + fclose($startApp); + } + sleep(5); //sleep till the software starts + //the software should be running already and set the lock, now we test it and then connect to it! - $softwareRunning1 = isLocked($softwareLock); - if($softwareRunning1 == '0') //Software running and waiting for connection! - { - //try to open the socket and connect to the software - $fp = fsockopen($ip, $port, $errno, $error, 5); - - if (!$fp) - { - echo 'Could not open the socket or connect to the testing software! Check ports on both sides!'; - - } - else - { - socket_set_timeout($fp,50); //one should set the number of the longest test, so we can define the timeout function (it is the number after "$fp,") - - fwrite($fp, "START TEST"); - - //fwrite($fp, "SMART TEST"); //send command to start the tests - if(!feof($fp)) - { - while(!feof($fp)) - { - $received = fgets($fp, 128); //receive data! - - if ($received == "CONFIRM\n") //we got the confirmation from the testing software - { - //test finished successfully - - $GSMRZ1 = 0; - $GSMRZ2 = 0; - $GSMRZ3 = 0; - - $SIP = 0; - $UNISIP = 0; - $LANDLINE = 0; - $LSFKS = 0; - - $GSMEE = 0; - $GSMEV = 0; - $GSMET = 0; - $GSMEO = 0; - - $SIPP = 2; - $LANDLINEP = 2; - $UNISIPP = 2; - $NANOBTS1P = 2; - $NANOBTS2P = 2; - /////////// end of test! - echo str_pad(' ',4096).'
'."\n"; - ob_implicit_flush(1); - - echo '
- - - - - - - - - - - '; - ob_implicit_flush(1); - sleep(6); - $pings = mysql_query("select * from PingResultTable where taskNo=(select max(taskNo) from PingResultTable)"); - - while($row = mysql_fetch_array($pings)) - { - // echo $row['taskNo']; - $SIPP = $row['sipServer']; - $LANDLINEP = $row['sipGate']; - $UNISIPP = $row['unisip']; - $NANOBTS1P = $row['gsmBox1']; - $NANOBTS2P = $row['gsmBox2']; - } - } - elseif ($received == "TEST DONE\n") - { + $softwareRunning1 = isLocked($softwareLock); + if($softwareRunning1 == '0') //Software running and waiting for connection! + { + //try to open the socket and connect to the software + $fp = fsockopen($ip, $port, $errno, $error, 5); + + if (!$fp) + { + echo 'Could not open the socket or connect to the testing software! Check ports on both sides!'; + } + else + { + socket_set_timeout($fp,50); + fwrite($fp, "START TEST"); + + if(!feof($fp)) + { + while(!feof($fp)) + { + $received = fgets($fp, 128); //receive data! + + if ($received == "CONFIRM\n") //we got the confirmation from the testing software + { + $GSMRZ1 = 0; + $GSMRZ2 = 0; + $GSMRZ3 = 0; + + $SIP = 0; + $UNISIP = 0; + $LANDLINE = 0; + $LSFKS = 0; + + $GSMEE = 0; + $GSMEV = 0; + $GSMET = 0; + $GSMEO = 0; + + $SIPP = 2; + $LANDLINEP = 2; + $UNISIPP = 2; + $NANOBTS1P = 2; + $NANOBTS2P = 2; + echo str_pad(' ',4096).'
'."\n"; + ob_implicit_flush(1); + echo '
+
From: To: Message: Status:
+ + + + + + + + + '; + ob_implicit_flush(1); + sleep(6); + $pings = mysql_query("select * from PingResultTable where taskNo=(select max(taskNo) from PingResultTable)"); + + while($row = mysql_fetch_array($pings)) + { + $SIPP = $row['sipServer']; + $LANDLINEP = $row['sipGate']; + $UNISIPP = $row['unisip']; + $NANOBTS1P = $row['gsmBox1']; + $NANOBTS2P = $row['gsmBox2']; + } + } + elseif ($received == "TEST DONE\n") + { - echo '
From: To: Message: Status:
'; - echo '
'; - echo '"; - echo ''; - ob_implicit_flush(1); - usleep(100); - fwrite($fp, 'DISCONNECT'); //tell the testing software it may close - break; - } - else - { - //parse the received data! - $received = str_replace("\n",'',$received); - $dataForTable = explode("|", $received); - $callFrom = strtoupper($dataForTable[1]); - $callTo = strtoupper($dataForTable[2]); - $testStatus = strtoupper($dataForTable[3]); - //ADD HERE THE TEST CASES BUT MAKE IT INSIDE OF A FILE (e.q. include 'testing.php'); HERE I PUT IT ONLY FOR EXAMPLE PURPOSES! + echo ''; + echo ''; + echo '"; +echo ''; + ob_implicit_flush(1); + usleep(100); + fwrite($fp, 'DISCONNECT'); //tell the testing software it may close + break; + } + else + { + //parse the received data! + $received = str_replace("\n",'',$received); + $dataForTable = explode("|", $received); + $callFrom = strtoupper($dataForTable[1]); + $callTo = strtoupper($dataForTable[2]); + $testStatus = strtoupper($dataForTable[3]); if($callFrom == 'SIP' || $callTo == 'SIP') { @@ -947,64 +929,60 @@ if ($locking == '1') //1 means nobody is on the website } } } - echo ' - '. $dataForTable[1] . ' - '. $dataForTable[2] . ' - ' . $dataForTable[4] . ' - ' . $dataForTable[3] . ' - '; - //echo $received . '
'; - ob_implicit_flush(1); - usleep(100); - fwrite($fp, "CONTINUE"); //tell the software to proceed with the test and confirm receiving data - } - } - } - - fclose($fp);//close the soccket and the connection - - } + echo ' + '. $dataForTable[1] . ' + '. $dataForTable[2] . ' + ' . $dataForTable[4] . ' + ' . $dataForTable[3] . ' + '; + ob_implicit_flush(1); + usleep(100); + fwrite($fp, "CONTINUE"); //tell the software to proceed with the test and confirm receiving data + } + } + } + + fclose($fp);//close the soccket and the connection + + } - } - elseif($softwareRunning1 == '1') - { - echo 'Testing software was not started(didn\'t obtain the lock)! Check it!'; - } - else - { - echo 'Testing software didn\'t obtain the lock'; - } - } - elseif($softwareRunning == '0') //0 means the software is still running in the background - { - echo 'Testing software is still running! Maybe you should kill it (if not started manually!)'; - } - else - { - echo 'We have an unknown error! Refresh te web page!'; - } - - //$release = ReleaseLock($nameOfLock); - //echo $release . "
"; - } - else - { - echo 'No single test was selected! Please go back and select at least one test'; - } - } - elseif($lockMe == '0') //0 means if the attempt timed out (for example, because another client has previously locked the name) - { - echo 'Someone was faster than you'; - } - else - { - // # if an error occurred (such as running out of memory or the thread was killed with - echo 'We have an error here'; - } -} + } + elseif($softwareRunning1 == '1') + { + echo 'Testing software was not started(didn\'t obtain the lock)! Check it!'; + } + else + { + echo 'Testing software didn\'t obtain the lock'; + } + } + elseif($softwareRunning == '0') //0 means the software is still running in the background + { + echo 'Testing software is still running! Maybe you should kill it (if not started manually!)'; + } + else + { + echo 'We have an unknown error! Refresh te web page!'; + } + } + else + { + echo 'No single test was selected! Please go back and select at least one test'; + } + } + elseif($lockMe == '0') //0 means if the attempt timed out (for example, because another client has previously locked the name) + { + echo 'Someone was faster than you'; + } + else + { + // # if an error occurred (such as running out of memory or the thread was killed with + echo 'We have an error here'; + } + } elseif ($locking == '0') //0 means somebody is already on the web site { - echo 'Somebody is using the web site already!' . "
"; +echo 'Somebody is using the web site already!' . "
"; } else { -- cgit v1.2.3-55-g7522