Consolidate db test prep steps to rake task (#28886)
This commit is contained in:
parent
59d2ea0d82
commit
ca7053f19c
19
.github/workflows/test-migrations-one-step.yml
vendored
19
.github/workflows/test-migrations-one-step.yml
vendored
@ -78,23 +78,8 @@ jobs:
|
|||||||
- name: Create database
|
- name: Create database
|
||||||
run: './bin/rails db:create'
|
run: './bin/rails db:create'
|
||||||
|
|
||||||
- name: Run migrations up to v2.0.0
|
- name: Run historical migrations with data population
|
||||||
run: './bin/rails db:migrate VERSION=20171010025614'
|
run: './bin/rails tests:migrations:prepare_database'
|
||||||
|
|
||||||
- name: Populate database with test data
|
|
||||||
run: './bin/rails tests:migrations:populate_v2'
|
|
||||||
|
|
||||||
- name: Run migrations up to v2.4.0
|
|
||||||
run: './bin/rails db:migrate VERSION=20180514140000'
|
|
||||||
|
|
||||||
- name: Populate database with test data
|
|
||||||
run: './bin/rails tests:migrations:populate_v2_4'
|
|
||||||
|
|
||||||
- name: Run migrations up to v2.4.3
|
|
||||||
run: './bin/rails db:migrate VERSION=20180707154237'
|
|
||||||
|
|
||||||
- name: Populate database with test data
|
|
||||||
run: './bin/rails tests:migrations:populate_v2_4_3'
|
|
||||||
|
|
||||||
- name: Run all remaining migrations
|
- name: Run all remaining migrations
|
||||||
run: './bin/rails db:migrate'
|
run: './bin/rails db:migrate'
|
||||||
|
22
.github/workflows/test-migrations-two-step.yml
vendored
22
.github/workflows/test-migrations-two-step.yml
vendored
@ -45,6 +45,7 @@ jobs:
|
|||||||
--health-retries 5
|
--health-retries 5
|
||||||
ports:
|
ports:
|
||||||
- 5432:5432
|
- 5432:5432
|
||||||
|
|
||||||
redis:
|
redis:
|
||||||
image: redis:7-alpine
|
image: redis:7-alpine
|
||||||
options: >-
|
options: >-
|
||||||
@ -77,28 +78,11 @@ jobs:
|
|||||||
- name: Create database
|
- name: Create database
|
||||||
run: './bin/rails db:create'
|
run: './bin/rails db:create'
|
||||||
|
|
||||||
- name: Run migrations up to v2.0.0
|
- name: Run historical migrations with data population
|
||||||
run: './bin/rails db:migrate VERSION=20171010025614'
|
run: './bin/rails tests:migrations:prepare_database'
|
||||||
|
|
||||||
- name: Populate database with test data
|
|
||||||
run: './bin/rails tests:migrations:populate_v2'
|
|
||||||
|
|
||||||
- name: Run pre-deployment migrations up to v2.4.0
|
|
||||||
run: './bin/rails db:migrate VERSION=20180514140000'
|
|
||||||
env:
|
env:
|
||||||
SKIP_POST_DEPLOYMENT_MIGRATIONS: true
|
SKIP_POST_DEPLOYMENT_MIGRATIONS: true
|
||||||
|
|
||||||
- name: Populate database with test data
|
|
||||||
run: './bin/rails tests:migrations:populate_v2_4'
|
|
||||||
|
|
||||||
- name: Run migrations up to v2.4.3
|
|
||||||
run: './bin/rails db:migrate VERSION=20180707154237'
|
|
||||||
env:
|
|
||||||
SKIP_POST_DEPLOYMENT_MIGRATIONS: true
|
|
||||||
|
|
||||||
- name: Populate database with test data
|
|
||||||
run: './bin/rails tests:migrations:populate_v2_4_3'
|
|
||||||
|
|
||||||
- name: Run all remaining pre-deployment migrations
|
- name: Run all remaining pre-deployment migrations
|
||||||
run: './bin/rails db:migrate'
|
run: './bin/rails db:migrate'
|
||||||
env:
|
env:
|
||||||
|
@ -2,6 +2,22 @@
|
|||||||
|
|
||||||
namespace :tests do
|
namespace :tests do
|
||||||
namespace :migrations do
|
namespace :migrations do
|
||||||
|
desc 'Prepares all migrations and test data for consistency checks'
|
||||||
|
task prepare_database: :environment do
|
||||||
|
{
|
||||||
|
'2' => 2017_10_10_025614,
|
||||||
|
'2_4' => 2018_05_14_140000,
|
||||||
|
'2_4_3' => 2018_07_07_154237,
|
||||||
|
}.each do |release, version|
|
||||||
|
ActiveRecord::Tasks::DatabaseTasks
|
||||||
|
.migration_connection
|
||||||
|
.migration_context
|
||||||
|
.migrate(version)
|
||||||
|
Rake::Task["tests:migrations:populate_v#{release}"]
|
||||||
|
.invoke
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
desc 'Check that database state is consistent with a successful migration from populated data'
|
desc 'Check that database state is consistent with a successful migration from populated data'
|
||||||
task check_database: :environment do
|
task check_database: :environment do
|
||||||
unless Account.find_by(username: 'admin', domain: nil)&.hide_collections? == false
|
unless Account.find_by(username: 'admin', domain: nil)&.hide_collections? == false
|
||||||
@ -88,6 +104,8 @@ namespace :tests do
|
|||||||
puts 'Locale for fr-QC users not updated to fr-CA as expected'
|
puts 'Locale for fr-QC users not updated to fr-CA as expected'
|
||||||
exit(1)
|
exit(1)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
puts 'No errors found. Database state is consistent with a successful migration process.'
|
||||||
end
|
end
|
||||||
|
|
||||||
desc 'Populate the database with test data for 2.4.3'
|
desc 'Populate the database with test data for 2.4.3'
|
||||||
|
Loading…
Reference in New Issue
Block a user