pgsql_host_data_source_unittest.cc 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565
  1. // Copyright (C) 2016-2017 Internet Systems Consortium, Inc. ("ISC")
  2. //
  3. // This Source Code Form is subject to the terms of the Mozilla Public
  4. // License, v. 2.0. If a copy of the MPL was not distributed with this
  5. // file, You can obtain one at http://mozilla.org/MPL/2.0/.
  6. #include <config.h>
  7. #include <asiolink/io_address.h>
  8. #include <dhcpsrv/tests/test_utils.h>
  9. #include <exceptions/exceptions.h>
  10. #include <dhcpsrv/host.h>
  11. #include <dhcpsrv/pgsql_connection.h>
  12. #include <dhcpsrv/pgsql_host_data_source.h>
  13. #include <dhcpsrv/tests/generic_host_data_source_unittest.h>
  14. #include <dhcpsrv/testutils/pgsql_schema.h>
  15. #include <dhcpsrv/host_data_source_factory.h>
  16. #include <gtest/gtest.h>
  17. #include <algorithm>
  18. #include <iostream>
  19. #include <sstream>
  20. #include <string>
  21. #include <utility>
  22. using namespace isc;
  23. using namespace isc::asiolink;
  24. using namespace isc::dhcp;
  25. using namespace isc::dhcp::test;
  26. using namespace std;
  27. namespace {
  28. class PgSqlHostDataSourceTest : public GenericHostDataSourceTest {
  29. public:
  30. /// @brief Constructor
  31. ///
  32. /// Deletes everything from the database and opens it.
  33. PgSqlHostDataSourceTest() {
  34. // Ensure schema is the correct one.
  35. destroyPgSQLSchema();
  36. createPgSQLSchema();
  37. // Connect to the database
  38. try {
  39. HostDataSourceFactory::create(validPgSQLConnectionString());
  40. } catch (...) {
  41. std::cerr << "*** ERROR: unable to open database. The test\n"
  42. "*** environment is broken and must be fixed before\n"
  43. "*** the PostgreSQL tests will run correctly.\n"
  44. "*** The reason for the problem is described in the\n"
  45. "*** accompanying exception output.\n";
  46. throw;
  47. }
  48. hdsptr_ = HostDataSourceFactory::getHostDataSourcePtr();
  49. }
  50. /// @brief Destructor
  51. ///
  52. /// Rolls back all pending transactions. The deletion of myhdsptr_ will
  53. /// close the database. Then reopen it and delete everything created by
  54. /// the test.
  55. virtual ~PgSqlHostDataSourceTest() {
  56. try {
  57. hdsptr_->rollback();
  58. } catch (...) {
  59. // Rollback may fail if backend is in read only mode. That's ok.
  60. }
  61. HostDataSourceFactory::destroy();
  62. hdsptr_.reset();
  63. destroyPgSQLSchema();
  64. }
  65. /// @brief Reopen the database
  66. ///
  67. /// Closes the database and re-open it. Anything committed should be
  68. /// visible.
  69. ///
  70. /// Parameter is ignored for PostgreSQL backend as the v4 and v6 leases
  71. /// share the same database.
  72. void reopen(Universe) {
  73. HostDataSourceFactory::destroy();
  74. HostDataSourceFactory::create(validPgSQLConnectionString());
  75. hdsptr_ = HostDataSourceFactory::getHostDataSourcePtr();
  76. }
  77. /// @brief returns number of rows in a table
  78. ///
  79. /// Note: This method uses its own connection. It will not work if your test
  80. /// uses transactions.
  81. ///
  82. /// @param name of the table
  83. /// @return number of rows currently present in the table
  84. int countRowsInTable(const std::string& table) {
  85. string query = "SELECT * FROM " + table;
  86. PgSqlConnection::ParameterMap params;
  87. params["name"] = "keatest";
  88. params["user"] = "keatest";
  89. params["password"] = "keatest";
  90. PgSqlConnection conn(params);
  91. conn.openDatabase();
  92. PgSqlResult r(PQexec(conn, query.c_str()));
  93. if (PQresultStatus(r) != PGRES_TUPLES_OK) {
  94. isc_throw(DbOperationError, "Query failed:" << PQerrorMessage(conn));
  95. }
  96. int numrows = PQntuples(r);
  97. return (numrows);
  98. }
  99. /// @brief Returns number of IPv4 options in the DB table.
  100. virtual int countDBOptions4() {
  101. return (countRowsInTable("dhcp4_options"));
  102. }
  103. /// @brief Returns number of IPv4 options in the DB table.
  104. virtual int countDBOptions6() {
  105. return (countRowsInTable("dhcp6_options"));
  106. }
  107. /// @brief Returns number of IPv6 reservations in the DB table.
  108. virtual int countDBReservations6() {
  109. return (countRowsInTable("ipv6_reservations"));
  110. }
  111. };
  112. /// @brief Check that database can be opened
  113. ///
  114. /// This test checks if the PgSqlHostDataSource can be instantiated. This happens
  115. /// only if the database can be opened. Note that this is not part of the
  116. /// PgSqlLeaseMgr test fixure set. This test checks that the database can be
  117. /// opened: the fixtures assume that and check basic operations.
  118. TEST(PgSqlHostDataSource, OpenDatabase) {
  119. // Schema needs to be created for the test to work.
  120. destroyPgSQLSchema();
  121. createPgSQLSchema();
  122. // Check that lease manager open the database opens correctly and tidy up.
  123. // If it fails, print the error message.
  124. try {
  125. HostDataSourceFactory::create(validPgSQLConnectionString());
  126. EXPECT_NO_THROW((void) HostDataSourceFactory::getHostDataSourcePtr());
  127. HostDataSourceFactory::destroy();
  128. } catch (const isc::Exception& ex) {
  129. FAIL() << "*** ERROR: unable to open database, reason:\n"
  130. << " " << ex.what() << "\n"
  131. << "*** The test environment is broken and must be fixed\n"
  132. << "*** before the PostgreSQL tests will run correctly.\n";
  133. }
  134. // Check that lease manager open the database opens correctly with a longer
  135. // timeout. If it fails, print the error message.
  136. try {
  137. string connection_string = validPgSQLConnectionString() + string(" ") +
  138. string(VALID_TIMEOUT);
  139. HostDataSourceFactory::create(connection_string);
  140. EXPECT_NO_THROW((void) HostDataSourceFactory::getHostDataSourcePtr());
  141. HostDataSourceFactory::destroy();
  142. } catch (const isc::Exception& ex) {
  143. FAIL() << "*** ERROR: unable to open database, reason:\n"
  144. << " " << ex.what() << "\n"
  145. << "*** The test environment is broken and must be fixed\n"
  146. << "*** before the PostgreSQL tests will run correctly.\n";
  147. }
  148. // Check that attempting to get an instance of the lease manager when
  149. // none is set throws an exception.
  150. EXPECT_FALSE(HostDataSourceFactory::getHostDataSourcePtr());
  151. // Check that wrong specification of backend throws an exception.
  152. // (This is really a check on LeaseMgrFactory, but is convenient to
  153. // perform here.)
  154. EXPECT_THROW(HostDataSourceFactory::create(connectionString(
  155. NULL, VALID_NAME, VALID_HOST, INVALID_USER, VALID_PASSWORD)),
  156. InvalidParameter);
  157. EXPECT_THROW(HostDataSourceFactory::create(connectionString(
  158. INVALID_TYPE, VALID_NAME, VALID_HOST, VALID_USER, VALID_PASSWORD)),
  159. InvalidType);
  160. // Check that invalid login data causes an exception.
  161. EXPECT_THROW(HostDataSourceFactory::create(connectionString(
  162. PGSQL_VALID_TYPE, INVALID_NAME, VALID_HOST, VALID_USER, VALID_PASSWORD)),
  163. DbOpenError);
  164. EXPECT_THROW(HostDataSourceFactory::create(connectionString(
  165. PGSQL_VALID_TYPE, VALID_NAME, INVALID_HOST, VALID_USER, VALID_PASSWORD)),
  166. DbOpenError);
  167. EXPECT_THROW(HostDataSourceFactory::create(connectionString(
  168. PGSQL_VALID_TYPE, VALID_NAME, VALID_HOST, INVALID_USER, VALID_PASSWORD)),
  169. DbOpenError);
  170. EXPECT_THROW(HostDataSourceFactory::create(connectionString(
  171. PGSQL_VALID_TYPE, VALID_NAME, VALID_HOST, VALID_USER, INVALID_PASSWORD)),
  172. DbOpenError);
  173. EXPECT_THROW(HostDataSourceFactory::create(connectionString(
  174. PGSQL_VALID_TYPE, VALID_NAME, VALID_HOST, VALID_USER, VALID_PASSWORD, INVALID_TIMEOUT_1)),
  175. DbInvalidTimeout);
  176. EXPECT_THROW(HostDataSourceFactory::create(connectionString(
  177. PGSQL_VALID_TYPE, VALID_NAME, VALID_HOST, VALID_USER, VALID_PASSWORD, INVALID_TIMEOUT_2)),
  178. DbInvalidTimeout);
  179. // Check for missing parameters
  180. EXPECT_THROW(HostDataSourceFactory::create(connectionString(
  181. PGSQL_VALID_TYPE, NULL, VALID_HOST, INVALID_USER, VALID_PASSWORD)),
  182. NoDatabaseName);
  183. // Tidy up after the test
  184. destroyPgSQLSchema();
  185. }
  186. // This test verifies that database backend can operate in Read-Only mode.
  187. TEST_F(PgSqlHostDataSourceTest, testReadOnlyDatabase) {
  188. testReadOnlyDatabase(PGSQL_VALID_TYPE);
  189. }
  190. // Test verifies if a host reservation can be added and later retrieved by IPv4
  191. // address. Host uses hw address as identifier.
  192. TEST_F(PgSqlHostDataSourceTest, basic4HWAddr) {
  193. testBasic4(Host::IDENT_HWADDR);
  194. }
  195. // Test verifies if a host reservation can be added and later retrieved by IPv4
  196. // address. Host uses client-id (DUID) as identifier.
  197. TEST_F(PgSqlHostDataSourceTest, basic4ClientId) {
  198. testBasic4(Host::IDENT_DUID);
  199. }
  200. // Test verifies that multiple hosts can be added and later retrieved by their
  201. // reserved IPv4 address. This test uses HW addresses as identifiers.
  202. TEST_F(PgSqlHostDataSourceTest, getByIPv4HWaddr) {
  203. testGetByIPv4(Host::IDENT_HWADDR);
  204. }
  205. // Test verifies that multiple hosts can be added and later retrieved by their
  206. // reserved IPv4 address. This test uses client-id (DUID) as identifiers.
  207. TEST_F(PgSqlHostDataSourceTest, getByIPv4ClientId) {
  208. testGetByIPv4(Host::IDENT_DUID);
  209. }
  210. // Test verifies if a host reservation can be added and later retrieved by
  211. // hardware address.
  212. TEST_F(PgSqlHostDataSourceTest, get4ByHWaddr) {
  213. testGet4ByIdentifier(Host::IDENT_HWADDR);
  214. }
  215. // Test verifies if a host reservation can be added and later retrieved by
  216. // DUID.
  217. TEST_F(PgSqlHostDataSourceTest, get4ByDUID) {
  218. testGet4ByIdentifier(Host::IDENT_DUID);
  219. }
  220. // Test verifies if a host reservation can be added and later retrieved by
  221. // circuit id.
  222. TEST_F(PgSqlHostDataSourceTest, get4ByCircuitId) {
  223. testGet4ByIdentifier(Host::IDENT_CIRCUIT_ID);
  224. }
  225. // Test verifies if a host reservation can be added and later retrieved by
  226. // client-id.
  227. TEST_F(PgSqlHostDataSourceTest, get4ByClientId) {
  228. testGet4ByIdentifier(Host::IDENT_CLIENT_ID);
  229. }
  230. // Test verifies if hardware address and client identifier are not confused.
  231. TEST_F(PgSqlHostDataSourceTest, hwaddrNotClientId1) {
  232. testHWAddrNotClientId();
  233. }
  234. // Test verifies if hardware address and client identifier are not confused.
  235. TEST_F(PgSqlHostDataSourceTest, hwaddrNotClientId2) {
  236. testClientIdNotHWAddr();
  237. }
  238. // Test verifies if a host with FQDN hostname can be stored and later retrieved.
  239. TEST_F(PgSqlHostDataSourceTest, hostnameFQDN) {
  240. testHostname("foo.example.org", 1);
  241. }
  242. // Test verifies if 100 hosts with unique FQDN hostnames can be stored and later
  243. // retrieved.
  244. TEST_F(PgSqlHostDataSourceTest, hostnameFQDN100) {
  245. testHostname("foo.example.org", 100);
  246. }
  247. // Test verifies if a host without any hostname specified can be stored and
  248. // later retrieved.
  249. TEST_F(PgSqlHostDataSourceTest, noHostname) {
  250. testHostname("", 1);
  251. }
  252. // Test verifies if the hardware or client-id query can match hardware address.
  253. TEST_F(PgSqlHostDataSourceTest, DISABLED_hwaddrOrClientId1) {
  254. /// @todo: The logic behind ::get4(subnet_id, hwaddr, duid) call needs to
  255. /// be discussed.
  256. ///
  257. /// @todo: Add host reservation with hardware address X, try to retrieve
  258. /// host for hardware address X or client identifier Y, verify that the
  259. /// reservation is returned.
  260. }
  261. // Test verifies if the hardware or client-id query can match client-id.
  262. TEST_F(PgSqlHostDataSourceTest, DISABLED_hwaddrOrClientId2) {
  263. /// @todo: The logic behind ::get4(subnet_id, hwaddr, duid) call needs to
  264. /// be discussed.
  265. ///
  266. /// @todo: Add host reservation with client identifier Y, try to retrieve
  267. /// host for hardware address X or client identifier Y, verify that the
  268. /// reservation is returned.
  269. }
  270. // Test verifies that host with IPv6 address and DUID can be added and
  271. // later retrieved by IPv6 address.
  272. TEST_F(PgSqlHostDataSourceTest, get6AddrWithDuid) {
  273. testGetByIPv6(Host::IDENT_DUID, false);
  274. }
  275. // Test verifies that host with IPv6 address and HWAddr can be added and
  276. // later retrieved by IPv6 address.
  277. TEST_F(PgSqlHostDataSourceTest, get6AddrWithHWAddr) {
  278. testGetByIPv6(Host::IDENT_HWADDR, false);
  279. }
  280. // Test verifies that host with IPv6 prefix and DUID can be added and
  281. // later retrieved by IPv6 prefix.
  282. TEST_F(PgSqlHostDataSourceTest, get6PrefixWithDuid) {
  283. testGetByIPv6(Host::IDENT_DUID, true);
  284. }
  285. // Test verifies that host with IPv6 prefix and HWAddr can be added and
  286. // later retrieved by IPv6 prefix.
  287. TEST_F(PgSqlHostDataSourceTest, get6PrefixWithHWaddr) {
  288. testGetByIPv6(Host::IDENT_HWADDR, true);
  289. }
  290. // Test verifies that host with IPv6 prefix reservation can be retrieved
  291. // by subnet id and prefix value.
  292. TEST_F(PgSqlHostDataSourceTest, get6SubnetPrefix) {
  293. testGetBySubnetIPv6();
  294. }
  295. // Test verifies if a host reservation can be added and later retrieved by
  296. // hardware address.
  297. TEST_F(PgSqlHostDataSourceTest, get6ByHWaddr) {
  298. testGet6ByHWAddr();
  299. }
  300. // Test verifies if a host reservation can be added and later retrieved by
  301. // client identifier.
  302. TEST_F(PgSqlHostDataSourceTest, get6ByClientId) {
  303. testGet6ByClientId();
  304. }
  305. // Test verifies if a host reservation can be stored with both IPv6 address and
  306. // prefix.
  307. TEST_F(PgSqlHostDataSourceTest, addr6AndPrefix) {
  308. testAddr6AndPrefix();
  309. }
  310. // Tests if host with multiple IPv6 reservations can be added and then
  311. // retrieved correctly. Test checks reservations comparing.
  312. TEST_F(PgSqlHostDataSourceTest, multipleReservations){
  313. testMultipleReservations();
  314. }
  315. // Tests if compareIPv6Reservations() method treats same pool of reservations
  316. // but added in different order as equal.
  317. TEST_F(PgSqlHostDataSourceTest, multipleReservationsDifferentOrder){
  318. testMultipleReservationsDifferentOrder();
  319. }
  320. // Test that multiple client classes for IPv4 can be inserted and
  321. // retrieved for a given host reservation.
  322. TEST_F(PgSqlHostDataSourceTest, multipleClientClasses4) {
  323. testMultipleClientClasses4();
  324. }
  325. // Test that multiple client classes for IPv6 can be inserted and
  326. // retrieved for a given host reservation.
  327. TEST_F(PgSqlHostDataSourceTest, multipleClientClasses6) {
  328. testMultipleClientClasses6();
  329. }
  330. // Test that multiple client classes for both IPv4 and IPv6 can
  331. // be inserted and retrieved for a given host reservation.
  332. TEST_F(PgSqlHostDataSourceTest, multipleClientClassesBoth) {
  333. testMultipleClientClassesBoth();
  334. }
  335. // Test if the same host can have reservations in different subnets (with the
  336. // same hardware address). The test logic is as follows:
  337. // Insert 10 host reservations for a given physical host (the same
  338. // hardware address), but for different subnets (different subnet-ids).
  339. // Make sure that getAll() returns them all correctly.
  340. TEST_F(PgSqlHostDataSourceTest, multipleSubnetsHWAddr) {
  341. testMultipleSubnets(10, Host::IDENT_HWADDR);
  342. }
  343. // Test if the same host can have reservations in different subnets (with the
  344. // same client identifier). The test logic is as follows:
  345. //
  346. // Insert 10 host reservations for a given physical host (the same
  347. // client-identifier), but for different subnets (different subnet-ids).
  348. // Make sure that getAll() returns them correctly.
  349. TEST_F(PgSqlHostDataSourceTest, multipleSubnetsClientId) {
  350. testMultipleSubnets(10, Host::IDENT_DUID);
  351. }
  352. // Test if host reservations made for different IPv6 subnets are handled correctly.
  353. // The test logic is as follows:
  354. //
  355. // Insert 10 host reservations for different subnets. Make sure that
  356. // get6(subnet-id, ...) calls return correct reservation.
  357. TEST_F(PgSqlHostDataSourceTest, subnetId6) {
  358. testSubnetId6(10, Host::IDENT_HWADDR);
  359. }
  360. // Test if the duplicate host instances can't be inserted. The test logic is as
  361. // follows: try to add multiple instances of the same host reservation and
  362. // verify that the second and following attempts will throw exceptions.
  363. // Hosts with same DUID.
  364. TEST_F(PgSqlHostDataSourceTest, addDuplicate6WithDUID) {
  365. testAddDuplicate6WithSameDUID();
  366. }
  367. // Test if the duplicate host instances can't be inserted. The test logic is as
  368. // follows: try to add multiple instances of the same host reservation and
  369. // verify that the second and following attempts will throw exceptions.
  370. // Hosts with same HWAddr.
  371. TEST_F(PgSqlHostDataSourceTest, addDuplicate6WithHWAddr) {
  372. testAddDuplicate6WithSameHWAddr();
  373. }
  374. // Test if the duplicate IPv4 host instances can't be inserted. The test logic is as
  375. // follows: try to add multiple instances of the same host reservation and
  376. // verify that the second and following attempts will throw exceptions.
  377. TEST_F(PgSqlHostDataSourceTest, addDuplicate4) {
  378. testAddDuplicate4();
  379. }
  380. // This test verifies that DHCPv4 options can be inserted in a binary format
  381. /// and retrieved from the PostgreSQL host database.
  382. TEST_F(PgSqlHostDataSourceTest, optionsReservations4) {
  383. testOptionsReservations4(false);
  384. }
  385. // This test verifies that DHCPv6 options can be inserted in a binary format
  386. /// and retrieved from the PostgreSQL host database.
  387. TEST_F(PgSqlHostDataSourceTest, optionsReservations6) {
  388. testOptionsReservations6(false);
  389. }
  390. // This test verifies that DHCPv4 and DHCPv6 options can be inserted in a
  391. /// binary format and retrieved with a single query to the database.
  392. TEST_F(PgSqlHostDataSourceTest, optionsReservations46) {
  393. testOptionsReservations46(false);
  394. }
  395. // This test verifies that DHCPv4 options can be inserted in a textual format
  396. /// and retrieved from the PostgreSQL host database.
  397. TEST_F(PgSqlHostDataSourceTest, formattedOptionsReservations4) {
  398. testOptionsReservations4(true);
  399. }
  400. // This test verifies that DHCPv6 options can be inserted in a textual format
  401. /// and retrieved from the PostgreSQL host database.
  402. TEST_F(PgSqlHostDataSourceTest, formattedOptionsReservations6) {
  403. testOptionsReservations6(true);
  404. }
  405. // This test verifies that DHCPv4 and DHCPv6 options can be inserted in a
  406. // textual format and retrieved with a single query to the database.
  407. TEST_F(PgSqlHostDataSourceTest, formattedOptionsReservations46) {
  408. testOptionsReservations46(true);
  409. }
  410. // This test checks transactional insertion of the host information
  411. // into the database. The failure to insert host information at
  412. // any stage should cause the whole transaction to be rolled back.
  413. TEST_F(PgSqlHostDataSourceTest, testAddRollback) {
  414. // Make sure we have the pointer to the host data source.
  415. ASSERT_TRUE(hdsptr_);
  416. // To test the transaction rollback mechanism we need to cause the
  417. // insertion of host information to fail at some stage. The 'hosts'
  418. // table should be updated correctly but the failure should occur
  419. // when inserting reservations or options. The simplest way to
  420. // achieve that is to simply drop one of the tables. To do so, we
  421. // connect to the database and issue a DROP query.
  422. PgSqlConnection::ParameterMap params;
  423. params["name"] = "keatest";
  424. params["user"] = "keatest";
  425. params["password"] = "keatest";
  426. PgSqlConnection conn(params);
  427. ASSERT_NO_THROW(conn.openDatabase());
  428. PgSqlResult r(PQexec(conn, "DROP TABLE IF EXISTS ipv6_reservations"));
  429. ASSERT_TRUE (PQresultStatus(r) == PGRES_COMMAND_OK)
  430. << " drop command failed :" << PQerrorMessage(conn);
  431. // Create a host with a reservation.
  432. HostPtr host = initializeHost6("2001:db8:1::1", Host::IDENT_HWADDR, false);
  433. // Let's assign some DHCPv4 subnet to the host, because we will use the
  434. // DHCPv4 subnet to try to retrieve the host after failed insertion.
  435. host->setIPv4SubnetID(SubnetID(4));
  436. // There is no ipv6_reservations table, so the insertion should fail.
  437. ASSERT_THROW(hdsptr_->add(host), DbOperationError);
  438. // Even though we have created a DHCPv6 host, we can't use get6()
  439. // method to retrieve the host from the database, because the
  440. // query would expect that the ipv6_reservations table is present.
  441. // Therefore, the query would fail. Instead, we use the get4 method
  442. // which uses the same client identifier, but doesn't attempt to
  443. // retrieve the data from ipv6_reservations table. The query should
  444. // pass but return no host because the (insert) transaction is expected
  445. // to be rolled back.
  446. ConstHostPtr from_hds = hdsptr_->get4(host->getIPv4SubnetID(),
  447. host->getIdentifierType(),
  448. &host->getIdentifier()[0],
  449. host->getIdentifier().size());
  450. EXPECT_FALSE(from_hds);
  451. }
  452. // This test checks that siaddr, sname, file fields can be retrieved
  453. /// from a database for a host.
  454. TEST_F(PgSqlHostDataSourceTest, messageFields) {
  455. testMessageFields4();
  456. }
  457. // Check that delete(subnet-id, addr4) works.
  458. TEST_F(PgSqlHostDataSourceTest, deleteByAddr4) {
  459. testDeleteByAddr4();
  460. }
  461. // Check that delete(subnet4-id, identifier-type, identifier) works.
  462. TEST_F(PgSqlHostDataSourceTest, deleteById4) {
  463. testDeleteById4();
  464. }
  465. // Check that delete(subnet4-id, identifier-type, identifier) works,
  466. // even when options are present.
  467. TEST_F(PgSqlHostDataSourceTest, deleteById4Options) {
  468. testDeleteById4Options();
  469. }
  470. // Check that delete(subnet6-id, identifier-type, identifier) works.
  471. TEST_F(PgSqlHostDataSourceTest, deleteById6) {
  472. testDeleteById6();
  473. }
  474. // Check that delete(subnet6-id, identifier-type, identifier) works,
  475. // even when options are present.
  476. TEST_F(PgSqlHostDataSourceTest, deleteById6Options) {
  477. testDeleteById6Options();
  478. }
  479. }; // Of anonymous namespace