Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion test/integration/echo_integration_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,12 @@ TEST_P(EchoIntegrationTest, AddRemoveListener) {
RawConnectionDriver connection2(
new_listener_port, buffer,
[&](Network::ClientConnection&, const Buffer::Instance&) -> void { FAIL(); }, version_);
connection2.run(Event::Dispatcher::RunType::NonBlock);
while (connection2.connecting()) {
// Don't busy loop, but OS X often needs a moment to decide this connection isn't happening.
std::this_thread::sleep_for(std::chrono::milliseconds(10));

connection2.run(Event::Dispatcher::RunType::NonBlock);
}
if (connection2.connection().state() == Network::Connection::State::Closed) {
connect_fail = true;
break;
Expand Down
2 changes: 2 additions & 0 deletions test/integration/utility.cc
Original file line number Diff line number Diff line change
Expand Up @@ -111,10 +111,12 @@ RawConnectionDriver::RawConnectionDriver(uint32_t port, Buffer::Instance& initia
Network::Address::IpVersion version) {
api_.reset(new Api::Impl(std::chrono::milliseconds(10000)));
dispatcher_ = api_->allocateDispatcher(IntegrationUtil::evil_singleton_test_time_.timeSource());
callbacks_.reset(new ConnectionCallbacks());
client_ = dispatcher_->createClientConnection(
Network::Utility::resolveUrl(
fmt::format("tcp://{}:{}", Network::Test::getLoopbackAddressUrlString(version), port)),
Network::Address::InstanceConstSharedPtr(), Network::Test::createRawBufferSocket(), nullptr);
client_->addConnectionCallbacks(*callbacks_);
client_->addReadFilter(Network::ReadFilterSharedPtr{new ForwardingFilter(*this, data_callback)});
client_->write(initial_data, false);
client_->connect();
Expand Down
10 changes: 10 additions & 0 deletions test/integration/utility.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ class RawConnectionDriver {
Network::Address::IpVersion version);
~RawConnectionDriver();
const Network::Connection& connection() { return *client_; }
bool connecting() { return callbacks_->connecting_; }
void run(Event::Dispatcher::RunType run_type = Event::Dispatcher::RunType::Block);
void close();

Expand All @@ -81,8 +82,17 @@ class RawConnectionDriver {
ReadCallback data_callback_;
};

struct ConnectionCallbacks : public Network::ConnectionCallbacks {
void onEvent(Network::ConnectionEvent) override { connecting_ = false; }
void onAboveWriteBufferHighWatermark() override {}
void onBelowWriteBufferLowWatermark() override {}

bool connecting_{true};
};

Api::ApiPtr api_;
Event::DispatcherPtr dispatcher_;
std::shared_ptr<ConnectionCallbacks> callbacks_;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this need to be a shared pointer, or can we get away with unique?

Network::ClientConnectionPtr client_;
};

Expand Down