tests: increase tolerance in several time-sensitive test cases
To avoid spurious failures when CI build bots are overloaded. Change-Id: If6ec5579dfef1f9fdbd57723e6aeec0a46221a3f
This commit is contained in:
1 parent
de33245d9f
commit
003357899d
3 files changed
+58
-55
No files matched your search
@@ -80,7 +80,7 @@ BOOST_AUTO_TEST_CASE(ChangePersistencyFromPermanentWhenDown)
|
||||
limitedIo.afterOp();
|
||||
});
|
||||
remoteSocket.close();
|
||||
BOOST_REQUIRE_EQUAL(limitedIo.run(1, time::seconds(1)), LimitedIo::EXCEED_OPS);
|
||||
BOOST_REQUIRE_EQUAL(limitedIo.run(1, 1_s), LimitedIo::EXCEED_OPS);
|
||||
|
||||
bool didStateChange = false;
|
||||
transport->afterStateChange.connectSingleShot(
|
||||
@@ -104,7 +104,7 @@ BOOST_FIXTURE_TEST_CASE_TEMPLATE(PermanentReconnect, T, TcpTransportFixtures, T)
|
||||
this->limitedIo.afterOp();
|
||||
});
|
||||
this->remoteSocket.close();
|
||||
BOOST_REQUIRE_EQUAL(this->limitedIo.run(1, time::seconds(1)), LimitedIo::EXCEED_OPS);
|
||||
BOOST_REQUIRE_EQUAL(this->limitedIo.run(1, 1_s), LimitedIo::EXCEED_OPS);
|
||||
|
||||
this->transport->afterStateChange.connectSingleShot(
|
||||
[this] (TransportState oldState, TransportState newState) {
|
||||
@@ -112,7 +112,7 @@ BOOST_FIXTURE_TEST_CASE_TEMPLATE(PermanentReconnect, T, TcpTransportFixtures, T)
|
||||
BOOST_CHECK_EQUAL(newState, TransportState::UP);
|
||||
this->limitedIo.afterOp();
|
||||
});
|
||||
BOOST_REQUIRE_EQUAL(this->limitedIo.run(1, time::seconds(1)), LimitedIo::EXCEED_OPS);
|
||||
BOOST_REQUIRE_EQUAL(this->limitedIo.run(1, 1_s), LimitedIo::EXCEED_OPS);
|
||||
}
|
||||
|
||||
class PermanentTcpTransportReconnectObserver : public TcpTransport
|
||||
@@ -174,7 +174,7 @@ BOOST_FIXTURE_TEST_CASE_TEMPLATE(PermanentReconnectWithExponentialBackoff, T, Tc
|
||||
BOOST_REQUIRE_EQUAL(error, boost::system::errc::success);
|
||||
this->limitedIo.afterOp();
|
||||
});
|
||||
BOOST_REQUIRE_EQUAL(this->limitedIo.run(2, time::seconds(1)), LimitedIo::EXCEED_OPS);
|
||||
BOOST_REQUIRE_EQUAL(this->limitedIo.run(2, 1_s), LimitedIo::EXCEED_OPS);
|
||||
|
||||
auto transportObserver =
|
||||
make_unique<PermanentTcpTransportReconnectObserver>(std::move(sock), std::ref(this->limitedIo));
|
||||
@@ -188,23 +188,23 @@ BOOST_FIXTURE_TEST_CASE_TEMPLATE(PermanentReconnectWithExponentialBackoff, T, Tc
|
||||
auto retryTime1 = time::steady_clock::now();
|
||||
|
||||
auto expectedWait1 = TcpTransport::s_initialReconnectWait;
|
||||
BOOST_REQUIRE_EQUAL(this->limitedIo.run(2, expectedWait1 + time::seconds(1)), // add some slack
|
||||
BOOST_REQUIRE_EQUAL(this->limitedIo.run(2, expectedWait1 + 1_s), // add some slack
|
||||
LimitedIo::EXCEED_OPS);
|
||||
auto retryTime2 = time::steady_clock::now();
|
||||
BOOST_CHECK_EQUAL(transportObserver->getState(), TransportState::DOWN);
|
||||
|
||||
auto expectedWait2 = time::duration_cast<time::nanoseconds>(expectedWait1 *
|
||||
TcpTransport::s_reconnectWaitMultiplier);
|
||||
BOOST_REQUIRE_EQUAL(this->limitedIo.run(2, expectedWait2 + time::seconds(1)), // add some slack
|
||||
BOOST_REQUIRE_EQUAL(this->limitedIo.run(2, expectedWait2 + 1_s), // add some slack
|
||||
LimitedIo::EXCEED_OPS);
|
||||
auto retryTime3 = time::steady_clock::now();
|
||||
BOOST_CHECK_EQUAL(transportObserver->getState(), TransportState::DOWN);
|
||||
|
||||
// check that the backoff algorithm works
|
||||
BOOST_CHECK_CLOSE(asFloatMilliseconds(retryTime2 - retryTime1),
|
||||
asFloatMilliseconds(expectedWait1), 10.0);
|
||||
asFloatMilliseconds(expectedWait1), 20.0); // 200ms tolerance
|
||||
BOOST_CHECK_CLOSE(asFloatMilliseconds(retryTime3 - retryTime2),
|
||||
asFloatMilliseconds(expectedWait2), 10.0);
|
||||
asFloatMilliseconds(expectedWait2), 10.0); // 200ms tolerance
|
||||
|
||||
// reestablish the TCP connection
|
||||
this->startAccept(remoteEp);
|
||||
@@ -212,7 +212,7 @@ BOOST_FIXTURE_TEST_CASE_TEMPLATE(PermanentReconnectWithExponentialBackoff, T, Tc
|
||||
auto expectedWait3 = time::duration_cast<time::nanoseconds>(expectedWait2 *
|
||||
TcpTransport::s_reconnectWaitMultiplier);
|
||||
BOOST_REQUIRE_EQUAL(this->limitedIo.run(3, // reconnect, handleReconnect, async_accept
|
||||
expectedWait3 + time::seconds(1)), LimitedIo::EXCEED_OPS);
|
||||
expectedWait3 + 1_s), LimitedIo::EXCEED_OPS);
|
||||
BOOST_CHECK_EQUAL(transportObserver->getState(), TransportState::UP);
|
||||
|
||||
// break the TCP connection again
|
||||
@@ -221,14 +221,14 @@ BOOST_FIXTURE_TEST_CASE_TEMPLATE(PermanentReconnectWithExponentialBackoff, T, Tc
|
||||
|
||||
// measure retry intervals
|
||||
auto retryTime4 = time::steady_clock::now();
|
||||
BOOST_REQUIRE_EQUAL(this->limitedIo.run(2, expectedWait1 + time::seconds(1)), // add some slack
|
||||
BOOST_REQUIRE_EQUAL(this->limitedIo.run(2, expectedWait1 + 1_s), // add some slack
|
||||
LimitedIo::EXCEED_OPS);
|
||||
auto retryTime5 = time::steady_clock::now();
|
||||
BOOST_CHECK_EQUAL(transportObserver->getState(), TransportState::DOWN);
|
||||
|
||||
// check that the timeout restarts from the initial value after a successful reconnection
|
||||
BOOST_CHECK_CLOSE(asFloatMilliseconds(retryTime5 - retryTime4),
|
||||
asFloatMilliseconds(expectedWait1), 10.0);
|
||||
asFloatMilliseconds(expectedWait1), 20.0); // 200ms tolerance
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_SUITE_END() // TestTcpTransport
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/*
|
||||
* Copyright (c) 2014-2017, Regents of the University of California,
|
||||
* Copyright (c) 2014-2018, Regents of the University of California,
|
||||
* Arizona Board of Regents,
|
||||
* Colorado State University,
|
||||
* University Pierre & Marie Curie, Sorbonne University,
|
||||
@@ -49,8 +49,8 @@ protected:
|
||||
|
||||
void
|
||||
listen(const ip::address& addr,
|
||||
const time::milliseconds& pingInterval = time::seconds(10),
|
||||
const time::milliseconds& pongTimeout = time::seconds(1))
|
||||
const time::milliseconds& pingInterval = 10_s,
|
||||
const time::milliseconds& pongTimeout = 1_s)
|
||||
{
|
||||
listenerEp = websocket::Endpoint(addr, 20030);
|
||||
listenerChannel = makeChannel(addr, 20030);
|
||||
@@ -80,13 +80,13 @@ protected:
|
||||
|
||||
void
|
||||
initialize(const ip::address& addr,
|
||||
const time::milliseconds& pingInterval = time::seconds(10),
|
||||
const time::milliseconds& pongTimeout = time::seconds(1))
|
||||
const time::milliseconds& pingInterval = 10_s,
|
||||
const time::milliseconds& pongTimeout = 1_s)
|
||||
{
|
||||
listen(addr, pingInterval, pongTimeout);
|
||||
clientConnect(client);
|
||||
BOOST_REQUIRE_EQUAL(limitedIo.run(2, // listenerOnFaceCreated, clientHandleOpen
|
||||
time::seconds(1)), LimitedIo::EXCEED_OPS);
|
||||
1_s), LimitedIo::EXCEED_OPS);
|
||||
BOOST_REQUIRE_EQUAL(listenerChannel->size(), 1);
|
||||
}
|
||||
|
||||
@@ -150,8 +150,9 @@ protected:
|
||||
std::vector<std::string> clientReceivedMessages;
|
||||
|
||||
time::steady_clock::Duration measuredPingInterval;
|
||||
bool clientShouldPong = true; // set clientShouldPong false to disable the pong response,
|
||||
// which will cause timeout in listenerChannel
|
||||
// set clientShouldPong to false to disable the pong response,
|
||||
// which will eventually cause a timeout in listenerChannel
|
||||
bool clientShouldPong = true;
|
||||
|
||||
private:
|
||||
time::steady_clock::TimePoint m_prevPingRecvTime;
|
||||
@@ -193,7 +194,7 @@ BOOST_AUTO_TEST_CASE(MultipleAccepts)
|
||||
this->clientConnect(client1);
|
||||
|
||||
BOOST_CHECK_EQUAL(limitedIo.run(2, // listenerOnFaceCreated, clientHandleOpen
|
||||
time::seconds(1)), LimitedIo::EXCEED_OPS);
|
||||
1_s), LimitedIo::EXCEED_OPS);
|
||||
BOOST_CHECK_EQUAL(listenerChannel->size(), 1);
|
||||
|
||||
websocket::Client client2;
|
||||
@@ -202,7 +203,7 @@ BOOST_AUTO_TEST_CASE(MultipleAccepts)
|
||||
this->clientConnect(client3);
|
||||
|
||||
BOOST_CHECK_EQUAL(limitedIo.run(4, // 2 listenerOnFaceCreated, 2 clientHandleOpen
|
||||
time::seconds(2)), LimitedIo::EXCEED_OPS);
|
||||
2_s), LimitedIo::EXCEED_OPS);
|
||||
BOOST_CHECK_EQUAL(listenerChannel->size(), 3);
|
||||
|
||||
// check face persistency
|
||||
@@ -219,14 +220,14 @@ BOOST_AUTO_TEST_CASE(Send)
|
||||
auto transport = listenerFaces.front()->getTransport();
|
||||
|
||||
Block pkt1 = ndn::encoding::makeStringBlock(300, "hello");
|
||||
transport->send(face::Transport::Packet(Block(pkt1)));
|
||||
transport->send(Transport::Packet(Block(pkt1)));
|
||||
BOOST_CHECK_EQUAL(limitedIo.run(1, // clientHandleMessage
|
||||
time::seconds(1)), LimitedIo::EXCEED_OPS);
|
||||
1_s), LimitedIo::EXCEED_OPS);
|
||||
|
||||
Block pkt2 = ndn::encoding::makeStringBlock(301, "world!");
|
||||
transport->send(face::Transport::Packet(Block(pkt2)));
|
||||
transport->send(Transport::Packet(Block(pkt2)));
|
||||
BOOST_CHECK_EQUAL(limitedIo.run(1, // clientHandleMessage
|
||||
time::seconds(1)), LimitedIo::EXCEED_OPS);
|
||||
1_s), LimitedIo::EXCEED_OPS);
|
||||
|
||||
BOOST_REQUIRE_EQUAL(clientReceivedMessages.size(), 2);
|
||||
BOOST_CHECK_EQUAL_COLLECTIONS(
|
||||
@@ -252,11 +253,11 @@ BOOST_AUTO_TEST_CASE(Receive)
|
||||
|
||||
clientSendInterest(*interest1);
|
||||
BOOST_CHECK_EQUAL(limitedIo.run(1, // faceAfterReceiveInterest
|
||||
time::seconds(1)), LimitedIo::EXCEED_OPS);
|
||||
1_s), LimitedIo::EXCEED_OPS);
|
||||
|
||||
clientSendInterest(*interest2);
|
||||
BOOST_CHECK_EQUAL(limitedIo.run(1, // faceAfterReceiveInterest
|
||||
time::seconds(1)), LimitedIo::EXCEED_OPS);
|
||||
1_s), LimitedIo::EXCEED_OPS);
|
||||
|
||||
BOOST_REQUIRE_EQUAL(faceReceivedInterests.size(), 2);
|
||||
BOOST_CHECK_EQUAL(faceReceivedInterests[0].getName(), interest1->getName());
|
||||
@@ -281,19 +282,19 @@ BOOST_AUTO_TEST_CASE(RemoteClose)
|
||||
|
||||
client.close(clientHandle, websocketpp::close::status::going_away, "");
|
||||
BOOST_CHECK_EQUAL(limitedIo.run(1, // faceClosedSignal
|
||||
time::seconds(1)), LimitedIo::EXCEED_OPS);
|
||||
1_s), LimitedIo::EXCEED_OPS);
|
||||
BOOST_CHECK_EQUAL(listenerChannel->size(), 0);
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(SetPingInterval)
|
||||
{
|
||||
const time::milliseconds pingInterval(800);
|
||||
auto address = getTestIp(AddressFamily::V4, AddressScope::Loopback);
|
||||
SKIP_IF_IP_UNAVAILABLE(address);
|
||||
this->initialize(address, pingInterval, time::milliseconds(1000));
|
||||
const auto pingInterval = 1200_ms;
|
||||
this->initialize(address, pingInterval);
|
||||
|
||||
BOOST_CHECK_EQUAL(limitedIo.run(2, // clientHandlePing
|
||||
pingInterval * 3), LimitedIo::EXCEED_OPS);
|
||||
pingInterval * 3), LimitedIo::EXCEED_OPS);
|
||||
BOOST_CHECK_LE(measuredPingInterval, pingInterval * 1.1);
|
||||
BOOST_CHECK_GE(measuredPingInterval, pingInterval * 0.9);
|
||||
}
|
||||
@@ -302,17 +303,18 @@ BOOST_AUTO_TEST_CASE(SetPongTimeOut)
|
||||
{
|
||||
auto address = getTestIp(AddressFamily::V4, AddressScope::Loopback);
|
||||
SKIP_IF_IP_UNAVAILABLE(address);
|
||||
this->initialize(address, time::milliseconds(500), time::milliseconds(300));
|
||||
this->initialize(address, 600_ms, 300_ms);
|
||||
clientShouldPong = false;
|
||||
|
||||
BOOST_CHECK_EQUAL(limitedIo.run(2, // clientHandlePing, faceClosedSignal
|
||||
time::seconds(2)), LimitedIo::EXCEED_OPS);
|
||||
2_s), LimitedIo::EXCEED_OPS);
|
||||
BOOST_CHECK_EQUAL(listenerChannel->size(), 0);
|
||||
|
||||
auto transport = static_cast<face::WebSocketTransport*>(listenerFaces.front()->getTransport());
|
||||
BOOST_CHECK(transport->getState() == face::TransportState::FAILED ||
|
||||
transport->getState() == face::TransportState::CLOSED);
|
||||
BOOST_CHECK_EQUAL(transport->getCounters().nOutPings, 1);
|
||||
auto transport = static_cast<WebSocketTransport*>(listenerFaces.front()->getTransport());
|
||||
BOOST_CHECK(transport->getState() == TransportState::FAILED ||
|
||||
transport->getState() == TransportState::CLOSED);
|
||||
BOOST_CHECK_GE(transport->getCounters().nOutPings, 1);
|
||||
BOOST_CHECK_LE(transport->getCounters().nOutPings, 2);
|
||||
BOOST_CHECK_EQUAL(transport->getCounters().nInPongs, 0);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014-2017, Regents of the University of California,
|
||||
/*
|
||||
* Copyright (c) 2014-2018, Regents of the University of California,
|
||||
* Arizona Board of Regents,
|
||||
* Colorado State University,
|
||||
* University Pierre & Marie Curie, Sorbonne University,
|
||||
@@ -26,6 +26,7 @@
|
||||
#include "ndn-autoconfig-server/program.hpp"
|
||||
|
||||
#include "tests/identity-management-fixture.hpp"
|
||||
|
||||
#include <ndn-cxx/encoding/buffer.hpp>
|
||||
#include <ndn-cxx/util/dummy-client-face.hpp>
|
||||
|
||||
@@ -48,11 +49,11 @@ public:
|
||||
initialize(const Options& options)
|
||||
{
|
||||
program = make_unique<Program>(options, face, m_keyChain);
|
||||
face.processEvents(time::milliseconds(1));
|
||||
face.processEvents(500_ms);
|
||||
face.sentInterests.clear();
|
||||
}
|
||||
|
||||
public:
|
||||
protected:
|
||||
util::DummyClientFace face;
|
||||
unique_ptr<Program> program;
|
||||
};
|
||||
@@ -68,10 +69,10 @@ BOOST_AUTO_TEST_CASE(HubData)
|
||||
|
||||
Interest interest("/localhop/ndn-autoconf/hub");
|
||||
face.receive(interest);
|
||||
face.processEvents(time::milliseconds(1));
|
||||
face.processEvents(500_ms);
|
||||
|
||||
BOOST_CHECK_EQUAL(face.sentData.size(), 1);
|
||||
const Name& dataName = face.sentData.at(0).getName();
|
||||
BOOST_REQUIRE_EQUAL(face.sentData.size(), 1);
|
||||
const Name& dataName = face.sentData[0].getName();
|
||||
BOOST_CHECK_EQUAL(dataName.size(), interest.getName().size() + 1);
|
||||
BOOST_CHECK(interest.getName().isPrefixOf(dataName));
|
||||
BOOST_CHECK(dataName.at(-1).isVersion());
|
||||
@@ -79,7 +80,7 @@ BOOST_AUTO_TEST_CASE(HubData)
|
||||
// interest2 asks for a different version, and should not be responded
|
||||
Interest interest2(Name(interest.getName()).appendVersion(dataName.at(-1).toVersion() - 1));
|
||||
face.receive(interest2);
|
||||
face.processEvents(time::milliseconds(1));
|
||||
face.processEvents(500_ms);
|
||||
BOOST_CHECK_EQUAL(face.sentData.size(), 1);
|
||||
}
|
||||
|
||||
@@ -87,18 +88,18 @@ BOOST_AUTO_TEST_CASE(RoutablePrefixesDataset)
|
||||
{
|
||||
Options options;
|
||||
options.hubFaceUri = FaceUri("udp4://192.0.2.1:6363");
|
||||
const int nRoutablePrefixes = 2000;
|
||||
for (int i = 0; i < nRoutablePrefixes; ++i) {
|
||||
const size_t nRoutablePrefixes = 2000;
|
||||
for (size_t i = 0; i < nRoutablePrefixes; ++i) {
|
||||
options.routablePrefixes.push_back(Name("/PREFIX").appendNumber(i));
|
||||
}
|
||||
this->initialize(options);
|
||||
|
||||
Interest interest("/localhop/nfd/rib/routable-prefixes");
|
||||
face.receive(interest);
|
||||
face.processEvents(time::milliseconds(1));
|
||||
face.processEvents(500_ms);
|
||||
|
||||
BOOST_CHECK_EQUAL(face.sentData.size(), 1);
|
||||
const Name& dataName0 = face.sentData.at(0).getName();
|
||||
BOOST_REQUIRE_EQUAL(face.sentData.size(), 1);
|
||||
const Name& dataName0 = face.sentData[0].getName();
|
||||
BOOST_CHECK_EQUAL(dataName0.size(), interest.getName().size() + 2);
|
||||
BOOST_CHECK(interest.getName().isPrefixOf(dataName0));
|
||||
BOOST_CHECK(dataName0.at(-2).isVersion());
|
||||
@@ -108,7 +109,7 @@ BOOST_AUTO_TEST_CASE(RoutablePrefixesDataset)
|
||||
const Name& lastName = face.sentData.back().getName();
|
||||
Interest interest2(lastName.getPrefix(-1).appendSegment(lastName.at(-1).toSegment() + 1));
|
||||
face.receive(interest2);
|
||||
face.processEvents(time::milliseconds(1));
|
||||
face.processEvents(500_ms);
|
||||
}
|
||||
|
||||
auto buffer = make_shared<Buffer>();
|
||||
@@ -119,9 +120,9 @@ BOOST_AUTO_TEST_CASE(RoutablePrefixesDataset)
|
||||
|
||||
Block payload(tlv::Content, buffer);
|
||||
payload.parse();
|
||||
BOOST_CHECK_EQUAL(payload.elements_size(), nRoutablePrefixes);
|
||||
for (int i = 0; i < nRoutablePrefixes; ++i) {
|
||||
BOOST_CHECK_EQUAL(Name(payload.elements().at(i)), options.routablePrefixes.at(i));
|
||||
BOOST_REQUIRE_EQUAL(payload.elements_size(), nRoutablePrefixes);
|
||||
for (size_t i = 0; i < nRoutablePrefixes; ++i) {
|
||||
BOOST_CHECK_EQUAL(Name(payload.elements()[i]), options.routablePrefixes[i]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -133,7 +134,7 @@ BOOST_AUTO_TEST_CASE(RoutablePrefixesDisabled)
|
||||
|
||||
Interest interest("/localhop/nfd/rib/routable-prefixes");
|
||||
face.receive(interest);
|
||||
face.processEvents(time::milliseconds(1));
|
||||
face.processEvents(500_ms);
|
||||
BOOST_CHECK_EQUAL(face.sentData.size(), 0);
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user