diff --git a/test/integration/server.cc b/test/integration/server.cc index 956cb4381e422..fa8bb9a8c18f3 100644 --- a/test/integration/server.cc +++ b/test/integration/server.cc @@ -58,11 +58,12 @@ void IntegrationTestServer::start(const Network::Address::IpVersion version, IntegrationTestServer::~IntegrationTestServer() { ENVOY_LOG(info, "stopping integration test server"); - BufferingStreamDecoderPtr response = - IntegrationUtil::makeSingleRequest(server_->admin().socket().localAddress(), "POST", - "/quitquitquit", "", Http::CodecClient::Type::HTTP1); - EXPECT_TRUE(response->complete()); - EXPECT_STREQ("200", response->headers().Status()->value().c_str()); + if (admin_address_ != nullptr) { + BufferingStreamDecoderPtr response = IntegrationUtil::makeSingleRequest( + admin_address_, "POST", "/quitquitquit", "", Http::CodecClient::Type::HTTP1); + EXPECT_TRUE(response->complete()); + EXPECT_STREQ("200", response->headers().Status()->value().c_str()); + } thread_->join(); } @@ -107,6 +108,10 @@ void IntegrationTestServer::threadRoutine(const Network::Address::IpVersion vers restarter, stats_store, lock, *this, std::move(random_generator), tls)); pending_listeners_ = server_->listenerManager().listeners().size(); ENVOY_LOG(info, "waiting for {} test server listeners", pending_listeners_); + // This is technically thread unsafe (assigning to a shared_ptr accessed + // across threads), but because we synchronize below on server_set, the only + // consumer on the main test thread in ~IntegrationTestServer will not race. + admin_address_ = server_->admin().socket().localAddress(); server_set_.setReady(); server_->run(); server_.reset(); diff --git a/test/integration/server.h b/test/integration/server.h index 0cc04041ceab0..9f6a27dcf0363 100644 --- a/test/integration/server.h +++ b/test/integration/server.h @@ -309,6 +309,7 @@ class IntegrationTestServer : Logger::Loggable, Stats::Store* stat_store_{}; std::function on_worker_listener_added_cb_; std::function on_worker_listener_removed_cb_; + Network::Address::InstanceConstSharedPtr admin_address_; }; } // namespace Envoy