"${kea_admin}" db-version mysql -u "${db_user}" -p "${db_password}" -n "${db_name}"
assert_eq 1 "${EXIT_CODE}" "schema_version table still exists. (expected %d, exit code %d)"
- # Ok, now let's create a version 1.7
+ # Create the database
run_command \
- mysql -u"${db_user}" -p"${db_password}" "${db_name}" -e \
-'CREATE TABLE schema_version (
- version INT PRIMARY KEY NOT NULL,
- minor INT
-);
-INSERT INTO schema_version VALUES (1, 7)'
- assert_eq 0 "${EXIT_CODE}" "schema_version table cannot be created. (expected %d, exit code %d)"
+ "${kea_admin}" db-init mysql -u "${db_user}" -p "${db_password}" -n "${db_name}" -d "${db_scripts_dir}"
+ assert_eq 0 "${EXIT_CODE}" "cannot initialize the database, expected exit code: %d, actual: %d"
+ # Verify that kea-admin db-version returns the latest version.
run_command \
"${kea_admin}" db-version mysql -u "${db_user}" -p "${db_password}" -n "${db_name}"
version="${OUTPUT}"
- assert_str_eq "1.7" "${version}" "Expected kea-admin to return %s, returned value was %s"
+ assert_str_eq "29.0" "${version}" "Expected kea-admin to return %s, returned value was %s"
# Let's wipe the whole database
mysql_wipe
}
mysql_upgrade_25_to_26_test() {
+ qry="select name from option_def_data_type where id = 3"
+ run_command \
+ mysql_execute "${qry}"
+ assert_eq 0 "${EXIT_CODE}" "${qry}. (expected status code %d, returned %d)"
+ assert_str_eq 'int8' "${OUTPUT}" "${qry}: expected output %s, returned %s"
# client_classes been added to dhcp4_options
check_table_column client_classes dhcp4_options
input_file_cp=""
fi
- # Wipe the whole database.
+ # Let's wipe the whole database.
mysql_wipe
# Clean up any test files left from prior failed runs unless -y was provided in which case
rm -f "${output_file}"
rm -f "${output_file}.tmp"
- # Wipe the whole database.
+ # Let's wipe the whole database.
mysql_wipe
test_finish 0
input_file_cp=""
fi
- # Wipe the whole database.
+ # Let's wipe the whole database.
mysql_wipe
# Clean up any test files left from prior failed runs unless -y was provided in which case
rm -f "${output_file}"
rm -f "${output_file}.tmp"
- # Wipe the whole database.
+ # Let's wipe the whole database.
mysql_wipe
test_finish 0
pgsql_db_version_test() {
test_start "pgsql.db-version"
- # Wipe the whole database
+ # Let's wipe the whole database
pgsql_wipe
# Do not create any table so db-version will raise an error
}
pgsql_upgrade_25_to_26_test() {
+ qry="select name from option_def_data_type where id = 3"
+ run_command \
+ pgsql_execute "${qry}"
+ assert_eq 0 "${EXIT_CODE}" "${qry}. (expected status code %d, returned %d)"
+ assert_str_eq 'int8' "${OUTPUT}" "${qry}: expected output %s, returned %s"
+
# client_classes been added to dhcp4_options
check_table_column client_classes dhcp4_options
pgsql_upgrade_test() {
test_start "pgsql.upgrade"
- # Wipe the whole database
+ # Let's wipe the whole database
pgsql_wipe
# Initialize database to schema 1.0.
input_file_cp=""
fi
- # Wipe the whole database.
+ # Let's wipe the whole database.
pgsql_wipe
# Clean up any test files left from prior failed runs unless -y was provided in which case
rm -f "${output_file}"
rm -f "${output_file}.tmp"
- # Wipe the whole database.
+ # Let's wipe the whole database.
pgsql_wipe
test_finish 0
input_file_cp=""
fi
- # Wipe the whole database.
+ # Let's wipe the whole database.
pgsql_wipe
# Clean up any test files left from prior failed runs unless -y was provided in which case
rm -f "${output_file}"
rm -f "${output_file}.tmp"
- # Wipe the whole database.
+ # Let's wipe the whole database.
pgsql_wipe
test_finish 0
# Check version.
version=$(mysql_version "${@}")
-if [ "$version" != "22.0" ] && [ "$version" != "22.1" ]; then
+if [ "$version" != "22.0" ] && [ "$version" != "22.1" ] && [ "$version" != "22.2" ]; then
printf 'This script upgrades 22.0 or 22.1 to 23.0. '
printf 'Reported version is %s. Skipping upgrade.\n' "${version}"
exit 0
VERSION=$(pgsql_version "$@")
-if [ "$VERSION" != "22.0" ] && [ "$VERSION" != "22.1" ]; then
+if [ "$VERSION" != "22.0" ] && [ "$VERSION" != "22.1" ] && [ "$VERSION" != "22.2" ]; then
printf 'This script upgrades 22.0 or 22.1 to 23.0. '
printf 'Reported version is %s. Skipping upgrade.\n' "${VERSION}"
exit 0
matches = re.search('^' + dirname + '/' + startswith + '.*$', i)
if matches is not None:
files.append(matches.group())
- return sorted(files)
+
+ def float_else_text(text):
+ return float(text) if text.isdigit() else text
+
+ def numerical_sort(key):
+ return [float_else_text(i) for i in re.split(r'([0-9]+\.?[0-9]*)', key)]
+
+ files.sort(key=lambda filename: numerical_sort(filename.split('_')[-1]))
+ return files
def find_last_file_in_same_directory_starting_with(file: str, startswith: str):