Skip to content

Commit 249e147

Browse files
committed
implement read timeout capability in contract tests
1 parent 24fcdfc commit 249e147

File tree

5 files changed

+11
-1
lines changed

5 files changed

+11
-1
lines changed

contract-tests/sse-contract-tests/src/entity_manager.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,11 @@ std::optional<std::string> EntityManager::create(ConfigParams const& params) {
3535
std::chrono::milliseconds(*params.readTimeoutMs));
3636
}
3737

38+
if (params.initialDelayMs) {
39+
client_builder.initial_reconnect_delay(
40+
std::chrono::milliseconds(*params.initialDelayMs));
41+
}
42+
3843
client_builder.logger([this](std::string msg) {
3944
LD_LOG(logger_, LogLevel::kDebug) << std::move(msg);
4045
});

contract-tests/sse-contract-tests/src/event_outbox.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,8 @@ EventOutbox::RequestType EventOutbox::build_request(
9393
break;
9494
case Error::UnrecoverableClientError:
9595
msg.comment = "unrecoverable client error";
96+
case Error::ReadTimeout:
97+
msg.comment = "read timeout";
9698
default:
9799
msg.comment = "unspecified error";
98100
}

contract-tests/sse-contract-tests/src/main.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ int main(int argc, char* argv[]) {
2020
launchdarkly::Logger logger{
2121
std::make_unique<ConsoleBackend>("sse-contract-tests")};
2222

23-
const std::string default_port = "8123";
23+
std::string const default_port = "8123";
2424
std::string port = default_port;
2525
if (argc == 2) {
2626
port =
@@ -38,6 +38,7 @@ int main(int argc, char* argv[]) {
3838
srv.add_capability("report");
3939
srv.add_capability("post");
4040
srv.add_capability("reconnection");
41+
srv.add_capability("read-timeout");
4142

4243
net::signal_set signals{ioc, SIGINT, SIGTERM};
4344

libs/server-sent-events/include/launchdarkly/sse/error.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,6 @@ enum class Error {
66
NoContent = 1,
77
InvalidRedirectLocation = 2,
88
UnrecoverableClientError = 3,
9+
ReadTimeout = 4,
910
};
1011
}

libs/server-sent-events/src/client.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -309,6 +309,7 @@ class FoxyClient : public Client,
309309
if (shutting_down_) {
310310
return;
311311
}
312+
errors_(Error::ReadTimeout);
312313
return do_backoff(
313314
"aborting read of response body (timeout/shutdown)");
314315
}

0 commit comments

Comments
 (0)