printf "Verifying upgrade permissions for %s\n" "$db_user"
mysql_can_create
- for script in "${upgrade_scripts_dir}"/upgrade*.sh
+ upgrade_scripts=$(find "${upgrade_scripts_dir}" -type f -name 'upgrade_*.sh' | sort -V)
+ for script in ${upgrade_scripts}
do
echo "Processing $script file..."
"${script}" --host="${db_host}" --user="${db_user}" \
# thru an env
export PGPASSWORD=$db_password
- for script in "${upgrade_scripts_dir}"/upgrade*.sh
+ upgrade_scripts=$(find "${upgrade_scripts_dir}" -type f -name 'upgrade_*.sh' | sort -V)
+ for script in ${upgrade_scripts}
do
echo "Processing $script file..."
"${script}" -U "${db_user}" -h "${db_host}" \
}
mysql_upgrade_22_0_to_22_1_test() {
- query="SELECT count(id) from option_def_data_type"
+ query="SELECT count(id) FROM option_def_data_type"
run_command \
mysql_execute "${query}"
assert_eq 0 "${EXIT_CODE}" "${query}: expected %d, returned %d"
insert into dhcp6_option_def (code,name,space,type,modification_ts,record_types, is_array, encapsulate)\
values ('224','bar2','dhcp6',18,current_timestamp,'10, 7, 2, 14', false, false);
"
- run_statement "insert otion definitions" "$sql"
+ run_statement "insert option definitions" "$sql"
# Verify the inserted record counts.
qry="select count(*) from dhcp4_option_def;"
mysql_upgrade_schema_to_version 22.1
# Verify the migrated records.
- qry="select type from dhcp4_option_def where name = 'foo';"
+ qry="select type from dhcp4_option_def = 'foo';"
run_statement "#get 4_option_def_foo after update" "$qry" 17
- qry="select type from dhcp4_option_def where name = 'bar';"
+ qry="select type from dhcp4_option_def = 'bar';"
run_statement "#get 4_option_def_bar after update" "$qry" 254
- qry="select type from dhcp4_option_def where name = 'bar2';"
+ qry="select type from dhcp4_option_def = 'bar2';"
run_statement "#get 4_option_def_bar2 after update" "$qry" 254
- qry="select type from dhcp6_option_def where name = 'foo';"
+ qry="select type from dhcp6_option_def = 'foo';"
run_statement "#get 6_option_def_foo after update" "$qry" 17
- qry="select type from dhcp6_option_def where name = 'bar';"
+ qry="select type from dhcp6_option_def = 'bar';"
run_statement "#get 6_option_def_bar after update" "$qry" 254
- qry="select type from dhcp6_option_def where name = 'bar2';"
+ qry="select type from dhcp6_option_def = 'bar2';"
run_statement "#get 6_option_def_bar2 after update" "$qry" 254
# Let's wipe the whole database
}
pgsql_upgrade_22_to_22_1_test() {
- query="SELECT count(id) from option_def_data_type"
+ query="SELECT count(id) FROM option_def_data_type"
run_command \
pgsql_execute "${query}"
assert_eq 0 "${EXIT_CODE}" "${query}: expected %d, returned %d"
insert into dhcp6_option_def (code,name,space,type,modification_ts,record_types, is_array, encapsulate)\
values ('224','bar2','dhcp6',18,current_timestamp,'10, 7, 2, 14', false, false);
"
- run_statement "insert otion definitions" "$sql"
+ run_statement "insert option definitions" "$sql"
# Verify the inserted record counts.
qry="select count(*) from dhcp4_option_def;"
pgsql_upgrade_schema_to_version 24.0
# Verify the migrated records.
- qry="select type from dhcp4_option_def where name = 'foo';"
+ qry="select type from dhcp4_option_def where name = 'foo';"
run_statement "#get 4_option_def_foo after update" "$qry" 17
- qry="select type from dhcp4_option_def where name = 'bar';"
+ qry="select type from dhcp4_option_def where name = 'bar';"
run_statement "#get 4_option_def_bar after update" "$qry" 254
- qry="select type from dhcp4_option_def where name = 'bar2';"
+ qry="select type from dhcp4_option_def where name = 'bar2';"
run_statement "#get 4_option_def_bar2 after update" "$qry" 254
- qry="select type from dhcp6_option_def where name = 'foo';"
+ qry="select type from dhcp6_option_def where name = 'foo';"
run_statement "#get 6_option_def_foo after update" "$qry" 17
- qry="select type from dhcp6_option_def where name = 'bar';"
+ qry="select type from dhcp6_option_def where name = 'bar';"
run_statement "#get 6_option_def_bar after update" "$qry" 254
- qry="select type from dhcp6_option_def where name = 'bar2';"
+ qry="select type from dhcp6_option_def where name = 'bar2';"
run_statement "#get 6_option_def_bar2 after update" "$qry" 254
# Let's wipe the whole database
/// @brief Data types of DHCP option fields.
///
-/// @warning The order of data types matters: OPT_UNKNOWN_TYPE
-/// must always be the last position. Also, OPT_RECORD_TYPE
-/// must be at last but one position. This is because some
-/// functions perform sanity checks on data type values using
-/// '>' operators, assuming that all values beyond the
-/// OPT_RECORD_TYPE are invalid.
-enum OptionDataType {
- OPT_EMPTY_TYPE,
- OPT_BINARY_TYPE,
- OPT_BOOLEAN_TYPE,
- OPT_INT8_TYPE,
- OPT_INT16_TYPE,
- OPT_INT32_TYPE,
- OPT_UINT8_TYPE,
- OPT_UINT16_TYPE,
- OPT_UINT32_TYPE,
- OPT_ANY_ADDRESS_TYPE,
- OPT_IPV4_ADDRESS_TYPE,
- OPT_IPV6_ADDRESS_TYPE,
- OPT_IPV6_PREFIX_TYPE,
- OPT_PSID_TYPE,
- OPT_STRING_TYPE,
- OPT_TUPLE_TYPE,
- OPT_FQDN_TYPE,
+/// @warning Do NOT alter existing values to add (or remove) new types.
+/// These values are stored by config backend. Altering any existing
+/// values will produce code that is incompatiable with pre-existing data.
+/// Futhermore, the order of data types matters: OPT_UNKNOWN_TYPE
+/// must always be and OPT_RECORD_TYPE must be at second to last.
+/// This is because some functions perform sanity checks on data type
+/// values using '>' operators, assuming that all values beyond the
+enum OptionDataType : int {
+ OPT_EMPTY_TYPE = 0,
+ OPT_BINARY_TYPE = 1,
+ OPT_BOOLEAN_TYPE = 2,
+ OPT_INT8_TYPE = 3,
+ OPT_INT16_TYPE = 4,
+ OPT_INT32_TYPE = 5,
+ OPT_UINT8_TYPE = 6,
+ OPT_UINT16_TYPE = 7,
+ OPT_UINT32_TYPE = 8,
+ OPT_ANY_ADDRESS_TYPE = 9,
+ OPT_IPV4_ADDRESS_TYPE = 10,
+ OPT_IPV6_ADDRESS_TYPE = 11,
+ OPT_IPV6_PREFIX_TYPE = 12,
+ OPT_PSID_TYPE = 13,
+ OPT_STRING_TYPE = 14,
+ OPT_TUPLE_TYPE = 15,
+ OPT_FQDN_TYPE = 16,
// Type to be used only internally. Allows convenient notation of the option config.
- OPT_INTERNAL_TYPE,
- OPT_RECORD_TYPE = 254, // Do not alter this value.
- OPT_UNKNOWN_TYPE = 255 // Do not alter this value.
+ OPT_INTERNAL_TYPE = 17,
+ OPT_RECORD_TYPE = 254,
+ OPT_UNKNOWN_TYPE = 255
};
/// @brief Parameters being used to make up an option definition.
EXPECT_EQ(OPT_STRING_TYPE, OptionDataTypeUtil::getDataType("string"));
EXPECT_EQ(OPT_TUPLE_TYPE, OptionDataTypeUtil::getDataType("tuple"));
EXPECT_EQ(OPT_FQDN_TYPE, OptionDataTypeUtil::getDataType("fqdn"));
- // EXPECT_EQ(OPT_INTERNAL_TYPE, OptionDataTypeUtil::getDataType("internal"));
+ EXPECT_EQ(OPT_INTERNAL_TYPE, OptionDataTypeUtil::getDataType("internal"));
EXPECT_EQ(OPT_RECORD_TYPE, OptionDataTypeUtil::getDataType("record"));
EXPECT_EQ(OPT_UNKNOWN_TYPE, OptionDataTypeUtil::getDataType("bogus"));
}
EXPECT_EQ("string", OptionDataTypeUtil::getDataTypeName(OPT_STRING_TYPE));
EXPECT_EQ("tuple", OptionDataTypeUtil::getDataTypeName(OPT_TUPLE_TYPE));
EXPECT_EQ("fqdn", OptionDataTypeUtil::getDataTypeName(OPT_FQDN_TYPE));
- // EXPECT_EQ("internal", OptionDataTypeUtil::getDataTypeName(OPT_INTERNAL_TYPE));
+ EXPECT_EQ("internal", OptionDataTypeUtil::getDataTypeName(OPT_INTERNAL_TYPE));
EXPECT_EQ("record", OptionDataTypeUtil::getDataTypeName(OPT_RECORD_TYPE));
EXPECT_EQ("unknown", OptionDataTypeUtil::getDataTypeName(OPT_UNKNOWN_TYPE));
}
GenericConfigBackendDHCPv4Test::invalidOptionDefDataType4Test() {
OptionDefinitionPtr test_def;
ASSERT_NO_THROW_LOG(test_def.reset(new OptionDefinition("foobar", 234, DHCP4_OPTION_SPACE,
- "unknown", true)));
+ "unknown", true)));
ASSERT_TRUE(test_def);
ASSERT_THROW(cbptr_->createUpdateOptionDef4(ServerSelector::ALL(), test_def),
DbOperationError);
ASSERT_TRUE(found_def) << "no option found for " << test_def->getName();
ASSERT_EQ(*found_def, *test_def);
- std::cout << "option ok for " << found_def->getName() << std::endl;
}
}
GenericConfigBackendDHCPv6Test::invalidOptionDefDataType6Test() {
OptionDefinitionPtr test_def;
ASSERT_NO_THROW_LOG(test_def.reset(new OptionDefinition("foobar", 234, DHCP6_OPTION_SPACE,
- "unknown", true)));
+ "unknown", true)));
ASSERT_TRUE(test_def);
ASSERT_THROW(cbptr_->createUpdateOptionDef6(ServerSelector::ALL(), test_def),
DbOperationError);
ASSERT_TRUE(found_def) << "no option found for " << test_def->getName();
ASSERT_EQ(*found_def, *test_def);
- std::cout << "option ok for " << found_def->getName() << std::endl;
}
}
ALTER TABLE dhcp6_option_def
ADD CONSTRAINT fk_option_def_data_type6 FOREIGN KEY (type) REFERENCES option_def_data_type(id);
+SET @disable_audit = 1;
-- Update the schema version number.
UPDATE schema_version
SET version = '22', minor = '1';
ALTER TABLE dhcp6_option_def
ADD CONSTRAINT fk_option_def_data_type6 FOREIGN KEY (type) REFERENCES option_def_data_type(id);
+SET @disable_audit = 0;
-- Update the schema version number.
UPDATE schema_version
SET version = '22', minor = '1';
ALTER TABLE dhcp6_option_def
ADD CONSTRAINT fk_option_def_data_type6 FOREIGN KEY (type) REFERENCES option_def_data_type(id);
+SELECT set_config('kea.disable_audit', 'false', false);
UPDATE schema_version
SET version = '22', minor = '1';
ALTER TABLE dhcp6_option_def
ADD CONSTRAINT fk_option_def_data_type6 FOREIGN KEY (type) REFERENCES option_def_data_type(id);
+SELECT set_config('kea.disable_audit', 'false', false);
UPDATE schema_version
SET version = '22', minor = '1';