Merge branch 'migration_log_file' into 'master'
Move migration log file to a persisted location Fixes gitlab-org/omnibus-gitlab#1615 See merge request !1016
This commit is contained in:
commit
b368c46cd7
|
@ -12,6 +12,7 @@ omnibus-gitlab repository.
|
|||
- Updated cacerts.pem to 2016-09-14 version
|
||||
- Add support for nginx status
|
||||
- Enable jemalloc by default 0a7799d2
|
||||
- Move database migration log to a persisted location
|
||||
|
||||
8.12.4
|
||||
|
||||
|
|
|
@ -44,9 +44,8 @@ db_migrate_status_file = ::File.join(upgrade_status_dir, "db-migrate-#{connectio
|
|||
bash "migrate gitlab-rails database" do
|
||||
code <<-EOH
|
||||
set -e
|
||||
log_file="/tmp/gitlab-rails-db-migrate-$(date +%s)-$$/output.log"
|
||||
log_file="#{node['gitlab']['gitlab-rails']['log_directory']}/gitlab-rails-db-migrate-$(date +%s)-$$.log"
|
||||
umask 077
|
||||
mkdir $(dirname ${log_file})
|
||||
/opt/gitlab/bin/gitlab-rake gitlab:db:configure 2>& 1 | tee ${log_file}
|
||||
STATUS=${PIPESTATUS[0]}
|
||||
echo $STATUS > #{db_migrate_status_file}
|
||||
|
|
|
@ -0,0 +1,40 @@
|
|||
require 'chef_helper'
|
||||
|
||||
# NOTE: These specs do not verify whether the code actually ran
|
||||
# Nor whether the resource inside of the recipe was notified correctly.
|
||||
# At this moment they only verify whether the expected commands are passed
|
||||
# to the bash block.
|
||||
#
|
||||
|
||||
describe 'gitlab::database-migrations' do
|
||||
let(:chef_run) { ChefSpec::SoloRunner.converge('gitlab::default') }
|
||||
|
||||
before do
|
||||
allow(Gitlab).to receive(:[]).and_call_original
|
||||
end
|
||||
|
||||
context 'when migration should run' do
|
||||
let(:bash_block) { chef_run.bash('migrate gitlab-rails database') }
|
||||
|
||||
context 'places the log file' do
|
||||
# Testing only path as escaping the file name "$(date +%s)-$$.log"
|
||||
# is causing issues with chefspec.
|
||||
|
||||
it 'in a default location' do
|
||||
path = %Q(/var/log/gitlab/gitlab-rails/gitlab-rails-db-migrate-)
|
||||
expect(bash_block.code).to match(/#{path}/)
|
||||
end
|
||||
|
||||
it 'in a custom location' do
|
||||
stub_gitlab_rb(gitlab_rails: { log_directory: "/tmp"})
|
||||
path = %Q(/tmp/gitlab-rails-db-migrate-)
|
||||
expect(bash_block.code).to match(/#{path}/)
|
||||
end
|
||||
end
|
||||
|
||||
it 'triggers the gitlab:db:configure task' do
|
||||
migrate = %Q(/opt/gitlab/bin/gitlab-rake gitlab:db:configure 2>& 1 | tee ${log_file})
|
||||
expect(bash_block.code).to match(/#{migrate}/)
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Reference in New Issue