Browse Source

fix headers for kohana tests

Keith Newman 9 years ago
parent
commit
9b1a556a57

+ 12 - 7
frameworks/PHP/kohana/application/classes/Controller/Bench.php

@@ -10,11 +10,20 @@ Class Controller_Bench extends Controller
     }
 
     public function action_db()
+    {
+        $query = DB::query(Database::SELECT, 'SELECT * FROM World WHERE id = :id')->bind(':id', $id);
+
+        $world = $query->param(':id', mt_rand(1, 10000))->execute()->current();
+
+        $this->response
+            ->headers(array('Content-Type' => 'application/json'))
+            ->body(json_encode($world));
+    }
+
+    public function action_queries()
     {
         $queries = $this->request->param('queries', false);
-        $queries = $queries
-                    ? $queries
-                    : 1;
+        $queries = is_numeric($queries) ? min(max($queries, 1), 500) : 1;
 
         $worlds = array();
 
@@ -24,10 +33,6 @@ Class Controller_Bench extends Controller
             $worlds[] = $query->param(':id', mt_rand(1, 10000))->execute()->current();
         }
 
-        if ($queries == 1) {
-            $worlds = $worlds[0];
-        }
-
         $this->response
             ->headers(array('Content-Type' => 'application/json'))
             ->body(json_encode($worlds));

+ 1 - 1
frameworks/PHP/kohana/application/config/database.php

@@ -14,7 +14,7 @@ return array
 		 * string   password    database password
 		 * boolean  persistent  use persistent connections?
 		 */
-	    'dsn'        => 'mysql:host=localhost;dbname=hello_world',
+	    'dsn'        => 'mysql:host=127.0.0.1;dbname=hello_world',
             'username'   => 'benchmarkdbuser',
             'password'   => 'benchmarkdbpass',
             'persistent' => FALSE,

+ 1 - 1
frameworks/PHP/kohana/benchmark_config.json

@@ -22,7 +22,7 @@
     "raw": {
       "setup_file": "setup",
       "db_url": "/bench/db",
-      "query_url": "/bench/db/",
+      "query_url": "/bench/queries/",
       "fortune_url": "/bench/fortunes",
       "port": 8080,
       "approach": "Realistic",