-
Notifications
You must be signed in to change notification settings - Fork 438
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Introduces ENV['RUNNING_MINITEST_WITH_DOCKER']
Make it possible to run some (like ~97% as of this writing) minitest tests in the container based development environment against the backend that is running there. $ rake dev:minitest:fixtures:create RAILS_ENV=test $ export RUNNING_MINITEST_WITH_DOCKER=1 $ rake test TEST=test/functional/request_events_test.rb Please be aware: If you are using this you'll be responsible for resetting the state of the backend. Like running $ docker-compose stop backend $ docker-compose rm -f backend $ docker-compose up -d backend before and after executing a test as the tests are optimized to be run once. It'll also not work for tests that "mock" backend functionality. Like the ones using TestHelper.inject_build_job or doing something with OBS_BACKEND_TEMP. $ grep -Hrl OBS_BACKEND_TEMP test test/functional/zzz_post_consistency_test.rb test/functional/build_controller_test.rb test/functional/channel_maintenance_test.rb test/functional/published_controller_test.rb test/functional/backend_test.rb test/functional/maintenance_test.rb test/functional/source_controller_test.rb $ grep -Hrl inject_build_job test test/functional/release_management_test.rb test/functional/product_test.rb test/functional/search_controller_test.rb test/functional/channel_maintenance_test.rb test/functional/kgraft_maintenance_test.rb test/functional/maintenance_test.rb
- Loading branch information
1 parent
a77877c
commit 3d7c8c3
Showing
4 changed files
with
55 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
namespace :dev do | ||
namespace :minitest do | ||
namespace :fixtures do | ||
desc 'Create minitest fixtures in the database (as opposed to loading them with db:fixture:load)' | ||
task create: :test_environment do | ||
puts "\n\nMake sure you start with a fresh backend! Outside the container run..." | ||
puts "docker-compose stop backend; docker-compose rm -f backend; docker-compose up -d backend\n\n" | ||
puts 'Please also note this will drop your current test database' | ||
puts "Confirm? Enter 'YES' to confirm:" | ||
input = $stdin.gets.chomp | ||
raise "Aborting... You entered: #{input} not YES" unless input == 'YES' | ||
|
||
Rake::Task['db:drop'].invoke | ||
Rake::Task['db:setup'].invoke | ||
Rake::Task['db:fixtures:load'].invoke | ||
# Enable writing to the backend | ||
CONFIG['global_write_through'] = true | ||
# Login default admin for syncing projects/packages to the backend | ||
User.session = User.get_default_admin | ||
# Rewrite interconnect url | ||
Project.where(remoteurl: 'http://localhost:3200').map { |project| project.update!(remoteurl: 'http://backend:5352') } | ||
# Sync all projects to the backend | ||
Project.all.map(&:store) | ||
# Sync all packages to the backend | ||
# FIXME: Why do we have `_product:fixed-release` in the fixtures if you can't even store it? | ||
Package.where.not(name: '_product:fixed-release').map(&:store) | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters