Browse Source

rails version of update test

Patrick Falls 12 years ago
parent
commit
b9fbdad1e8

+ 1 - 1
framework_test.py

@@ -154,7 +154,7 @@ class FrameworkTest:
 
     # Update
     try:
-      print "VERIFYING Update (" + self.update_url + ") ..."
+      print "VERIFYING Update (" + self.update_url + "2) ..."
       url = self.benchmarker.generate_url(self.update_url, self.port)
       subprocess.check_call(["curl", "-f", url])
       print ""

+ 15 - 0
rails/app/controllers/hello_world_controller.rb

@@ -20,4 +20,19 @@ class HelloWorldController < ApplicationController
     @fortunes << Fortune.new(:message => "Additional fortune added at request time.")
     @fortunes = @fortunes.sort { |x, y| x.message <=> y.message }
   end
+
+  def update
+    queries = (params[:queries] || 1).to_i
+
+    results = (1..queries).map do
+      # get a random row from the database, which we know has 10000
+      # rows with ids 1 - 10000
+      world = World.find(Random.rand(10000) + 1)
+      world.randomNumber = Random.rand(10000) + 1
+      world.save
+
+      world
+    end
+    render :json => results
+  end
 end

+ 2 - 0
rails/benchmark_config

@@ -7,6 +7,7 @@
       "db_url": "/hello_world/db",
       "query_url": "/hello_world/db?queries=",
       "fortune_url": "/fortune",
+      "update_url": "/rupdate",
       "port": 8080,
       "sort": 16
     },
@@ -16,6 +17,7 @@
       "db_url": "/rails/hello_world/db",
       "query_url": "/rails/hello_world/db?queries=",
       "fortune_url": "/rails/fortune",
+      "update_url": "/rails/update",
       "port": 8080,
       "sort": 17
     }

+ 1 - 0
rails/config/routes.rb

@@ -2,6 +2,7 @@ Hello::Application.routes.draw do
   get "hello_world/json"
   get "hello_world/db"
   get "fortune" => "hello_world#fortune"
+  get "update" => "hello_world#update"
 
 
   # The priority is based upon order of creation: