]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[#3479] removed parameters from database and added unittests
authorRazvan Becheriu <razvan@isc.org>
Thu, 18 Jul 2024 17:17:53 +0000 (20:17 +0300)
committerRazvan Becheriu <razvan@isc.org>
Thu, 18 Jul 2024 17:26:42 +0000 (20:26 +0300)
ChangeLog
src/bin/admin/tests/mysql_tests.sh.in
src/bin/admin/tests/pgsql_tests.sh.in
src/bin/dhcp4/dhcp4_messages.mes
src/share/database/scripts/mysql/dhcpdb_create.mysql
src/share/database/scripts/mysql/upgrade_023_to_024.sh.in
src/share/database/scripts/pgsql/dhcpdb_create.pgsql
src/share/database/scripts/pgsql/upgrade_023_to_024.sh.in

index 317d1223ed086782ab283b3f3aa87d312819de37..1a23a50430f108b91ba7f5016c1264a8246216f7 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2265.  [bug]*          fdupont
+       The 'control-socket' ('control-socket.socket-name' and
+       'control-socket.socket-type') was removed from the global maps
+       which can be managed by the config backend because in fact if
+       it is possible to change values they are not applied.
+       (Gitlab #3479)
+
 2264.  [bug]*          tmark
        Corrected an issue with overlapping enum values
        for option definition data type.  This was causing
index 304933bcded9c852829616994db539988ba729f1..e0049e2a849eecb8aa792368f4ed8e04948452ed 100644 (file)
@@ -3386,6 +3386,57 @@ mysql_migrate_opt_record_type() {
     test_finish 0
 }
 
+# Verifies that control-socket global map parameters are removed.
+mysql_remove_control_socket_parameters_test() {
+    test_start "mysql.mysql_remove_control_socket_parameters_test"
+
+    # Let's wipe the whole database
+    mysql_wipe
+
+    # We need to create an older database.
+    # Initialize database to schema 1.0.
+    mysql -u"${db_user}" -p"${db_password}" "${db_name}" < "@abs_top_srcdir@/src/bin/admin/tests/dhcpdb_create_1.0.mysql"
+
+    # Now upgrade to schema 23.0.
+    mysql_upgrade_schema_to_version 23.0
+
+    # Now insert global parameter instances of control-socket.
+    sql=\
+"set @disable_audit = 1; \
+ insert into dhcp4_global_parameter (name,value,modification_ts,parameter_type)\
+    values ('control-socket.socket-name','/tmp/socket',current_time(),4);
+ insert into dhcp4_global_parameter (name,value,modification_ts,parameter_type)\
+    values ('control-socket.socket-type','unix',current_time(),4);
+ insert into dhcp6_global_parameter (name,value,modification_ts,parameter_type)\
+    values ('control-socket.socket-name','/tmp/socket',current_time(),4);
+ insert into dhcp6_global_parameter (name,value,modification_ts,parameter_type)\
+    values ('control-socket.socket-type','unix',current_time(),4);"
+
+    run_statement "insert control-socket map parameters" "$sql"
+
+    # Verify the inserted record counts.
+    qry="select count(*) from dhcp4_global_parameter where name like '%control-socket%';"
+    run_statement "#get 4_global parameter count before update" "$qry" 2
+
+    qry="select count(*) from dhcp6_global_parameter where name like '%control-socket%';"
+    run_statement "#get 6_global parameter count before update" "$qry" 2
+
+    # Upgrade to schema 24.0
+    mysql_upgrade_schema_to_version 24.0
+
+    # Verify the record have been removed.
+    qry="select count(*) from dhcp4_global_parameter where name like '%control-socket%';"
+    run_statement "#get 4_global parameter count after update" "$qry" 0
+
+    qry="select count(*) from dhcp6_global_parameter where name like '%control-socket%';"
+    run_statement "#get 6_global parameter count after update" "$qry" 0
+
+    # Let's wipe the whole database
+    mysql_wipe
+
+    test_finish 0
+}
+
 # Run tests.
 mysql_db_init_test
 mysql_host_reservation_init_test
@@ -3419,3 +3470,4 @@ mysql_reservation_mode_all_parameters_test
 mysql_reservation_mode_global_parameters_test
 mysql_reservation_mode_out_of_pool_parameters_test
 mysql_migrate_opt_record_type
+mysql_remove_control_socket_parameters_test
index e5c0de51af955bc8231f4e861ceff33e43dd40c5..aa7a179d0a6d8345b05b9d92bd2b3652b01c8656 100644 (file)
@@ -2647,6 +2647,61 @@ pgsql_migrate_opt_record_type() {
     test_finish 0
 }
 
+# Verifies that control-socket global map parameters are removed.
+pgsql_remove_control_socket_parameters_test() {
+    test_start "pgsql.pgsql_remove_control_socket_parameters_test"
+
+    # Let's wipe the whole database
+    pgsql_wipe
+
+    # We need to create an older database with lease data so we can
+    # verify the upgrade mechanisms which prepopulate the lease stat
+    # tables.
+    #
+    # Initialize database to schema 1.0.
+    pgsql_execute_script "@abs_top_srcdir@/src/bin/admin/tests/dhcpdb_create_1.0.pgsql"
+    assert_eq 0 "${EXIT_CODE}" "cannot initialize 1.0 database, expected exit code: %d, actual: %d"
+
+    # Now upgrade to schema 23.0
+    pgsql_upgrade_schema_to_version 23.0
+
+    # Now insert global parameter instances of control-socket.
+    sql=\
+"select set_config('kea.disable_audit', 'true', false);\
+ insert into dhcp4_global_parameter (name,value,modification_ts,parameter_type)\
+    values ('control-socket.socket-name','/tmp/socket',current_timestamp,4);
+ insert into dhcp4_global_parameter (name,value,modification_ts,parameter_type)\
+    values ('control-socket.socket-type','unix',current_timestamp,4);
+ insert into dhcp6_global_parameter (name,value,modification_ts,parameter_type)\
+    values ('control-socket.socket-name','/tmp/socket',current_timestamp,4);
+ insert into dhcp6_global_parameter (name,value,modification_ts,parameter_type)\
+    values ('control-socket.socket-type','unix',current_timestamp,4);"
+
+    run_statement "insert control-socket map parameters" "$sql"
+
+    # Verify the inserted record counts.
+    qry="select count(*) from dhcp4_global_parameter where name like '%control-socket%';"
+    run_statement "#get 4_global parameter count before update" "$qry" 2
+
+    qry="select count(*) from dhcp6_global_parameter where name like '%control-socket%';"
+    run_statement "#get 6_global parameter count before update" "$qry" 2
+
+    # Upgrade to schema 24.0
+    pgsql_upgrade_schema_to_version 24.0
+
+    # Verify the record have been removed.
+    qry="select count(*) from dhcp4_global_parameter where name like '%control-socket%';"
+    run_statement "#get 4_global parameter count after update" "$qry" 0
+
+    qry="select count(*) from dhcp6_global_parameter where name like '%control-socket%';"
+    run_statement "#get 6_global parameter count after update" "$qry" 0
+
+    # Let's wipe the whole database
+    pgsql_wipe
+
+    test_finish 0
+}
+
 # Run tests.
 pgsql_db_init_test
 pgsql_db_version_test
@@ -2674,3 +2729,4 @@ pgsql_reservation_mode_all_parameters_test
 pgsql_reservation_mode_global_parameters_test
 pgsql_reservation_mode_out_of_pool_parameters_test
 pgsql_migrate_opt_record_type
+pgsql_remove_control_socket_parameters_test
index 5daf669fbceea127864f26186a7cc666b12f6185..59509b590b7b4279f1c50749c562ba2ba4b69e8c 100644 (file)
@@ -1155,7 +1155,7 @@ The second argument contains the IPv4 address in the ciaddr field. The
 third argument contains the IPv4 address in the requested-ip-address
 option (if present).
 
-% DHCP4_V6_ONLY_PREFERRED_MISSING_IN_ACK v6-only-preferred option missing in 0.0.0.0 offer to query: %1
+% DHCP4_V6_ONLY_PREFERRED_MISSING_IN_ACK v6-only-preferred option missing in 0.0.0.0 reply to query: %1
 An DHCPACK for the 0.0.0.0 address was generated for a client requesting
 the v6-only-preferred (108) option but the option is not in the response as
 expected: the erroneous response is dropped, the request query is displayed.
index c9b8f8148409e0b24d9d22ff475c76528f85562a..7461b50296c499f7c524cd7d9cf82ccc36309259 100644 (file)
@@ -5929,6 +5929,16 @@ UPDATE schema_version
 
 -- This line starts the schema upgrade to version 24.0.
 
+SET @disable_audit = 1;
+
+DELETE FROM dhcp4_global_parameter WHERE name='control-socket.socket-name';
+DELETE FROM dhcp4_global_parameter WHERE name='control-socket.socket-type';
+
+DELETE FROM dhcp6_global_parameter WHERE name='control-socket.socket-name';
+DELETE FROM dhcp6_global_parameter WHERE name='control-socket.socket-type';
+
+SET @disable_audit = 0;
+
 -- Create a function to conditionally migrate option_def data type
 -- values.  If they are updating from 2.6.1 this has been done already
 -- and we don't want to do it twice.
index fd438731cb87592253dd6c506d531773a67b6909..a012e523802b81212a729a0c791d71ac396e713a 100644 (file)
@@ -56,6 +56,16 @@ mysql "$@" <<EOF
 
 -- This line starts the schema upgrade to version 24.0.
 
+SET @disable_audit = 1;
+
+DELETE FROM dhcp4_global_parameter WHERE name='control-socket.socket-name';
+DELETE FROM dhcp4_global_parameter WHERE name='control-socket.socket-type';
+
+DELETE FROM dhcp6_global_parameter WHERE name='control-socket.socket-name';
+DELETE FROM dhcp6_global_parameter WHERE name='control-socket.socket-type';
+
+SET @disable_audit = 0;
+
 -- Create a function to conditionally migrate option_def data type
 -- values.  If they are updating from 2.6.1 this has been done already
 -- and we don't want to do it twice.
index e2a5f848a032e3888c15ceedef888f0e02acebf3..b212312afa35ae5db041b5719a5cfca6b114b0f8 100644 (file)
@@ -6391,6 +6391,16 @@ UPDATE schema_version
 
 -- This line starts the schema upgrade to version 24.0.
 
+SELECT set_config('kea.disable_audit', 'true', false);
+
+DELETE FROM dhcp4_global_parameter WHERE name='control-socket.socket-name';
+DELETE FROM dhcp4_global_parameter WHERE name='control-socket.socket-type';
+
+DELETE FROM dhcp6_global_parameter WHERE name='control-socket.socket-name';
+DELETE FROM dhcp6_global_parameter WHERE name='control-socket.socket-type';
+
+SELECT set_config('kea.disable_audit', 'false', false);
+
 -- Create a function to conditionally migrate option_def data type
 -- values.  If they are updating from 2.6.1 this has been done already
 -- and we don't want to do it twice.
index 04749d855ac45f36911cd093a72217aa9599a583..5130e4ce588414be8ee2d3449e0f80e7acb2855e 100644 (file)
@@ -39,6 +39,16 @@ START TRANSACTION;
 
 -- This line starts the schema upgrade to version 24.0.
 
+SELECT set_config('kea.disable_audit', 'true', false);
+
+DELETE FROM dhcp4_global_parameter WHERE name='control-socket.socket-name';
+DELETE FROM dhcp4_global_parameter WHERE name='control-socket.socket-type';
+
+DELETE FROM dhcp6_global_parameter WHERE name='control-socket.socket-name';
+DELETE FROM dhcp6_global_parameter WHERE name='control-socket.socket-type';
+
+SELECT set_config('kea.disable_audit', 'false', false);
+
 -- Create a function to conditionally migrate option_def data type
 -- values.  If they are updating from 2.6.1 this has been done already
 -- and we don't want to do it twice.