Skip to content

Commit 4493316

Browse files
committed
tests: use a monotonic timer
Change-Id: I89cdd08082b025643dac81788ca174d3c2177089
1 parent ffc52b2 commit 4493316

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

tests/restconf-eventstream.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ TEST_CASE("Event stream tests")
101101
netconfWatcher,
102102
"/streams/NETCONF/JSON",
103103
std::map<std::string, std::string>{AUTH_ROOT},
104-
boost::posix_time::seconds{5},
104+
std::chrono::seconds{5},
105105
SSEClient::ReportIgnoredLines::Yes);
106106

107107
RUN_LOOP_WITH_EXCEPTIONS;

tests/restconf_utils.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -172,10 +172,10 @@ SSEClient::SSEClient(
172172
const RestconfNotificationWatcher& eventWatcher,
173173
const std::string& uri,
174174
const std::map<std::string, std::string>& headers,
175-
const boost::posix_time::seconds silenceTimeout,
175+
const std::chrono::seconds silenceTimeout,
176176
const ReportIgnoredLines reportIgnoredLines)
177177
: client(std::make_shared<ng_client::session>(io, server_address, server_port))
178-
, t(io, silenceTimeout)
178+
, t(io, std::chrono::seconds(silenceTimeout))
179179
{
180180
ng::header_map reqHeaders;
181181
for (const auto& [name, value] : headers) {
@@ -201,7 +201,7 @@ SSEClient::SSEClient(
201201
res.on_data([&, silenceTimeout, reportIgnoredLines](const uint8_t* data, std::size_t len) {
202202
dataBuffer.append(std::string(reinterpret_cast<const char*>(data), len));
203203
parseEvents(eventWatcher, reportIgnoredLines);
204-
t.expires_from_now(silenceTimeout);
204+
t.expires_after(std::chrono::seconds(silenceTimeout));
205205
});
206206
});
207207

tests/restconf_utils.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ void setupRealNacm(sysrepo::Session session);
8686

8787
struct SSEClient {
8888
std::shared_ptr<ng_client::session> client;
89-
boost::asio::deadline_timer t;
89+
boost::asio::steady_timer t;
9090
std::string dataBuffer;
9191

9292
enum class ReportIgnoredLines {
@@ -102,7 +102,7 @@ struct SSEClient {
102102
const RestconfNotificationWatcher& eventWatcher,
103103
const std::string& uri,
104104
const std::map<std::string, std::string>& headers,
105-
const boost::posix_time::seconds silenceTimeout = boost::posix_time::seconds(1), // test code; the server should respond "soon"
105+
const std::chrono::seconds silenceTimeout = std::chrono::seconds{1}, // test code; the server should respond "soon"
106106
const ReportIgnoredLines reportIgnoredLines = ReportIgnoredLines::No);
107107

108108
void parseEvents(const RestconfNotificationWatcher& eventWatcher, const ReportIgnoredLines reportIgnoredLines);

0 commit comments

Comments
 (0)