Skip to content

Commit 9e9e28d

Browse files
author
Razvan Becheriu
committed
[#3479] removed parameters from database and added unittests
1 parent 3143a19 commit 9e9e28d

8 files changed

+156
-1
lines changed

ChangeLog

+7
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
2265. [bug]* fdupont
2+
The 'control-socket' ('control-socket.socket-name' and
3+
'control-socket.socket-type') was removed from the global maps
4+
which can be managed by the config backend because in fact if
5+
it is possible to change values they are not applied.
6+
(Gitlab #3479)
7+
18
2264. [bug]* tmark
29
Corrected an issue with overlapping enum values
310
for option definition data type. This was causing

src/bin/admin/tests/mysql_tests.sh.in

+52
Original file line numberDiff line numberDiff line change
@@ -3386,6 +3386,57 @@ mysql_migrate_opt_record_type() {
33863386
test_finish 0
33873387
}
33883388

3389+
# Verifies that control-socket global map parameters are removed.
3390+
mysql_remove_control_socket_parameters_test() {
3391+
test_start "mysql.mysql_remove_control_socket_parameters_test"
3392+
3393+
# Let's wipe the whole database
3394+
mysql_wipe
3395+
3396+
# We need to create an older database.
3397+
# Initialize database to schema 1.0.
3398+
mysql -u"${db_user}" -p"${db_password}" "${db_name}" < "@abs_top_srcdir@/src/bin/admin/tests/dhcpdb_create_1.0.mysql"
3399+
3400+
# Now upgrade to schema 23.0.
3401+
mysql_upgrade_schema_to_version 23.0
3402+
3403+
# Now insert global parameter instances of control-socket.
3404+
sql=\
3405+
"set @disable_audit = 1; \
3406+
insert into dhcp4_global_parameter (name,value,modification_ts,parameter_type)\
3407+
values ('control-socket.socket-name','/tmp/socket',current_time(),4);
3408+
insert into dhcp4_global_parameter (name,value,modification_ts,parameter_type)\
3409+
values ('control-socket.socket-type','unix',current_time(),4);
3410+
insert into dhcp6_global_parameter (name,value,modification_ts,parameter_type)\
3411+
values ('control-socket.socket-name','/tmp/socket',current_time(),4);
3412+
insert into dhcp6_global_parameter (name,value,modification_ts,parameter_type)\
3413+
values ('control-socket.socket-type','unix',current_time(),4);"
3414+
3415+
run_statement "insert control-socket map parameters" "$sql"
3416+
3417+
# Verify the inserted record counts.
3418+
qry="select count(*) from dhcp4_global_parameter where name like '%control-socket%';"
3419+
run_statement "#get 4_global parameter count before update" "$qry" 2
3420+
3421+
qry="select count(*) from dhcp6_global_parameter where name like '%control-socket%';"
3422+
run_statement "#get 6_global parameter count before update" "$qry" 2
3423+
3424+
# Upgrade to schema 24.0
3425+
mysql_upgrade_schema_to_version 24.0
3426+
3427+
# Verify the record have been removed.
3428+
qry="select count(*) from dhcp4_global_parameter where name like '%control-socket%';"
3429+
run_statement "#get 4_global parameter count after update" "$qry" 0
3430+
3431+
qry="select count(*) from dhcp6_global_parameter where name like '%control-socket%';"
3432+
run_statement "#get 6_global parameter count after update" "$qry" 0
3433+
3434+
# Let's wipe the whole database
3435+
mysql_wipe
3436+
3437+
test_finish 0
3438+
}
3439+
33893440
# Run tests.
33903441
mysql_db_init_test
33913442
mysql_host_reservation_init_test
@@ -3419,3 +3470,4 @@ mysql_reservation_mode_all_parameters_test
34193470
mysql_reservation_mode_global_parameters_test
34203471
mysql_reservation_mode_out_of_pool_parameters_test
34213472
mysql_migrate_opt_record_type
3473+
mysql_remove_control_socket_parameters_test

src/bin/admin/tests/pgsql_tests.sh.in

+56
Original file line numberDiff line numberDiff line change
@@ -2647,6 +2647,61 @@ pgsql_migrate_opt_record_type() {
26472647
test_finish 0
26482648
}
26492649

2650+
# Verifies that control-socket global map parameters are removed.
2651+
pgsql_remove_control_socket_parameters_test() {
2652+
test_start "pgsql.pgsql_remove_control_socket_parameters_test"
2653+
2654+
# Let's wipe the whole database
2655+
pgsql_wipe
2656+
2657+
# We need to create an older database with lease data so we can
2658+
# verify the upgrade mechanisms which prepopulate the lease stat
2659+
# tables.
2660+
#
2661+
# Initialize database to schema 1.0.
2662+
pgsql_execute_script "@abs_top_srcdir@/src/bin/admin/tests/dhcpdb_create_1.0.pgsql"
2663+
assert_eq 0 "${EXIT_CODE}" "cannot initialize 1.0 database, expected exit code: %d, actual: %d"
2664+
2665+
# Now upgrade to schema 23.0
2666+
pgsql_upgrade_schema_to_version 23.0
2667+
2668+
# Now insert global parameter instances of control-socket.
2669+
sql=\
2670+
"select set_config('kea.disable_audit', 'true', false);\
2671+
insert into dhcp4_global_parameter (name,value,modification_ts,parameter_type)\
2672+
values ('control-socket.socket-name','/tmp/socket',current_timestamp,4);
2673+
insert into dhcp4_global_parameter (name,value,modification_ts,parameter_type)\
2674+
values ('control-socket.socket-type','unix',current_timestamp,4);
2675+
insert into dhcp6_global_parameter (name,value,modification_ts,parameter_type)\
2676+
values ('control-socket.socket-name','/tmp/socket',current_timestamp,4);
2677+
insert into dhcp6_global_parameter (name,value,modification_ts,parameter_type)\
2678+
values ('control-socket.socket-type','unix',current_timestamp,4);"
2679+
2680+
run_statement "insert control-socket map parameters" "$sql"
2681+
2682+
# Verify the inserted record counts.
2683+
qry="select count(*) from dhcp4_global_parameter where name like '%control-socket%';"
2684+
run_statement "#get 4_global parameter count before update" "$qry" 2
2685+
2686+
qry="select count(*) from dhcp6_global_parameter where name like '%control-socket%';"
2687+
run_statement "#get 6_global parameter count before update" "$qry" 2
2688+
2689+
# Upgrade to schema 24.0
2690+
pgsql_upgrade_schema_to_version 24.0
2691+
2692+
# Verify the record have been removed.
2693+
qry="select count(*) from dhcp4_global_parameter where name like '%control-socket%';"
2694+
run_statement "#get 4_global parameter count after update" "$qry" 0
2695+
2696+
qry="select count(*) from dhcp6_global_parameter where name like '%control-socket%';"
2697+
run_statement "#get 6_global parameter count after update" "$qry" 0
2698+
2699+
# Let's wipe the whole database
2700+
pgsql_wipe
2701+
2702+
test_finish 0
2703+
}
2704+
26502705
# Run tests.
26512706
pgsql_db_init_test
26522707
pgsql_db_version_test
@@ -2674,3 +2729,4 @@ pgsql_reservation_mode_all_parameters_test
26742729
pgsql_reservation_mode_global_parameters_test
26752730
pgsql_reservation_mode_out_of_pool_parameters_test
26762731
pgsql_migrate_opt_record_type
2732+
pgsql_remove_control_socket_parameters_test

src/bin/dhcp4/dhcp4_messages.mes

+1-1
Original file line numberDiff line numberDiff line change
@@ -1155,7 +1155,7 @@ The second argument contains the IPv4 address in the ciaddr field. The
11551155
third argument contains the IPv4 address in the requested-ip-address
11561156
option (if present).
11571157

1158-
% DHCP4_V6_ONLY_PREFERRED_MISSING_IN_ACK v6-only-preferred option missing in 0.0.0.0 offer to query: %1
1158+
% DHCP4_V6_ONLY_PREFERRED_MISSING_IN_ACK v6-only-preferred option missing in 0.0.0.0 reply to query: %1
11591159
An DHCPACK for the 0.0.0.0 address was generated for a client requesting
11601160
the v6-only-preferred (108) option but the option is not in the response as
11611161
expected: the erroneous response is dropped, the request query is displayed.

src/share/database/scripts/mysql/dhcpdb_create.mysql

+10
Original file line numberDiff line numberDiff line change
@@ -5929,6 +5929,16 @@ UPDATE schema_version
59295929

59305930
-- This line starts the schema upgrade to version 24.0.
59315931

5932+
SET @disable_audit = 1;
5933+
5934+
DELETE FROM dhcp4_global_parameter WHERE name='control-socket.socket-name';
5935+
DELETE FROM dhcp4_global_parameter WHERE name='control-socket.socket-type';
5936+
5937+
DELETE FROM dhcp6_global_parameter WHERE name='control-socket.socket-name';
5938+
DELETE FROM dhcp6_global_parameter WHERE name='control-socket.socket-type';
5939+
5940+
SET @disable_audit = 0;
5941+
59325942
-- Create a function to conditionally migrate option_def data type
59335943
-- values. If they are updating from 2.6.1 this has been done already
59345944
-- and we don't want to do it twice.

src/share/database/scripts/mysql/upgrade_023_to_024.sh.in

+10
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,16 @@ mysql "$@" <<EOF
5656
5757
-- This line starts the schema upgrade to version 24.0.
5858
59+
SET @disable_audit = 1;
60+
61+
DELETE FROM dhcp4_global_parameter WHERE name='control-socket.socket-name';
62+
DELETE FROM dhcp4_global_parameter WHERE name='control-socket.socket-type';
63+
64+
DELETE FROM dhcp6_global_parameter WHERE name='control-socket.socket-name';
65+
DELETE FROM dhcp6_global_parameter WHERE name='control-socket.socket-type';
66+
67+
SET @disable_audit = 0;
68+
5969
-- Create a function to conditionally migrate option_def data type
6070
-- values. If they are updating from 2.6.1 this has been done already
6171
-- and we don't want to do it twice.

src/share/database/scripts/pgsql/dhcpdb_create.pgsql

+10
Original file line numberDiff line numberDiff line change
@@ -6391,6 +6391,16 @@ UPDATE schema_version
63916391

63926392
-- This line starts the schema upgrade to version 24.0.
63936393

6394+
SELECT set_config('kea.disable_audit', 'true', false);
6395+
6396+
DELETE FROM dhcp4_global_parameter WHERE name='control-socket.socket-name';
6397+
DELETE FROM dhcp4_global_parameter WHERE name='control-socket.socket-type';
6398+
6399+
DELETE FROM dhcp6_global_parameter WHERE name='control-socket.socket-name';
6400+
DELETE FROM dhcp6_global_parameter WHERE name='control-socket.socket-type';
6401+
6402+
SELECT set_config('kea.disable_audit', 'false', false);
6403+
63946404
-- Create a function to conditionally migrate option_def data type
63956405
-- values. If they are updating from 2.6.1 this has been done already
63966406
-- and we don't want to do it twice.

src/share/database/scripts/pgsql/upgrade_023_to_024.sh.in

+10
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,16 @@ START TRANSACTION;
3939
4040
-- This line starts the schema upgrade to version 24.0.
4141
42+
SELECT set_config('kea.disable_audit', 'true', false);
43+
44+
DELETE FROM dhcp4_global_parameter WHERE name='control-socket.socket-name';
45+
DELETE FROM dhcp4_global_parameter WHERE name='control-socket.socket-type';
46+
47+
DELETE FROM dhcp6_global_parameter WHERE name='control-socket.socket-name';
48+
DELETE FROM dhcp6_global_parameter WHERE name='control-socket.socket-type';
49+
50+
SELECT set_config('kea.disable_audit', 'false', false);
51+
4252
-- Create a function to conditionally migrate option_def data type
4353
-- values. If they are updating from 2.6.1 this has been done already
4454
-- and we don't want to do it twice.

0 commit comments

Comments
 (0)