Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Run the updates based on the installed version #7579

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions testsuite/podman_runner/07_manager_setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,13 @@ sudo -i podman exec uyuni-server-all-in-one-test bash -c "/usr/bin/spacewalk-sch

# Make sure latest sql migration scripts have been executed for both the main and the reporting database
available_schemas=("spacewalk" "reportdb")
for schema in ${available_schemas[@]}; do
specfile=$(find ${src_dir}/schema/${schema}/ -name *.spec)
# Use Perl extended regexp and look-around assertions to extract only the values from the spec properties
schema_name=$(grep -oP "Name:\s+\K(.*)$" ${specfile})
schema_version=$(grep -oP "Version:\s+\K(.*)$" ${specfile})
for schema in "${available_schemas[@]}"; do
specfile=$(find "${src_dir}/schema/${schema}/" -name '*.spec')
# Get the package name from the spec using Perl extended regexp and look-around assertions to extract only its value
schema_name=$(grep -oP "Name:\s+\K(.*)$" "${specfile}")
# Check the version of the package installed in the podman container
schema_version=$(sudo -i podman exec uyuni-server-all-in-one-test rpm -q --queryformat '%{version}' "${schema_name}")

# Run the missing migrations and only those, to ensure no script is out of place
sudo -i podman exec uyuni-server-all-in-one-test bash -c "/testsuite/podman_runner/run_db_migrations.sh ${schema_name} ${schema_version}"
done

5 changes: 4 additions & 1 deletion testsuite/podman_runner/run_db_migrations.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@ else
exit 1
fi

for i in $(find ${upgrade_dir} -name "$1-$2-to-*"); do
# Including all sub-folders of the upgrade dir that comes after the one called "${schema_name}-${schema_version}-to-..."
# This should make sure we apply all the scripts meant to be executed on top of the current schema version.
# It probably won't happen often that we have multiple pending directories, but it could happen in case of re-tagging
for i in $(find ${upgrade_dir} -name "$1-*-to-*" | sed -n "/$1-$2-to-.*$/,$ p"); do
echo $(basename $i)
for j in $(find $i -name *.sql); do
echo -e "\t$(basename $j)"; spacewalk-sql ${additional_params} $j | sed 's/^/\t\t/';
Expand Down