Browse Source

[3083] Unit test setting FQDN lease parameters.

Marcin Siodelski 11 years ago
parent
commit
9fab3d3a01

+ 6 - 2
src/bin/dhcp4/dhcp4_srv.cc

@@ -614,9 +614,13 @@ Dhcpv4Srv::assignLease(const Pkt4Ptr& question, Pkt4Ptr& answer) {
     // will try to honour the hint, but it is just a hint - some other address
     // may be used instead. If fake_allocation is set to false, the lease will
     // be inserted into the LeaseMgr as well.
+    // @todo pass the actual FQDN data.
+    Lease4Ptr old_lease;
     Lease4Ptr lease = alloc_engine_->allocateAddress4(subnet, client_id, hwaddr,
-                                                      hint, fake_allocation,
-                                                      callout_handle);
+                                                      hint, false, false, "",
+                                                      fake_allocation,
+                                                      callout_handle,
+                                                      old_lease);
 
     if (lease) {
         // We have a lease! Let's set it in the packet and send it back to

+ 0 - 2
src/lib/dhcpsrv/alloc_engine.cc

@@ -820,8 +820,6 @@ Lease4Ptr AllocEngine::createLease4(const SubnetPtr& subnet,
         callout_handle->getArgument("lease4", lease);
     }
 
-
-
     if (!fake_allocation) {
         // That is a real (REQUEST) allocation
         bool status = LeaseMgrFactory::instance().addLease(lease);

+ 9 - 10
src/lib/dhcpsrv/tests/alloc_engine_unittest.cc

@@ -164,8 +164,6 @@ public:
         EXPECT_EQ(subnet_->getValid(), lease->valid_lft_);
         EXPECT_EQ(subnet_->getT1(), lease->t1_);
         EXPECT_EQ(subnet_->getT2(), lease->t2_);
-        EXPECT_TRUE(false == lease->fqdn_fwd_);
-        EXPECT_TRUE(false == lease->fqdn_rev_);
         if (lease->client_id_ && !clientid_) {
             ADD_FAILURE() << "Lease4 has a client-id, while it should have none.";
         } else
@@ -614,7 +612,8 @@ TEST_F(AllocEngine4Test, simpleAlloc4) {
 
     Lease4Ptr lease = engine->allocateAddress4(subnet_, clientid_, hwaddr_,
                                                IOAddress("0.0.0.0"),
-                                               false, false, "",
+                                               false, true,
+                                               "somehost.example.com.",
                                                false, CalloutHandlePtr(),
                                                old_lease_);
     // The new lease has been allocated, so the old lease should not exist.
@@ -642,7 +641,7 @@ TEST_F(AllocEngine4Test, fakeAlloc4) {
 
     Lease4Ptr lease = engine->allocateAddress4(subnet_, clientid_, hwaddr_,
                                                IOAddress("0.0.0.0"),
-                                               false, false, "",
+                                               false, true, "host.example.com.",
                                                true, CalloutHandlePtr(),
                                                old_lease_);
 
@@ -670,7 +669,7 @@ TEST_F(AllocEngine4Test, allocWithValidHint4) {
 
     Lease4Ptr lease = engine->allocateAddress4(subnet_, clientid_, hwaddr_,
                                                IOAddress("192.0.2.105"),
-                                               false, false, "",
+                                               true, true, "host.example.com.",
                                                false, CalloutHandlePtr(),
                                                old_lease_);
     // Check that we got a lease
@@ -805,7 +804,7 @@ TEST_F(AllocEngine4Test, allocateAddress4Nulls) {
     clientid_ = ClientIdPtr();
     lease = engine->allocateAddress4(subnet_, ClientIdPtr(), hwaddr_,
                                      IOAddress("0.0.0.0"),
-                                     false, false, "",
+                                     true, true, "myhost.example.com.",
                                      false, CalloutHandlePtr(),
                                      old_lease_);
     // Check that we got a lease
@@ -914,7 +913,7 @@ TEST_F(AllocEngine4Test, smallPool4) {
 
     Lease4Ptr lease = engine->allocateAddress4(subnet_, clientid_, hwaddr_,
                                                IOAddress("0.0.0.0"),
-                                               false, false, "",
+                                               true, true, "host.example.com.",
                                                false, CalloutHandlePtr(),
                                                old_lease_);
 
@@ -1070,7 +1069,7 @@ TEST_F(AllocEngine4Test, requestReuseExpiredLease4) {
     // A client comes along, asking specifically for this address
     lease = engine->allocateAddress4(subnet_, clientid_, hwaddr_,
                                      IOAddress(addr.toText()),
-                                     false, false, "",
+                                     false, true, "host.example.com.",
                                      false, CalloutHandlePtr(),
                                      old_lease_);
 
@@ -1117,8 +1116,8 @@ TEST_F(AllocEngine4Test, renewLease4) {
     // Lease was assigned 45 seconds ago and is valid for 100 seconds. Let's
     // renew it.
     ASSERT_FALSE(lease->expired());
-    lease = engine->renewLease4(subnet_, clientid_, hwaddr_, false,
-                                false, "", lease, false);
+    lease = engine->renewLease4(subnet_, clientid_, hwaddr_, true,
+                                true, "host.example.com.", lease, false);
     // Check that he got that single lease
     ASSERT_TRUE(lease);
     EXPECT_EQ(addr.toText(), lease->addr_.toText());

+ 6 - 0
src/lib/dhcpsrv/tests/test_utils.cc

@@ -47,6 +47,9 @@ detailCompareLease(const Lease4Ptr& first, const Lease4Ptr& second) {
     EXPECT_EQ(first->valid_lft_, second->valid_lft_);
     EXPECT_EQ(first->cltt_, second->cltt_);
     EXPECT_EQ(first->subnet_id_, second->subnet_id_);
+    EXPECT_EQ(first->fqdn_fwd_, second->fqdn_fwd_);
+    EXPECT_EQ(first->fqdn_rev_, second->fqdn_rev_);
+    EXPECT_EQ(first->hostname_, second->hostname_);
 }
 
 void
@@ -67,6 +70,9 @@ detailCompareLease(const Lease6Ptr& first, const Lease6Ptr& second) {
     EXPECT_EQ(first->valid_lft_, second->valid_lft_);
     EXPECT_EQ(first->cltt_, second->cltt_);
     EXPECT_EQ(first->subnet_id_, second->subnet_id_);
+    EXPECT_EQ(first->fqdn_fwd_, second->fqdn_fwd_);
+    EXPECT_EQ(first->fqdn_rev_, second->fqdn_rev_);
+    EXPECT_EQ(first->hostname_, second->hostname_);
 }
 
 };