assert_eq 0 "${EXIT_CODE}" "${qry}. (expected status code %d, returned %d)"
}
+mysql_upgrade_16_to_17_test() {
+ # Check if allocator was added to dhcp4_shared_network table.
+ qry="SELECT allocator from dhcp4_shared_network limit 1;"
+ run_command \
+ mysql_execute "${qry}"
+ assert_eq 0 "${EXIT_CODE}" "${qry}. (expected status code %d, returned %d)"
+
+ # Check if allocator was added to dhcp6_shared_network table.
+ qry="SELECT allocator from dhcp6_shared_network limit 1;"
+ run_command \
+ mysql_execute "${qry}"
+ assert_eq 0 "${EXIT_CODE}" "${qry}. (expected status code %d, returned %d)"
+
+ # Check if pd_allocator was added to dhcp6_shared_network table.
+ qry="SELECT pd_allocator from dhcp6_shared_network limit 1;"
+ run_command \
+ mysql_execute "${qry}"
+ assert_eq 0 "${EXIT_CODE}" "${qry}. (expected status code %d, returned %d)"
+
+ # Check if allocator was added to dhcp4_subnet table.
+ qry="SELECT allocator from dhcp4_subnet limit 1;"
+ run_command \
+ mysql_execute "${qry}"
+ assert_eq 0 "${EXIT_CODE}" "${qry}. (expected status code %d, returned %d)"
+
+ # Check if allocator was added to dhcp6_subnet table.
+ qry="SELECT allocator from dhcp6_subnet limit 1;"
+ run_command \
+ mysql_execute "${qry}"
+ assert_eq 0 "${EXIT_CODE}" "${qry}. (expected status code %d, returned %d)"
+
+ # Check if pd_allocator was added to dhcp6_subnet table.
+ qry="SELECT pd_allocator from dhcp6_subnet limit 1;"
+ run_command \
+ mysql_execute "${qry}"
+ assert_eq 0 "${EXIT_CODE}" "${qry}. (expected status code %d, returned %d)"
+}
+
mysql_upgrade_test() {
test_start "mysql.upgrade"
# Verify that the upgraded schema reports the latest version.
version=$("${kea_admin}" db-version mysql -u "${db_user}" -p "${db_password}" -n "${db_name}" -d "${db_scripts_dir}")
- assert_str_eq "16.0" "${version}" "Expected kea-admin to return %s, returned value was %s"
+ assert_str_eq "17.0" "${version}" "Expected kea-admin to return %s, returned value was %s"
# Let's check that the new tables are indeed there.
count=$(echo "${OUTPUT}" | grep -Fci lease4_by_remote_id)
assert_eq 1 "${count}" "lease4_by_remote_id wrong or missing. (expected count %d, actual %d)"
+ # Check upgrade from 16.0 to 17.0.
+ mysql_upgrade_16_to_17_test
+
# Let's wipe the whole database
mysql_wipe
run_command \
"${kea_admin}" db-version pgsql -u "${db_user}" -p "${db_password}" -n "${db_name}"
version="${OUTPUT}"
- assert_str_eq "15.0" "${version}" "Expected kea-admin to return %s, returned value was %s"
+ assert_str_eq "16.0" "${version}" "Expected kea-admin to return %s, returned value was %s"
# Let's wipe the whole database
pgsql_wipe
assert_eq 0 "${EXIT_CODE}" "lease4 is missing remote_id column. (expected status code %d, returned %d)"
}
+pgsql_upgrade_15_to_16_test() {
+ # Added allocator column to dhcp4_shared_network
+ run_command \
+ pgsql_execute "select allocator from dhcp4_shared_network;"
+ assert_eq 0 "${EXIT_CODE}" "dhcp4_shared_network is missing allocator column. (expected status code %d, returned %d)"
+
+ # Added allocator column to dhcp6_shared_network
+ run_command \
+ pgsql_execute "select allocator from dhcp6_shared_network;"
+ assert_eq 0 "${EXIT_CODE}" "dhcp6_shared_network is missing allocator column. (expected status code %d, returned %d)"
+
+ # Added pd_allocator column to dhcp6_shared_network
+ run_command \
+ pgsql_execute "select pd_allocator from dhcp6_shared_network;"
+ assert_eq 0 "${EXIT_CODE}" "dhcp6_shared_network is missing pd_allocator column. (expected status code %d, returned %d)"
+
+ # Added allocator column to dhcp4_subnet
+ run_command \
+ pgsql_execute "select allocator from dhcp4_subnet;"
+ assert_eq 0 "${EXIT_CODE}" "dhcp4_subnet is missing allocator column. (expected status code %d, returned %d)"
+
+ # Added allocator column to dhcp6_subnet
+ run_command \
+ pgsql_execute "select allocator from dhcp6_subnet;"
+ assert_eq 0 "${EXIT_CODE}" "dhcp6_subnet is missing allocator column. (expected status code %d, returned %d)"
+
+ # Added pd_allocator column to dhcp6_subnet
+ run_command \
+ pgsql_execute "select pd_allocator from dhcp6_subnet;"
+ assert_eq 0 "${EXIT_CODE}" "dhcp6_subnet is missing pd_allocator column. (expected status code %d, returned %d)"
+}
+
pgsql_upgrade_test() {
test_start "pgsql.upgrade"
# Verify upgraded schema reports the latest version.
version=$("${kea_admin}" db-version pgsql -u "${db_user}" -p "${db_password}" -n "${db_name}" -d "${db_scripts_dir}")
- assert_str_eq "15.0" "${version}" 'Expected kea-admin to return %s, returned value was %s'
+ assert_str_eq "16.0" "${version}" 'Expected kea-admin to return %s, returned value was %s'
# Check 1.0 to 2.0 upgrade
pgsql_upgrade_1_0_to_2_0
# Check 14 to 15 upgrade
pgsql_upgrade_14_to_15_test
+ # Check 15 to 16 upgrade
+ pgsql_upgrade_15_to_16_test
+
# Let's wipe the whole database
pgsql_wipe