]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[#2823] Added db upgrade tests
authorMarcin Siodelski <marcin@isc.org>
Wed, 12 Apr 2023 13:29:12 +0000 (15:29 +0200)
committerMarcin Siodelski <marcin@isc.org>
Wed, 19 Apr 2023 16:26:04 +0000 (18:26 +0200)
src/bin/admin/tests/mysql_tests.sh.in
src/bin/admin/tests/pgsql_tests.sh.in

index c6577c18a514bee1145dd023dbf86ef0de582b83..b46a967722d37aeb3d2d9632fb538a9d4b24e42b 100644 (file)
@@ -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
 
index 22b22e22744140feb4411a8ae0f73a20141d8439..51af1343d94203380a4833080c021881ea9f505f 100644 (file)
@@ -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