2
0
mirror of https://gitlab.isc.org/isc-projects/kea synced 2025-08-31 05:55:28 +00:00

[#3163] relax time-senstitive tests in dhcp[46]

This commit is contained in:
Andrei Pavel
2024-04-29 15:19:13 +03:00
parent e82ee81747
commit af91168026
2 changed files with 18 additions and 20 deletions

View File

@@ -48,7 +48,6 @@
#include <iostream>
#include <cstdlib>
#include <sstream>
#include <arpa/inet.h>
#include <dirent.h>
@@ -1892,8 +1891,7 @@ TEST_F(Dhcpv4SrvTest, DiscoverCache) {
OptionUint32Ptr opt = boost::dynamic_pointer_cast<
OptionUint32>(offer->getOption(DHO_DHCP_LEASE_TIME));
ASSERT_TRUE(opt);
EXPECT_GE(subnet_->getValid() - delta, opt->getValue());
EXPECT_LE(subnet_->getValid() - delta - 10, opt->getValue());
EXPECT_EQ_MARGIN(subnet_->getValid() - delta, opt->getValue(), 1);
// Check address
EXPECT_EQ(addr, offer->getYiaddr());
@@ -2074,7 +2072,7 @@ TEST_F(Dhcpv4SrvTest, RenewBasic) {
int32_t cltt = static_cast<int32_t>(l->cltt_);
int32_t expected = static_cast<int32_t>(time(NULL));
// Equality or difference by 1 between cltt and expected is ok.
EXPECT_GE(1, abs(cltt - expected));
EXPECT_EQ_MARGIN(cltt, expected, 1);
Lease4Ptr lease = LeaseMgrFactory::instance().getLease4(addr);
EXPECT_TRUE(LeaseMgrFactory::instance().deleteLease(lease));
@@ -2197,7 +2195,7 @@ TEST_F(Dhcpv4SrvTest, RenewDefaultLifetime) {
int32_t cltt = static_cast<int32_t>(c.l->cltt_);
int32_t expected = static_cast<int32_t>(time(NULL));
// Equality or difference by 1 between cltt and expected is ok.
EXPECT_GE(1, abs(cltt - expected));
EXPECT_EQ_MARGIN(cltt, expected, 1);
Lease4Ptr lease = LeaseMgrFactory::instance().getLease4(c.addr);
EXPECT_TRUE(LeaseMgrFactory::instance().deleteLease(lease));
@@ -2243,7 +2241,7 @@ TEST_F(Dhcpv4SrvTest, RenewHintLifetime) {
int32_t cltt = static_cast<int32_t>(c.l->cltt_);
int32_t expected = static_cast<int32_t>(time(NULL));
// Equality or difference by 1 between cltt and expected is ok.
EXPECT_GE(1, abs(cltt - expected));
EXPECT_EQ_MARGIN(cltt, expected, 1);
Lease4Ptr lease = LeaseMgrFactory::instance().getLease4(c.addr);
EXPECT_TRUE(LeaseMgrFactory::instance().deleteLease(lease));
@@ -2289,7 +2287,7 @@ TEST_F(Dhcpv4SrvTest, RenewMinLifetime) {
int32_t cltt = static_cast<int32_t>(c.l->cltt_);
int32_t expected = static_cast<int32_t>(time(NULL));
// Equality or difference by 1 between cltt and expected is ok.
EXPECT_GE(1, abs(cltt - expected));
EXPECT_EQ_MARGIN(cltt, expected, 1);
Lease4Ptr lease = LeaseMgrFactory::instance().getLease4(c.addr);
EXPECT_TRUE(LeaseMgrFactory::instance().deleteLease(lease));
@@ -2334,7 +2332,7 @@ TEST_F(Dhcpv4SrvTest, RenewMaxLifetime) {
int32_t cltt = static_cast<int32_t>(c.l->cltt_);
int32_t expected = static_cast<int32_t>(time(NULL));
// Equality or difference by 1 between cltt and expected is ok.
EXPECT_GE(1, abs(cltt - expected));
EXPECT_EQ_MARGIN(cltt, expected, 1);
Lease4Ptr lease = LeaseMgrFactory::instance().getLease4(c.addr);
EXPECT_TRUE(LeaseMgrFactory::instance().deleteLease(lease));
@@ -2402,8 +2400,7 @@ TEST_F(Dhcpv4SrvTest, RenewCache) {
OptionUint32Ptr opt = boost::dynamic_pointer_cast<
OptionUint32>(ack->getOption(DHO_DHCP_LEASE_TIME));
ASSERT_TRUE(opt);
EXPECT_GE(subnet_->getValid() - delta, opt->getValue());
EXPECT_LE(subnet_->getValid() - delta - 10, opt->getValue());
EXPECT_EQ_MARGIN(subnet_->getValid() - delta, opt->getValue(), 1);
// Check address
EXPECT_EQ(addr, ack->getYiaddr());

View File

@@ -48,9 +48,7 @@
#include <boost/pointer_cast.hpp>
#include <boost/scoped_ptr.hpp>
#include <fstream>
#include <iostream>
#include <sstream>
#include <dirent.h>
#include <unistd.h>
@@ -1706,8 +1704,11 @@ TEST_F(Dhcpv6SrvTest, RequestCache) {
// Check the address.
EXPECT_EQ(addr, iaaddr->getAddress());
EXPECT_EQ(pref - delta, iaaddr->getPreferred());
EXPECT_EQ(valid - delta, iaaddr->getValid());
// Since the initial time values were set, one second could have ticked,
// so allow one second of margin error.
EXPECT_EQ_MARGIN(pref - delta, iaaddr->getPreferred(), 1);
EXPECT_EQ_MARGIN(valid - delta, iaaddr->getValid(), 1);
// check DUIDs
checkServerId(reply, srv.getServerID());
@@ -1781,8 +1782,8 @@ TEST_F(Dhcpv6SrvTest, pdRequestCache) {
// Check the prefix.
EXPECT_EQ(prefix, iapref->getAddress());
EXPECT_EQ(prefixlen, iapref->getLength());
EXPECT_EQ(pref - delta, iapref->getPreferred());
EXPECT_EQ(valid - delta, iapref->getValid());
EXPECT_EQ_MARGIN(pref - delta, iapref->getPreferred(), 1);
EXPECT_EQ_MARGIN(valid - delta, iapref->getValid(), 1);
// check DUIDs
checkServerId(reply, srv.getServerID());
@@ -1996,8 +1997,8 @@ TEST_F(Dhcpv6SrvTest, RenewCache) {
// Check the address.
EXPECT_EQ(addr, iaaddr->getAddress());
EXPECT_EQ(pref - delta, iaaddr->getPreferred());
EXPECT_EQ(valid - delta, iaaddr->getValid());
EXPECT_EQ_MARGIN(pref - delta, iaaddr->getPreferred(), 1);
EXPECT_EQ_MARGIN(valid - delta, iaaddr->getValid(), 1);
// check DUIDs
checkServerId(reply, srv.getServerID());
@@ -2071,8 +2072,8 @@ TEST_F(Dhcpv6SrvTest, pdRenewCache) {
// Check the prefix.
EXPECT_EQ(prefix, iapref->getAddress());
EXPECT_EQ(prefixlen, iapref->getLength());
EXPECT_EQ(pref - delta, iapref->getPreferred());
EXPECT_EQ(valid - delta, iapref->getValid());
EXPECT_EQ_MARGIN(pref - delta, iapref->getPreferred(), 1);
EXPECT_EQ_MARGIN(valid - delta, iapref->getValid(), 1);
// check DUIDs
checkServerId(reply, srv.getServerID());