diff --git a/src/lib/dhcpsrv/mysql_lease_mgr.cc b/src/lib/dhcpsrv/mysql_lease_mgr.cc index f6044281cd..e33b34e869 100644 --- a/src/lib/dhcpsrv/mysql_lease_mgr.cc +++ b/src/lib/dhcpsrv/mysql_lease_mgr.cc @@ -1820,9 +1820,8 @@ MySqlLeaseMgr::addLeaseCommon(MySqlLeaseContextPtr ctx, bool MySqlLeaseMgr::addLease(const Lease4Ptr& lease) { - LOG_DEBUG(dhcpsrv_logger, DHCPSRV_DBG_TRACE_DETAIL, - DHCPSRV_MYSQL_ADD_ADDR4) - .arg(lease->addr_.toText()); + LOG_DEBUG(dhcpsrv_logger, DHCPSRV_DBG_TRACE_DETAIL, DHCPSRV_MYSQL_ADD_ADDR4) + .arg(lease->addr_.toText()); // Get a context MySqlLeaseContextAlloc get_context(*this); @@ -1837,10 +1836,9 @@ MySqlLeaseMgr::addLease(const Lease4Ptr& lease) { bool MySqlLeaseMgr::addLease(const Lease6Ptr& lease) { - LOG_DEBUG(dhcpsrv_logger, DHCPSRV_DBG_TRACE_DETAIL, - DHCPSRV_MYSQL_ADD_ADDR6) - .arg(lease->addr_.toText()) - .arg(lease->type_); + LOG_DEBUG(dhcpsrv_logger, DHCPSRV_DBG_TRACE_DETAIL, DHCPSRV_MYSQL_ADD_ADDR6) + .arg(lease->addr_.toText()) + .arg(lease->type_); // Get a context MySqlLeaseContextAlloc get_context(*this); @@ -1986,9 +1984,8 @@ void MySqlLeaseMgr::getLease(MySqlLeaseContextPtr ctx, Lease4Ptr MySqlLeaseMgr::getLease4(const isc::asiolink::IOAddress& addr) const { - LOG_DEBUG(dhcpsrv_logger, DHCPSRV_DBG_TRACE_DETAIL, - DHCPSRV_MYSQL_GET_ADDR4) - .arg(addr.toText()); + LOG_DEBUG(dhcpsrv_logger, DHCPSRV_DBG_TRACE_DETAIL, DHCPSRV_MYSQL_GET_ADDR4) + .arg(addr.toText()); // Set up the WHERE clause value MYSQL_BIND inbind[1]; @@ -2013,9 +2010,8 @@ MySqlLeaseMgr::getLease4(const isc::asiolink::IOAddress& addr) const { Lease4Collection MySqlLeaseMgr::getLease4(const HWAddr& hwaddr) const { - LOG_DEBUG(dhcpsrv_logger, DHCPSRV_DBG_TRACE_DETAIL, - DHCPSRV_MYSQL_GET_HWADDR) - .arg(hwaddr.toText()); + LOG_DEBUG(dhcpsrv_logger, DHCPSRV_DBG_TRACE_DETAIL, DHCPSRV_MYSQL_GET_HWADDR) + .arg(hwaddr.toText()); // Set up the WHERE clause value MYSQL_BIND inbind[1]; @@ -2055,10 +2051,9 @@ MySqlLeaseMgr::getLease4(const HWAddr& hwaddr) const { Lease4Ptr MySqlLeaseMgr::getLease4(const HWAddr& hwaddr, SubnetID subnet_id) const { - LOG_DEBUG(dhcpsrv_logger, DHCPSRV_DBG_TRACE_DETAIL, - DHCPSRV_MYSQL_GET_SUBID_HWADDR) - .arg(subnet_id) - .arg(hwaddr.toText()); + LOG_DEBUG(dhcpsrv_logger, DHCPSRV_DBG_TRACE_DETAIL, DHCPSRV_MYSQL_GET_SUBID_HWADDR) + .arg(subnet_id) + .arg(hwaddr.toText()); // Set up the WHERE clause value MYSQL_BIND inbind[2]; @@ -2102,9 +2097,8 @@ MySqlLeaseMgr::getLease4(const HWAddr& hwaddr, SubnetID subnet_id) const { Lease4Collection MySqlLeaseMgr::getLease4(const ClientId& clientid) const { - LOG_DEBUG(dhcpsrv_logger, DHCPSRV_DBG_TRACE_DETAIL, - DHCPSRV_MYSQL_GET_CLIENTID) - .arg(clientid.toText()); + LOG_DEBUG(dhcpsrv_logger, DHCPSRV_DBG_TRACE_DETAIL, DHCPSRV_MYSQL_GET_CLIENTID) + .arg(clientid.toText()); // Set up the WHERE clause value MYSQL_BIND inbind[1]; @@ -2149,10 +2143,9 @@ MySqlLeaseMgr::getLease4(const ClientId&, const HWAddr&, SubnetID) const { Lease4Ptr MySqlLeaseMgr::getLease4(const ClientId& clientid, SubnetID subnet_id) const { - LOG_DEBUG(dhcpsrv_logger, DHCPSRV_DBG_TRACE_DETAIL, - DHCPSRV_MYSQL_GET_SUBID_CLIENTID) - .arg(subnet_id) - .arg(clientid.toText()); + LOG_DEBUG(dhcpsrv_logger, DHCPSRV_DBG_TRACE_DETAIL, DHCPSRV_MYSQL_GET_SUBID_CLIENTID) + .arg(subnet_id) + .arg(clientid.toText()); // Set up the WHERE clause value MYSQL_BIND inbind[2]; @@ -2191,9 +2184,8 @@ MySqlLeaseMgr::getLease4(const ClientId& clientid, SubnetID subnet_id) const { Lease4Collection MySqlLeaseMgr::getLeases4(SubnetID subnet_id) const { - LOG_DEBUG(dhcpsrv_logger, DHCPSRV_DBG_TRACE_DETAIL, - DHCPSRV_MYSQL_GET_SUBID4) - .arg(subnet_id); + LOG_DEBUG(dhcpsrv_logger, DHCPSRV_DBG_TRACE_DETAIL, DHCPSRV_MYSQL_GET_SUBID4) + .arg(subnet_id); // Set up the WHERE clause value MYSQL_BIND inbind[1]; @@ -2218,9 +2210,8 @@ MySqlLeaseMgr::getLeases4(SubnetID subnet_id) const { Lease4Collection MySqlLeaseMgr::getLeases4(const string& hostname) const { - LOG_DEBUG(dhcpsrv_logger, DHCPSRV_DBG_TRACE_DETAIL, - DHCPSRV_MYSQL_GET_HOSTNAME4) - .arg(hostname); + LOG_DEBUG(dhcpsrv_logger, DHCPSRV_DBG_TRACE_DETAIL, DHCPSRV_MYSQL_GET_HOSTNAME4) + .arg(hostname); // Set up the WHERE clause value MYSQL_BIND inbind[1]; @@ -2245,8 +2236,7 @@ MySqlLeaseMgr::getLeases4(const string& hostname) const { Lease4Collection MySqlLeaseMgr::getLeases4() const { - LOG_DEBUG(dhcpsrv_logger, DHCPSRV_DBG_TRACE_DETAIL, - DHCPSRV_MYSQL_GET4); + LOG_DEBUG(dhcpsrv_logger, DHCPSRV_DBG_TRACE_DETAIL, DHCPSRV_MYSQL_GET4); Lease4Collection result; @@ -2269,10 +2259,9 @@ MySqlLeaseMgr::getLeases4(const asiolink::IOAddress& lower_bound_address, << lower_bound_address); } - LOG_DEBUG(dhcpsrv_logger, DHCPSRV_DBG_TRACE_DETAIL, - DHCPSRV_MYSQL_GET_PAGE4) - .arg(page_size.page_size_) - .arg(lower_bound_address.toText()); + LOG_DEBUG(dhcpsrv_logger, DHCPSRV_DBG_TRACE_DETAIL, DHCPSRV_MYSQL_GET_PAGE4) + .arg(page_size.page_size_) + .arg(lower_bound_address.toText()); // Prepare WHERE clause MYSQL_BIND inbind[2]; @@ -2305,10 +2294,9 @@ MySqlLeaseMgr::getLeases4(const asiolink::IOAddress& lower_bound_address, Lease6Ptr MySqlLeaseMgr::getLease6(Lease::Type lease_type, const isc::asiolink::IOAddress& addr) const { - LOG_DEBUG(dhcpsrv_logger, DHCPSRV_DBG_TRACE_DETAIL, - DHCPSRV_MYSQL_GET_ADDR6) - .arg(addr.toText()) - .arg(lease_type); + LOG_DEBUG(dhcpsrv_logger, DHCPSRV_DBG_TRACE_DETAIL, DHCPSRV_MYSQL_GET_ADDR6) + .arg(addr.toText()) + .arg(lease_type); // Set up the WHERE clause value MYSQL_BIND inbind[2]; @@ -2343,11 +2331,10 @@ MySqlLeaseMgr::getLease6(Lease::Type lease_type, Lease6Collection MySqlLeaseMgr::getLeases6(Lease::Type lease_type, const DUID& duid, uint32_t iaid) const { - LOG_DEBUG(dhcpsrv_logger, DHCPSRV_DBG_TRACE_DETAIL, - DHCPSRV_MYSQL_GET_IAID_DUID) - .arg(iaid) - .arg(duid.toText()) - .arg(lease_type); + LOG_DEBUG(dhcpsrv_logger, DHCPSRV_DBG_TRACE_DETAIL, DHCPSRV_MYSQL_GET_IAID_DUID) + .arg(iaid) + .arg(duid.toText()) + .arg(lease_type); // Set up the WHERE clause value MYSQL_BIND inbind[3]; @@ -2407,12 +2394,11 @@ MySqlLeaseMgr::getLeases6(Lease::Type lease_type, const DUID& duid, Lease6Collection MySqlLeaseMgr::getLeases6(Lease::Type lease_type, const DUID& duid, uint32_t iaid, SubnetID subnet_id) const { - LOG_DEBUG(dhcpsrv_logger, DHCPSRV_DBG_TRACE_DETAIL, - DHCPSRV_MYSQL_GET_IAID_SUBID_DUID) - .arg(iaid) - .arg(subnet_id) - .arg(duid.toText()) - .arg(lease_type); + LOG_DEBUG(dhcpsrv_logger, DHCPSRV_DBG_TRACE_DETAIL, DHCPSRV_MYSQL_GET_IAID_SUBID_DUID) + .arg(iaid) + .arg(subnet_id) + .arg(duid.toText()) + .arg(lease_type); // Set up the WHERE clause value MYSQL_BIND inbind[4]; @@ -2457,9 +2443,8 @@ MySqlLeaseMgr::getLeases6(Lease::Type lease_type, const DUID& duid, Lease6Collection MySqlLeaseMgr::getLeases6(SubnetID subnet_id) const { - LOG_DEBUG(dhcpsrv_logger, DHCPSRV_DBG_TRACE_DETAIL, - DHCPSRV_MYSQL_GET_SUBID6) - .arg(subnet_id); + LOG_DEBUG(dhcpsrv_logger, DHCPSRV_DBG_TRACE_DETAIL, DHCPSRV_MYSQL_GET_SUBID6) + .arg(subnet_id); // Set up the WHERE clause value MYSQL_BIND inbind[1]; @@ -2484,8 +2469,7 @@ MySqlLeaseMgr::getLeases6(SubnetID subnet_id) const { Lease6Collection MySqlLeaseMgr::getLeases6() const { - LOG_DEBUG(dhcpsrv_logger, DHCPSRV_DBG_TRACE_DETAIL, - DHCPSRV_MYSQL_GET6); + LOG_DEBUG(dhcpsrv_logger, DHCPSRV_DBG_TRACE_DETAIL, DHCPSRV_MYSQL_GET6); Lease6Collection result; @@ -2500,9 +2484,8 @@ MySqlLeaseMgr::getLeases6() const { Lease6Collection MySqlLeaseMgr::getLeases6(const DUID& duid) const { - LOG_DEBUG(dhcpsrv_logger, DHCPSRV_DBG_TRACE_DETAIL, - DHCPSRV_MYSQL_GET_DUID) - .arg(duid.toText()); + LOG_DEBUG(dhcpsrv_logger, DHCPSRV_DBG_TRACE_DETAIL, DHCPSRV_MYSQL_GET_DUID) + .arg(duid.toText()); // Set up the WHERE clause value MYSQL_BIND inbind[1]; @@ -2530,9 +2513,8 @@ MySqlLeaseMgr::getLeases6(const DUID& duid) const { Lease6Collection MySqlLeaseMgr::getLeases6(const string& hostname) const { - LOG_DEBUG(dhcpsrv_logger, DHCPSRV_DBG_TRACE_DETAIL, - DHCPSRV_MYSQL_GET_HOSTNAME6) - .arg(hostname); + LOG_DEBUG(dhcpsrv_logger, DHCPSRV_DBG_TRACE_DETAIL, DHCPSRV_MYSQL_GET_HOSTNAME6) + .arg(hostname); // Set up the WHERE clause value MYSQL_BIND inbind[1]; @@ -2565,10 +2547,9 @@ MySqlLeaseMgr::getLeases6(const asiolink::IOAddress& lower_bound_address, << lower_bound_address); } - LOG_DEBUG(dhcpsrv_logger, DHCPSRV_DBG_TRACE_DETAIL, - DHCPSRV_MYSQL_GET_PAGE6) - .arg(page_size.page_size_) - .arg(lower_bound_address.toText()); + LOG_DEBUG(dhcpsrv_logger, DHCPSRV_DBG_TRACE_DETAIL, DHCPSRV_MYSQL_GET_PAGE6) + .arg(page_size.page_size_) + .arg(lower_bound_address.toText()); // Prepare WHERE clause MYSQL_BIND inbind[2]; @@ -2610,18 +2591,16 @@ MySqlLeaseMgr::getLeases6(const asiolink::IOAddress& lower_bound_address, void MySqlLeaseMgr::getExpiredLeases4(Lease4Collection& expired_leases, const size_t max_leases) const { - LOG_DEBUG(dhcpsrv_logger, DHCPSRV_DBG_TRACE_DETAIL, - DHCPSRV_MYSQL_GET_EXPIRED4) - .arg(max_leases); + LOG_DEBUG(dhcpsrv_logger, DHCPSRV_DBG_TRACE_DETAIL, DHCPSRV_MYSQL_GET_EXPIRED4) + .arg(max_leases); getExpiredLeasesCommon(expired_leases, max_leases, GET_LEASE4_EXPIRE); } void MySqlLeaseMgr::getExpiredLeases6(Lease6Collection& expired_leases, const size_t max_leases) const { - LOG_DEBUG(dhcpsrv_logger, DHCPSRV_DBG_TRACE_DETAIL, - DHCPSRV_MYSQL_GET_EXPIRED6) - .arg(max_leases); + LOG_DEBUG(dhcpsrv_logger, DHCPSRV_DBG_TRACE_DETAIL, DHCPSRV_MYSQL_GET_EXPIRED6) + .arg(max_leases); getExpiredLeasesCommon(expired_leases, max_leases, GET_LEASE6_EXPIRE); } @@ -2699,9 +2678,8 @@ void MySqlLeaseMgr::updateLease4(const Lease4Ptr& lease) { const StatementIndex stindex = UPDATE_LEASE4; - LOG_DEBUG(dhcpsrv_logger, DHCPSRV_DBG_TRACE_DETAIL, - DHCPSRV_MYSQL_UPDATE_ADDR4) - .arg(lease->addr_.toText()); + LOG_DEBUG(dhcpsrv_logger, DHCPSRV_DBG_TRACE_DETAIL, DHCPSRV_MYSQL_UPDATE_ADDR4) + .arg(lease->addr_.toText()); // Get a context MySqlLeaseContextAlloc get_context(*this); @@ -2728,10 +2706,9 @@ void MySqlLeaseMgr::updateLease6(const Lease6Ptr& lease) { const StatementIndex stindex = UPDATE_LEASE6; - LOG_DEBUG(dhcpsrv_logger, DHCPSRV_DBG_TRACE_DETAIL, - DHCPSRV_MYSQL_UPDATE_ADDR6) - .arg(lease->addr_.toText()) - .arg(lease->type_); + LOG_DEBUG(dhcpsrv_logger, DHCPSRV_DBG_TRACE_DETAIL, DHCPSRV_MYSQL_UPDATE_ADDR6) + .arg(lease->addr_.toText()) + .arg(lease->type_); // Get a context MySqlLeaseContextAlloc get_context(*this); @@ -2786,9 +2763,8 @@ MySqlLeaseMgr::deleteLeaseCommon(StatementIndex stindex, MYSQL_BIND* bind) { bool MySqlLeaseMgr::deleteLease(const isc::asiolink::IOAddress& addr) { - LOG_DEBUG(dhcpsrv_logger, DHCPSRV_DBG_TRACE_DETAIL, - DHCPSRV_MYSQL_DELETE_ADDR) - .arg(addr.toText()); + LOG_DEBUG(dhcpsrv_logger, DHCPSRV_DBG_TRACE_DETAIL, DHCPSRV_MYSQL_DELETE_ADDR) + .arg(addr.toText()); // Set up the WHERE clause value MYSQL_BIND inbind[1]; @@ -2820,17 +2796,15 @@ MySqlLeaseMgr::deleteLease(const isc::asiolink::IOAddress& addr) { uint64_t MySqlLeaseMgr::deleteExpiredReclaimedLeases4(const uint32_t secs) { - LOG_DEBUG(dhcpsrv_logger, DHCPSRV_DBG_TRACE_DETAIL, - DHCPSRV_MYSQL_DELETE_EXPIRED_RECLAIMED4) - .arg(secs); + LOG_DEBUG(dhcpsrv_logger, DHCPSRV_DBG_TRACE_DETAIL, DHCPSRV_MYSQL_DELETE_EXPIRED_RECLAIMED4) + .arg(secs); return (deleteExpiredReclaimedLeasesCommon(secs, DELETE_LEASE4_STATE_EXPIRED)); } uint64_t MySqlLeaseMgr::deleteExpiredReclaimedLeases6(const uint32_t secs) { - LOG_DEBUG(dhcpsrv_logger, DHCPSRV_DBG_TRACE_DETAIL, - DHCPSRV_MYSQL_DELETE_EXPIRED_RECLAIMED6) - .arg(secs); + LOG_DEBUG(dhcpsrv_logger, DHCPSRV_DBG_TRACE_DETAIL, DHCPSRV_MYSQL_DELETE_EXPIRED_RECLAIMED6) + .arg(secs); return (deleteExpiredReclaimedLeasesCommon(secs, DELETE_LEASE6_STATE_EXPIRED)); } @@ -2856,9 +2830,8 @@ MySqlLeaseMgr::deleteExpiredReclaimedLeasesCommon(const uint32_t secs, // Get the number of deleted leases and log it. uint64_t deleted_leases = deleteLeaseCommon(statement_index, inbind); - LOG_DEBUG(dhcpsrv_logger, DHCPSRV_DBG_TRACE_DETAIL, - DHCPSRV_MYSQL_DELETED_EXPIRED_RECLAIMED) - .arg(deleted_leases); + LOG_DEBUG(dhcpsrv_logger, DHCPSRV_DBG_TRACE_DETAIL, DHCPSRV_MYSQL_DELETED_EXPIRED_RECLAIMED) + .arg(deleted_leases); return (deleted_leases); } @@ -2983,22 +2956,19 @@ MySqlLeaseMgr::getDescription() const { std::pair MySqlLeaseMgr::getVersion() const { - LOG_DEBUG(dhcpsrv_logger, DHCPSRV_DBG_TRACE_DETAIL, - DHCPSRV_MYSQL_GET_VERSION); + LOG_DEBUG(dhcpsrv_logger, DHCPSRV_DBG_TRACE_DETAIL, DHCPSRV_MYSQL_GET_VERSION); return (MySqlConnection::getVersion(parameters_)); } void MySqlLeaseMgr::commit() { - LOG_DEBUG(dhcpsrv_logger, DHCPSRV_DBG_TRACE_DETAIL, - DHCPSRV_MYSQL_COMMIT); + LOG_DEBUG(dhcpsrv_logger, DHCPSRV_DBG_TRACE_DETAIL, DHCPSRV_MYSQL_COMMIT); } void MySqlLeaseMgr::rollback() { - LOG_DEBUG(dhcpsrv_logger, DHCPSRV_DBG_TRACE_DETAIL, - DHCPSRV_MYSQL_ROLLBACK); + LOG_DEBUG(dhcpsrv_logger, DHCPSRV_DBG_TRACE_DETAIL, DHCPSRV_MYSQL_ROLLBACK); } void diff --git a/src/lib/dhcpsrv/pgsql_lease_mgr.cc b/src/lib/dhcpsrv/pgsql_lease_mgr.cc index 022e8bb853..0c4a1c9091 100644 --- a/src/lib/dhcpsrv/pgsql_lease_mgr.cc +++ b/src/lib/dhcpsrv/pgsql_lease_mgr.cc @@ -1190,7 +1190,7 @@ PgSqlLeaseMgr::createContext() const { // Now prepare the SQL statements. uint32_t i = 0; - for (; tagged_statements[i].text != NULL ; ++i) { + for (; tagged_statements[i].text != NULL; ++i) { ctx->conn_.prepareStatement(tagged_statements[i]); } @@ -1244,9 +1244,8 @@ PgSqlLeaseMgr::addLeaseCommon(PgSqlLeaseContextPtr ctx, bool PgSqlLeaseMgr::addLease(const Lease4Ptr& lease) { - LOG_DEBUG(dhcpsrv_logger, DHCPSRV_DBG_TRACE_DETAIL, - DHCPSRV_PGSQL_ADD_ADDR4) - .arg(lease->addr_.toText()); + LOG_DEBUG(dhcpsrv_logger, DHCPSRV_DBG_TRACE_DETAIL, DHCPSRV_PGSQL_ADD_ADDR4) + .arg(lease->addr_.toText()); // Get a context PgSqlLeaseContextAlloc get_context(*this); @@ -1259,10 +1258,9 @@ PgSqlLeaseMgr::addLease(const Lease4Ptr& lease) { bool PgSqlLeaseMgr::addLease(const Lease6Ptr& lease) { - LOG_DEBUG(dhcpsrv_logger, DHCPSRV_DBG_TRACE_DETAIL, - DHCPSRV_PGSQL_ADD_ADDR6) - .arg(lease->addr_.toText()) - .arg(lease->type_); + LOG_DEBUG(dhcpsrv_logger, DHCPSRV_DBG_TRACE_DETAIL, DHCPSRV_PGSQL_ADD_ADDR6) + .arg(lease->addr_.toText()) + .arg(lease->type_); // Get a context PgSqlLeaseContextAlloc get_context(*this); @@ -1346,9 +1344,8 @@ PgSqlLeaseMgr::getLease(PgSqlLeaseContextPtr ctx, Lease4Ptr PgSqlLeaseMgr::getLease4(const isc::asiolink::IOAddress& addr) const { - LOG_DEBUG(dhcpsrv_logger, DHCPSRV_DBG_TRACE_DETAIL, - DHCPSRV_PGSQL_GET_ADDR4) - .arg(addr.toText()); + LOG_DEBUG(dhcpsrv_logger, DHCPSRV_DBG_TRACE_DETAIL, DHCPSRV_PGSQL_GET_ADDR4) + .arg(addr.toText()); // Set up the WHERE clause value PsqlBindArray bind_array; @@ -1372,9 +1369,8 @@ PgSqlLeaseMgr::getLease4(const isc::asiolink::IOAddress& addr) const { Lease4Collection PgSqlLeaseMgr::getLease4(const HWAddr& hwaddr) const { - LOG_DEBUG(dhcpsrv_logger, DHCPSRV_DBG_TRACE_DETAIL, - DHCPSRV_PGSQL_GET_HWADDR) - .arg(hwaddr.toText()); + LOG_DEBUG(dhcpsrv_logger, DHCPSRV_DBG_TRACE_DETAIL, DHCPSRV_PGSQL_GET_HWADDR) + .arg(hwaddr.toText()); // Set up the WHERE clause value PsqlBindArray bind_array; @@ -1400,10 +1396,9 @@ PgSqlLeaseMgr::getLease4(const HWAddr& hwaddr) const { Lease4Ptr PgSqlLeaseMgr::getLease4(const HWAddr& hwaddr, SubnetID subnet_id) const { - LOG_DEBUG(dhcpsrv_logger, DHCPSRV_DBG_TRACE_DETAIL, - DHCPSRV_PGSQL_GET_SUBID_HWADDR) - .arg(subnet_id) - .arg(hwaddr.toText()); + LOG_DEBUG(dhcpsrv_logger, DHCPSRV_DBG_TRACE_DETAIL, DHCPSRV_PGSQL_GET_SUBID_HWADDR) + .arg(subnet_id) + .arg(hwaddr.toText()); // Set up the WHERE clause value PsqlBindArray bind_array; @@ -1433,9 +1428,8 @@ PgSqlLeaseMgr::getLease4(const HWAddr& hwaddr, SubnetID subnet_id) const { Lease4Collection PgSqlLeaseMgr::getLease4(const ClientId& clientid) const { - LOG_DEBUG(dhcpsrv_logger, DHCPSRV_DBG_TRACE_DETAIL, - DHCPSRV_PGSQL_GET_CLIENTID) - .arg(clientid.toText()); + LOG_DEBUG(dhcpsrv_logger, DHCPSRV_DBG_TRACE_DETAIL, DHCPSRV_PGSQL_GET_CLIENTID) + .arg(clientid.toText()); // Set up the WHERE clause value PsqlBindArray bind_array; @@ -1467,10 +1461,9 @@ PgSqlLeaseMgr::getLease4(const ClientId&, const HWAddr&, SubnetID) const { Lease4Ptr PgSqlLeaseMgr::getLease4(const ClientId& clientid, SubnetID subnet_id) const { - LOG_DEBUG(dhcpsrv_logger, DHCPSRV_DBG_TRACE_DETAIL, - DHCPSRV_PGSQL_GET_SUBID_CLIENTID) - .arg(subnet_id) - .arg(clientid.toText()); + LOG_DEBUG(dhcpsrv_logger, DHCPSRV_DBG_TRACE_DETAIL, DHCPSRV_PGSQL_GET_SUBID_CLIENTID) + .arg(subnet_id) + .arg(clientid.toText()); // Set up the WHERE clause value PsqlBindArray bind_array; @@ -1496,9 +1489,8 @@ PgSqlLeaseMgr::getLease4(const ClientId& clientid, SubnetID subnet_id) const { Lease4Collection PgSqlLeaseMgr::getLeases4(SubnetID subnet_id) const { - LOG_DEBUG(dhcpsrv_logger, DHCPSRV_DBG_TRACE_DETAIL, - DHCPSRV_PGSQL_GET_SUBID4) - .arg(subnet_id); + LOG_DEBUG(dhcpsrv_logger, DHCPSRV_DBG_TRACE_DETAIL, DHCPSRV_PGSQL_GET_SUBID4) + .arg(subnet_id); // Set up the WHERE clause value PsqlBindArray bind_array; @@ -1521,9 +1513,8 @@ PgSqlLeaseMgr::getLeases4(SubnetID subnet_id) const { Lease4Collection PgSqlLeaseMgr::getLeases4(const string& hostname) const { - LOG_DEBUG(dhcpsrv_logger, DHCPSRV_DBG_TRACE_DETAIL, - DHCPSRV_PGSQL_GET_HOSTNAME4) - .arg(hostname); + LOG_DEBUG(dhcpsrv_logger, DHCPSRV_DBG_TRACE_DETAIL, DHCPSRV_PGSQL_GET_HOSTNAME4) + .arg(hostname); // Set up the WHERE clause value PsqlBindArray bind_array; @@ -1545,8 +1536,7 @@ PgSqlLeaseMgr::getLeases4(const string& hostname) const { Lease4Collection PgSqlLeaseMgr::getLeases4() const { - LOG_DEBUG(dhcpsrv_logger, DHCPSRV_DBG_TRACE_DETAIL, - DHCPSRV_PGSQL_GET4); + LOG_DEBUG(dhcpsrv_logger, DHCPSRV_DBG_TRACE_DETAIL, DHCPSRV_PGSQL_GET4); // Provide empty binding array because our query has no parameters in // WHERE clause. @@ -1572,10 +1562,9 @@ PgSqlLeaseMgr::getLeases4(const asiolink::IOAddress& lower_bound_address, << lower_bound_address); } - LOG_DEBUG(dhcpsrv_logger, DHCPSRV_DBG_TRACE_DETAIL, - DHCPSRV_PGSQL_GET_PAGE4) - .arg(page_size.page_size_) - .arg(lower_bound_address.toText()); + LOG_DEBUG(dhcpsrv_logger, DHCPSRV_DBG_TRACE_DETAIL, DHCPSRV_PGSQL_GET_PAGE4) + .arg(page_size.page_size_) + .arg(lower_bound_address.toText()); // Prepare WHERE clause PsqlBindArray bind_array; @@ -1604,10 +1593,9 @@ PgSqlLeaseMgr::getLeases4(const asiolink::IOAddress& lower_bound_address, Lease6Ptr PgSqlLeaseMgr::getLease6(Lease::Type lease_type, const isc::asiolink::IOAddress& addr) const { - LOG_DEBUG(dhcpsrv_logger, DHCPSRV_DBG_TRACE_DETAIL, - DHCPSRV_PGSQL_GET_ADDR6) - .arg(addr.toText()) - .arg(lease_type); + LOG_DEBUG(dhcpsrv_logger, DHCPSRV_DBG_TRACE_DETAIL, DHCPSRV_PGSQL_GET_ADDR6) + .arg(addr.toText()) + .arg(lease_type); // Set up the WHERE clause value PsqlBindArray bind_array; @@ -1635,11 +1623,10 @@ PgSqlLeaseMgr::getLease6(Lease::Type lease_type, Lease6Collection PgSqlLeaseMgr::getLeases6(Lease::Type lease_type, const DUID& duid, uint32_t iaid) const { - LOG_DEBUG(dhcpsrv_logger, DHCPSRV_DBG_TRACE_DETAIL, - DHCPSRV_PGSQL_GET_IAID_DUID) - .arg(iaid) - .arg(duid.toText()) - .arg(lease_type); + LOG_DEBUG(dhcpsrv_logger, DHCPSRV_DBG_TRACE_DETAIL, DHCPSRV_PGSQL_GET_IAID_DUID) + .arg(iaid) + .arg(duid.toText()) + .arg(lease_type); // Set up the WHERE clause value PsqlBindArray bind_array; @@ -1670,12 +1657,11 @@ PgSqlLeaseMgr::getLeases6(Lease::Type lease_type, const DUID& duid, Lease6Collection PgSqlLeaseMgr::getLeases6(Lease::Type lease_type, const DUID& duid, uint32_t iaid, SubnetID subnet_id) const { - LOG_DEBUG(dhcpsrv_logger, DHCPSRV_DBG_TRACE_DETAIL, - DHCPSRV_PGSQL_GET_IAID_SUBID_DUID) - .arg(iaid) - .arg(subnet_id) - .arg(duid.toText()) - .arg(lease_type); + LOG_DEBUG(dhcpsrv_logger, DHCPSRV_DBG_TRACE_DETAIL, DHCPSRV_PGSQL_GET_IAID_SUBID_DUID) + .arg(iaid) + .arg(subnet_id) + .arg(duid.toText()) + .arg(lease_type); // Set up the WHERE clause value PsqlBindArray bind_array; @@ -1709,9 +1695,8 @@ PgSqlLeaseMgr::getLeases6(Lease::Type lease_type, const DUID& duid, Lease6Collection PgSqlLeaseMgr::getLeases6(SubnetID subnet_id) const { - LOG_DEBUG(dhcpsrv_logger, DHCPSRV_DBG_TRACE_DETAIL, - DHCPSRV_PGSQL_GET_SUBID6) - .arg(subnet_id); + LOG_DEBUG(dhcpsrv_logger, DHCPSRV_DBG_TRACE_DETAIL, DHCPSRV_PGSQL_GET_SUBID6) + .arg(subnet_id); // Set up the WHERE clause value PsqlBindArray bind_array; @@ -1734,9 +1719,8 @@ PgSqlLeaseMgr::getLeases6(SubnetID subnet_id) const { Lease6Collection PgSqlLeaseMgr::getLeases6(const DUID& duid) const { - LOG_DEBUG(dhcpsrv_logger, DHCPSRV_DBG_TRACE_DETAIL, - DHCPSRV_PGSQL_GET_DUID) - .arg(duid.toText()); + LOG_DEBUG(dhcpsrv_logger, DHCPSRV_DBG_TRACE_DETAIL, DHCPSRV_PGSQL_GET_DUID) + .arg(duid.toText()); // Set up the WHERE clause value PsqlBindArray bind_array; @@ -1757,9 +1741,8 @@ PgSqlLeaseMgr::getLeases6(const DUID& duid) const { Lease6Collection PgSqlLeaseMgr::getLeases6(const string& hostname) const { - LOG_DEBUG(dhcpsrv_logger, DHCPSRV_DBG_TRACE_DETAIL, - DHCPSRV_PGSQL_GET_HOSTNAME6) - .arg(hostname); + LOG_DEBUG(dhcpsrv_logger, DHCPSRV_DBG_TRACE_DETAIL, DHCPSRV_PGSQL_GET_HOSTNAME6) + .arg(hostname); // Set up the WHERE clause value PsqlBindArray bind_array; @@ -1781,8 +1764,7 @@ PgSqlLeaseMgr::getLeases6(const string& hostname) const { Lease6Collection PgSqlLeaseMgr::getLeases6() const { - LOG_DEBUG(dhcpsrv_logger, DHCPSRV_DBG_TRACE_DETAIL, - DHCPSRV_PGSQL_GET6); + LOG_DEBUG(dhcpsrv_logger, DHCPSRV_DBG_TRACE_DETAIL, DHCPSRV_PGSQL_GET6); // Provide empty binding array because our query has no parameters in // WHERE clause. @@ -1808,10 +1790,9 @@ PgSqlLeaseMgr::getLeases6(const asiolink::IOAddress& lower_bound_address, << lower_bound_address); } - LOG_DEBUG(dhcpsrv_logger, DHCPSRV_DBG_TRACE_DETAIL, - DHCPSRV_PGSQL_GET_PAGE6) - .arg(page_size.page_size_) - .arg(lower_bound_address.toText()); + LOG_DEBUG(dhcpsrv_logger, DHCPSRV_DBG_TRACE_DETAIL, DHCPSRV_PGSQL_GET_PAGE6) + .arg(page_size.page_size_) + .arg(lower_bound_address.toText()); // Prepare WHERE clause PsqlBindArray bind_array; @@ -1846,18 +1827,16 @@ PgSqlLeaseMgr::getLeases6(const asiolink::IOAddress& lower_bound_address, void PgSqlLeaseMgr::getExpiredLeases4(Lease4Collection& expired_leases, const size_t max_leases) const { - LOG_DEBUG(dhcpsrv_logger, DHCPSRV_DBG_TRACE_DETAIL, - DHCPSRV_PGSQL_GET_EXPIRED4) - .arg(max_leases); + LOG_DEBUG(dhcpsrv_logger, DHCPSRV_DBG_TRACE_DETAIL, DHCPSRV_PGSQL_GET_EXPIRED4) + .arg(max_leases); getExpiredLeasesCommon(expired_leases, max_leases, GET_LEASE4_EXPIRE); } void PgSqlLeaseMgr::getExpiredLeases6(Lease6Collection& expired_leases, const size_t max_leases) const { - LOG_DEBUG(dhcpsrv_logger, DHCPSRV_DBG_TRACE_DETAIL, - DHCPSRV_PGSQL_GET_EXPIRED6) - .arg(max_leases); + LOG_DEBUG(dhcpsrv_logger, DHCPSRV_DBG_TRACE_DETAIL, DHCPSRV_PGSQL_GET_EXPIRED6) + .arg(max_leases); getExpiredLeasesCommon(expired_leases, max_leases, GET_LEASE6_EXPIRE); } @@ -1928,9 +1907,8 @@ void PgSqlLeaseMgr::updateLease4(const Lease4Ptr& lease) { const StatementIndex stindex = UPDATE_LEASE4; - LOG_DEBUG(dhcpsrv_logger, DHCPSRV_DBG_TRACE_DETAIL, - DHCPSRV_PGSQL_UPDATE_ADDR4) - .arg(lease->addr_.toText()); + LOG_DEBUG(dhcpsrv_logger, DHCPSRV_DBG_TRACE_DETAIL, DHCPSRV_PGSQL_UPDATE_ADDR4) + .arg(lease->addr_.toText()); // Get a context PgSqlLeaseContextAlloc get_context(*this); @@ -1953,10 +1931,9 @@ void PgSqlLeaseMgr::updateLease6(const Lease6Ptr& lease) { const StatementIndex stindex = UPDATE_LEASE6; - LOG_DEBUG(dhcpsrv_logger, DHCPSRV_DBG_TRACE_DETAIL, - DHCPSRV_PGSQL_UPDATE_ADDR6) - .arg(lease->addr_.toText()) - .arg(lease->type_); + LOG_DEBUG(dhcpsrv_logger, DHCPSRV_DBG_TRACE_DETAIL, DHCPSRV_PGSQL_UPDATE_ADDR6) + .arg(lease->addr_.toText()) + .arg(lease->type_); // Get a context PgSqlLeaseContextAlloc get_context(*this); @@ -1995,9 +1972,8 @@ PgSqlLeaseMgr::deleteLeaseCommon(StatementIndex stindex, bool PgSqlLeaseMgr::deleteLease(const isc::asiolink::IOAddress& addr) { - LOG_DEBUG(dhcpsrv_logger, DHCPSRV_DBG_TRACE_DETAIL, - DHCPSRV_PGSQL_DELETE_ADDR) - .arg(addr.toText()); + LOG_DEBUG(dhcpsrv_logger, DHCPSRV_DBG_TRACE_DETAIL, DHCPSRV_PGSQL_DELETE_ADDR) + .arg(addr.toText()); // Set up the WHERE clause value PsqlBindArray bind_array; @@ -2016,17 +1992,15 @@ PgSqlLeaseMgr::deleteLease(const isc::asiolink::IOAddress& addr) { uint64_t PgSqlLeaseMgr::deleteExpiredReclaimedLeases4(const uint32_t secs) { - LOG_DEBUG(dhcpsrv_logger, DHCPSRV_DBG_TRACE_DETAIL, - DHCPSRV_PGSQL_DELETE_EXPIRED_RECLAIMED4) - .arg(secs); + LOG_DEBUG(dhcpsrv_logger, DHCPSRV_DBG_TRACE_DETAIL, DHCPSRV_PGSQL_DELETE_EXPIRED_RECLAIMED4) + .arg(secs); return (deleteExpiredReclaimedLeasesCommon(secs, DELETE_LEASE4_STATE_EXPIRED)); } uint64_t PgSqlLeaseMgr::deleteExpiredReclaimedLeases6(const uint32_t secs) { - LOG_DEBUG(dhcpsrv_logger, DHCPSRV_DBG_TRACE_DETAIL, - DHCPSRV_PGSQL_DELETE_EXPIRED_RECLAIMED6) - .arg(secs); + LOG_DEBUG(dhcpsrv_logger, DHCPSRV_DBG_TRACE_DETAIL, DHCPSRV_PGSQL_DELETE_EXPIRED_RECLAIMED6) + .arg(secs); return (deleteExpiredReclaimedLeasesCommon(secs, DELETE_LEASE6_STATE_EXPIRED)); } @@ -2166,22 +2140,19 @@ PgSqlLeaseMgr::getDescription() const { pair PgSqlLeaseMgr::getVersion() const { - LOG_DEBUG(dhcpsrv_logger, DHCPSRV_DBG_TRACE_DETAIL, - DHCPSRV_PGSQL_GET_VERSION); + LOG_DEBUG(dhcpsrv_logger, DHCPSRV_DBG_TRACE_DETAIL, DHCPSRV_PGSQL_GET_VERSION); return (PgSqlConnection::getVersion(parameters_)); } void PgSqlLeaseMgr::commit() { - LOG_DEBUG(dhcpsrv_logger, DHCPSRV_DBG_TRACE_DETAIL, - DHCPSRV_PGSQL_COMMIT); + LOG_DEBUG(dhcpsrv_logger, DHCPSRV_DBG_TRACE_DETAIL, DHCPSRV_PGSQL_COMMIT); } void PgSqlLeaseMgr::rollback() { - LOG_DEBUG(dhcpsrv_logger, DHCPSRV_DBG_TRACE_DETAIL, - DHCPSRV_PGSQL_ROLLBACK); + LOG_DEBUG(dhcpsrv_logger, DHCPSRV_DBG_TRACE_DETAIL, DHCPSRV_PGSQL_ROLLBACK); } } // namespace dhcp diff --git a/src/lib/dhcpsrv/tests/pgsql_lease_mgr_unittest.cc b/src/lib/dhcpsrv/tests/pgsql_lease_mgr_unittest.cc index 18322a6e23..835c4d52b7 100644 --- a/src/lib/dhcpsrv/tests/pgsql_lease_mgr_unittest.cc +++ b/src/lib/dhcpsrv/tests/pgsql_lease_mgr_unittest.cc @@ -7,11 +7,11 @@ #include #include -#include #include #include #include #include +#include #include #include #include @@ -67,11 +67,6 @@ public: /// @brief Destroys the LM and the schema. void destroyTest() { - try { - lmptr_->rollback(); - } catch (...) { - // Rollback may fail if backend is in read only mode. That's ok. - } LeaseMgrFactory::destroy(); // If data wipe enabled, delete transient data otherwise destroy the schema destroyPgSQLSchema(); @@ -115,7 +110,6 @@ public: /// only if the database can be opened. Note that this is not part of the /// PgSqlLeaseMgr test fixure set. This test checks that the database can be /// opened: the fixtures assume that and check basic operations. - TEST(PgSqlOpenTest, OpenDatabase) { // Explicitely disable Multi-Threading. MultiThreadingMgr::instance().setMode(false); @@ -232,54 +226,6 @@ TEST(PgSqlOpenTest, OpenDatabaseMultiThreading) { MultiThreadingMgr::instance().setMode(false); } -/// @brief Test fixture class for validating @c LeaseMgr using -/// PostgreSQL as back end and PostgreSQL connectivity loss. -class PgSqlLeaseMgrDbLostCallbackTest : public LeaseMgrDbLostCallbackTest { -public: - virtual void destroySchema() { - // If data wipe enabled, delete transient data otherwise destroy the schema - destroyPgSQLSchema(); - } - - virtual void createSchema() { - // Ensure we have the proper schema with no transient data. - createPgSQLSchema(); - } - - virtual std::string validConnectString() { - return (validPgSQLConnectionString()); - } - - virtual std::string invalidConnectString() { - return (connectionString(PGSQL_VALID_TYPE, VALID_NAME, INVALID_HOST, - VALID_USER, VALID_PASSWORD)); - } -}; - -// Verifies that db lost callback is not invoked on an open failure -TEST_F(PgSqlLeaseMgrDbLostCallbackTest, testNoCallbackOnOpenFailure) { - MultiThreadingMgr::instance().setMode(false); - testDbLostCallback(); -} - -// Verifies that db lost callback is not invoked on an open failure -TEST_F(PgSqlLeaseMgrDbLostCallbackTest, testNoCallbackOnOpenFailureMultiThreading) { - MultiThreadingMgr::instance().setMode(true); - testDbLostCallback(); -} - -// Verifies that loss of connectivity to PostgreSQL is handled correctly. -TEST_F(PgSqlLeaseMgrDbLostCallbackTest, testDbLostCallback) { - MultiThreadingMgr::instance().setMode(false); - testDbLostCallback(); -} - -// Verifies that loss of connectivity to PostgreSQL is handled correctly. -TEST_F(PgSqlLeaseMgrDbLostCallbackTest, testDbLostCallbackMultiThreading) { - MultiThreadingMgr::instance().setMode(true); - testDbLostCallback(); -} - /// @brief Check the getType() method /// /// getType() returns a string giving the type of the backend, which should @@ -366,15 +312,15 @@ TEST_F(PgSqlLeaseMgrTest, getLease4HWAddr2MultiThreading) { testGetLease4HWAddr2(); } -// @brief Get lease4 by hardware address (2) -// -// Check that the system can cope with getting a hardware address of -// any size. +/// @brief Get lease4 by hardware address (2) +/// +/// Check that the system can cope with getting a hardware address of +/// any size. TEST_F(PgSqlLeaseMgrTest, getLease4HWAddrSize) { testGetLease4HWAddrSize(); } -// @brief Get lease4 by hardware address (2) +/// @brief Get lease4 by hardware address (2) TEST_F(PgSqlLeaseMgrTest, getLease4HWAddrSizeMultiThreading) { MultiThreadingMgr::instance().setMode(true); testGetLease4HWAddrSize(); @@ -394,26 +340,26 @@ TEST_F(PgSqlLeaseMgrTest, getLease4HwaddrSubnetIdMultiThreading) { testGetLease4HWAddrSubnetId(); } -// @brief Get lease4 by hardware address and subnet ID (2) -// -// Check that the system can cope with getting a hardware address of -// any size. +/// @brief Get lease4 by hardware address and subnet ID (2) +/// +/// Check that the system can cope with getting a hardware address of +/// any size. TEST_F(PgSqlLeaseMgrTest, getLease4HWAddrSubnetIdSize) { testGetLease4HWAddrSubnetIdSize(); } -// @brief Get lease4 by hardware address and subnet ID (2) +/// @brief Get lease4 by hardware address and subnet ID (2) TEST_F(PgSqlLeaseMgrTest, getLease4HWAddrSubnetIdSizeMultiThreading) { MultiThreadingMgr::instance().setMode(true); testGetLease4HWAddrSubnetIdSize(); } -// This test was derived from memfile. +/// @brief This test was derived from memfile. TEST_F(PgSqlLeaseMgrTest, getLease4ClientId) { testGetLease4ClientId(); } -// This test was derived from memfile. +/// @brief This test was derived from memfile. TEST_F(PgSqlLeaseMgrTest, getLease4ClientIdMultiThreading) { MultiThreadingMgr::instance().setMode(true); testGetLease4ClientId(); @@ -433,14 +379,14 @@ TEST_F(PgSqlLeaseMgrTest, getLease4ClientId2MultiThreading) { testGetLease4ClientId2(); } -// @brief Get Lease4 by client ID (2) -// -// Check that the system can cope with a client ID of any size. +/// @brief Get Lease4 by client ID (2) +/// +/// Check that the system can cope with a client ID of any size. TEST_F(PgSqlLeaseMgrTest, getLease4ClientIdSize) { testGetLease4ClientIdSize(); } -// @brief Get Lease4 by client ID (2) +/// @brief Get Lease4 by client ID (2) TEST_F(PgSqlLeaseMgrTest, getLease4ClientIdSizeMultiThreading) { MultiThreadingMgr::instance().setMode(true); testGetLease4ClientIdSize(); @@ -460,89 +406,89 @@ TEST_F(PgSqlLeaseMgrTest, getLease4ClientIdSubnetIdMultiThreading) { testGetLease4ClientIdSubnetId(); } -// This test checks that all IPv4 leases for a specified subnet id are returned. +/// @brief This test checks that all IPv4 leases for a specified subnet id are returned. TEST_F(PgSqlLeaseMgrTest, getLeases4SubnetId) { testGetLeases4SubnetId(); } -// This test checks that all IPv4 leases for a specified subnet id are returned. +/// @brief This test checks that all IPv4 leases for a specified subnet id are returned. TEST_F(PgSqlLeaseMgrTest, getLeases4SubnetIdMultiThreading) { MultiThreadingMgr::instance().setMode(true); testGetLeases4SubnetId(); } -// This test checks that all IPv4 leases with a specified hostname are returned. +/// @brief This test checks that all IPv4 leases with a specified hostname are returned. TEST_F(PgSqlLeaseMgrTest, getLeases4Hostname) { testGetLeases4Hostname(); } -// This test checks that all IPv4 leases with a specified hostname are returned. +/// @brief This test checks that all IPv4 leases with a specified hostname are returned. TEST_F(PgSqlLeaseMgrTest, getLeases4HostnameMultiThreading) { MultiThreadingMgr::instance().setMode(true); testGetLeases4Hostname(); } -// This test checks that all IPv4 leases are returned. +/// @brief This test checks that all IPv4 leases are returned. TEST_F(PgSqlLeaseMgrTest, getLeases4) { testGetLeases4(); } -// This test checks that all IPv4 leases are returned. +/// @brief This test checks that all IPv4 leases are returned. TEST_F(PgSqlLeaseMgrTest, getLeases4MultiThreading) { MultiThreadingMgr::instance().setMode(true); testGetLeases4(); } -// Test that a range of IPv4 leases is returned with paging. +/// @brief Test that a range of IPv4 leases is returned with paging. TEST_F(PgSqlLeaseMgrTest, getLeases4Paged) { testGetLeases4Paged(); } -// Test that a range of IPv4 leases is returned with paging. +/// @brief Test that a range of IPv4 leases is returned with paging. TEST_F(PgSqlLeaseMgrTest, getLeases4PagedMultiThreading) { MultiThreadingMgr::instance().setMode(true); testGetLeases4Paged(); } -// This test checks that all IPv6 leases for a specified subnet id are returned. +/// @brief This test checks that all IPv6 leases for a specified subnet id are returned. TEST_F(PgSqlLeaseMgrTest, getLeases6SubnetId) { testGetLeases6SubnetId(); } -// This test checks that all IPv6 leases for a specified subnet id are returned. +/// @brief This test checks that all IPv6 leases for a specified subnet id are returned. TEST_F(PgSqlLeaseMgrTest, getLeases6SubnetIdMultiThreading) { MultiThreadingMgr::instance().setMode(true); testGetLeases6SubnetId(); } -// This test checks that all IPv6 leases with a specified hostname are returned. +/// @brief This test checks that all IPv6 leases with a specified hostname are returned. TEST_F(PgSqlLeaseMgrTest, getLeases6Hostname) { testGetLeases6Hostname(); } -// This test checks that all IPv6 leases with a specified hostname are returned. +/// @brief This test checks that all IPv6 leases with a specified hostname are returned. TEST_F(PgSqlLeaseMgrTest, getLeases6HostnameMultiThreading) { MultiThreadingMgr::instance().setMode(true); testGetLeases6Hostname(); } -// This test checks that all IPv6 leases are returned. +/// @brief This test checks that all IPv6 leases are returned. TEST_F(PgSqlLeaseMgrTest, getLeases6) { testGetLeases6(); } -// This test checks that all IPv6 leases are returned. +/// @brief This test checks that all IPv6 leases are returned. TEST_F(PgSqlLeaseMgrTest, getLeases6MultiThreading) { MultiThreadingMgr::instance().setMode(true); testGetLeases6(); } -// Test that a range of IPv6 leases is returned with paging. +/// @brief Test that a range of IPv6 leases is returned with paging. TEST_F(PgSqlLeaseMgrTest, getLeases6Paged) { testGetLeases6Paged(); } -// Test that a range of IPv6 leases is returned with paging. +/// @brief Test that a range of IPv6 leases is returned with paging. TEST_F(PgSqlLeaseMgrTest, getLeases6PagedMultiThreading) { MultiThreadingMgr::instance().setMode(true); testGetLeases6Paged(); @@ -609,14 +555,14 @@ TEST_F(PgSqlLeaseMgrTest, deleteExpiredReclaimedLeases4MultiThreading) { /// LEASE6 ///////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////// -// Test checks whether simple add, get and delete operations are possible -// on Lease6 +/// @brief Test checks whether simple add, get and delete operations +/// are possible on Lease6 TEST_F(PgSqlLeaseMgrTest, testAddGetDelete6) { testAddGetDelete6(); } -// Test checks whether simple add, get and delete operations are possible -// on Lease6 +/// @brief Test checks whether simple add, get and delete operations +/// are possible on Lease6 TEST_F(PgSqlLeaseMgrTest, testAddGetDelete6MultiThreading) { MultiThreadingMgr::instance().setMode(true); testAddGetDelete6(); @@ -689,12 +635,12 @@ TEST_F(PgSqlLeaseMgrTest, getLeases6DuidIaidMultiThreading) { testGetLeases6DuidIaid(); } -// Check that the system can cope with a DUID of allowed size. +/// @brief Check that the system can cope with a DUID of allowed size. TEST_F(PgSqlLeaseMgrTest, getLeases6DuidSize) { testGetLeases6DuidSize(); } -// Check that the system can cope with a DUID of allowed size. +/// @brief Check that the system can cope with a DUID of allowed size. TEST_F(PgSqlLeaseMgrTest, getLeases6DuidSizeMultiThreading) { MultiThreadingMgr::instance().setMode(true); testGetLeases6DuidSize(); @@ -716,20 +662,6 @@ TEST_F(PgSqlLeaseMgrTest, lease6LeaseTypeCheckMultiThreading) { testLease6LeaseTypeCheck(); } -/// @brief Verifies the getLeases6(DUID) method -/// -/// Adds 3 lease and verifies fetch by DUID. -/// Verifies retrival of non existant DUID fails -TEST_F(PgSqlLeaseMgrTest, getLeases6Duid) { - testGetLeases6Duid(); -} - -/// @brief Verifies the getLeases6(DUID) method -TEST_F(PgSqlLeaseMgrTest, getLeases6DuidMultiThreading) { - MultiThreadingMgr::instance().setMode(true); - testGetLeases6Duid(); -} - /// @brief Check GetLease6 methods - access by DUID/IAID/SubnetID /// /// Adds leases to the database and checks that they can be accessed via @@ -744,17 +676,31 @@ TEST_F(PgSqlLeaseMgrTest, getLease6DuidIaidSubnetIdMultiThreading) { testGetLease6DuidIaidSubnetId(); } -// Test checks that getLease6() works with different DUID sizes +/// @brief Test checks that getLease6() works with different DUID sizes TEST_F(PgSqlLeaseMgrTest, getLease6DuidIaidSubnetIdSize) { testGetLease6DuidIaidSubnetIdSize(); } -// Test checks that getLease6() works with different DUID sizes +/// @brief Test checks that getLease6() works with different DUID sizes TEST_F(PgSqlLeaseMgrTest, getLease6DuidIaidSubnetIdSizeMultiThreading) { MultiThreadingMgr::instance().setMode(true); testGetLease6DuidIaidSubnetIdSize(); } +/// @brief check leases could be retrieved by DUID +/// +/// Create leases, add them to backend and verify if it can be queried +/// using DUID index +TEST_F(PgSqlLeaseMgrTest, getLeases6Duid) { + testGetLeases6Duid(); +} + +/// @brief check leases could be retrieved by DUID +TEST_F(PgSqlLeaseMgrTest, getLeases6DuidMultiThreading) { + MultiThreadingMgr::instance().setMode(true); + testGetLeases6Duid(); +} + /// @brief Lease6 update tests /// /// Checks that we are able to update a lease in the database. @@ -903,23 +849,69 @@ TEST_F(PgSqlLeaseMgrTest, DISABLED_wipeLeases6MultiThreading) { testWipeLeases6(); } -// Tests v4 lease stats query variants. +/// @brief Test fixture class for validating @c LeaseMgr using +/// PostgreSQL as back end and PostgreSQL connectivity loss. +class PgSqlLeaseMgrDbLostCallbackTest : public LeaseMgrDbLostCallbackTest { +public: + virtual void destroySchema() { + destroyPgSQLSchema(); + } + + virtual void createSchema() { + createPgSQLSchema(); + } + + virtual std::string validConnectString() { + return (validPgSQLConnectionString()); + } + + virtual std::string invalidConnectString() { + return (connectionString(PGSQL_VALID_TYPE, VALID_NAME, INVALID_HOST, + VALID_USER, VALID_PASSWORD)); + } +}; + +/// @brief Verifies that db lost callback is not invoked on an open failure +TEST_F(PgSqlLeaseMgrDbLostCallbackTest, testNoCallbackOnOpenFailure) { + MultiThreadingMgr::instance().setMode(false); + testDbLostCallback(); +} + +/// @brief Verifies that db lost callback is not invoked on an open failure +TEST_F(PgSqlLeaseMgrDbLostCallbackTest, testNoCallbackOnOpenFailureMultiThreading) { + MultiThreadingMgr::instance().setMode(true); + testDbLostCallback(); +} + +/// @brief Verifies that loss of connectivity to PostgreSQL is handled correctly. +TEST_F(PgSqlLeaseMgrDbLostCallbackTest, testDbLostCallback) { + MultiThreadingMgr::instance().setMode(false); + testDbLostCallback(); +} + +/// @brief Verifies that loss of connectivity to PostgreSQL is handled correctly. +TEST_F(PgSqlLeaseMgrDbLostCallbackTest, testDbLostCallbackMultiThreading) { + MultiThreadingMgr::instance().setMode(true); + testDbLostCallback(); +} + +/// @brief Tests v4 lease stats query variants. TEST_F(PgSqlLeaseMgrTest, leaseStatsQuery4) { testLeaseStatsQuery4(); } -// Tests v4 lease stats query variants. +/// @brief Tests v4 lease stats query variants. TEST_F(PgSqlLeaseMgrTest, leaseStatsQuery4MultiThreading) { MultiThreadingMgr::instance().setMode(true); testLeaseStatsQuery4(); } -// Tests v6 lease stats query variants. +/// @brief Tests v6 lease stats query variants. TEST_F(PgSqlLeaseMgrTest, leaseStatsQuery6) { testLeaseStatsQuery6(); } -// Tests v6 lease stats query variants. +/// @brief Tests v6 lease stats query variants. TEST_F(PgSqlLeaseMgrTest, leaseStatsQuery6MultiThreading) { MultiThreadingMgr::instance().setMode(true); testLeaseStatsQuery6();