Support db schema upgrade

The rally db command provides the separate upgrade subcommand to
upgrade schema of existing database. This change provides the option to
use the upgrade command instead of the create command so that users can
use the sync class for schema upgrade.

Change-Id: I778381879c9aa6c790423262c90142a6b383c252
This commit is contained in:
Takashi Kajinami 2023-01-10 13:50:48 +09:00
parent 16a35f2fc6
commit 399172e192
3 changed files with 45 additions and 1 deletions

View File

@ -13,15 +13,27 @@
# (Optional) Timeout for the execution of the db_sync
# Defaults to 300
#
# [*upgrade*]
# (Optional) Run rally db upgrade command instead of rally db create command.
# Defaults to false
#
class rally::db::sync(
$extra_params = '--config-file /etc/rally/rally.conf',
$db_sync_timeout = 300,
$upgrade = false,
) {
include rally::deps
validate_legacy(Boolean, 'validate_bool', $upgrade)
$subcommand = $upgrade ? {
true => 'upgrade',
default => 'create'
}
exec { 'rally db_sync':
command => "rally ${extra_params} db create",
command => "rally ${extra_params} db ${subcommand}",
path => '/usr/bin',
user => 'root',
refreshonly => true,

View File

@ -0,0 +1,6 @@
---
features:
- |
The new ``rally::db::sync::upgrade`` parameter has been added. When this
parameter is set to ``true``, ``rally db upgrade`` command is executed
instead of ``rally db create`` command.

View File

@ -50,6 +50,32 @@ describe 'rally::db::sync' do
)
}
end
context "upgrade enabled" do
let :params do
{
:upgrade => true
}
end
it {
is_expected.to contain_exec('rally db_sync').with(
:command => 'rally --config-file /etc/rally/rally.conf db upgrade',
:user => 'root',
:path => '/usr/bin',
:refreshonly => 'true',
:try_sleep => 5,
:tries => 10,
:timeout => 300,
:logoutput => 'on_failure',
:subscribe => ['Anchor[rally::install::end]',
'Anchor[rally::config::end]',
'Anchor[rally::dbsync::begin]'],
:notify => 'Anchor[rally::dbsync::end]',
:tag => 'openstack-db',
)
}
end
end
on_supported_os({