From: Marcin Siodelski Date: Wed, 12 Apr 2023 13:29:12 +0000 (+0200) Subject: [#2823] Added db upgrade tests X-Git-Tag: Kea-2.3.7~26 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=465c6ed9816addbbba1382061b9f2c0ecdcd9feb;p=thirdparty%2Fkea.git [#2823] Added db upgrade tests --- diff --git a/src/bin/admin/tests/mysql_tests.sh.in b/src/bin/admin/tests/mysql_tests.sh.in index c6577c18a5..b46a967722 100644 --- a/src/bin/admin/tests/mysql_tests.sh.in +++ b/src/bin/admin/tests/mysql_tests.sh.in @@ -715,6 +715,44 @@ mysql_upgrade_14_to_15_test() { 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" @@ -736,7 +774,7 @@ mysql_upgrade_test() { # 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. @@ -1390,6 +1428,9 @@ SET @disable_audit = 0;" 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 diff --git a/src/bin/admin/tests/pgsql_tests.sh.in b/src/bin/admin/tests/pgsql_tests.sh.in index 22b22e2274..51af1343d9 100644 --- a/src/bin/admin/tests/pgsql_tests.sh.in +++ b/src/bin/admin/tests/pgsql_tests.sh.in @@ -143,7 +143,7 @@ pgsql_db_version_test() { 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 @@ -805,6 +805,38 @@ pgsql_upgrade_14_to_15_test() { 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" @@ -822,7 +854,7 @@ pgsql_upgrade_test() { # 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 @@ -863,6 +895,9 @@ pgsql_upgrade_test() { # 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