Merge branch 'master' into 4358-graph-not-comparing
[arvados.git] / apps / workbench / test / performance_test_helper.rb
1 require 'integration_helper'
2
3 # Performance test can run in two two different ways:
4 #
5 # 1. Similar to other integration tests using the command:
6 #     RAILS_ENV=test bundle exec rake test:benchmark
7 #
8 # 2. Against a configured workbench url using "RAILS_ENV=performance".
9 #     RAILS_ENV=performance bundle exec rake TEST=test/performance/*.rb
10
11 class WorkbenchPerformanceTest < ActionDispatch::PerformanceTest
12
13   # When running in "RAILS_ENV=performance" mode, uses performance config params.
14   # In this mode, prepends workbench URL to the given path provided,
15   # and visits that page using the configured "user_token".
16   def visit_page_with_token path='/'
17     if ENV["RAILS_ENV"].eql? 'performance'
18       token = Rails.configuration.user_token
19       workbench_url = Rails.configuration.arvados_workbench_url
20       if workbench_url.end_with? '/'
21         workbench_url = workbench_url[0, workbench_url.size-1]
22       end
23     else
24       token = 'active'
25       workbench_url = ''
26     end
27
28     visit page_with_token(token, (workbench_url + path))
29   end
30
31   # We do not want to reset the database fixtures in "RAILS_ENV=performance" mode.
32   protected
33   def self.reset_api_fixtures_now
34   end
35
36 end