[svn] commit: r3803 - in /branches/trac408/src/lib/nsas: nameserver_entry.cc tests/nameserver_entry_unittest.cc
BIND 10 source code commits
bind10-changes at lists.isc.org
Sat Dec 11 20:25:43 UTC 2010
Author: vorner
Date: Sat Dec 11 20:25:42 2010
New Revision: 3803
Log:
Enable tests that didn't compile after merge
Modified:
branches/trac408/src/lib/nsas/nameserver_entry.cc
branches/trac408/src/lib/nsas/tests/nameserver_entry_unittest.cc
Modified: branches/trac408/src/lib/nsas/nameserver_entry.cc
==============================================================================
--- branches/trac408/src/lib/nsas/nameserver_entry.cc (original)
+++ branches/trac408/src/lib/nsas/nameserver_entry.cc Sat Dec 11 20:25:42 2010
@@ -206,7 +206,6 @@
ResolverCallback(shared_ptr<NameserverEntry> entry,
AddressFamily family, const RRType& type) :
entry_(entry),
- rtt_(0),
family_(family),
type_(type)
{ }
@@ -249,7 +248,7 @@
}
// If we found it, use it. If not, create a new one.
entries.push_back(found ? *found : AddressEntry(IOAddress(
- i->getCurrent().toText()), ++ rtt_));
+ i->getCurrent().toText()), 1));
i->next();
}
@@ -300,7 +299,6 @@
}
private:
shared_ptr<NameserverEntry> entry_;
- int rtt_;
AddressFamily family_;
RRType type_;
Modified: branches/trac408/src/lib/nsas/tests/nameserver_entry_unittest.cc
==============================================================================
--- branches/trac408/src/lib/nsas/tests/nameserver_entry_unittest.cc (original)
+++ branches/trac408/src/lib/nsas/tests/nameserver_entry_unittest.cc Sat Dec 11 20:25:42 2010
@@ -33,6 +33,7 @@
#include "../asiolink.h"
#include "../address_entry.h"
#include "../nameserver_entry.h"
+#include "../nameserver_address.h"
#include "../zone_entry.h"
#include "nsas_test.h"
@@ -479,30 +480,30 @@
}
}
-// TODO This test must be updated, the rrsets are not passed trough constructor
-#if 0
// Select one address from the address list
TEST_F(NameserverEntryTest, AddressSelection) {
- boost::shared_ptr<NameserverEntry> ns(new NameserverEntry(&rrv4_, &rrv6_));
+ boost::shared_ptr<NameserverEntry> ns(new NameserverEntry(EXAMPLE_CO_UK,
+ RRClass::IN()));
+ fillNSEntry(ns, rrv4_, rrv6_);
NameserverEntry::AddressVector v4Addresses;
NameserverEntry::AddressVector v6Addresses;
- ns->getAddresses(v4Addresses, AF_INET);
- ns->getAddresses(v6Addresses, AF_INET6);
+ ns->getAddresses(v4Addresses, V4_ONLY);
+ ns->getAddresses(v6Addresses, V6_ONLY);
int c1 = 0;
int c2 = 0;
int c3 = 0;
NameserverAddress ns_address;
for(int i = 0; i < 10000; ++i){
- ns.get()->getAddress(ns_address, AF_INET);
+ ns->getAddress(ns_address, V4_ONLY);
asiolink::IOAddress io_address = ns_address.getAddress();
if(io_address.toText() == v4Addresses[0].getAddress().toText()) ++c1;
else if(io_address.toText() == v4Addresses[1].getAddress().toText()) ++c2;
else if(io_address.toText() == v4Addresses[2].getAddress().toText()) ++c3;
}
// c1, c2 and c3 should almost be equal
- ASSERT_EQ(1, (int)(c1*1.0/c2 + 0.5));
- ASSERT_EQ(1, (int)(c2*1.0/c3 + 0.5));
+ EXPECT_EQ(1, (int)(c1*1.0/c2 + 0.5));
+ EXPECT_EQ(1, (int)(c2*1.0/c3 + 0.5));
// update the rtt to 1, 2, 3
ns->setAddressRTT(v4Addresses[0].getAddress(), 1);
@@ -510,7 +511,7 @@
ns->setAddressRTT(v4Addresses[2].getAddress(), 3);
c1 = c2 = c3 = 0;
for(int i = 0; i < 100000; ++i){
- ns.get()->getAddress(ns_address, AF_INET);
+ ns->getAddress(ns_address, V4_ONLY);
asiolink::IOAddress io_address = ns_address.getAddress();
if(io_address.toText() == v4Addresses[0].getAddress().toText()) ++c1;
else if(io_address.toText() == v4Addresses[1].getAddress().toText()) ++c2;
@@ -518,9 +519,9 @@
}
// c1 should be (2*2) times of c2
- ASSERT_EQ(4, (int)(c1*1.0/c2 + 0.5));
+ EXPECT_EQ(4, (int)(c1*1.0/c2 + 0.5));
// c1 should be (3*3) times of c3
- ASSERT_EQ(9, (int)(c1*1.0/c3 + 0.5));
+ EXPECT_EQ(9, (int)(c1*1.0/c3 + 0.5));
// Test unreachable address
ns->setAddressRTT(v4Addresses[0].getAddress(), 1);
@@ -528,7 +529,7 @@
ns->setAddressUnreachable(v4Addresses[2].getAddress());
c1 = c2 = c3 = 0;
for(int i = 0; i < 100000; ++i){
- ns.get()->getAddress(ns_address, AF_INET);
+ ns->getAddress(ns_address, V4_ONLY);
asiolink::IOAddress io_address = ns_address.getAddress();
if(io_address.toText() == v4Addresses[0].getAddress().toText()) ++c1;
else if(io_address.toText() == v4Addresses[1].getAddress().toText()) ++c2;
@@ -536,7 +537,7 @@
}
// The 3rd address should not be selected again
- ASSERT_EQ(0, c3);
+ EXPECT_EQ(0, c3);
// Test if all the servers are unrachable
ns->setAddressUnreachable(v4Addresses[0].getAddress());
@@ -544,7 +545,7 @@
ns->setAddressUnreachable(v4Addresses[2].getAddress());
c1 = c2 = c3 = 0;
for(int i = 0; i < 100000; ++i){
- ns.get()->getAddress(ns_address, AF_INET);
+ ns.get()->getAddress(ns_address, V4_ONLY);
asiolink::IOAddress io_address = ns_address.getAddress();
if(io_address.toText() == v4Addresses[0].getAddress().toText()) ++c1;
else if(io_address.toText() == v4Addresses[1].getAddress().toText()) ++c2;
@@ -552,45 +553,46 @@
}
// All the unreachable servers should be selected with equal opportunity
- ASSERT_EQ(1, (int)(c1*1.0/c2 + 0.5));
- ASSERT_EQ(1, (int)(c1*1.0/c3 + 0.5));
+ EXPECT_EQ(1, (int)(c1*1.0/c2 + 0.5));
+ EXPECT_EQ(1, (int)(c1*1.0/c3 + 0.5));
// TODO: The unreachable server should be changed to reachable after 5minutes, but how to test?
}
// Test the RTT is updated smoothly
TEST_F(NameserverEntryTest, UpdateRTT) {
- NameserverEntry ns(&rrv4_, &rrv6_);
+ shared_ptr<NameserverEntry> ns(new NameserverEntry(EXAMPLE_CO_UK,
+ RRClass::IN()));
+ fillNSEntry(ns, rrv4_, rrv6_);
NameserverEntry::AddressVector vec;
- ns.getAddresses(vec);
+ ns->getAddresses(vec);
// Initialize the rtt with a small value
uint32_t init_rtt = 1;
- ns.setAddressRTT(vec[0].getAddress(), init_rtt);
+ ns->setAddressRTT(vec[0].getAddress(), init_rtt);
// The rtt will be stablized to a large value
uint32_t stable_rtt = 100;
// Update the rtt
- ns.updateAddressRTTAtIndex(stable_rtt, 0, AF_INET);
+ ns->updateAddressRTTAtIndex(stable_rtt, 0, V4_ONLY);
vec.clear();
- ns.getAddresses(vec);
+ ns->getAddresses(vec);
uint32_t new_rtt = vec[0].getRTT();
// The rtt should not close to new rtt immediately
- ASSERT_TRUE((stable_rtt - new_rtt) > (new_rtt - init_rtt));
+ EXPECT_TRUE((stable_rtt - new_rtt) > (new_rtt - init_rtt));
// Update the rtt for enough times
for(int i = 0; i < 10000; ++i){
- ns.updateAddressRTTAtIndex(stable_rtt, 0, AF_INET);
+ ns->updateAddressRTTAtIndex(stable_rtt, 0, V4_ONLY);
}
vec.clear();
- ns.getAddresses(vec);
+ ns->getAddresses(vec);
new_rtt = vec[0].getRTT();
// The rtt should be close to stable rtt value
- ASSERT_TRUE((stable_rtt - new_rtt) < (new_rtt - init_rtt));
-}
-#endif
+ EXPECT_TRUE((stable_rtt - new_rtt) < (new_rtt - init_rtt));
+}
} // namespace
More information about the bind10-changes
mailing list