tests: increase tolerance in several time-sensitive test cases

To avoid spurious failures when CI build bots are overloaded.

Change-Id: If6ec5579dfef1f9fdbd57723e6aeec0a46221a3f
diff --git a/tests/daemon/face/websocket-channel.t.cpp b/tests/daemon/face/websocket-channel.t.cpp
index 439422f..5c4f433 100644
--- a/tests/daemon/face/websocket-channel.t.cpp
+++ b/tests/daemon/face/websocket-channel.t.cpp
@@ -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 @@
 
   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 @@
 
   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 @@
   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 @@
   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 @@
   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 @@
   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 @@
 
   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 @@
 
   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 @@
 {
   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);
 }