4754: add rails-perftest and ruby-prof gems to enable performance benchmarking and...
authorRadhika Chippada <radhika@curoverse.com>
Tue, 9 Dec 2014 21:18:50 +0000 (16:18 -0500)
committerRadhika Chippada <radhika@curoverse.com>
Tue, 9 Dec 2014 21:18:50 +0000 (16:18 -0500)
apps/workbench/Gemfile
apps/workbench/Gemfile.lock
apps/workbench/test/performance/browsing_test.rb
apps/workbench/test/performance/search_test.rb [new file with mode: 0644]

index f97869b394c194a528f627c5330dae8f8940f47c..58702791a2ec9f4810148c801593ac5306d77a2d 100644 (file)
@@ -90,3 +90,6 @@ gem "deep_merge", :require => 'deep_merge/rails_compat'
 
 gem 'morrisjs-rails'
 gem 'raphael-rails'
+
+gem 'rails-perftest'
+gem 'ruby-prof'
index 757514343fc3ea1828c8c9c797e1a97e18cb234d..d0f38b2615490c70fd70225f4f1f15c1978adf73 100644 (file)
@@ -170,6 +170,7 @@ GEM
       bundler (>= 1.3.0, < 2.0)
       railties (= 4.1.8)
       sprockets-rails (~> 2.0)
+    rails-perftest (0.0.5)
     railties (4.1.8)
       actionpack (= 4.1.8)
       activesupport (= 4.1.8)
@@ -179,6 +180,7 @@ GEM
     raphael-rails (2.1.2)
     ref (1.0.5)
     ruby-debug-passenger (0.2.0)
+    ruby-prof (0.15.2)
     rubyzip (1.1.6)
     rvm-capistrano (1.5.5)
       capistrano (~> 2.15.4)
@@ -262,8 +264,10 @@ DEPENDENCIES
   piwik_analytics
   poltergeist
   rails (~> 4.1.0)
+  rails-perftest
   raphael-rails
   ruby-debug-passenger
+  ruby-prof
   rvm-capistrano
   sass
   sass-rails (~> 4.0.4)
index 3fea27b91670e04c83a15269790a44b41b7d9ce1..27b55c4268e05b11f013a8c94acd73e05762afce 100644 (file)
@@ -1,12 +1,31 @@
+# http://guides.rubyonrails.org/v3.2.13/performance_testing.html
+
 require 'test_helper'
 require 'rails/performance_test_help'
+require 'integration_helper'
+require 'selenium-webdriver'
+require 'headless'
 
 class BrowsingTest < ActionDispatch::PerformanceTest
   # Refer to the documentation for all available options
   # self.profile_options = { :runs => 5, :metrics => [:wall_time, :memory]
   #                          :output => 'tmp/performance', :formats => [:flat] }
 
+  self.profile_options = { :runs => 10,
+                           :metrics => [:wall_time],
+                           :output => 'tmp/performance',
+                           :formats => [:flat] }
+
+  setup do
+    headless = Headless.new
+    headless.start
+    Capybara.current_driver = :selenium
+    Capybara.current_session.driver.browser.manage.window.resize_to(1024, 768)
+  end
+
   def test_homepage
-    get '/'
+    visit page_with_token('active')
+    assert_text 'Dashboard'
+    assert_selector 'a', text: 'Run a pipeline'
   end
 end
diff --git a/apps/workbench/test/performance/search_test.rb b/apps/workbench/test/performance/search_test.rb
new file mode 100644 (file)
index 0000000..c84a47b
--- /dev/null
@@ -0,0 +1,34 @@
+# http://guides.rubyonrails.org/v3.2.13/performance_testing.html
+
+require 'test_helper'
+require 'rails/performance_test_help'
+require 'integration_helper'
+require 'selenium-webdriver'
+require 'headless'
+
+class SearchTest < ActionDispatch::PerformanceTest
+  self.profile_options = { :runs => 10,
+                           :metrics => [:wall_time],
+                           :output => 'tmp/performance',
+                           :formats => [:flat] }
+
+  setup do
+    headless = Headless.new
+    headless.start
+    Capybara.current_driver = :selenium
+    Capybara.current_session.driver.browser.manage.window.resize_to(1024, 768)
+  end
+
+  def test_search
+    visit page_with_token('active')
+
+    within('.navbar-fixed-top') do
+      page.find_field('search').set('hash')
+      page.find('.glyphicon-search').click
+    end
+
+    # We should now be in the search dialog. Expect at least one collection in the result display. 
+    assert_text 'Search'
+    assert_text '-8i9sb-'
+  end
+end