Commit ca15b760 authored by Marcin Siodelski's avatar Marcin Siodelski

[#27,!138] Fixed assertion in CQL Host Manager.

parent 31e72acc
......@@ -2049,7 +2049,7 @@ bool
CqlHostDataSource::del(const SubnetID& subnet_id, const asiolink::IOAddress& address) {
HostPtr host = boost::const_pointer_cast<Host>(impl_->get4(subnet_id, address));
return (impl_->insertOrDelete(host, false));
return (host ? impl_->insertOrDelete(host, false) : false);
}
bool
......@@ -2058,7 +2058,7 @@ CqlHostDataSource::del4(const SubnetID& subnet_id, const Host::IdentifierType& i
HostPtr host = boost::const_pointer_cast<Host>(impl_->get4(subnet_id, identifier_type,
identifier_begin, identifier_len));
return (impl_->insertOrDelete(host, false));
return (host ? impl_->insertOrDelete(host, false) : false);
}
bool
......@@ -2067,7 +2067,7 @@ CqlHostDataSource::del6(const SubnetID& subnet_id, const Host::IdentifierType& i
HostPtr host = boost::const_pointer_cast<Host>(impl_->get6(subnet_id, identifier_type,
identifier_begin, identifier_len));
return (impl_->insertOrDelete(host, false));
return (host ? impl_->insertOrDelete(host, false) : false);
}
ConstHostCollection
......
......@@ -1364,6 +1364,12 @@ void GenericHostDataSourceTest::testDeleteByAddr4() {
// ... and that it's gone after deletion.
EXPECT_FALSE(after);
// An attempt to delete it should not cause an exception. It
// should return false.
bool result = false;
EXPECT_NO_THROW(result = hdsptr_->del(subnet1, IOAddress("192.0.2.1")));
EXPECT_FALSE(result);
}
void GenericHostDataSourceTest::testDeleteById4() {
......@@ -1399,6 +1405,14 @@ void GenericHostDataSourceTest::testDeleteById4() {
// ... and that it's gone after deletion.
EXPECT_FALSE(after);
// An attempt to delete it should not cause an exception. It
// should return false.
bool result = false;
EXPECT_NO_THROW(result = hdsptr_->del4(subnet1, host1->getIdentifierType(),
&host1->getIdentifier()[0],
host1->getIdentifier().size()));
EXPECT_FALSE(result);
}
// Test checks when a IPv4 host with options is deleted that the options are
......@@ -1446,6 +1460,14 @@ void GenericHostDataSourceTest::testDeleteById4Options() {
// Check the options are indeed gone.
EXPECT_EQ(0, countDBOptions4());
// An attempt to delete it should not cause an exception. It
// should return false.
bool result = false;
EXPECT_NO_THROW(result = hdsptr_->del4(subnet1, host1->getIdentifierType(),
&host1->getIdentifier()[0],
host1->getIdentifier().size()));
EXPECT_FALSE(result);
}
void GenericHostDataSourceTest::testDeleteById6() {
......@@ -1482,6 +1504,14 @@ void GenericHostDataSourceTest::testDeleteById6() {
// ... and that it's gone after deletion.
EXPECT_FALSE(after);
// An attempt to delete it should not cause an exception. It
// should return false.
bool result = false;
EXPECT_NO_THROW(result = hdsptr_->del6(subnet1, host1->getIdentifierType(),
&host1->getIdentifier()[0],
host1->getIdentifier().size()));
EXPECT_FALSE(result);
}
void GenericHostDataSourceTest::testDeleteById6Options() {
......@@ -1530,6 +1560,14 @@ void GenericHostDataSourceTest::testDeleteById6Options() {
// Check the options are indeed gone.
EXPECT_EQ(0, countDBReservations6());
// An attempt to delete it should not cause an exception. It
// should return false.
bool result = false;
EXPECT_NO_THROW(result = hdsptr_->del6(subnet1, host1->getIdentifierType(),
&host1->getIdentifier()[0],
host1->getIdentifier().size()));
EXPECT_FALSE(result);
}
void
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment