]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[#2882] print error on kea-admin db-upgrade
authorAndrei Pavel <andrei@isc.org>
Tue, 20 Aug 2024 09:13:48 +0000 (12:13 +0300)
committerAndrei Pavel <andrei@isc.org>
Tue, 20 Aug 2024 10:05:50 +0000 (13:05 +0300)
src/bin/admin/kea-admin.in
src/bin/admin/tests/mysql_tests.sh.in
src/bin/admin/tests/pgsql_tests.sh.in

index f24a90ac3ca6ef03b8d888aed95d6644cb966648..0642a57de36819b11343c9925d555945f049f9b0 100644 (file)
@@ -373,9 +373,17 @@ mysql_upgrade() {
     for script in ${upgrade_scripts}
     do
         echo "Processing $script file..."
-        "${script}" -N -B --host="${db_host}" ${db_port_full_parameter-} \
-        --database="${db_name}" --user="${db_user}" \
-        --password="${db_password}" ${extra_arguments}
+        run_command \
+          "${script}" -N -B --host="${db_host}" ${db_port_full_parameter-} \
+          --database="${db_name}" --user="${db_user}" \
+          --password="${db_password}" ${extra_arguments}
+        if test "${EXIT_CODE}" != 0; then
+            if test -n "${OUTPUT}"; then
+                printf '%s\n' "${OUTPUT}"
+            fi
+            log_error "Could not execute script: ${script}"
+            exit "${EXIT_CODE}"
+        fi
     done
 
     version=$(checked_mysql_version)
@@ -422,9 +430,17 @@ pgsql_upgrade() {
     for script in ${upgrade_scripts}
     do
         echo "Processing $script file..."
-        "${script}" --set ON_ERROR_STOP=1 -A -t \
-        -h "${db_host}" ${db_port_full_parameter-} -q -U "${db_user}" \
-        -d "${db_name}" ${extra_arguments}
+        run_command \
+          "${script}" --set ON_ERROR_STOP=1 -A -t \
+          -h "${db_host}" ${db_port_full_parameter-} -q -U "${db_user}" \
+          -d "${db_name}" ${extra_arguments}
+        if test "${EXIT_CODE}" != 0; then
+            if test -n "${OUTPUT}"; then
+                printf '%s\n' "${OUTPUT}"
+            fi
+            log_error "Could not execute script: ${script}"
+            exit "${EXIT_CODE}"
+        fi
     done
 
     version=$(checked_pgsql_version)
index e0049e2a849eecb8aa792368f4ed8e04948452ed..e429b53f62c2eba9ec6e3364c520816c4b60d3a0 100644 (file)
@@ -2419,13 +2419,13 @@ mysql_unused_subnet_id_test() {
 
     run_statement "insert options" "$qry"
 
-    # Ok, we have a 6.0 database with hosts and options. Let's upgrade it to 7.0
+    # Ok, we have a 6.0 schema with hosts and options. Let's upgrade it to 7.0
     # For versions higher than 7.0 some new constraints fail to be added
     # with the not empty tables, for instance the 9.1 -> 9.2 upgrade script
     # can raise a MySQL error 1452 for fk_dhcp4_options_subnet constraint.
     mysql_upgrade_schema_to_version 7.0
 
-    # Version should be new 7.0
+    # Version should now be 7.0.
     version=$("${kea_admin}" db-version mysql -u "${db_user}" -p "${db_password}" -n "${db_name}" -d "${db_scripts_dir}")
     assert_str_eq "7.0" "${version}" "Expected kea-admin to return %s, returned value was %s"
 
index 11584e6c7344faef8181f918e5f4da828a161508..f3962f970940659bf466b575e9e64920abe25fbb 100644 (file)
@@ -1980,13 +1980,13 @@ pgsql_unused_subnet_id_test() {
 
     run_statement "insert options" "$qry"
 
-    # We have a 4.0 database with hosts and options. Let's upgrade it to 6.2.
+    # We have a 4.0 schema with hosts and options. Let's upgrade it to 6.2.
     # For versions higher than 6.2 some new constraints fail to be added
     # with the not empty tables, for instance the 6.2 -> 7.0 upgrade script
     # can raise a key constraing violation for fk_dhcp6_options_subnet.
     pgsql_upgrade_schema_to_version 6.2
 
-    # Version should be new 6.2
+    # Version should now be 6.2.
     version=$("${kea_admin}" db-version pgsql -u "${db_user}" -p "${db_password}" -n "${db_name}" -d "${db_scripts_dir}")
     assert_str_eq "6.2" "${version}" "Expected kea-admin to return %s, returned value was %s"