Browse Source

[3146] Minor changes after review:

 - LeaseType is now initalized from static array
 - @todos added in 2 MySQL tests
 - Added a comment about lease type values to MySQL schema
Tomek Mrugalski 11 years ago
parent
commit
05a05d810b

+ 3 - 1
src/lib/dhcpsrv/dhcpdb_create.mysql

@@ -76,7 +76,9 @@ CREATE INDEX lease6_by_iaid_subnet_id_duid ON lease6 (iaid, subnet_id, duid);
 
 # ... and a definition of lease6 types.  This table is a convenience for
 # users of the database - if they want to view the lease table and use the
-# type names, they can join this table with the lease6 table
+# type names, they can join this table with the lease6 table.
+# Make sure those values match Lease6::LeaseType enum (see src/bin/dhcpsrv/
+# lease_mgr.h)
 CREATE TABLE lease6_types (
     lease_type TINYINT PRIMARY KEY NOT NULL,    # Lease type code.
     name VARCHAR(5)                             # Name of the lease type

+ 2 - 0
src/lib/dhcpsrv/tests/mysql_lease_mgr_unittest.cc

@@ -824,6 +824,7 @@ TEST_F(MySqlLeaseMgrTest, getLease4ClientIdSubnetId) {
 ///
 /// Adds leases to the database and checks that they can be accessed via
 /// a combination of DIUID and IAID.
+/// @todo: update this test once type checking/filtering is implemented
 TEST_F(MySqlLeaseMgrTest, getLease6DuidIaid) {
     // Get the leases to be used for the test.
     vector<Lease6Ptr> leases = createLeases6();
@@ -870,6 +871,7 @@ TEST_F(MySqlLeaseMgrTest, getLease6DuidIaid) {
 // @brief Get Lease4 by DUID and IAID (2)
 //
 // Check that the system can cope with a DUID of any size.
+/// @todo: update this test once type checking/filtering is implemented
 TEST_F(MySqlLeaseMgrTest, getLease6DuidIaidSize) {
 
     // Create leases, although we need only one.

+ 10 - 2
src/lib/dhcpsrv/tests/test_utils.cc

@@ -36,6 +36,13 @@ const char* ADDRESS6[] = {
     NULL
 };
 
+// Lease types that correspond to ADDRESS6 leases
+static const Lease6::LeaseType LEASETYPE6[] = {
+    Lease6::LEASE_IA_NA, Lease6::LEASE_IA_TA, Lease6::LEASE_IA_PD,
+    Lease6::LEASE_IA_NA, Lease6::LEASE_IA_TA, Lease6::LEASE_IA_PD,
+    Lease6::LEASE_IA_NA, Lease6::LEASE_IA_TA
+};
+
 void
 detailCompareLease(const Lease4Ptr& first, const Lease4Ptr& second) {
     // Compare address strings.  Comparison of address objects is not used, as
@@ -109,8 +116,9 @@ GenericLeaseMgrTest::GenericLeaseMgrTest()
         IOAddress ioaddr(addr);
         ioaddress6_.push_back(ioaddr);
 
-        /// Let's create different lease types
-        leasetype6_.push_back(static_cast<Lease6::LeaseType>(i%3));
+        /// Let's create different lease types. We use LEASETYPE6 values as
+        /// a template
+        leasetype6_.push_back(LEASETYPE6[i]);
     }
 }