Merge branch '8784-dir-listings'
[arvados.git] / apps / workbench / test / performance_test_helper.rb
1 # Copyright (C) The Arvados Authors. All rights reserved.
2 #
3 # SPDX-License-Identifier: AGPL-3.0
4
5 require 'integration_helper'
6
7 # Performance test can run in two different ways:
8 #
9 # 1. Similar to other integration tests using the command:
10 #     RAILS_ENV=test bundle exec rake test:benchmark
11 #
12 # 2. Against a configured workbench url using "RAILS_ENV=performance".
13 #     RAILS_ENV=performance bundle exec rake test:benchmark
14
15 class WorkbenchPerformanceTest < ActionDispatch::PerformanceTest
16
17   # When running in "RAILS_ENV=performance" mode, uses performance
18   # config params.  In this mode, prepends workbench URL to the given
19   # path provided, and visits that page using the configured
20   # "user_token".
21   def visit_page_with_token path='/'
22     if Rails.env == 'performance'
23       token = Rails.configuration.user_token
24       workbench_url = Rails.configuration.arvados_workbench_url
25       if workbench_url.end_with? '/'
26         workbench_url = workbench_url[0, workbench_url.size-1]
27       end
28     else
29       token = 'active'
30       workbench_url = ''
31     end
32
33     visit page_with_token(token, (workbench_url + path))
34   end
35
36 end