mirror of
https://gitlab.isc.org/isc-projects/kea
synced 2025-08-30 13:37:55 +00:00
[#3683] Added registered lease state
This commit is contained in:
@@ -1020,6 +1020,13 @@ mysql_upgrade_27_to_28_test() {
|
||||
check_table_column ddns_ttl dhcp6_subnet
|
||||
check_table_column ddns_ttl_min dhcp6_subnet
|
||||
check_table_column ddns_ttl_max dhcp6_subnet
|
||||
|
||||
# check registered were added tp lease_state
|
||||
qry="SELECT name FROM lease_state WHERE state = 4"
|
||||
run_command \
|
||||
mysql_execute "${qry}"
|
||||
assert_eq 0 "${EXIT_CODE}" "${qry}: expected %d, returned %d"
|
||||
assert_str_eq 'registered' "${OUTPUT}" "${qry}: expected output %s, returned %s"
|
||||
}
|
||||
|
||||
mysql_upgrade_test() {
|
||||
|
@@ -1111,6 +1111,13 @@ pgsql_upgrade_27_to_28_test() {
|
||||
check_table_column ddns_ttl dhcp6_subnet
|
||||
check_table_column ddns_ttl_min dhcp6_subnet
|
||||
check_table_column ddns_ttl_max dhcp6_subnet
|
||||
|
||||
# check registered were added tp lease_state
|
||||
query="SELECT name FROM lease_state WHERE state = 4"
|
||||
run_command \
|
||||
pgsql_execute "${query}"
|
||||
assert_eq 0 "${EXIT_CODE}" "${query}: expected %d, returned %d"
|
||||
assert_str_eq 'registered' "${OUTPUT}" "${query}: expected output %s, returned %s"
|
||||
}
|
||||
|
||||
pgsql_upgrade_test() {
|
||||
|
@@ -28,6 +28,7 @@ const uint32_t Lease::STATE_DEFAULT = 0;
|
||||
const uint32_t Lease::STATE_DECLINED = 1;
|
||||
const uint32_t Lease::STATE_EXPIRED_RECLAIMED = 2;
|
||||
const uint32_t Lease::STATE_RELEASED = 3;
|
||||
const uint32_t Lease::STATE_REGISTERED = 4;
|
||||
|
||||
std::string
|
||||
Lease::lifetimeToText(uint32_t lifetime) {
|
||||
@@ -100,6 +101,8 @@ Lease::basicStatesToText(const uint32_t state) {
|
||||
return ("expired-reclaimed");
|
||||
case STATE_RELEASED:
|
||||
return ("released");
|
||||
case STATE_REGISTERED:
|
||||
return ("registered");
|
||||
default:
|
||||
// The default case will be handled further on
|
||||
;
|
||||
@@ -284,10 +287,10 @@ Lease::fromElementCommon(const LeasePtr& lease, const data::ConstElementPtr& ele
|
||||
" or it is not an integer");
|
||||
}
|
||||
|
||||
if ((state->intValue() < 0) || (state->intValue() > Lease::STATE_RELEASED)) {
|
||||
if ((state->intValue() < 0) || (state->intValue() > Lease::STATE_REGISTERED)) {
|
||||
isc_throw(BadValue, "state " << state->intValue()
|
||||
<< " must be in range [0.."
|
||||
<< Lease::STATE_RELEASED << "]");
|
||||
<< Lease::STATE_REGISTERED << "]");
|
||||
}
|
||||
|
||||
lease->state_ = state->intValue();
|
||||
|
@@ -77,6 +77,9 @@ struct Lease : public isc::data::UserContext, public isc::data::CfgToElement {
|
||||
/// @brief Released lease held in the database for lease affinity.
|
||||
static const uint32_t STATE_RELEASED;
|
||||
|
||||
/// @brief Registered self-generated lease.
|
||||
static const uint32_t STATE_REGISTERED;
|
||||
|
||||
/// @brief Returns name(s) of the basic lease state(s).
|
||||
///
|
||||
/// @param state A numeric value holding a state information.
|
||||
|
@@ -619,7 +619,8 @@ TEST_F(Lease4Test, stateToText) {
|
||||
EXPECT_EQ("declined", Lease4::statesToText(Lease::STATE_DECLINED));
|
||||
EXPECT_EQ("expired-reclaimed", Lease4::statesToText(Lease::STATE_EXPIRED_RECLAIMED));
|
||||
EXPECT_EQ("released", Lease4::statesToText(Lease::STATE_RELEASED));
|
||||
EXPECT_EQ("unknown (4)", Lease4::statesToText(4));
|
||||
EXPECT_EQ("registered", Lease4::statesToText(Lease::STATE_REGISTERED));
|
||||
EXPECT_EQ("unknown (5)", Lease4::statesToText(5));
|
||||
}
|
||||
|
||||
/// @brief Creates an instance of the lease with certain FQDN data.
|
||||
@@ -1329,8 +1330,8 @@ TEST(Lease6Test, fromElementPD) {
|
||||
EXPECT_EQ(400, lease->preferred_lft_);
|
||||
}
|
||||
|
||||
// Verify that a released Lease6 can be created from JSON.
|
||||
TEST(Lease6Test, fromElementReleased) {
|
||||
// Verify that a registered Lease6 can be created from JSON.
|
||||
TEST(Lease6Test, fromElementRegistered) {
|
||||
// Same as fromElementNA test at the exception of the state.
|
||||
std::string json = "{"
|
||||
"\"cltt\": 12345678,"
|
||||
@@ -1342,7 +1343,7 @@ TEST(Lease6Test, fromElementReleased) {
|
||||
"\"iaid\": 123456,"
|
||||
"\"ip-address\": \"2001:db8::1\","
|
||||
"\"preferred-lft\": 400,"
|
||||
"\"state\": 3,"
|
||||
"\"state\": 4,"
|
||||
"\"subnet-id\": 5678,"
|
||||
"\"pool-id\": 5,"
|
||||
"\"type\": \"IA_NA\","
|
||||
@@ -1355,7 +1356,7 @@ TEST(Lease6Test, fromElementReleased) {
|
||||
|
||||
ASSERT_TRUE(lease);
|
||||
|
||||
EXPECT_EQ(Lease::STATE_RELEASED, lease->state_);
|
||||
EXPECT_EQ(Lease::STATE_REGISTERED, lease->state_);
|
||||
}
|
||||
|
||||
// Test that specifying invalid values for a lease or not specifying
|
||||
@@ -1424,7 +1425,8 @@ TEST(Lease6Test, stateToText) {
|
||||
EXPECT_EQ("declined", Lease6::statesToText(Lease::STATE_DECLINED));
|
||||
EXPECT_EQ("expired-reclaimed", Lease6::statesToText(Lease::STATE_EXPIRED_RECLAIMED));
|
||||
EXPECT_EQ("released", Lease6::statesToText(Lease::STATE_RELEASED));
|
||||
EXPECT_EQ("unknown (4)", Lease6::statesToText(4));
|
||||
EXPECT_EQ("registered", Lease6::statesToText(Lease::STATE_REGISTERED));
|
||||
EXPECT_EQ("unknown (5)", Lease6::statesToText(5));
|
||||
}
|
||||
|
||||
} // end of anonymous namespace
|
||||
|
@@ -6157,6 +6157,9 @@ ALTER TABLE dhcp6_subnet
|
||||
ADD COLUMN ddns_ttl_min INT(10) DEFAULT NULL,
|
||||
ADD COLUMN ddns_ttl_max INT(10) DEFAULT NULL;
|
||||
|
||||
-- New lease state for address registration
|
||||
INSERT INTO lease_state VALUES (4, 'registered');
|
||||
|
||||
-- Update the schema version number.
|
||||
UPDATE schema_version
|
||||
SET version = '28', minor = '0';
|
||||
|
@@ -80,6 +80,9 @@ ALTER TABLE dhcp6_subnet
|
||||
ADD COLUMN ddns_ttl_min INT(10) DEFAULT NULL,
|
||||
ADD COLUMN ddns_ttl_max INT(10) DEFAULT NULL;
|
||||
|
||||
-- New lease state for address registration
|
||||
INSERT INTO lease_state VALUES (4, 'registered');
|
||||
|
||||
-- Update the schema version number.
|
||||
UPDATE schema_version
|
||||
SET version = '28', minor = '0';
|
||||
|
@@ -6616,6 +6616,9 @@ ALTER TABLE dhcp6_subnet
|
||||
ADD COLUMN ddns_ttl_min BIGINT DEFAULT NULL,
|
||||
ADD COLUMN ddns_ttl_max BIGINT DEFAULT NULL;
|
||||
|
||||
-- New lease state for address registration
|
||||
INSERT INTO lease_state VALUES (4, 'registered');
|
||||
|
||||
-- Update the schema version number.
|
||||
UPDATE schema_version
|
||||
SET version = '28', minor = '0';
|
||||
|
@@ -63,6 +63,9 @@ ALTER TABLE dhcp6_subnet
|
||||
ADD COLUMN ddns_ttl_min BIGINT DEFAULT NULL,
|
||||
ADD COLUMN ddns_ttl_max BIGINT DEFAULT NULL;
|
||||
|
||||
-- New lease state for address registration
|
||||
INSERT INTO lease_state VALUES (4, 'registered');
|
||||
|
||||
-- Update the schema version number.
|
||||
UPDATE schema_version
|
||||
SET version = '28', minor = '0';
|
||||
|
Reference in New Issue
Block a user