2
0
mirror of https://gitlab.isc.org/isc-projects/kea synced 2025-08-29 13:07:50 +00:00

[#2166] Added missing CB elements to postgresql schema

Initial commit.

src/bin/admin/tests/pgsql_tests.sh.in
    pgsql_upgrade_6_2_to_7_0()  - replaced insert into dhcp6_server
    with selects. Inserting fails without an audit-revision to match.

src/share/database/scripts/pgsql/dhcpdb_create.pgsql
    Reduced to a single transaction and commit to avoid partial
    creations.

    Added CB audit procedures, trigger functions, triggers, and
    client class elements for v4 and v6.

src/share/database/scripts/pgsql/dhcpdb_drop.pgsql
    Added drops of new elements.

src/share/database/scripts/pgsql/upgrade_6.2_to_7.0.sh.in
    Added CB audit procedures, trigger functions, triggers, and
    client class elements for v4 and v6.
This commit is contained in:
tmark 2021-11-02 09:03:36 -04:00 committed by Tomek Mrugalski
parent fbdf5a8c98
commit 6ac227cb79
4 changed files with 3886 additions and 60 deletions

View File

@ -289,24 +289,27 @@ insert into hosts(dhcp_identifier, dhcp_identifier_type, dhcp4_subnet_id, ipv4_a
}
pgsql_upgrade_6_2_to_7_0() {
# Verify upgraded schema reports version 7.0.
version=$("${kea_admin}" db-version pgsql -u "${db_user}" -p "${db_password}" -n "${db_name}" -d "${db_scripts_dir}")
assert_str_eq "7.0" "${version}" "Expected kea-admin to return %s, returned value was %s"
# The dhcp6_server table has been introduced in this schema update. It should contain a special value "all" (with id 1)
# Hence we're adding tag "server1" with id 2.
insert_sql="insert into dhcp6_server (id,tag,description) values(2, 'server1', 'This is only a test server');"
run_command \
pgsql_execute "$insert_sql"
assert_eq 0 "${EXIT_CODE}" "insert into dhcp6_server failed, expected exit code %d, actual %d"
# And now check if it's possible to read something from the table.
select_sql="SELECT id, tag, description, modification_ts from dhcp6_server;"
# dhcp4_server should have a single entry for 'all'
select_sql="SELECT id, tag, description, modification_ts from dhcp4_server where id = 1 and tag = 'all';"
run_command \
pgsql_execute "$select_sql"
assert_eq 0 "${EXIT_CODE}" "the dhcp6_server table is broken or missing. (expected status code %d, returned %d)"
assert_eq 0 "${EXIT_CODE}" "the dhcp4_server table is broken or missing. (expected status code %d, returned %d)"
# Verify upgraded schema reports version 7.0.
version=$("${kea_admin}" db-version pgsql -u "${db_user}" -p "${db_password}" -n "${db_name}" -d "${db_scripts_dir}")
assert_str_eq "7.0" "${version}" "Expected kea-admin to return %s, returned value was %s"
# dhcp6_server should have a single entry for 'all'
select_sql="SELECT id, tag, description, modification_ts from dhcp6_server where id = 1 and tag = 'all';"
run_command \
pgsql_execute "$select_sql"
assert_eq 0 "${EXIT_CODE}" "the dhcp6_server table is broken or missing. (expected status code %d, returned %d)"
}
pgsql_upgrade_test() {

File diff suppressed because it is too large Load Diff

View File

@ -1,4 +1,4 @@
-- Copyright (C) 2016-2018 Internet Systems Consortium.
-- Copyright (C) 2016-2021 Internet Systems Consortium.
-- This Source Code Form is subject to the terms of the Mozilla Public
-- License, v. 2.0. If a copy of the MPL was not distributed with this
@ -30,6 +30,15 @@ DROP FUNCTION IF EXISTS proc_stat_lease6_update ();
DROP FUNCTION IF EXISTS proc_stat_lease6_delete ();
DROP TABLE IF EXISTS logs CASCADE;
-- config backend procedures for DHCPv6
DROP FUNCTION IF EXISTS createAuditRevisionDHCP6;
DROP FUNCTION IF EXISTS createAuditEntryDHCP6;
DROP FUNCTION IF EXISTS createOptionAuditDHCP6;
DROP FUNCTION IF EXISTS setClientClass6Order;
DROP FUNCTION IF EXISTS checkDHCPv6ClientClassDependency;
DROP FUNCTION IF EXISTS updateDHCPv6ClientClassKnownDependency;
DROP FUNCTION IF EXISTS checkDHCPv6ClientClassKnownDependencyChange;
-- config backend tables for DHCPv6
DROP TABLE IF EXISTS dhcp6_audit CASCADE;
DROP TABLE IF EXISTS dhcp6_option_def_server CASCADE;
@ -45,6 +54,47 @@ DROP TABLE IF EXISTS dhcp6_global_parameter_server CASCADE;
DROP TABLE IF EXISTS dhcp6_global_parameter CASCADE;
DROP TABLE IF EXISTS dhcp6_server CASCADE;
DROP TABLE IF EXISTS dhcp6_audit_revision CASCADE;
DROP TABLE IF EXISTS dhcp6_client_class_server CASCADE;
DROP TABLE IF EXISTS dhcp6_client_class_dependency CASCADE;
DROP TABLE IF EXISTS dhcp6_client_class_order CASCADE;
DROP TABLE IF EXISTS dhcp6_client_class CASCADE;
-- drop trigger functions for DHCPv6
DROP FUNCTION IF EXISTS func_dhcp6_client_class_AINS;
DROP FUNCTION IF EXISTS func_dhcp6_client_class_AUPD;
DROP FUNCTION IF EXISTS func_dhcp6_client_class_ADEL;
DROP FUNCTION IF EXISTS func_dhcp6_client_class_check_dependency_BINS;
DROP FUNCTION IF EXISTS func_dhcp6_client_class_dependency_AINS;
DROP FUNCTION IF EXISTS func_dhcp6_pool_BDEL;
DROP FUNCTION IF EXISTS func_dhcp6_global_parameter_AINS;
DROP FUNCTION IF EXISTS func_dhcp6_global_parameter_AUPD;
DROP FUNCTION IF EXISTS func_dhcp6_global_parameter_ADEL;
DROP FUNCTION IF EXISTS func_dhcp6_subnet_AINS;
DROP FUNCTION IF EXISTS func_dhcp6_subnet_AUPD;
DROP FUNCTION IF EXISTS func_dhcp6_shared_network_AINS;
DROP FUNCTION IF EXISTS func_dhcp6_shared_network_AUPD;
DROP FUNCTION IF EXISTS func_dhcp6_shared_network_ADEL;
DROP FUNCTION IF EXISTS func_dhcp6_option_def_AINS;
DROP FUNCTION IF EXISTS func_dhcp6_option_def_AUPD;
DROP FUNCTION IF EXISTS func_dhcp6_option_def_ADEL;
DROP FUNCTION IF EXISTS func_dhcp6_options_AINS;
DROP FUNCTION IF EXISTS func_dhcp6_options_AUPD;
DROP FUNCTION IF EXISTS func_dhcp6_options_ADEL;
DROP FUNCTION IF EXISTS func_dhcp6_server_AINS;
DROP FUNCTION IF EXISTS func_dhcp6_server_AUPD;
DROP FUNCTION IF EXISTS func_dhcp6_server_ADEL;
DROP FUNCTION IF EXISTS func_dhcp6_shared_network_BDEL;
DROP FUNCTION IF EXISTS func_dhcp6_subnet_BDEL;
DROP FUNCTION IF EXISTS func_dhcp6_pd_pool_BDEL;
-- config backend procedures for DHCPv4
DROP FUNCTION IF EXISTS createAuditRevisionDHCP4;
DROP FUNCTION IF EXISTS createAuditEntryDHCP4;
DROP FUNCTION IF EXISTS createOptionAuditDHCP4;
DROP FUNCTION IF EXISTS setClientClass4Order;
DROP FUNCTION IF EXISTS checkDHCPv4ClientClassDependency;
DROP FUNCTION IF EXISTS updateDHCPv4ClientClassKnownDependency;
DROP FUNCTION IF EXISTS checkDHCPv4ClientClassKnownDependencyChange;
-- config backend tables for DHCPv4
DROP TABLE IF EXISTS dhcp4_audit CASCADE;
@ -61,9 +111,41 @@ DROP TABLE IF EXISTS dhcp4_global_parameter_server CASCADE;
DROP TABLE IF EXISTS dhcp4_global_parameter CASCADE;
DROP TABLE IF EXISTS dhcp4_server CASCADE;
DROP TABLE IF EXISTS dhcp4_audit_revision CASCADE;
DROP TABLE IF EXISTS dhcp4_client_class_server CASCADE;
DROP TABLE IF EXISTS dhcp4_client_class_dependency CASCADE;
DROP TABLE IF EXISTS dhcp4_client_class_order CASCADE;
DROP TABLE IF EXISTS dhcp4_client_class CASCADE;
-- drop trigger functions for DHCPv4
DROP FUNCTION IF EXISTS func_dhcp4_client_class_AINS;
DROP FUNCTION IF EXISTS func_dhcp4_client_class_AUPD;
DROP FUNCTION IF EXISTS func_dhcp4_client_class_ADEL;
DROP FUNCTION IF EXISTS func_dhcp4_client_class_check_dependency_BINS;
DROP FUNCTION IF EXISTS func_dhcp4_client_class_dependency_AINS;
DROP FUNCTION IF EXISTS func_dhcp4_pool_BDEL;
DROP FUNCTION IF EXISTS func_dhcp4_global_parameter_AINS;
DROP FUNCTION IF EXISTS func_dhcp4_global_parameter_AUPD;
DROP FUNCTION IF EXISTS func_dhcp4_global_parameter_ADEL;
DROP FUNCTION IF EXISTS func_dhcp4_subnet_AINS;
DROP FUNCTION IF EXISTS func_dhcp4_subnet_AUPD;
DROP FUNCTION IF EXISTS func_dhcp4_shared_network_AINS;
DROP FUNCTION IF EXISTS func_dhcp4_shared_network_AUPD;
DROP FUNCTION IF EXISTS func_dhcp4_shared_network_ADEL;
DROP FUNCTION IF EXISTS func_dhcp4_option_def_AINS;
DROP FUNCTION IF EXISTS func_dhcp4_option_def_AUPD;
DROP FUNCTION IF EXISTS func_dhcp4_option_def_ADEL;
DROP FUNCTION IF EXISTS func_dhcp4_options_AINS;
DROP FUNCTION IF EXISTS func_dhcp4_options_AUPD;
DROP FUNCTION IF EXISTS func_dhcp4_options_ADEL;
DROP FUNCTION IF EXISTS func_dhcp4_server_AINS;
DROP FUNCTION IF EXISTS func_dhcp4_server_AUPD;
DROP FUNCTION IF EXISTS func_dhcp4_server_ADEL;
DROP FUNCTION IF EXISTS func_dhcp4_shared_network_BDEL;
DROP FUNCTION IF EXISTS func_dhcp4_subnet_BDEL;
-- common tables for config backend
DROP TABLE IF EXISTS modification CASCADE;
DROP TABLE IF EXISTS parameter_data_type CASCADE;
DROP TABLE IF EXISTS ddns_replace_client_name_types CASCADE;
DROP FUNCTION IF EXISTS modification_ts_update;

File diff suppressed because it is too large Load Diff