Refactoring: Improve browser test suite speed by starting ruby/rails context only once for all tests by using Rails build in test running rake task.
This commit is contained in:
parent
ca73fdd9b7
commit
fa0ed8c0ba
3 changed files with 47 additions and 42 deletions
|
@ -135,8 +135,8 @@ test:rspec:postgresql:
|
||||||
script:
|
script:
|
||||||
- bundle exec rake zammad:db:init
|
- bundle exec rake zammad:db:init
|
||||||
- bundle exec rake test:units
|
- bundle exec rake test:units
|
||||||
- bundle exec ruby -I test/ test/integration/object_manager_test.rb
|
- bundle exec rails test test/integration/object_manager_test.rb
|
||||||
- bundle exec ruby -I test/ test/integration/package_test.rb
|
- bundle exec rails test test/integration/package_test.rb
|
||||||
|
|
||||||
test:unit:mysql:
|
test:unit:mysql:
|
||||||
stage: test
|
stage: test
|
||||||
|
@ -162,32 +162,32 @@ test:integration:email_helper_deliver:
|
||||||
<<: *requires_mail_port_access
|
<<: *requires_mail_port_access
|
||||||
script:
|
script:
|
||||||
- bundle exec rake zammad:db:unseeded
|
- bundle exec rake zammad:db:unseeded
|
||||||
- bundle exec ruby -I test/ test/integration/email_helper_test.rb
|
- bundle exec rails test test/integration/email_helper_test.rb
|
||||||
- bundle exec ruby -I test/ test/integration/email_deliver_test.rb
|
- bundle exec rails test test/integration/email_deliver_test.rb
|
||||||
- bundle exec ruby -I test/ test/integration/email_keep_on_server_test.rb
|
- bundle exec rails test test/integration/email_keep_on_server_test.rb
|
||||||
|
|
||||||
test:integration:facebook:
|
test:integration:facebook:
|
||||||
<<: *test_integration_definition
|
<<: *test_integration_definition
|
||||||
script:
|
script:
|
||||||
- bundle exec rake zammad:db:init
|
- bundle exec rake zammad:db:init
|
||||||
- bundle exec ruby -I test/ test/integration/facebook_test.rb
|
- bundle exec rails test test/integration/facebook_test.rb
|
||||||
allow_failure: true
|
allow_failure: true
|
||||||
|
|
||||||
test:integration:geo:
|
test:integration:geo:
|
||||||
<<: *test_integration_definition
|
<<: *test_integration_definition
|
||||||
script:
|
script:
|
||||||
- bundle exec rake zammad:db:unseeded
|
- bundle exec rake zammad:db:unseeded
|
||||||
- bundle exec ruby -I test/ test/integration/geo_calendar_test.rb
|
- bundle exec rails test test/integration/geo_calendar_test.rb
|
||||||
- bundle exec ruby -I test/ test/integration/geo_location_test.rb
|
- bundle exec rails test test/integration/geo_location_test.rb
|
||||||
- bundle exec ruby -I test/ test/integration/geo_ip_test.rb
|
- bundle exec rails test test/integration/geo_ip_test.rb
|
||||||
|
|
||||||
test:integration:user_agent:
|
test:integration:user_agent:
|
||||||
<<: *test_integration_definition
|
<<: *test_integration_definition
|
||||||
script:
|
script:
|
||||||
- bundle exec rake zammad:db:unseeded
|
- bundle exec rake zammad:db:unseeded
|
||||||
- bundle exec ruby -I test/ test/integration/user_agent_test.rb
|
- bundle exec rails test test/integration/user_agent_test.rb
|
||||||
- export ZAMMAD_PROXY_TEST=true
|
- export ZAMMAD_PROXY_TEST=true
|
||||||
- bundle exec ruby -I test/ test/integration/user_agent_test.rb
|
- bundle exec rails test test/integration/user_agent_test.rb
|
||||||
allow_failure: true
|
allow_failure: true
|
||||||
|
|
||||||
test:integration:slack:
|
test:integration:slack:
|
||||||
|
@ -196,13 +196,13 @@ test:integration:slack:
|
||||||
- bundle exec rake zammad:db:unseeded
|
- bundle exec rake zammad:db:unseeded
|
||||||
- echo "gem 'slack-api'" >> Gemfile.local
|
- echo "gem 'slack-api'" >> Gemfile.local
|
||||||
- bundle install -j $(nproc)
|
- bundle install -j $(nproc)
|
||||||
- bundle exec ruby -I test test/integration/slack_test.rb
|
- bundle exec rails test test/integration/slack_test.rb
|
||||||
|
|
||||||
test:integration:clearbit:
|
test:integration:clearbit:
|
||||||
<<: *test_integration_definition
|
<<: *test_integration_definition
|
||||||
script:
|
script:
|
||||||
- bundle exec rake zammad:db:unseeded
|
- bundle exec rake zammad:db:unseeded
|
||||||
- bundle exec ruby -I test test/integration/clearbit_test.rb
|
- bundle exec rails test test/integration/clearbit_test.rb
|
||||||
allow_failure: true
|
allow_failure: true
|
||||||
|
|
||||||
### Elasticsearch
|
### Elasticsearch
|
||||||
|
@ -216,9 +216,9 @@ test:integration:clearbit:
|
||||||
ES_URL: "http://elasticsearch:9200"
|
ES_URL: "http://elasticsearch:9200"
|
||||||
script:
|
script:
|
||||||
- bundle exec rake zammad:db:unseeded
|
- bundle exec rake zammad:db:unseeded
|
||||||
- bundle exec ruby -I test/ test/integration/elasticsearch_active_test.rb
|
- bundle exec rails test test/integration/elasticsearch_active_test.rb
|
||||||
- bundle exec ruby -I test/ test/integration/elasticsearch_test.rb
|
- bundle exec rails test test/integration/elasticsearch_test.rb
|
||||||
- bundle exec ruby -I test/ test/integration/report_test.rb
|
- bundle exec rails test test/integration/report_test.rb
|
||||||
- bundle exec rspec --tag searchindex
|
- bundle exec rspec --tag searchindex
|
||||||
|
|
||||||
test:integration:es_mysql:
|
test:integration:es_mysql:
|
||||||
|
@ -247,7 +247,7 @@ test:integration:es_postgresql:
|
||||||
RAILS_ENV: "test"
|
RAILS_ENV: "test"
|
||||||
script:
|
script:
|
||||||
- bundle exec rake zammad:db:unseeded
|
- bundle exec rake zammad:db:unseeded
|
||||||
- bundle exec ruby -I test/ test/integration/zendesk_import_test.rb
|
- bundle exec rails test test/integration/zendesk_import_test.rb
|
||||||
allow_failure: true
|
allow_failure: true
|
||||||
|
|
||||||
test:integration:zendesk_mysql:
|
test:integration:zendesk_mysql:
|
||||||
|
@ -265,7 +265,7 @@ test:integration:zendesk_postgresql:
|
||||||
stage: test
|
stage: test
|
||||||
script:
|
script:
|
||||||
- bundle exec rake zammad:db:unseeded
|
- bundle exec rake zammad:db:unseeded
|
||||||
- bundle exec ruby -I test/ test/integration/otrs_import_test.rb
|
- bundle exec rails test test/integration/otrs_import_test.rb
|
||||||
|
|
||||||
.variables_integration_otrs_6_template: &variables_integration_otrs_6_definition
|
.variables_integration_otrs_6_template: &variables_integration_otrs_6_definition
|
||||||
variables:
|
variables:
|
||||||
|
@ -458,7 +458,7 @@ test:browser:integration:api_client_php:
|
||||||
- script/build/test_slice_tests.sh $TEST_SLICE
|
- script/build/test_slice_tests.sh $TEST_SLICE
|
||||||
- RAILS_ENV=test bundle exec rake db:create
|
- RAILS_ENV=test bundle exec rake db:create
|
||||||
- bundle exec rake zammad:ci:test:start[with_elasticsearch]
|
- bundle exec rake zammad:ci:test:start[with_elasticsearch]
|
||||||
- bundle exec rake test:browser
|
- time bundle exec rails test --fail-fast test/browser
|
||||||
|
|
||||||
.test_browser_core_postgresql_template: &test_browser_core_postgresql_definition
|
.test_browser_core_postgresql_template: &test_browser_core_postgresql_definition
|
||||||
<<: *test_browser_core_definition
|
<<: *test_browser_core_definition
|
||||||
|
@ -665,7 +665,7 @@ test:browser:core:chrome_6_postgresql:
|
||||||
- RAILS_ENV=test bundle exec rake db:create
|
- RAILS_ENV=test bundle exec rake db:create
|
||||||
- cp $AUTO_WIZARD_FILE auto_wizard.json
|
- cp $AUTO_WIZARD_FILE auto_wizard.json
|
||||||
- bundle exec rake zammad:ci:test:start
|
- bundle exec rake zammad:ci:test:start
|
||||||
- bundle exec ruby -I test/ $TEST_FILE
|
- bundle exec rails test $TEST_FILE
|
||||||
|
|
||||||
.browser_core_auto_wizard_template: &browser_core_auto_wizard_definition
|
.browser_core_auto_wizard_template: &browser_core_auto_wizard_definition
|
||||||
<<: *test_browser_core_definition
|
<<: *test_browser_core_definition
|
||||||
|
@ -746,7 +746,7 @@ test:browser:integration:idoit_chrome:
|
||||||
script:
|
script:
|
||||||
- RAILS_ENV=test bundle exec rake db:create
|
- RAILS_ENV=test bundle exec rake db:create
|
||||||
- bundle exec rake zammad:ci:test:start
|
- bundle exec rake zammad:ci:test:start
|
||||||
- bundle exec ruby -I test/ $TEST_FILE
|
- bundle exec rails test $TEST_FILE
|
||||||
|
|
||||||
test:browser:integration:otrs_chrome:
|
test:browser:integration:otrs_chrome:
|
||||||
<<: *browser_integration_import_definition
|
<<: *browser_integration_import_definition
|
||||||
|
|
|
@ -1,20 +0,0 @@
|
||||||
$LOAD_PATH << './lib'
|
|
||||||
require 'rubygems'
|
|
||||||
|
|
||||||
namespace :test do
|
|
||||||
desc 'Start browser tests'
|
|
||||||
task :browser, [:opts] => :environment do |_t, args|
|
|
||||||
|
|
||||||
start = Time.zone.now
|
|
||||||
if !args.opts
|
|
||||||
args.opts = ''
|
|
||||||
end
|
|
||||||
Dir.glob('test/browser/*_test.rb').sort.each do |r|
|
|
||||||
sh "#{args.opts} ruby -Itest #{r}" do |ok, res|
|
|
||||||
raise 'Failed test. ' + res.inspect if !ok
|
|
||||||
end
|
|
||||||
end
|
|
||||||
puts 'All browser tests, elapsed: ' + (Time.zone.now - start).to_s + ' seconds'
|
|
||||||
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -6,10 +6,35 @@ require 'json'
|
||||||
require 'net/http'
|
require 'net/http'
|
||||||
require 'uri'
|
require 'uri'
|
||||||
|
|
||||||
class TestCase < Test::Unit::TestCase
|
# This is a workaround for running the browser test suite
|
||||||
|
# in an alphabetical order
|
||||||
|
# because `test/browser/aaa_*` tests are required to run first
|
||||||
|
require 'minitest'
|
||||||
|
module Minitest
|
||||||
|
def self.__run(reporter, options)
|
||||||
|
Runnable.runnables
|
||||||
|
.reject { |s| s.runnable_methods.empty? }
|
||||||
|
.map { |suite| suite.run reporter, options }
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
class TestCase < ActiveSupport::TestCase
|
||||||
|
|
||||||
DEBUG = true
|
DEBUG = true
|
||||||
|
|
||||||
|
setup do
|
||||||
|
# print current test case to STDOUT
|
||||||
|
# for status reasoning and debugging purposes
|
||||||
|
source_location = self.class.instance_method(method_name).source_location
|
||||||
|
test_file_path = source_location[0].remove("#{Rails.root}/") # rubocop:disable Rails/FilePath
|
||||||
|
test_method_line = source_location[1]
|
||||||
|
puts <<~HTML
|
||||||
|
|
||||||
|
Performing test #{self.class.name}##{method_name} (#{test_file_path}:#{test_method_line}):
|
||||||
|
|
||||||
|
HTML
|
||||||
|
end
|
||||||
|
|
||||||
def browser
|
def browser
|
||||||
ENV['BROWSER'] || 'firefox'
|
ENV['BROWSER'] || 'firefox'
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue