Explorar o código

Added an automatic test: stressing import.php

git-svn-id: http://svn.code.sf.net/p/itop/code/trunk@823 a333f486-631f-4898-b8df-5754b55c2be0
romainq %!s(int64=14) %!d(string=hai) anos
pai
achega
240bef3259
Modificáronse 2 ficheiros con 61 adicións e 5 borrados
  1. 9 1
      core/test.class.inc.php
  2. 52 4
      pages/testlist.inc.php

+ 9 - 1
core/test.class.inc.php

@@ -252,7 +252,15 @@ abstract class TestWebServices extends TestHandler
 		$fp = @fopen($sUrl, 'rb', false, $ctx);
 		if (!$fp)
 		{
-			throw new Exception("Problem with $sUrl, $php_errormsg");
+			global $php_errormsg;
+			if (isset($php_errormsg))
+			{
+				throw new Exception("Problem with $sUrl, $php_errormsg");
+			}
+			else
+			{
+				throw new Exception("Problem with $sUrl");
+			}
 		}
 		$response = @stream_get_contents($fp);
 		if ($response === false)

+ 52 - 4
pages/testlist.inc.php

@@ -1206,7 +1206,7 @@ class TestImportREST extends TestWebServices
 
 	static public function GetDescription()
 	{
-		return 'Bulk load in the background';
+		return 'Test various options and fonctionality of import.php';
 	}
 
 	protected function DoExecSingleLoad($aLoadSpec)
@@ -1230,12 +1230,21 @@ class TestImportREST extends TestWebServices
 
 		$sArguments = implode('<br/>', $aGetParamReport);
 
+		if (strlen($sCsvData) > 5000)
+		{
+			$sCsvDataViewable = 'INPUT TOO LONG TO BE DISPLAYED ('.strlen($sCsvData).")\n".substr($sCsvData, 0, 500)."\n... TO BE CONTINUED";
+		}
+		else
+		{
+			$sCsvDataViewable = $sCsvData;
+		}
+
 		echo "<div style=\"\">\n";
-		echo "   <div style=\"float: left; padding: 5; background-color: #eeeeff;\">\n";
+		echo "   <div style=\"float:left; width:45%; padding:5; background-color:#eeeeff;\">\n";
 		echo "      $sArguments\n";
 		echo "   </div>\n";
-		echo "   <div style=\"float: right; padding: 5; background-color: #eeeeff\">\n";
-		echo "      <pre class=\"vardump\">$sCsvData</pre>\n";
+		echo "   <div style=\"float:right; width:45%; padding:5; background-color:#eeeeff\">\n";
+		echo "      <pre class=\"vardump\">$sCsvDataViewable</pre>\n";
 		echo "   </div>\n";
 		echo "</div>\n";
 
@@ -1495,6 +1504,45 @@ class TestImportREST extends TestWebServices
 	}
 }
 
+///////////////////////////////////////////////////////////////////////////
+// Test massive data load
+///////////////////////////////////////////////////////////////////////////
+
+class TestImportRESTMassive extends TestImportREST
+{
+	static public function GetName()
+	{
+		return 'CSV import (REST) - HUGE data set (20000 PCs)';
+	}
+
+	static public function GetDescription()
+	{
+		return 'Stress import.php';
+	}
+
+	protected function DoExecute()
+	{
+		$aLoadSpec = array(
+			'desc' => 'Missing class',
+			'args' => array(
+				'class' => 'PC',
+				'output' => 'summary',
+			),
+			'csvdata' => "name;org_id;brand\n",
+		);
+		$iMaxPC = 20000;
+		for($i = 0 ; $i <= $iMaxPC ; $i++)
+		{
+			$aLoadSpec['csvdata'] .= "pc.import.$i;2;Combodo\n";
+		}
+		$this->DoExecSingleLoad($aLoadSpec);
+	}
+}
+
+
+///////////////////////////////////////////////////////////////////////////
+// Test SOAP services
+///////////////////////////////////////////////////////////////////////////
 
 $aWebServices = array(
 	array(