[ARVADOS] created: 739f6e8722bb4ce8fc130149dfeba7b87149c8c6

git at public.curoverse.com git at public.curoverse.com
Mon Dec 15 14:26:44 EST 2014


        at  739f6e8722bb4ce8fc130149dfeba7b87149c8c6 (commit)


commit 739f6e8722bb4ce8fc130149dfeba7b87149c8c6
Author: Tom Clegg <tom at curoverse.com>
Date:   Mon Dec 15 14:26:38 2014 -0500

    4754: Add rake task. Move perf/prof deps to :test group.
    Move "do not reset unless Rails.env==test" logic into one place.

diff --git a/apps/workbench/Gemfile b/apps/workbench/Gemfile
index f095c48..e0d0a6c 100644
--- a/apps/workbench/Gemfile
+++ b/apps/workbench/Gemfile
@@ -43,6 +43,8 @@ group :test do
   gem 'capybara'
   gem 'poltergeist'
   gem 'headless'
+  gem 'rails-perftest'
+  gem 'ruby-prof'
   # Note: "require: false" here tells bunder not to automatically
   # 'require' the packages during application startup. Installation is
   # still mandatory.
@@ -92,6 +94,3 @@ gem "deep_merge", :require => 'deep_merge/rails_compat'
 
 gem 'morrisjs-rails'
 gem 'raphael-rails'
-
-gem 'rails-perftest'
-gem 'ruby-prof'
diff --git a/apps/workbench/lib/tasks/test_performance.rake b/apps/workbench/lib/tasks/test_performance.rake
new file mode 100644
index 0000000..6519d02
--- /dev/null
+++ b/apps/workbench/lib/tasks/test_performance.rake
@@ -0,0 +1,6 @@
+namespace :test do
+  Rails::SubTestTask.new(:performance => "test:prepare") do |t|
+    t.libs << "test"
+    t.pattern = 'test/performance/**/*_test.rb'
+  end
+end
diff --git a/apps/workbench/test/diagnostics_test_helper.rb b/apps/workbench/test/diagnostics_test_helper.rb
index 09dc0bb..c7433bb 100644
--- a/apps/workbench/test/diagnostics_test_helper.rb
+++ b/apps/workbench/test/diagnostics_test_helper.rb
@@ -6,7 +6,7 @@ require 'yaml'
 # will not be executed.
 
 # Command to run diagnostics tests:
-#   RAILS_ENV=diagnostics bundle exec rake TEST=test/diagnostics/*.rb
+#   RAILS_ENV=diagnostics bundle exec rake TEST=test/diagnostics/**/*.rb
 
 class DiagnosticsTest < ActionDispatch::IntegrationTest
 
@@ -29,9 +29,4 @@ class DiagnosticsTest < ActionDispatch::IntegrationTest
     end
   end
 
-  # Diagnostics tests never want to reset the database fixtures.
-  protected
-  def self.reset_api_fixtures_now
-  end
-
 end
diff --git a/apps/workbench/test/performance_test_helper.rb b/apps/workbench/test/performance_test_helper.rb
index 7c40354..91d9a5b 100644
--- a/apps/workbench/test/performance_test_helper.rb
+++ b/apps/workbench/test/performance_test_helper.rb
@@ -3,18 +3,19 @@ require 'integration_helper'
 # Performance test can run in two two different ways:
 #
 # 1. Similar to other integration tests using the command:
-#     RAILS_ENV=test bundle exec rake test:benchmark
+#     RAILS_ENV=test bundle exec rake test:performance
 #
 # 2. Against a configured workbench url using "RAILS_ENV=performance".
-#     RAILS_ENV=performance bundle exec rake TEST=test/performance/*.rb
+#     RAILS_ENV=performance bundle exec rake test:performance
 
 class WorkbenchPerformanceTest < ActionDispatch::PerformanceTest
 
-  # When running in "RAILS_ENV=performance" mode, uses performance config params.
-  # In this mode, prepends workbench URL to the given path provided,
-  # and visits that page using the configured "user_token".
+  # When running in "RAILS_ENV=performance" mode, uses performance
+  # config params.  In this mode, prepends workbench URL to the given
+  # path provided, and visits that page using the configured
+  # "user_token".
   def visit_page_with_token path='/'
-    if ENV["RAILS_ENV"].eql? 'performance'
+    if Rails.env == 'performance'
       token = Rails.configuration.user_token
       workbench_url = Rails.configuration.arvados_workbench_url
       if workbench_url.end_with? '/'
@@ -28,9 +29,4 @@ class WorkbenchPerformanceTest < ActionDispatch::PerformanceTest
     visit page_with_token(token, (workbench_url + path))
   end
 
-  # We do not want to reset the database fixtures in "RAILS_ENV=performance" mode.
-  protected
-  def self.reset_api_fixtures_now
-  end
-
 end
diff --git a/apps/workbench/test/test_helper.rb b/apps/workbench/test/test_helper.rb
index 1e7b8eb..2b480f9 100644
--- a/apps/workbench/test/test_helper.rb
+++ b/apps/workbench/test/test_helper.rb
@@ -267,6 +267,10 @@ class ActiveSupport::TestCase
 
   protected
   def self.reset_api_fixtures_now
+    # Never try to reset fixtures when we're just using test
+    # infrastructure to run performance/diagnostics suites.
+    return unless Rails.env == 'test'
+
     auth = api_fixture('api_client_authorizations')['admin_trustedclient']
     Thread.current[:arvados_api_token] = auth['api_token']
     ArvadosApiClient.new.api(nil, '../../database/reset', {})

-----------------------------------------------------------------------


hooks/post-receive
-- 




More information about the arvados-commits mailing list